Re: [PATCH] arm64: dts: imx8mq-kontron-pitx-imx8m-u-boot.dtsi: disable assigned clocks

2022-06-13 Thread Heiko Thiery
Hi Tom,

Am Sa., 11. Juni 2022 um 16:56 Uhr schrieb Heiko Thiery
:
>
> Hi Marek,
>
> Am Sa., 11. Juni 2022 um 12:15 Uhr schrieb Marek Vasut :
> >
> > On 6/11/22 08:09, Heiko Thiery wrote:
> > > With the move to use DM_CLK the boards uart stops working. The used
> > > properties are not supported by the imx8mq clock driver. Thus
> > > the correct baudrate cannot be selected. Remove this properties here and
> > > the board can start with working uart. Keep it in the main dts because
> > > linux handles these porperties fine.
> >
> > Is this yet another
> >
> > 75f080df46f ("Revert "clk: Detect failure to set defaults"")
> >
> > kind of failure, where the clock uclass returns error code on something?
> >
> > Maybe the clock uclass should rather warn than fail outright, so we
> > won't need these workarounds in DT files ?
>
> I think this is another kind of issue here. I had already tried to
> solve the problem [1], but had not been able to follow it through to
> the end.
>
> Maybe now is the right time to tackle it again. But due to lack of
> time i can't say when i will get to it yet.
>
> [1] 
> https://patchwork.ozlabs.org/project/uboot/patch/20220317124127.1783768-1-heiko.thi...@gmail.com/

Is there a chance that this patch can still come in the next RC?
Without this change, the board no longer starts correctly.


> --
> Heiko


Re: imx8mn SPL serial output does not work after powerup

2022-06-13 Thread Heiko Thiery
Hi Peng,

Am Di., 14. Juni 2022 um 03:46 Uhr schrieb Peng Fan (OSS)
:
>
>
>
> 在 2022/6/14 3:49, Heiko Thiery 写道:
> > Am Mo., 13. Juni 2022 um 21:43 Uhr schrieb Heiko Thiery
> > :
> >> Hi,
> >>
> >> Am Mo., 13. Juni 2022 um 21:28 Uhr schrieb Fabio Estevam 
> >> :
> >>> Hi Heiko,
> >>>
> >>> On Mon, Jun 13, 2022 at 4:16 PM Heiko Thiery  
> >>> wrote:
> >>>
>  Can anyone confirm the behavior?
> >>> imx8mn ddr4 evk prints the SPL part just fine.
> >>>
> >>> Take a look at arch/arm/dts/imx8mn-ddr4-evk-u-boot.dtsi .
> >>>
> >>> It passes:
> >>>
> >>>  {
> >>>u-boot,dm-spl;
> >>> };
> >>>
> >>> _uart2 {
> >>>   u-boot,dm-spl;
> >>> };
> >>>
> >>> Are you doing the same for the imx8mn ddr3 u-boot dtsi?
> >> Indeed these are missing. Now I see the whole output from U-Boot but
> >> the output from SPL is still missing. When enabloing SPL_DM_SERIAL the
> >> board does not start.
> >
> > I now did include the whole "imx8mn-ddr4-evk-u-boot.dtsi" like it is
> > done in "imx8mn-evk-u-boot.dtsi". Then it works.
>
> make sure preload_console_init is called after spl_early_init or
> spl_init, not before.

The board init code is used from imx8mn_evk [1]. So the init sequence
seems to be correct.

[1] 
https://source.denx.de/u-boot/u-boot/-/blob/master/board/freescale/imx8mn_evk/spl.c#L137

--
Heiko


Re: [PATCH v5 07/12] efi_loader: disk: a helper function to create efi_disk objects from udevice

2022-06-13 Thread Heiko Thiery
Hi,

Am Di., 14. Juni 2022 um 01:54 Uhr schrieb Fabio Estevam :
>
> Hi Heinrich,
>
> On Mon, Jun 13, 2022 at 8:39 PM Heinrich Schuchardt  
> wrote:
>
> > Slowing down every boot without connected serial by 1000ms seems to be a 
> > bad idea.
> >
> > What baud rate are you using?
>
> 115200.
>
> > What terminal software are you using giving the late response?
>
> I will check. I am accessing the board remotely.
>
> Heiko also sees the problem. Maybe he could share what terminal
> software he uses.

I use ser2net and connect with the linux telnet client.

> > Does printf() return before the last byte is sent by the serial IO transfer 
> > buffer? What size has that buffer?
>
> Looks like I would need to instrument the code to answer this.
>
> > I suggest that the EFI console should not query the screen size before 
> > starting the first EFI binary.
>
> Could you please propose I patch doing this?
>
> To be honest, I don't need EFI, but it gets automatically selected,
> and that's why I see the problem.
>
> For the moment, I am disabling CONFIG_EFI_LOADER as a workaround.
>
> I can help to test patches, but I am not familiar with EFI to propose a fix.
>
> Thanks,
>
> Fabio Estevam

-- 
Heiko


[PATCH 7/8] Complete migration of MTDPARTS_DEFAULT / MTDIDS_DEFAULT, include in environment

2022-06-13 Thread Tom Rini
- Ensure that everyone setting mtdids= and mtdparts= is doing so via the
  CONFIG options.
- If the CONFIG options are set, ensure that the default environment
  sets mtdparts / mtdids.

Signed-off-by: Tom Rini 
---
 configs/aristainetos2c_defconfig   |  2 ++
 configs/aristainetos2ccslb_defconfig   |  2 ++
 configs/dockstar_defconfig |  1 +
 configs/ib62x0_defconfig   |  1 +
 configs/iconnect_defconfig |  1 +
 configs/nas220_defconfig   |  2 ++
 configs/nsa310s_defconfig  |  1 +
 configs/pogo_e02_defconfig |  2 ++
 include/configs/am335x_evm.h   |  2 --
 include/configs/am335x_igep003x.h  |  2 --
 include/configs/am3517_evm.h   |  2 --
 include/configs/am43xx_evm.h   |  2 --
 include/configs/am65x_evm.h|  9 -
 include/configs/aristainetos2.h|  3 ---
 include/configs/at91sam9n12ek.h|  1 -
 include/configs/baltos.h   |  2 --
 include/configs/bk4r1.h|  1 -
 include/configs/brppt1.h   |  2 --
 include/configs/chiliboard.h   |  2 --
 include/configs/cm_fx6.h   |  2 --
 include/configs/cm_t335.h  |  2 --
 include/configs/colibri-imx6ull.h  |  1 -
 include/configs/colibri_imx7.h |  1 -
 include/configs/colibri_t20.h  |  1 -
 include/configs/colibri_vf.h   |  1 -
 include/configs/dns325.h   |  1 -
 include/configs/dockstar.h |  2 --
 include/configs/goflexhome.h   |  2 --
 include/configs/guruplug.h |  1 -
 include/configs/gw_ventana.h   |  2 --
 include/configs/ib62x0.h   |  2 --
 include/configs/iconnect.h |  2 --
 include/configs/ids8313.h  |  2 --
 include/configs/imx27lite-common.h |  2 --
 include/configs/imx8mn_bsh_smm_s2.h|  2 --
 include/configs/j721e_evm.h|  9 -
 include/configs/j721s2_evm.h   |  9 -
 include/configs/km/keymile-common.h|  2 --
 include/configs/ls1028aqds.h   |  1 -
 include/configs/ls1028ardb.h   |  1 -
 include/configs/ls1043a_common.h   |  1 -
 include/configs/m53menlo.h |  2 --
 include/configs/mccmon6.h  |  1 -
 include/configs/mys_6ulx.h |  2 --
 include/configs/nas220.h   |  5 -
 include/configs/npi_imx6ull.h  |  2 --
 include/configs/nsa310s.h  |  2 --
 include/configs/omap3_evm.h|  2 --
 include/configs/omap3_logic.h  |  2 --
 include/configs/pcl063.h   |  2 --
 include/configs/pcm052.h   |  1 -
 include/configs/pcm058.h   |  2 --
 include/configs/phycore_am335x_r2.h|  2 --
 include/configs/pm9261.h   |  2 --
 include/configs/pm9263.h   |  2 --
 include/configs/pogo_e02.h |  3 ---
 include/configs/pogo_v4.h  |  2 --
 include/configs/s5pc210_universal.h|  1 -
 include/configs/smartweb.h |  1 -
 include/configs/smdkc100.h |  1 -
 include/configs/socfpga_arria5_secu1.h |  2 --
 include/configs/sunxi-common.h | 16 
 include/configs/ti816x_evm.h   |  4 +---
 include/configs/ti_armv7_keystone2.h   |  4 +---
 include/configs/usb_a9263.h|  1 -
 include/configs/vcoreiii.h |  9 -
 include/env_default.h  |  6 ++
 67 files changed, 20 insertions(+), 148 deletions(-)

diff --git a/configs/aristainetos2c_defconfig b/configs/aristainetos2c_defconfig
index 7a3e690ed661..26bcb00ff537 100644
--- a/configs/aristainetos2c_defconfig
+++ b/configs/aristainetos2c_defconfig
@@ -51,6 +51,8 @@ CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_CMD_MTDPARTS=y
+CONFIG_MTDIDS_DEFAULT="nor0=spi0.0"
+CONFIG_MTDPARTS_DEFAULT="mtdparts=spi0.0:832k(u-boot),64k(env),64k(env-red),-(ubi-nor)"
 CONFIG_CMD_UBI=y
 CONFIG_OF_CONTROL=y
 CONFIG_DTB_RESELECT=y
diff --git a/configs/aristainetos2ccslb_defconfig 
b/configs/aristainetos2ccslb_defconfig
index 6bc78b773295..682903082cba 100644
--- a/configs/aristainetos2ccslb_defconfig
+++ b/configs/aristainetos2ccslb_defconfig
@@ -51,6 +51,8 @@ CONFIG_CMD_EXT4_WRITE=y
 CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_CMD_MTDPARTS=y
+CONFIG_MTDIDS_DEFAULT="nor0=spi0.0"
+CONFIG_MTDPARTS_DEFAULT="mtdparts=spi0.0:832k(u-boot),64k(env),64k(env-red),-(ubi-nor)"
 CONFIG_CMD_UBI=y
 CONFIG_OF_CONTROL=y
 CONFIG_DTB_RESELECT=y
diff --git a/configs/dockstar_defconfig b/configs/dockstar_defconfig
index 3cb09ea4f7f0..6f99cdd44b05 100644
--- a/configs/dockstar_defconfig
+++ b/configs/dockstar_defconfig
@@ -36,6 +36,7 @@ CONFIG_CMD_EXT2=y
 CONFIG_CMD_FAT=y
 CONFIG_CMD_JFFS2=y
 CONFIG_CMD_MTDPARTS=y
+CONFIG_MTDIDS_DEFAULT="nand0=orion_nand"
 CONFIG_MTDPARTS_DEFAULT="mtdparts=orion_nand:1m(uboot),-(root)"
 CONFIG_CMD_UBI=y
 CONFIG_ISO_PARTITION=y
diff --git a/configs/ib62x0_defconfig 

[PATCH 6/8] Rename CONFIG_SYS_AUTOLAOD to CONFIG_SYS_DISABLE_AUTOLOAD

2022-06-13 Thread Tom Rini
The "autoload" environment variable is always checked with env_get_yesno
as it can be set to any form of no.  The default behavior of
env_get_yesno is to return -1 on variables that are not set, which acts
as true in general (we test for non-zero return).  To convert
CONFIG_SYS_AUTOLOAD to Kconfig, given that it was almost always used to
set autoload to no, first rename to CONFIG_SYS_DISABLE_AUTOLOAD for
consistency sake.  Then, make it so that if enabled we set autoload=0 in
the default environment.  Migrate all platforms which set
CONFIG_SYS_AUTOLOAD to non-true or that set autoload to false in their
default environment to using CONFIG_SYS_DISABLE_AUTOLOAD

Signed-off-by: Tom Rini 
---
 cmd/Kconfig  | 9 +
 configs/am335x_guardian_defconfig| 1 +
 configs/bitmain_antminer_s9_defconfig| 1 +
 configs/bk4r1_defconfig  | 1 +
 configs/brppt1_mmc_defconfig | 1 +
 configs/brppt1_nand_defconfig| 1 +
 configs/brppt1_spi_defconfig | 1 +
 configs/brppt2_defconfig | 1 +
 configs/brsmarc1_defconfig   | 1 +
 configs/brxre1_defconfig | 1 +
 configs/cl-som-imx7_defconfig| 1 +
 configs/cm_fx6_defconfig | 1 +
 configs/cm_t335_defconfig| 1 +
 configs/cm_t43_defconfig | 1 +
 configs/d2net_v2_defconfig   | 1 +
 configs/devkit3250_defconfig | 1 +
 configs/dns325_defconfig | 1 +
 configs/ethernut5_defconfig  | 1 +
 configs/inetspace_v2_defconfig   | 1 +
 configs/nas220_defconfig | 1 +
 configs/net2big_v2_defconfig | 1 +
 configs/netspace_lite_v2_defconfig   | 1 +
 configs/netspace_max_v2_defconfig| 1 +
 configs/netspace_mini_v2_defconfig   | 1 +
 configs/netspace_v2_defconfig| 1 +
 configs/octeontx2_95xx_defconfig | 1 +
 configs/octeontx2_96xx_defconfig | 1 +
 configs/omap35_logic_defconfig   | 1 +
 configs/omap35_logic_somlv_defconfig | 1 +
 configs/omap3_logic_defconfig| 1 +
 configs/omap3_logic_somlv_defconfig  | 1 +
 configs/opos6uldev_defconfig | 1 +
 configs/pcm052_defconfig | 1 +
 configs/stm32mp15-icore-stm32mp1-ctouch2_defconfig   | 1 +
 configs/stm32mp15-icore-stm32mp1-edimm2.2_defconfig  | 1 +
 .../stm32mp15-microgea-stm32mp1-microdev2-of7_defconfig  | 1 +
 configs/stm32mp15-microgea-stm32mp1-microdev2_defconfig  | 1 +
 configs/stm32mp15_basic_defconfig| 1 +
 configs/stm32mp15_defconfig  | 1 +
 configs/stm32mp15_dhcom_basic_defconfig  | 1 +
 configs/stm32mp15_dhcor_basic_defconfig  | 1 +
 configs/stm32mp15_trusted_defconfig  | 1 +
 include/configs/am335x_guardian.h| 1 -
 include/configs/bitmain_antminer_s9.h| 1 -
 include/configs/bk4r1.h  | 1 -
 include/configs/brppt1.h | 1 -
 include/configs/brppt2.h | 1 -
 include/configs/brsmarc1.h   | 1 -
 include/configs/brxre1.h | 1 -
 include/configs/cl-som-imx7.h| 4 
 include/configs/cm_fx6.h | 1 -
 include/configs/cm_t335.h| 2 --
 include/configs/cm_t43.h | 1 -
 include/configs/devkit3250.h | 1 -
 include/configs/dns325.h | 1 -
 include/configs/ethernut5.h  | 5 -
 include/configs/imx7-cm.h| 1 -
 include/configs/lacie_kw.h   | 1 -
 include/configs/nas220.h | 3 +--
 include/configs/octeontx2_common.h   | 3 +--
 include/configs/octeontx_common.h| 1 -
 include/configs/omap3_logic.h| 1 -
 include/configs/opos6uldev.h | 1 -
 include/configs/pcm052.h | 1 -
 include/configs/siemens-am33x-common.h   | 2 --
 include/configs/smartweb.h   | 3 ---
 include/configs/stm32mp15_common.h

[PATCH 8/8] gw_ventana: Migrate to using CONFIG_EXTRA_ENV_TEXT

2022-06-13 Thread Tom Rini
Move the environment text over from being set via
CONFIG_EXTRA_ENV_SETTINGS in include/configs/gw_ventana.h and over
to plain text in board/gateworks/gw_ventana/gw_ventana.env.  This lets
us drop CONFIG_EXTRA_ENV_SETTINGS_COMMON as everything resides in a
single environment file now.

Cc: Tim Harvey 
Signed-off-by: Tom Rini 
---
 board/gateworks/gw_ventana/gw_ventana.env | 145 +
 include/configs/gw_ventana.h  | 148 --
 2 files changed, 145 insertions(+), 148 deletions(-)
 create mode 100644 board/gateworks/gw_ventana/gw_ventana.env

diff --git a/board/gateworks/gw_ventana/gw_ventana.env 
b/board/gateworks/gw_ventana/gw_ventana.env
new file mode 100644
index ..9a316c74f215
--- /dev/null
+++ b/board/gateworks/gw_ventana/gw_ventana.env
@@ -0,0 +1,145 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2013 Gateworks Corporation
+ */
+
+splashpos=m,m
+splashimage=CONFIG_SYS_LOAD_ADDR
+usb_pgood_delay=2000
+console=ttymxc1
+bootdevs=usb mmc sata flash
+hwconfig=_UNKNOWN_
+
+disk=0
+part=1
+
+fdt_high=0x
+fdt_addr=0x1800
+initrd_high=0x
+fixfdt=fdt addr ${fdt_addr}
+bootdir=boot
+loadfdt=
+   if ${fsload} ${fdt_addr} ${bootdir}/${fdt_file}; then
+   echo Loaded DTB from ${bootdir}/${fdt_file};
+   run fixfdt;
+   elif ${fsload} ${fdt_addr} ${bootdir}/${fdt_file1}; then
+   echo Loaded DTB from ${bootdir}/${fdt_file1};
+   run fixfdt;
+   elif ${fsload} ${fdt_addr} ${bootdir}/${fdt_file2}; then
+   echo Loaded DTB from ${bootdir}/${fdt_file2};
+   run fixfdt;
+   fi
+
+fs=ext4
+script=6x_bootscript-ventana
+loadscript=
+   if ${fsload} ${loadaddr} ${bootdir}/${script}; then
+   source ${loadaddr};
+   fi
+
+uimage=uImage
+mmc_root=mmcblk0p1
+mmc_boot=
+   setenv fsload "${fs}load mmc ${disk}:${part}";
+   mmc dev ${disk} && mmc rescan &&
+   setenv dtype mmc; run loadscript;
+   if ${fsload} ${loadaddr} ${bootdir}/${uimage}; then
+   setenv bootargs console=${console},${baudrate}
+   root=/dev/${mmc_root} rootfstype=${fs}
+   rootwait rw ${video} ${extra};
+   if run loadfdt; then
+   bootm ${loadaddr} - ${fdt_addr};
+   else
+   bootm;
+   fi;
+   fi
+
+sata_boot=
+   setenv fsload "${fs}load sata ${disk}:${part}";
+   sata init &&
+   setenv dtype sata; run loadscript;
+   if ${fsload} ${loadaddr} ${bootdir}/${uimage}; then
+   setenv bootargs console=${console},${baudrate}
+   root=/dev/sda1 rootfstype=${fs}
+   rootwait rw ${video} ${extra};
+   if run loadfdt; then
+   bootm ${loadaddr} - ${fdt_addr};
+   else
+   bootm;
+   fi;
+   fi
+
+usb_boot=
+   setenv fsload "${fs}load usb ${disk}:${part}";
+   usb start && usb dev ${disk} &&
+   setenv dtype usb; run loadscript;
+   if ${fsload} ${loadaddr} ${bootdir}/${uimage}; then
+   setenv bootargs console=${console},${baudrate}
+   root=/dev/sda1 rootfstype=${fs}
+   rootwait rw ${video} ${extra};
+   if run loadfdt; then
+   bootm ${loadaddr} - ${fdt_addr};
+   else
+   bootm;
+   fi;
+   fi
+
+#ifdef CONFIG_SPI_FLASH
+image_os=ventana/openwrt-imx6-imx6q-gw5400-a-squashfs.bin
+image_uboot=ventana/u-boot_spi.imx
+
+spi_koffset=0x9
+spi_klen=0x20
+
+spi_updateuboot=echo Updating uboot from
+   ${serverip}:${image_uboot}...;
+   tftpboot ${loadaddr} ${image_uboot} &&
+   sf probe && sf erase 0 8 &&
+   sf write ${loadaddr} 400 ${filesize}
+spi_update=echo Updating OS from ${serverip}:${image_os}
+   to ${spi_koffset} ...;
+   tftp ${loadaddr} ${image_os} &&
+   sf probe &&
+   sf update ${loadaddr} ${spi_koffset} ${filesize}
+
+flash_boot=
+   if sf probe &&
+   sf read ${loadaddr} ${spi_koffset} ${spi_klen}; then
+   setenv bootargs console=${console},${baudrate}
+   root=/dev/mtdblock3
+   rootfstype=squashfs,jffs2
+   ${video} ${extra};
+   bootm;
+   fi
+#else
+image_rootfs=openwrt-imx6-ventana-rootfs.ubi
+nand_update=echo Updating NAND from ${serverip}:${image_rootfs}...;
+   tftp ${loadaddr} ${image_rootfs} &&
+   nand erase.part rootfs &&
+   nand write ${loadaddr} rootfs ${filesize}
+
+flash_boot=
+   setenv fsload 'ubifsload';
+   ubi part rootfs;
+   if ubi check boot; then
+   ubifsmount ubi0:boot;
+   setenv root ubi0:rootfs ubi.mtd=2
+   rootfstype=squashfs,ubifs;
+   setenv bootdir;
+   

[PATCH 5/8] opos6uldev: Migrate to using CONFIG_EXTRA_ENV_TEXT

2022-06-13 Thread Tom Rini
Move the environment text over from being set via
CONFIG_EXTRA_ENV_SETTINGS in include/configs/opos6uldev.h and over to
plain text in board/armadeus/opos6uldev/opos6uldev.env.  This lets us
manage env_version without a CONFIG variable.

Cc: Sébastien Szymanski 
Signed-off-by: Tom Rini 
---
 board/armadeus/opos6uldev/opos6uldev.env | 133 +++
 include/configs/opos6uldev.h | 131 --
 2 files changed, 133 insertions(+), 131 deletions(-)
 create mode 100644 board/armadeus/opos6uldev/opos6uldev.env

diff --git a/board/armadeus/opos6uldev/opos6uldev.env 
b/board/armadeus/opos6uldev/opos6uldev.env
new file mode 100644
index ..585f28ca8587
--- /dev/null
+++ b/board/armadeus/opos6uldev/opos6uldev.env
@@ -0,0 +1,133 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+/*
+ * Copyright (C) 2017 Armadeus Systems
+ */
+
+/* Environment is stored in the eMMC boot partition */
+
+env_version=100
+consoledev=ttymxc0
+board_name=opos6ul
+fdt_addr=0x8800
+fdt_high=0x
+fdt_name=opos6uldev
+initrd_high=0x
+ip_dyn=yes
+stdin=serial
+stdout=serial
+stderr=serial
+mmcdev=0
+mmcpart=2
+mmcroot=/dev/mmcblk0p2 ro
+mmcrootfstype=ext4 rootwait
+kernelimg=opos6ul-linux.bin
+splashpos=0,0
+splashimage=CONFIG_SYS_LOAD_ADDR
+videomode=video=ctfb:x:800,y:480,depth:18,pclk:33033,le:96,ri:96,up:20,lo:21,hs:64,vs:4,sync:0,vmode:0
+check_env=if test -n ${flash_env_version};
+   then env default env_version;
+   else env set flash_env_version ${env_version}; env save;
+   fi;
+   if itest ${flash_env_version} != ${env_version}; then
+   echo "*** Warning - Environment version
+change suggests: run flash_reset_env; reset";
+   env default flash_reset_env;
+   else exit; fi; 
+flash_reset_env=env default -f -a && saveenv &&
+   echo Environment variables erased!
+download_uboot_spl=tftpboot ${loadaddr} ${board_name}-u-boot.spl
+flash_uboot_spl=
+   if mmc dev 0 1; then
+   setexpr sz ${filesize} / 0x200;
+   setexpr sz ${sz} + 1;
+   if mmc write ${loadaddr} 0x2 ${sz}; then
+   echo Flashing of U-boot SPL succeed;
+   else echo Flashing of U-boot SPL failed;
+   fi;
+   fi;
+download_uboot_img=tftpboot ${loadaddr} ${board_name}-u-boot.img
+flash_uboot_img=
+   if mmc dev 0 1; then
+   setexpr sz ${filesize} / 0x200;
+   setexpr sz ${sz} + 1;
+   if mmc write ${loadaddr} 0x8a ${sz}; then
+   echo Flashing of U-boot image succeed;
+   else echo Flashing of U-boot image failed;
+   fi;
+   fi;
+update_uboot=run download_uboot_spl flash_uboot_spl
+   download_uboot_img flash_uboot_img
+download_kernel=tftpboot ${loadaddr} ${kernelimg}
+flash_kernel=
+   if ext4write mmc ${mmcdev}:${mmcpart} ${loadaddr} /boot/${kernelimg} 
${filesize}; then
+   echo kernel update succeed;
+   else echo kernel update failed;
+   fi;
+update_kernel=run download_kernel flash_kernel
+download_dtb=tftpboot ${fdt_addr} imx6ul-${fdt_name}.dtb
+flash_dtb=
+   if ext4write mmc ${mmcdev}:${mmcpart} ${fdt_addr} 
/boot/imx6ul-${fdt_name}.dtb ${filesize}; then
+   echo dtb update succeed;
+   else echo dtb update in failed;
+   fi;
+update_dtb=run download_dtb flash_dtb
+download_rootfs=tftpboot ${loadaddr} ${board_name}-rootfs.ext4
+flash_rootfs=
+   if mmc dev 0 0; then
+   setexpr nbblocks ${filesize} / 0x200;
+   setexpr nbblocks ${nbblocks} + 1;
+   if mmc write ${loadaddr} 0x40800 ${nbblocks}; then
+   echo Flashing of rootfs image succeed;
+   else echo Flashing of rootfs image failed;
+   fi;
+   fi;
+update_rootfs=run download_rootfs flash_rootfs
+flash_failsafe=
+   if mmc dev 0 0; then
+   setexpr nbblocks ${filesize} / 0x200;
+   setexpr nbblocks ${nbblocks} + 1;
+   if mmc write ${loadaddr} 0x800 ${nbblocks}; then
+   echo Flashing of rootfs image in failsafe partition 
succeed;
+   else echo Flashing of rootfs image in failsafe partition failed;
+   fi;
+   fi;
+update_failsafe=run download_rootfs flash_failsafe
+download_userdata=tftpboot ${loadaddr} ${board_name}-user_data.ext4
+flash_userdata=
+   if mmc dev 0 0; then
+   setexpr nbblocks ${filesize} / 0x200;
+   setexpr nbblocks ${nbblocks} + 1;
+   if mmc write ${loadaddr} 0 ${nbblocks}; then
+   echo Flashing of user_data image succeed;
+   else echo Flashing of user_data image failed;
+   fi;
+   fi;
+update_userdata=run download_userdata flash_userdata; mmc rescan
+erase_userdata=
+   if mmc dev 0 0; then
+   echo Erasing eMMC User Data partition, no way 

[PATCH 4/8] Convert CONFIG_ENV_RANGE to Kconfig

2022-06-13 Thread Tom Rini
This converts the following to Kconfig:
   CONFIG_ENV_RANGE

Now that this is in Kconfig we can enforce a minimum size and so remove
the check in C code to ensure range is larger than size.

Signed-off-by: Tom Rini 
---
 configs/P1010RDB-PA_36BIT_NAND_defconfig |  1 +
 configs/P1010RDB-PA_NAND_defconfig   |  1 +
 configs/P1010RDB-PB_36BIT_NAND_defconfig |  1 +
 configs/P1010RDB-PB_NAND_defconfig   |  1 +
 configs/P1020RDB-PC_36BIT_NAND_defconfig |  1 +
 configs/P1020RDB-PC_NAND_defconfig   |  1 +
 configs/P1020RDB-PD_NAND_defconfig   |  1 +
 configs/P2020RDB-PC_36BIT_NAND_defconfig |  1 +
 configs/P2020RDB-PC_NAND_defconfig   |  1 +
 configs/colibri-imx6ull_defconfig|  1 +
 configs/colibri_imx7_defconfig   |  1 +
 configs/colibri_vf_defconfig |  1 +
 configs/draco_defconfig  |  1 +
 configs/etamin_defconfig |  1 +
 configs/m53menlo_defconfig   |  1 +
 configs/mx28evk_nand_defconfig   |  1 +
 configs/rastaban_defconfig   |  1 +
 configs/smartweb_defconfig   |  1 +
 configs/thuban_defconfig |  1 +
 configs/vf610twr_nand_defconfig  |  1 +
 env/Kconfig  | 18 ++
 env/nand.c   |  8 
 include/configs/P1010RDB.h   |  6 --
 include/configs/colibri-imx6ull.h|  5 -
 include/configs/colibri_imx7.h   |  5 -
 include/configs/colibri_vf.h |  5 -
 include/configs/draco.h  |  3 ---
 include/configs/etamin.h |  4 
 include/configs/m53menlo.h   |  3 ---
 include/configs/mx28evk.h| 11 ---
 include/configs/p1_p2_rdb_pc.h   |  1 -
 include/configs/rastaban.h   |  3 ---
 include/configs/smartweb.h   |  5 -
 include/configs/thuban.h |  3 ---
 include/configs/vf610twr.h   |  4 
 35 files changed, 30 insertions(+), 74 deletions(-)

diff --git a/configs/P1010RDB-PA_36BIT_NAND_defconfig 
b/configs/P1010RDB-PA_36BIT_NAND_defconfig
index 4ebb8d06cdd3..8af653c65661 100644
--- a/configs/P1010RDB-PA_36BIT_NAND_defconfig
+++ b/configs/P1010RDB-PA_36BIT_NAND_defconfig
@@ -69,6 +69,7 @@ 
CONFIG_MTDPARTS_DEFAULT="mtdparts=ff80.flash:2m(uboot-env),1m(dtb),5m(kernel
 CONFIG_OF_CONTROL=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_NAND=y
+CONFIG_ENV_RANGE=0xc000
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_USE_BOOTFILE=y
 CONFIG_BOOTFILE="uImage"
diff --git a/configs/P1010RDB-PA_NAND_defconfig 
b/configs/P1010RDB-PA_NAND_defconfig
index 9ab41e80a278..f94b24d3bdc7 100644
--- a/configs/P1010RDB-PA_NAND_defconfig
+++ b/configs/P1010RDB-PA_NAND_defconfig
@@ -68,6 +68,7 @@ 
CONFIG_MTDPARTS_DEFAULT="mtdparts=ff80.flash:2m(uboot-env),1m(dtb),5m(kernel
 CONFIG_OF_CONTROL=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_NAND=y
+CONFIG_ENV_RANGE=0xc000
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_USE_BOOTFILE=y
 CONFIG_BOOTFILE="uImage"
diff --git a/configs/P1010RDB-PB_36BIT_NAND_defconfig 
b/configs/P1010RDB-PB_36BIT_NAND_defconfig
index e2abe92e7a6b..d5577435c922 100644
--- a/configs/P1010RDB-PB_36BIT_NAND_defconfig
+++ b/configs/P1010RDB-PB_36BIT_NAND_defconfig
@@ -70,6 +70,7 @@ 
CONFIG_MTDPARTS_DEFAULT="mtdparts=ff80.flash:2m(uboot-env),1m(dtb),5m(kernel
 CONFIG_OF_CONTROL=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_NAND=y
+CONFIG_ENV_RANGE=0x8
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_USE_BOOTFILE=y
 CONFIG_BOOTFILE="uImage"
diff --git a/configs/P1010RDB-PB_NAND_defconfig 
b/configs/P1010RDB-PB_NAND_defconfig
index f27a24b7a18e..3469ea0f40da 100644
--- a/configs/P1010RDB-PB_NAND_defconfig
+++ b/configs/P1010RDB-PB_NAND_defconfig
@@ -69,6 +69,7 @@ 
CONFIG_MTDPARTS_DEFAULT="mtdparts=ff80.flash:2m(uboot-env),1m(dtb),5m(kernel
 CONFIG_OF_CONTROL=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_NAND=y
+CONFIG_ENV_RANGE=0x8
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_USE_BOOTFILE=y
 CONFIG_BOOTFILE="uImage"
diff --git a/configs/P1020RDB-PC_36BIT_NAND_defconfig 
b/configs/P1020RDB-PC_36BIT_NAND_defconfig
index d8902bc03ffb..19d1718830e5 100644
--- a/configs/P1020RDB-PC_36BIT_NAND_defconfig
+++ b/configs/P1020RDB-PC_36BIT_NAND_defconfig
@@ -69,6 +69,7 @@ CONFIG_CMD_FAT=y
 CONFIG_OF_CONTROL=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_NAND=y
+CONFIG_ENV_RANGE=0xc000
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_USE_BOOTFILE=y
 CONFIG_BOOTFILE="uImage"
diff --git a/configs/P1020RDB-PC_NAND_defconfig 
b/configs/P1020RDB-PC_NAND_defconfig
index c581b9ddbe6c..19f4e1cbcb33 100644
--- a/configs/P1020RDB-PC_NAND_defconfig
+++ b/configs/P1020RDB-PC_NAND_defconfig
@@ -68,6 +68,7 @@ CONFIG_CMD_FAT=y
 CONFIG_OF_CONTROL=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_NAND=y
+CONFIG_ENV_RANGE=0xc000
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_USE_BOOTFILE=y
 CONFIG_BOOTFILE="uImage"
diff --git a/configs/P1020RDB-PD_NAND_defconfig 
b/configs/P1020RDB-PD_NAND_defconfig
index 

[PATCH 3/8] dragonboard410c: Migrate to using CONFIG_EXTRA_ENV_TEXT

2022-06-13 Thread Tom Rini
With the exception of distro_boot support, we can move all of the rest
of the environment changes to come from CONFIG_EXTRA_ENV_TEXT and in
turn remove CONFIG_ENV_REFLASH.

Cc: Ramon Fried 
Signed-off-by: Tom Rini 
---
 .../dragonboard410c/dragonboard410c.env   | 36 
 include/configs/dragonboard410c.h | 42 +--
 2 files changed, 38 insertions(+), 40 deletions(-)
 create mode 100644 board/qualcomm/dragonboard410c/dragonboard410c.env

diff --git a/board/qualcomm/dragonboard410c/dragonboard410c.env 
b/board/qualcomm/dragonboard410c/dragonboard410c.env
new file mode 100644
index ..9d9a575a0c3f
--- /dev/null
+++ b/board/qualcomm/dragonboard410c/dragonboard410c.env
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+/* Does what recovery does */
+#define REFLASH(file, partnum) \
+part start mmc 0 partnum start && \
+part size mmc 0 partnum size && \
+tftp $loadaddr file &&  \
+mmc write $loadaddr $start $size &&
+
+reflash=
+mmc dev 0 &&
+usb start &&
+dhcp &&
+tftp $loadaddr dragonboard/rescue/gpt_both0.bin &&
+mmc write $loadaddr 0 43 &&
+mmc rescan &&
+REFLASH(dragonboard/rescue/NON-HLOS.bin, 1)
+REFLASH(dragonboard/rescue/sbl1.mbn, 2)
+REFLASH(dragonboard/rescue/rpm.mbn, 3)
+REFLASH(dragonboard/rescue/tz.mbn, 4)
+REFLASH(dragonboard/rescue/hyp.mbn, 5)
+REFLASH(dragonboard/rescue/sec.dat, 6)
+REFLASH(dragonboard/rescue/emmc_appsboot.mbn, 7)
+REFLASH(dragonboard/u-boot.img, 8)
+usb stop &&
+echo Reflash completed
+
+loadaddr=0x8100
+initrd_high=0x
+linux_image=Image
+kernel_addr_r=0x8100
+fdtfile=qcom/apq8016-sbc.dtb
+fdt_addr_r=0x8300
+ramdisk_addr_r=0x8400
+scriptaddr=0x9000
+pxefile_addr_r=0x9010
diff --git a/include/configs/dragonboard410c.h 
b/include/configs/dragonboard410c.h
index 26a714c2886b..e1d580b1c8f8 100644
--- a/include/configs/dragonboard410c.h
+++ b/include/configs/dragonboard410c.h
@@ -20,8 +20,7 @@
 #define CONFIG_SYS_SDRAM_BASE  PHYS_SDRAM_1
 #define CONFIG_SYS_BOOTM_LEN   SZ_64M
 
-/* UART */
-
+/* Environment */
 #define BOOT_TARGET_DEVICES(func) \
func(USB, usb, 0) \
func(MMC, mmc, 1) \
@@ -30,43 +29,6 @@
 
 #include 
 
-/* Does what recovery does */
-#define REFLASH(file, part) \
-"part start mmc 0 "#part" start && "\
-"part size mmc 0 "#part" size && "\
-"tftp $loadaddr "#file" && " \
-"mmc write $loadaddr $start $size && "
-
-#define CONFIG_ENV_REFLASH \
-"mmc dev 0 && "\
-"usb start && "\
-"dhcp && "\
-"tftp $loadaddr dragonboard/rescue/gpt_both0.bin && "\
-"mmc write $loadaddr 0 43 && " \
-"mmc rescan && "\
-REFLASH(dragonboard/rescue/NON-HLOS.bin, 1)\
-REFLASH(dragonboard/rescue/sbl1.mbn, 2)\
-REFLASH(dragonboard/rescue/rpm.mbn, 3)\
-REFLASH(dragonboard/rescue/tz.mbn, 4)\
-REFLASH(dragonboard/rescue/hyp.mbn, 5)\
-REFLASH(dragonboard/rescue/sec.dat, 6)\
-REFLASH(dragonboard/rescue/emmc_appsboot.mbn, 7)\
-REFLASH(dragonboard/u-boot.img, 8)\
-"usb stop &&"\
-"echo Reflash completed"
-
-/* Environment */
-#define CONFIG_EXTRA_ENV_SETTINGS \
-   "reflash="CONFIG_ENV_REFLASH"\0"\
-   "loadaddr=0x8100\0" \
-   "initrd_high=0x\0" \
-   "linux_image=Image\0" \
-   "kernel_addr_r=0x8100\0"\
-   "fdtfile=qcom/apq8016-sbc.dtb\0" \
-   "fdt_addr_r=0x8300\0"\
-   "ramdisk_addr_r=0x8400\0"\
-   "scriptaddr=0x9000\0"\
-   "pxefile_addr_r=0x9010\0"\
-   BOOTENV
+#define CONFIG_EXTRA_ENV_SETTINGS BOOTENV
 
 #endif
-- 
2.25.1



[PATCH 2/8] env: Remove include/generated/env.* under "make clean"

2022-06-13 Thread Tom Rini
When running "make clean" we want to remove env.in and well as env.txt.

Cc: Simon Glass 
Signed-off-by: Tom Rini 
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 2fa3a3b488e6..101534566847 100644
--- a/Makefile
+++ b/Makefile
@@ -2209,7 +2209,7 @@ CLEAN_DIRS  += $(MODVERDIR) \
$(filter-out include, $(shell ls -1 $d 2>/dev/null
 
 CLEAN_FILES += include/bmp_logo.h include/bmp_logo_data.h \
-  include/generated/env.in drivers/video/u_boot_logo.S \
+  include/generated/env.* drivers/video/u_boot_logo.S \
   tools/version.h u-boot* MLO* SPL System.map fit-dtb.blob* \
   u-boot-ivt.img.log u-boot-dtb.imx.log SPL.log u-boot.imx.log \
   lpc32xx-* bl31.c bl31.elf bl31_*.bin image.map tispl.bin* \
-- 
2.25.1



[PATCH 1/8] env: Do not make CONFIG_EXTRA_ENV_TEXT and CONFIG_EXTRA_ENV_SETTINGS conflict

2022-06-13 Thread Tom Rini
Largely, the use of CONFIG_EXTRA_ENV_SETTINGS can be migrated directly
to come from CONFIG_EXTRA_ENV_TEXT.  The biggest case that cannot easily
be migrated is distro_bootcmd support.  Rather than block migration on
this, remove the #error here so that we can being moving forward.

Cc: Joe Hershberger 
Cc: Wolfgang Denk 
Cc: Simon Glass 
Signed-off-by: Tom Rini 
---
I spent about a day working at getting config_distro_bootcmd to work via
CONFIG_EXTRA_ENV_TEXT and _maybe_ there's a path forward if we rely on
less nesting of macros, I'm not convinced.  But I can clearly see how
moving everything else forward to text based environment files will
encourage sharing of environment and both remove otherwise unmigrated
CONFIG symbols and generally move forward with being able to remove
include/config/board.h files.
---
 include/env_default.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/include/env_default.h b/include/env_default.h
index 7004a6fef29b..7113e08e6b0f 100644
--- a/include/env_default.h
+++ b/include/env_default.h
@@ -109,9 +109,6 @@ const char default_environment[] = {
"bootlimit="__stringify(CONFIG_BOOTCOUNT_BOOTLIMIT)"\0"
 #endif
 #ifdef CONFIG_EXTRA_ENV_TEXT
-# ifdef CONFIG_EXTRA_ENV_SETTINGS
-# error "Your board uses a text-file environment, so must not define 
CONFIG_EXTRA_ENV_SETTINGS"
-# endif
/* This is created in the Makefile */
CONFIG_EXTRA_ENV_TEXT
 #endif
-- 
2.25.1



Re: [PATCH] mmc: fsl_esdhc: Fix 'Internal clock never stabilised.' error

2022-06-13 Thread Jaehoon Chung
Hi,

On 6/12/22 18:12, Pali Rohár wrote:
> PING?

Sorry for too late. 

> 
> On Friday 29 April 2022 20:27:34 Pali Rohár wrote:
>> Only newer eSDHC controllers set PRSSTAT_SDSTB flag. So do not wait until
>> flag PRSSTAT_SDSTB is set on old pre-2.2 controllers. Instead sleep for
>> fixed amount of time like it was before commit 6f883e501b65 ("mmc:
>> fsl_esdhc: Add emmc hs200 support").
>>
>> This change fixes error 'Internal clock never stabilised.' which is printed
>> on P2020 board at every access to SD card.
>>
>> Fixes: 6f883e501b65 ("mmc: fsl_esdhc: Add emmc hs200 support")
>> Signed-off-by: Pali Rohár 

Reviewed-by: Jaehoon Chung 

Best Regards,
Jaehoon Chung

>> ---
>>  drivers/mmc/fsl_esdhc.c | 17 +
>>  1 file changed, 17 insertions(+)
>>
>> diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
>> index fdf2cc290e06..3b3587bd8d72 100644
>> --- a/drivers/mmc/fsl_esdhc.c
>> +++ b/drivers/mmc/fsl_esdhc.c
>> @@ -503,6 +503,7 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, 
>> struct mmc *mmc, uint clock)
>>  u32 time_out;
>>  u32 value;
>>  uint clk;
>> +u32 hostver;
>>  
>>  if (clock < mmc->cfg->f_min)
>>  clock = mmc->cfg->f_min;
>> @@ -543,6 +544,14 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, 
>> struct mmc *mmc, uint clock)
>>  
>>  esdhc_clrsetbits32(>sysctl, SYSCTL_CLOCK_MASK, clk);
>>  
>> +/* Only newer eSDHC controllers set PRSSTAT_SDSTB flag */
>> +hostver = esdhc_read32(>esdhc_regs->hostver);
>> +if (HOSTVER_VENDOR(hostver) <= VENDOR_V_22) {
>> +udelay(1);
>> +esdhc_setbits32(>sysctl, SYSCTL_PEREN | SYSCTL_CKEN);
>> +return;
>> +}
>> +
>>  time_out = 20;
>>  value = PRSSTAT_SDSTB;
>>  while (!(esdhc_read32(>prsstat) & value)) {
>> @@ -562,6 +571,7 @@ static void esdhc_clock_control(struct fsl_esdhc_priv 
>> *priv, bool enable)
>>  struct fsl_esdhc *regs = priv->esdhc_regs;
>>  u32 value;
>>  u32 time_out;
>> +u32 hostver;
>>  
>>  value = esdhc_read32(>sysctl);
>>  
>> @@ -572,6 +582,13 @@ static void esdhc_clock_control(struct fsl_esdhc_priv 
>> *priv, bool enable)
>>  
>>  esdhc_write32(>sysctl, value);
>>  
>> +/* Only newer eSDHC controllers set PRSSTAT_SDSTB flag */
>> +hostver = esdhc_read32(>esdhc_regs->hostver);
>> +if (HOSTVER_VENDOR(hostver) <= VENDOR_V_22) {
>> +udelay(1);
>> +return;
>> +}
>> +
>>  time_out = 20;
>>  value = PRSSTAT_SDSTB;
>>  while (!(esdhc_read32(>prsstat) & value)) {
>> -- 
>> 2.20.1
>>
> 



Re: [PATCH 13/49] mmc: fsl_esdhc_imx: Support i.MX9

2022-06-13 Thread Jaehoon Chung
On 6/6/22 20:23, Peng Fan (OSS) wrote:
> From: Peng Fan 
> 
> Support i.MX9 for fsl_esdhc_imx driver
> 
> Signed-off-by: Peng Fan 

Reviewed-by: Jaehoon Chung 

Best Regards,
Jaehoon Chung

> ---
>  drivers/mmc/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
> index 5e2921ce41a..8a8a59b5d2c 100644
> --- a/drivers/mmc/Kconfig
> +++ b/drivers/mmc/Kconfig
> @@ -834,7 +834,7 @@ config FSL_ESDHC_IMX
>  
>  config FSL_USDHC
>   bool "Freescale/NXP i.MX uSDHC controller support"
> - depends on MX6 || MX7 ||ARCH_MX7ULP || IMX8 || IMX8M || IMX8ULP || IMXRT
> + depends on MX6 || MX7 ||ARCH_MX7ULP || IMX8 || IMX8M || IMX8ULP || IMX9 
> || IMXRT
>   select FSL_ESDHC_IMX
>   help
> This enables the Ultra Secured Digital Host Controller enhancements



Re: [PATCH v2 13/14] power: regulator: scmi: simplify scmi_voltd_set_enable()

2022-06-13 Thread Jaehoon Chung
On 6/1/22 01:09, Etienne Carriere wrote:
> Simplify scmi_voltd_set_enable() exit sequence.
> 
> Cc: Jaehoon Chung 
> Signed-off-by: Etienne Carriere 

Reviewed-by: Jaehoon Chung 

Best Regards,
Jaehoon Chung

> ---
> No change since v1.
> 
> ---
>  drivers/power/regulator/scmi_regulator.c | 6 +-
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/power/regulator/scmi_regulator.c 
> b/drivers/power/regulator/scmi_regulator.c
> index 352daa9bbc9..801148036ff 100644
> --- a/drivers/power/regulator/scmi_regulator.c
> +++ b/drivers/power/regulator/scmi_regulator.c
> @@ -51,11 +51,7 @@ static int scmi_voltd_set_enable(struct udevice *dev, bool 
> enable)
>   if (ret)
>   return ret;
>  
> - ret = scmi_to_linux_errno(out.status);
> - if (ret)
> - return ret;
> -
> - return ret;
> + return scmi_to_linux_errno(out.status);
>  }
>  
>  static int scmi_voltd_get_enable(struct udevice *dev)



Re: [PATCH v2 12/14] power: regulator: scmi: support SCMI multi-channel

2022-06-13 Thread Jaehoon Chung
On 6/1/22 01:09, Etienne Carriere wrote:
> Update SCMI regulator controller driver to get its assigned SCMI channel
> during initialization. This change allows SCMI voltage domain protocol
> to use a dedicated channel when defined in the DT. The reference is
> saved in SCMI regulator controller driver private data.
> 
> Cc: Jaehoon Chung 
> Signed-off-by: Etienne Carriere 

Reviewed-by: Jaehoon Chung 

Best Regards,
Jaehoon Chung

> ---
> Changes since v1:
> - Define a private struct to hold channel reference rather than using
>   device private data reference as opaque channel reference.
> 
> ---
>  drivers/power/regulator/scmi_regulator.c | 30 +++-
>  1 file changed, 24 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/power/regulator/scmi_regulator.c 
> b/drivers/power/regulator/scmi_regulator.c
> index 3325ddaf23b..352daa9bbc9 100644
> --- a/drivers/power/regulator/scmi_regulator.c
> +++ b/drivers/power/regulator/scmi_regulator.c
> @@ -1,6 +1,6 @@
>  // SPDX-License-Identifier: GPL-2.0+
>  /*
> - * Copyright (C) 2020-2021 Linaro Limited
> + * Copyright (C) 2020-2022 Linaro Limited
>   */
>  
>  #define LOG_CATEGORY UCLASS_REGULATOR
> @@ -25,9 +25,18 @@ struct scmi_regulator_platdata {
>   u32 domain_id;
>  };
>  
> +/**
> + * struct scmi_regulator_priv - Private data for SCMI voltage regulator
> + * @channel: Reference to the SCMI channel to use
> + */
> +struct scmi_regulator_priv {
> + struct scmi_channel *channel;
> +};
> +
>  static int scmi_voltd_set_enable(struct udevice *dev, bool enable)
>  {
>   struct scmi_regulator_platdata *pdata = dev_get_plat(dev);
> + struct scmi_regulator_priv *priv = dev_get_priv(dev);
>   struct scmi_voltd_config_set_in in = {
>   .domain_id = pdata->domain_id,
>   .config = enable ? SCMI_VOLTD_CONFIG_ON : SCMI_VOLTD_CONFIG_OFF,
> @@ -38,7 +47,7 @@ static int scmi_voltd_set_enable(struct udevice *dev, bool 
> enable)
> in, out);
>   int ret;
>  
> - ret = devm_scmi_process_msg(dev, NULL, );
> + ret = devm_scmi_process_msg(dev, priv->channel, );
>   if (ret)
>   return ret;
>  
> @@ -52,6 +61,7 @@ static int scmi_voltd_set_enable(struct udevice *dev, bool 
> enable)
>  static int scmi_voltd_get_enable(struct udevice *dev)
>  {
>   struct scmi_regulator_platdata *pdata = dev_get_plat(dev);
> + struct scmi_regulator_priv *priv = dev_get_priv(dev);
>   struct scmi_voltd_config_get_in in = {
>   .domain_id = pdata->domain_id,
>   };
> @@ -61,7 +71,7 @@ static int scmi_voltd_get_enable(struct udevice *dev)
> in, out);
>   int ret;
>  
> - ret = devm_scmi_process_msg(dev, NULL, );
> + ret = devm_scmi_process_msg(dev, priv->channel, );
>   if (ret < 0)
>   return ret;
>  
> @@ -74,6 +84,7 @@ static int scmi_voltd_get_enable(struct udevice *dev)
>  
>  static int scmi_voltd_set_voltage_level(struct udevice *dev, int uV)
>  {
> + struct scmi_regulator_priv *priv = dev_get_priv(dev);
>   struct scmi_regulator_platdata *pdata = dev_get_plat(dev);
>   struct scmi_voltd_level_set_in in = {
>   .domain_id = pdata->domain_id,
> @@ -85,7 +96,7 @@ static int scmi_voltd_set_voltage_level(struct udevice 
> *dev, int uV)
> in, out);
>   int ret;
>  
> - ret = devm_scmi_process_msg(dev, NULL, );
> + ret = devm_scmi_process_msg(dev, priv->channel, );
>   if (ret < 0)
>   return ret;
>  
> @@ -94,6 +105,7 @@ static int scmi_voltd_set_voltage_level(struct udevice 
> *dev, int uV)
>  
>  static int scmi_voltd_get_voltage_level(struct udevice *dev)
>  {
> + struct scmi_regulator_priv *priv = dev_get_priv(dev);
>   struct scmi_regulator_platdata *pdata = dev_get_plat(dev);
>   struct scmi_voltd_level_get_in in = {
>   .domain_id = pdata->domain_id,
> @@ -104,7 +116,7 @@ static int scmi_voltd_get_voltage_level(struct udevice 
> *dev)
> in, out);
>   int ret;
>  
> - ret = devm_scmi_process_msg(dev, NULL, );
> + ret = devm_scmi_process_msg(dev, priv->channel, );
>   if (ret < 0)
>   return ret;
>  
> @@ -132,6 +144,7 @@ static int scmi_regulator_of_to_plat(struct udevice *dev)
>  static int scmi_regulator_probe(struct udevice *dev)
>  {
>   struct scmi_regulator_platdata *pdata = dev_get_plat(dev);
> + struct scmi_regulator_priv *priv = dev_get_priv(dev);
>   struct scmi_voltd_attr_in in = { 0 };
>   struct scmi_voltd_attr_out out = { 0 };
>   struct scmi_msg scmi_msg = {
> @@ -144,10 +157,14 @@ static int scmi_regulator_probe(struct udevice *dev)
>   };
>   int ret;
>  
> + ret = devm_scmi_of_get_channel(dev->parent, >channel);
> + if (ret)
> + return ret;
> +
>   /* Check voltage domain is known from SCMI server */
>   

Re: [PATCH 2/2] pmic: pca9450: drop pointless .data entries

2022-06-13 Thread Jaehoon Chung
On 6/2/22 21:30, Rasmus Villemoes wrote:
> On 02/06/2022 02.30, Jaehoon Chung wrote:
>> Dear Rasums,
>>
>> On 5/17/22 08:44, Jaehoon Chung wrote:
>>> On 5/3/22 17:58, Rasmus Villemoes wrote:
 These are the i2c addresses of the chips, but that comes from device
 tree. Having that information duplicated here just adds confusion.

 Signed-off-by: Rasmus Villemoes 
>>
>> There is a conflict with commit 326337fb005f968911d897867d09d1228b070d84.
>> Could you send the patch again? Sorry for too late.
> 
> Oh, but that commit repurposes the .data member - or rather, "purposes",
> but I don't think that's a real verb. Previously the driver_data wasn't
> used for anything, but it is now.
> 
> So my patch should simply be dropped.

Okay. Thanks!

Best Regards,
Jaehoon Chung

> 
> Rasmus
> 



Re: [PATCH] spi: nxp_fspi: Fix clock imbalance

2022-06-13 Thread Peng Fan (OSS)




在 2022/6/13 20:35, Marek Vasut 写道:

The nxp_fspi_default_setup() is only ever called from nxp_fspi_probe(),
where the IP clock are initially disabled. Drop the second disabling of
clock to prevent clock enable/disable imbalance reported by clock core:

"
clk qspi_root_clk already disabled
"

Signed-off-by: Marek Vasut 
Cc: Fabio Estevam 
Cc: Peng Fan 
Cc: Stefano Babic 


Reviewed-by: Peng Fan 

---
  drivers/spi/nxp_fspi.c | 3 ---
  1 file changed, 3 deletions(-)

diff --git a/drivers/spi/nxp_fspi.c b/drivers/spi/nxp_fspi.c
index 607c953987b..579d6bac9b1 100644
--- a/drivers/spi/nxp_fspi.c
+++ b/drivers/spi/nxp_fspi.c
@@ -866,9 +866,6 @@ static int nxp_fspi_default_setup(struct nxp_fspi *f)
u32 reg;
  
  #if CONFIG_IS_ENABLED(CLK)

-   /* disable and unprepare clock to avoid glitch pass to controller */
-   nxp_fspi_clk_disable_unprep(f);
-
/* the default frequency, we will change it later if necessary. */
ret = clk_set_rate(>clk, 2000);
if (ret < 0)




Re: [PATCH V2 02/17] imx: imx8m[m/n]_beacon: Enable SPL_DM_SERIAL

2022-06-13 Thread Peng Fan (OSS)




在 2022/6/13 22:36, Adam Ford 写道:

On Sat, Jun 11, 2022 at 6:38 AM Peng Fan (OSS)  wrote:

From: Peng Fan 

Enable CONFIG_SPL_DM_SERIAL. uart2 and its pinmux was already
marked with u-boot,dm-spl.
Move preloader_console_init after spl_init to make sure driver
model work.

For what it's worth, the series doesn't appear to apply cleanly on the
current master, but I tested a Nano in addition to the Mini that I
tested before.


Signed-off-by: Peng Fan 
Tested-by: Adam Ford  #imx8mm_beacon

Tested-by: Adam Ford  #imx8mn_beacon


Thanks, the patchset is based or Tom's next branch as described in cover 
letter.


Thanks,
Peng.




Reviewed-by: Fabio Estevam 
---
  board/beacon/imx8mm/spl.c  | 12 ++--
  board/beacon/imx8mn/spl.c  | 11 ++-
  configs/imx8mm_beacon_defconfig|  1 -
  configs/imx8mn_beacon_2g_defconfig |  1 -
  configs/imx8mn_beacon_defconfig|  1 -
  include/configs/imx8mm_beacon.h|  2 --
  include/configs/imx8mn_beacon.h|  2 --
  7 files changed, 4 insertions(+), 26 deletions(-)

diff --git a/board/beacon/imx8mm/spl.c b/board/beacon/imx8mm/spl.c
index 12266b22a42..f92b4c3ed0a 100644
--- a/board/beacon/imx8mm/spl.c
+++ b/board/beacon/imx8mm/spl.c
@@ -59,14 +59,8 @@ int board_fit_config_name_match(const char *name)
  }
  #endif

-#define UART_PAD_CTRL  (PAD_CTL_DSE6 | PAD_CTL_FSEL1)
  #define WDOG_PAD_CTRL  (PAD_CTL_DSE6 | PAD_CTL_ODE | PAD_CTL_PUE | PAD_CTL_PE)

-static iomux_v3_cfg_t const uart_pads[] = {
-   IMX8MM_PAD_UART2_RXD_UART2_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
-   IMX8MM_PAD_UART2_TXD_UART2_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
-};
-
  static iomux_v3_cfg_t const wdog_pads[] = {
 IMX8MM_PAD_GPIO1_IO02_WDOG1_WDOG_B  | MUX_PAD_CTRL(WDOG_PAD_CTRL),
  };
@@ -79,8 +73,6 @@ int board_early_init_f(void)

 set_wdog_reset(wdog);

-   imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads));
-
 return 0;
  }

@@ -128,8 +120,6 @@ void board_init_f(ulong dummy)

 timer_init();

-   preloader_console_init();
-
 /* Clear the BSS. */
 memset(__bss_start, 0, __bss_end - __bss_start);

@@ -139,6 +129,8 @@ void board_init_f(ulong dummy)
 hang();
 }

+   preloader_console_init();
+
 ret = uclass_get_device_by_name(UCLASS_CLK,
 "clock-controller@3038",
 );
diff --git a/board/beacon/imx8mn/spl.c b/board/beacon/imx8mn/spl.c
index bb51be01c52..4563446db19 100644
--- a/board/beacon/imx8mn/spl.c
+++ b/board/beacon/imx8mn/spl.c
@@ -68,7 +68,6 @@ int board_fit_config_name_match(const char *name)
  }
  #endif

-#define UART_PAD_CTRL  (PAD_CTL_DSE6 | PAD_CTL_FSEL1)
  #define WDOG_PAD_CTRL  (PAD_CTL_DSE6 | PAD_CTL_ODE | PAD_CTL_PUE | PAD_CTL_PE)
  #define PWM1_PAD_CTRL (PAD_CTL_FSEL2 | PAD_CTL_DSE6)

@@ -76,11 +75,6 @@ static iomux_v3_cfg_t const pwm_pads[] = {
 IMX8MN_PAD_GPIO1_IO01__PWM1_OUT | MUX_PAD_CTRL(PWM1_PAD_CTRL),
  };

-static iomux_v3_cfg_t const uart_pads[] = {
-   IMX8MN_PAD_UART2_RXD__UART2_DCE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
-   IMX8MN_PAD_UART2_TXD__UART2_DCE_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
-};
-
  static iomux_v3_cfg_t const wdog_pads[] = {
 IMX8MN_PAD_GPIO1_IO02__WDOG1_WDOG_B  | MUX_PAD_CTRL(WDOG_PAD_CTRL),
  };
@@ -95,7 +89,6 @@ int board_early_init_f(void)
 imx_iomux_v3_setup_multiple_pads(wdog_pads, ARRAY_SIZE(wdog_pads));
 set_wdog_reset(wdog);

-   imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads));
 init_uart_clk(1);

 return 0;
@@ -114,14 +107,14 @@ void board_init_f(ulong dummy)

 timer_init();

-   preloader_console_init();
-
 ret = spl_init();
 if (ret) {
 debug("spl_init() failed: %d\n", ret);
 hang();
 }

+   preloader_console_init();
+
 enable_tzc380();

 /* DDR initialization */
diff --git a/configs/imx8mm_beacon_defconfig b/configs/imx8mm_beacon_defconfig
index 417ece1ef8c..e1acf7e8810 100644
--- a/configs/imx8mm_beacon_defconfig
+++ b/configs/imx8mm_beacon_defconfig
@@ -125,7 +125,6 @@ CONFIG_SPL_DM_REGULATOR_FIXED=y
  CONFIG_DM_REGULATOR_GPIO=y
  CONFIG_CONS_INDEX=2
  CONFIG_DM_SERIAL=y
-# CONFIG_SPL_DM_SERIAL is not set
  CONFIG_MXC_UART=y
  CONFIG_SPI=y
  CONFIG_DM_SPI=y
diff --git a/configs/imx8mn_beacon_2g_defconfig 
b/configs/imx8mn_beacon_2g_defconfig
index 5b9b3715b34..cadef45028d 100644
--- a/configs/imx8mn_beacon_2g_defconfig
+++ b/configs/imx8mn_beacon_2g_defconfig
@@ -127,7 +127,6 @@ CONFIG_DM_REGULATOR_FIXED=y
  CONFIG_DM_REGULATOR_GPIO=y
  CONFIG_DM_RESET=y
  CONFIG_DM_SERIAL=y
-# CONFIG_SPL_DM_SERIAL is not set
  CONFIG_MXC_UART=y
  CONFIG_SPI=y
  CONFIG_DM_SPI=y
diff --git a/configs/imx8mn_beacon_defconfig b/configs/imx8mn_beacon_defconfig
index b296898d6db..357109e32e5 100644
--- a/configs/imx8mn_beacon_defconfig
+++ b/configs/imx8mn_beacon_defconfig
@@ -131,7 +131,6 

Re: [PATCH v4] imx: add i.MX8MN DDR3L evk board support

2022-06-13 Thread Peng Fan (OSS)




在 2022/6/14 5:10, Heiko Thiery 写道:

Add the support for the 8MNANOD3L-EVK board. The board has an i.MX8MNano
UltraLite Quad SoC and uses 1GB DDR3L memory.

U-Boot SPL 2022.07-rc4-00017-gcf594ebce1 (Jun 13 2022 - 22:40:31 +0200)
Normal Boot
WDT:   Started watchdog@3028 with servicing (60s timeout)
Trying to boot from BOOTROM
image offset 0x8000, pagesize 0x200, ivt offset 0x0
NOTICE:  BL31: v2.6(release):v2.6-5-g9b1a4d832
NOTICE:  BL31: Built : 14:03:53, May 10 2022

U-Boot 2022.07-rc4-00017-gcf594ebce1 (Jun 13 2022 - 22:40:31 +0200)

CPU:   Freescale i.MX8MNano UltraLite Quad rev1.0 at 1200 MHz
Reset cause: WDOG
Model: NXP i.MX8MNano DDR3L EVK board
DRAM:  1 GiB
Core:  142 devices, 19 uclasses, devicetree: separate
WDT:   Started watchdog@3028 with servicing (60s timeout)
MMC:   FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... OK
In:serial@3089
Out:   serial@3089
Err:   serial@3089
Net:   eth0: ethernet@30be
Hit any key to stop autoboot:  0

Signed-off-by: Heiko Thiery 
Reviewed-by: Fabio Estevam 

Reviewed-by: Peng Fan 


---
v4:
  - rebase on current master to fix merge conflicts
  - remove config options from defconfig
  - enable SPL_DM_SERIAL
  - include imx8mn-ddr4-evk-u-boot.dtsi in imx8mn-ddr3l-evk-u-boot.dtsi
v3:
  - fix config option description in Kconfig (TARGET_IMX8MN_DDR3L_EVK)
v2:
  - change license formatting (thanks Marcel)

  arch/arm/dts/imx8mn-ddr3l-evk-u-boot.dtsi |  34 +
  arch/arm/dts/imx8mn-ddr3l-evk.dts | 114 +++
  arch/arm/dts/imx8mn-u-boot.dtsi   |  12 +
  arch/arm/mach-imx/imx8m/Kconfig   |   7 +
  board/freescale/imx8mn_evk/Kconfig|   2 +-
  board/freescale/imx8mn_evk/Makefile   |   1 +
  board/freescale/imx8mn_evk/ddr3l_timing.c | 943 ++
  board/freescale/imx8mn_evk/spl.c  |   9 +
  configs/imx8mn_ddr3l_evk_defconfig|  95 +++
  include/configs/imx8mn_evk.h  |   4 +
  10 files changed, 1220 insertions(+), 1 deletion(-)
  create mode 100644 arch/arm/dts/imx8mn-ddr3l-evk-u-boot.dtsi
  create mode 100644 arch/arm/dts/imx8mn-ddr3l-evk.dts
  create mode 100644 board/freescale/imx8mn_evk/ddr3l_timing.c
  create mode 100644 configs/imx8mn_ddr3l_evk_defconfig

diff --git a/arch/arm/dts/imx8mn-ddr3l-evk-u-boot.dtsi 
b/arch/arm/dts/imx8mn-ddr3l-evk-u-boot.dtsi
new file mode 100644
index 00..b9192515e5
--- /dev/null
+++ b/arch/arm/dts/imx8mn-ddr3l-evk-u-boot.dtsi
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include "imx8mn-u-boot.dtsi"
+#include "imx8mn-ddr4-evk-u-boot.dtsi"
+
+
+&{/soc@0} {
+   u-boot,dm-pre-reloc;
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+   u-boot,dm-pre-reloc;
+   /delete-property/ assigned-clocks;
+   /delete-property/ assigned-clock-parents;
+   /delete-property/ assigned-clock-rates;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+&{/soc@0/bus@3080/i2c@30a2/pmic@25} {
+   u-boot,dm-spl;
+};
+
+&{/soc@0/bus@3080/i2c@30a2/pmic@25/regulators} {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
diff --git a/arch/arm/dts/imx8mn-ddr3l-evk.dts 
b/arch/arm/dts/imx8mn-ddr3l-evk.dts
new file mode 100644
index 00..4cdc03c8f2
--- /dev/null
+++ b/arch/arm/dts/imx8mn-ddr3l-evk.dts
@@ -0,0 +1,114 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+/dts-v1/;
+
+#include "imx8mn.dtsi"
+#include "imx8mn-evk.dtsi"
+#include 
+
+/ {
+   model = "NXP i.MX8MNano DDR3L EVK board";
+   compatible = "fsl,imx8mn-ddr3l-evk", "fsl,imx8mn";
+};
+
+_0 {
+   cpu-supply = <>;
+};
+
+_1 {
+   cpu-supply = <>;
+};
+
+_2 {
+   cpu-supply = <>;
+};
+
+_3 {
+   cpu-supply = <>;
+};
+
+ {
+   pmic: pmic@25 {
+   compatible = "nxp,pca9450b";
+   reg = <0x25>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_pmic>;
+   interrupt-parent = <>;
+   interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
+
+   regulators {
+   buck1: BUCK1 {
+   regulator-name = "VDD_SOC_0V9";
+   regulator-min-microvolt = <85>;
+   regulator-max-microvolt = <95>;
+   regulator-boot-on;
+   regulator-always-on;
+   regulator-ramp-delay = <3125>;
+   };
+
+   buck4: BUCK4 {
+   regulator-name = "VDD_3V3";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+
+   buck5: BUCK5 {
+   regulator-name = "VDD_1V8";
+   regulator-min-microvolt = <180>;
+   

[PATCH v3] i2c: nuvoton: Add NPCM7xx i2c driver

2022-06-13 Thread Jim Liu
Add Nuvoton BMC NPCM750 i2c driver

Signed-off-by: Jim Liu 
---
changes for v3:
   - add i2c doc
Changes for v2:
   - use debug output in reset function
   - use clr/setbits_8
---
 .../i2c/nuvoton,npcm7xx-i2c.txt   |  28 +
 drivers/i2c/Kconfig   |   5 +
 drivers/i2c/Makefile  |   1 +
 drivers/i2c/npcm-i2c.c| 631 ++
 4 files changed, 665 insertions(+)
 create mode 100644 doc/device-tree-bindings/i2c/nuvoton,npcm7xx-i2c.txt
 create mode 100644 drivers/i2c/npcm-i2c.c

diff --git a/doc/device-tree-bindings/i2c/nuvoton,npcm7xx-i2c.txt 
b/doc/device-tree-bindings/i2c/nuvoton,npcm7xx-i2c.txt
new file mode 100644
index 00..d120490b32
--- /dev/null
+++ b/doc/device-tree-bindings/i2c/nuvoton,npcm7xx-i2c.txt
@@ -0,0 +1,28 @@
+* The NPCM750x includes sixteen I2C bus controllers.
+
+Required properties :
+- compatible : Must be "nuvoton,npcm750-i2c"
+- reg : Offset and length of the register set for the device
+- clocks: Reference clock for the I2C bus
+- A pinctrl state named "default" must be defined to set pins in mode of
+  operation for I2C transfer
+- #address-cells = <1>;
+- #size-cells = <0>;
+
+Optional properties :
+- clock-frequency : Desired I2C bus clock frequency in Hz. If not specified,
+  the default 100 kHz frequency will be used.
+  possible values are 10, 40 and 100.
+
+Example :
+   #include 
+   #include 
+   i2c0: i2c@8 {
+   reg = <0x8 0x1000>;
+   compatible = "nuvoton,npcm750-i2c";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   clocks = < NPCM7XX_CLK_APB2>;
+   interrupts = ;
+   status = "disabled";
+   };
diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index d25c5736ef..7e113b289e 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -447,6 +447,11 @@ config SYS_I2C_NEXELL
  have several I2C ports and all are provided, controlled by the
  device tree.
 
+config SYS_I2C_NPCM
+   bool "Nuvoton NPCM I2C driver"
+   help
+ Support for Nuvoton I2C controller driver.
+
 config SYS_I2C_OCORES
bool "ocores I2C driver"
depends on DM_I2C
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index 9d41f379bb..7e046f809a 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_SYS_I2C_MV) += mv_i2c.o
 obj-$(CONFIG_SYS_I2C_MVTWSI) += mvtwsi.o
 obj-$(CONFIG_SYS_I2C_MXC) += mxc_i2c.o
 obj-$(CONFIG_SYS_I2C_NEXELL) += nx_i2c.o
+obj-$(CONFIG_SYS_I2C_NPCM) += npcm_i2c.o
 obj-$(CONFIG_SYS_I2C_OCORES) += ocores_i2c.o
 obj-$(CONFIG_SYS_I2C_OCTEON) += octeon_i2c.o
 obj-$(CONFIG_SYS_I2C_OMAP24XX) += omap24xx_i2c.o
diff --git a/drivers/i2c/npcm-i2c.c b/drivers/i2c/npcm-i2c.c
new file mode 100644
index 00..dfac6483de
--- /dev/null
+++ b/drivers/i2c/npcm-i2c.c
@@ -0,0 +1,631 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define I2C_FREQ_100K  10
+#define NPCM_I2C_TIMEOUT_MS10
+#define NPCM7XX_I2CSEGCTL_INIT_VAL 0x0333F000
+#define NPCM8XX_I2CSEGCTL_INIT_VAL 0x9333F000
+
+/* SCLFRQ min/max field values  */
+#define SCLFRQ_MIN 10
+#define SCLFRQ_MAX 511
+
+/* SMBCTL1 */
+#define SMBCTL1_START  BIT(0)
+#define SMBCTL1_STOP   BIT(1)
+#define SMBCTL1_INTEN  BIT(2)
+#define SMBCTL1_ACKBIT(4)
+#define SMBCTL1_STASTREBIT(7)
+
+/* SMBCTL2 */
+#define SMBCTL2_ENABLE BIT(0)
+
+/* SMBCTL3 */
+#define SMBCTL3_SCL_LVLBIT(7)
+#define SMBCTL3_SDA_LVLBIT(6)
+
+/* SMBCST */
+#define SMBCST_BB  BIT(1)
+#define SMBCST_TGSCL   BIT(5)
+
+/* SMBST */
+#define SMBST_XMIT BIT(0)
+#define SMBST_MASTER   BIT(1)
+#define SMBST_STASTR   BIT(3)
+#define SMBST_NEGACK   BIT(4)
+#define SMBST_BER  BIT(5)
+#define SMBST_SDASTBIT(6)
+
+/* SMBCST3 in bank0 */
+#define SMBCST3_EO_BUSYBIT(7)
+
+/* SMBFIF_CTS in bank1 */
+#define SMBFIF_CTS_CLR_FIFOBIT(6)
+
+#define SMBFIF_CTL_FIFO_EN BIT(4)
+#define SMBCTL3_BNK_SELBIT(5)
+
+enum {
+   I2C_ERR_NACK = 1,
+   I2C_ERR_BER,
+   I2C_ERR_TIMEOUT,
+};
+
+struct smb_bank0_regs {
+   u8 addr3;
+   u8 addr7;
+   u8 addr4;
+   u8 addr8;
+   u16 addr5;
+   u16 addr6;
+   u8 cst2;
+   u8 cst3;
+   u8 ctl4;
+   u8 ctl5;
+   u8 scllt;
+   u8 fif_ctl;
+   u8 sclht;
+};
+
+struct smb_bank1_regs {
+   u8 fif_cts;
+   u8 fair_per;
+   u16 txf_ctl;
+   u32 t_out;
+   u8 cst2;
+   u8 cst3;
+   u16 txf_sts;
+   u16 rxf_sts;
+   u8 rxf_ctl;
+};
+
+struct npcm_i2c_regs {
+   u16 sda;
+   u16 st;

Re: imx8mn SPL serial output does not work after powerup

2022-06-13 Thread Peng Fan (OSS)




在 2022/6/14 3:49, Heiko Thiery 写道:

Am Mo., 13. Juni 2022 um 21:43 Uhr schrieb Heiko Thiery
:

Hi,

Am Mo., 13. Juni 2022 um 21:28 Uhr schrieb Fabio Estevam :

Hi Heiko,

On Mon, Jun 13, 2022 at 4:16 PM Heiko Thiery  wrote:


Can anyone confirm the behavior?

imx8mn ddr4 evk prints the SPL part just fine.

Take a look at arch/arm/dts/imx8mn-ddr4-evk-u-boot.dtsi .

It passes:

 {
   u-boot,dm-spl;
};

_uart2 {
  u-boot,dm-spl;
};

Are you doing the same for the imx8mn ddr3 u-boot dtsi?

Indeed these are missing. Now I see the whole output from U-Boot but
the output from SPL is still missing. When enabloing SPL_DM_SERIAL the
board does not start.


I now did include the whole "imx8mn-ddr4-evk-u-boot.dtsi" like it is
done in "imx8mn-evk-u-boot.dtsi". Then it works.


make sure preload_console_init is called after spl_early_init or 
spl_init, not before.


Regards,
Peng.




--
Heiko




Re: [PATCH v5 07/12] efi_loader: disk: a helper function to create efi_disk objects from udevice

2022-06-13 Thread Fabio Estevam
Hi Heinrich,

On Mon, Jun 13, 2022 at 8:39 PM Heinrich Schuchardt  wrote:

> Slowing down every boot without connected serial by 1000ms seems to be a bad 
> idea.
>
> What baud rate are you using?

115200.

> What terminal software are you using giving the late response?

I will check. I am accessing the board remotely.

Heiko also sees the problem. Maybe he could share what terminal
software he uses.

> Does printf() return before the last byte is sent by the serial IO transfer 
> buffer? What size has that buffer?

Looks like I would need to instrument the code to answer this.

> I suggest that the EFI console should not query the screen size before 
> starting the first EFI binary.

Could you please propose I patch doing this?

To be honest, I don't need EFI, but it gets automatically selected,
and that's why I see the problem.

For the moment, I am disabling CONFIG_EFI_LOADER as a workaround.

I can help to test patches, but I am not familiar with EFI to propose a fix.

Thanks,

Fabio Estevam


Re: [PATCH v5 07/12] efi_loader: disk: a helper function to create efi_disk objects from udevice

2022-06-13 Thread AKASHI, Takahiro
On Mon, Jun 13, 2022 at 07:48:01PM -0300, Fabio Estevam wrote:
> Hi Mark,
> 
> On Mon, Jun 13, 2022 at 7:21 PM Mark Kettenis  wrote:
> 
> > This looks like the reply the terminal sends in response to the "Query
> > cursor position" command that is sent in
> > lib/efi_loader/efi_console.c:query_console_serial().
> >
> > It might be worth trying to increase the timeout in term_get_char().
> 
> I did as you suggested and increased the timeout from 100ms to 1000ms.
> 
> After that, I no longer see the problem, thanks!

So I hope that my patch has broken nothing.

-Takahiro Akashi

> Would this be an acceptable fix?


Re: [PATCH v5 07/12] efi_loader: disk: a helper function to create efi_disk objects from udevice

2022-06-13 Thread Heinrich Schuchardt
Am 14. Juni 2022 00:48:01 MESZ schrieb Fabio Estevam :
>Hi Mark,
>
>On Mon, Jun 13, 2022 at 7:21 PM Mark Kettenis  wrote:
>
>> This looks like the reply the terminal sends in response to the "Query
>> cursor position" command that is sent in
>> lib/efi_loader/efi_console.c:query_console_serial().
>>
>> It might be worth trying to increase the timeout in term_get_char().
>
>I did as you suggested and increased the timeout from 100ms to 1000ms.
>
>After that, I no longer see the problem, thanks!
>
>Would this be an acceptable fix?

Slowing down every boot without connected serial by 1000ms seems to be a bad 
idea.

What baud rate are you using?

What terminal software are you using giving the late response?

Does printf() return before the last byte is sent by the serial IO transfer 
buffer? What size has that buffer?

I suggest that the EFI console should not query the screen size before starting 
the first EFI binary.

Best regards

Heinrich 




[PATCH v2] armv8: always use current exception level for TCR_ELx access

2022-06-13 Thread Andre Przywara
Currently get_tcr() takes an "el" parameter, to select the proper
version of the TCR_ELx system register.
This is problematic in case of the Apple M1, since it runs with
HCR_EL2.E2H fixed to 1, so TCR_EL2 is actually using the TCR_EL1 layout,
and we get the wrong version.

For U-Boot's purposes the only sensible choice here is the current
exception level, and indeed most callers treat it like that, so let's
remove that parameter and read the current EL inside the function.
This allows us to check for the E2H bit, and pretend it's EL1 in this
case.

There are two callers which don't care about the EL, and they pass 0,
which looks wrong, but is irrelevant in these two cases, since we don't
use the return value there. So the change cannot affect those two.

Signed-off-by: Andre Przywara 
---
Changelog v1 ... v2:
- Give bit 34 a name, and also use that in start.S

Mark, can you please test this? The A53s I have here for a quick test
are igorant of this patch ...

 arch/arm/cpu/armv8/cache_v8.c   | 28 +
 arch/arm/cpu/armv8/fsl-layerscape/cpu.c |  4 ++--
 arch/arm/cpu/armv8/start.S  |  2 +-
 arch/arm/include/asm/armv8/mmu.h|  4 +++-
 4 files changed, 30 insertions(+), 8 deletions(-)

diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c
index 3de18c7675b..e4736e56436 100644
--- a/arch/arm/cpu/armv8/cache_v8.c
+++ b/arch/arm/cpu/armv8/cache_v8.c
@@ -39,8 +39,28 @@ DECLARE_GLOBAL_DATA_PTR;
  *off:  FFF
  */
 
-u64 get_tcr(int el, u64 *pips, u64 *pva_bits)
+static int get_effective_el(void)
 {
+   int el = current_el();
+
+   if (el == 2) {
+   u64 hcr_el2;
+
+   /*
+* If we are using the EL2&0 translation regime, the TCR_EL2
+* looks like the EL1 version, even though we are in EL2.
+*/
+   __asm__ ("mrs %0, HCR_EL2\n" : "=r" (hcr_el2));
+   if (hcr_el2 & BIT(HCR_EL2_E2H_BIT))
+   return 1;
+   }
+
+   return el;
+}
+
+u64 get_tcr(u64 *pips, u64 *pva_bits)
+{
+   int el = get_effective_el();
u64 max_addr = 0;
u64 ips, va_bits;
u64 tcr;
@@ -115,7 +135,7 @@ static u64 *find_pte(u64 addr, int level)
 
debug("addr=%llx level=%d\n", addr, level);
 
-   get_tcr(0, NULL, _bits);
+   get_tcr(NULL, _bits);
if (va_bits < 39)
start_level = 1;
 
@@ -343,7 +363,7 @@ __weak u64 get_page_table_size(void)
u64 va_bits;
int start_level = 0;
 
-   get_tcr(0, NULL, _bits);
+   get_tcr(NULL, _bits);
if (va_bits < 39)
start_level = 1;
 
@@ -415,7 +435,7 @@ __weak void mmu_setup(void)
setup_all_pgtables();
 
el = current_el();
-   set_ttbr_tcr_mair(el, gd->arch.tlb_addr, get_tcr(el, NULL, NULL),
+   set_ttbr_tcr_mair(el, gd->arch.tlb_addr, get_tcr(NULL, NULL),
  MEMORY_ATTRIBUTES);
 
/* enable the mmu */
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c 
b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
index 253008a9c13..c989a43cbeb 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
@@ -454,7 +454,7 @@ static inline void early_mmu_setup(void)
 
/* point TTBR to the new table */
set_ttbr_tcr_mair(el, gd->arch.tlb_addr,
- get_tcr(el, NULL, NULL) &
+ get_tcr(NULL, NULL) &
  ~(TCR_ORGN_MASK | TCR_IRGN_MASK),
  MEMORY_ATTRIBUTES);
 
@@ -609,7 +609,7 @@ static inline void final_mmu_setup(void)
invalidate_icache_all();
 
/* point TTBR to the new table */
-   set_ttbr_tcr_mair(el, gd->arch.tlb_addr, get_tcr(el, NULL, NULL),
+   set_ttbr_tcr_mair(el, gd->arch.tlb_addr, get_tcr(NULL, NULL),
  MEMORY_ATTRIBUTES);
 
set_sctlr(get_sctlr() | CR_M);
diff --git a/arch/arm/cpu/armv8/start.S b/arch/arm/cpu/armv8/start.S
index d328e8c08a1..28f0df13f0d 100644
--- a/arch/arm/cpu/armv8/start.S
+++ b/arch/arm/cpu/armv8/start.S
@@ -125,7 +125,7 @@ pie_fixup_done:
msr cptr_el3, xzr   /* Enable FP/SIMD */
b   0f
 2: mrs x1, hcr_el2
-   tbnzx1, #34, 1f /* HCR_EL2.E2H */
+   tbnzx1, #HCR_EL2_E2H_BIT, 1f/* HCR_EL2.E2H */
orr x1, x1, #HCR_EL2_AMO_EL2/* Route SErrors to EL2 */
msr hcr_el2, x1
set_vbar vbar_el2, x0
diff --git a/arch/arm/include/asm/armv8/mmu.h b/arch/arm/include/asm/armv8/mmu.h
index c36b2cf5a58..9f58cedb650 100644
--- a/arch/arm/include/asm/armv8/mmu.h
+++ b/arch/arm/include/asm/armv8/mmu.h
@@ -103,6 +103,8 @@
 #define TCR_EL2_RSVD   (1U << 31 | 1 << 23)
 #define TCR_EL3_RSVD   (1U << 31 | 1 << 23)
 
+#define HCR_EL2_E2H_BIT34
+
 #ifndef __ASSEMBLY__
 static inline void set_ttbr_tcr_mair(int 

Re: [PATCH v5 07/12] efi_loader: disk: a helper function to create efi_disk objects from udevice

2022-06-13 Thread Fabio Estevam
Hi Mark,

On Mon, Jun 13, 2022 at 7:21 PM Mark Kettenis  wrote:

> This looks like the reply the terminal sends in response to the "Query
> cursor position" command that is sent in
> lib/efi_loader/efi_console.c:query_console_serial().
>
> It might be worth trying to increase the timeout in term_get_char().

I did as you suggested and increased the timeout from 100ms to 1000ms.

After that, I no longer see the problem, thanks!

Would this be an acceptable fix?


Re: [PATCH v5 07/12] efi_loader: disk: a helper function to create efi_disk objects from udevice

2022-06-13 Thread Mark Kettenis
> Date: Mon, 13 Jun 2022 16:10:57 -0400
> From: Tom Rini 
> 
> On Mon, Jun 13, 2022 at 04:54:45PM -0300, Fabio Estevam wrote:
> > On Wed, May 18, 2022 at 6:23 AM Neil Armstrong  
> > wrote:
> > 
> > > This change as commit a9bf024b2933bba0e23038892970a18b72dfaeb4 in master 
> > > makes Amlogic S905X board libretech-cc to crash:
> > 
> > This change also causes issues on a kontron-sl-mx8mm and imx8mn ddr3 evk 
> > boards.
> > 
> > The problem on these boards is that serial console garbage is seen:
> > 
> > Net:   eth0: ethernet@30be
> > Hit any key to stop autoboot:  0
> > u-boot=> [25;88R
> > Unknown command '[25' - try 'help'
> > Unknown command '88R' - try 'help'
> > 
> > These extraneous characters stop the boot process.

This looks like the reply the terminal sends in response to the "Query
cursor position" command that is sent in
lib/efi_loader/efi_console.c:query_console_serial().

It might be worth trying to increase the timeout in term_get_char().

If that doesn't help, it probably means the initial ESC character gets
lost because the serial port has a very small (or no) FIFO and u-boot
isn't reading characters fast enough.  If that is the case, maybe we
we should make the query_console_serial() call optional and only
enable it on SoCs that have a large enough FIFO for this to be safe.

Cheers,

Mark


Re: [PATCH 01/12] env: Complete generic support for writable list

2022-06-13 Thread Marek Vasut

On 6/8/22 16:39, Jan Kiszka wrote:

[...]


If you want to make this into a generic patch, can you somehow reduce
the ever-growing ifdeffery, so that the patch won't add to it so much ?
I suspect the code above can help with that, maybe it can be used to
remove at least the env_locations[] reordering ifdeffery ?


Your code is not generic enough as it ignores the config-selected
storage device. It would only happen to cover all our boards, but we are
not the world. That's why I had to add some ifdeffery.


That storage device part is trivial to fix, right.


I could try write an alternative arch_env_get_location that does the
required logic with a single ifdef. The prize might be some code
duplication, though.


Can you use CONFIG_IS_ENABLED()/IS_ENABLED() in arch_env_get_location() 
to avoid the #if ... and outright return ENVL_NOWHERE or whatever to 
avoid adding ifdefs to env_locations[] array ?


That should likely be possible.

[...]


[PATCH v4] imx: add i.MX8MN DDR3L evk board support

2022-06-13 Thread Heiko Thiery
Add the support for the 8MNANOD3L-EVK board. The board has an i.MX8MNano
UltraLite Quad SoC and uses 1GB DDR3L memory.

U-Boot SPL 2022.07-rc4-00017-gcf594ebce1 (Jun 13 2022 - 22:40:31 +0200)
Normal Boot
WDT:   Started watchdog@3028 with servicing (60s timeout)
Trying to boot from BOOTROM
image offset 0x8000, pagesize 0x200, ivt offset 0x0
NOTICE:  BL31: v2.6(release):v2.6-5-g9b1a4d832
NOTICE:  BL31: Built : 14:03:53, May 10 2022

U-Boot 2022.07-rc4-00017-gcf594ebce1 (Jun 13 2022 - 22:40:31 +0200)

CPU:   Freescale i.MX8MNano UltraLite Quad rev1.0 at 1200 MHz
Reset cause: WDOG
Model: NXP i.MX8MNano DDR3L EVK board
DRAM:  1 GiB
Core:  142 devices, 19 uclasses, devicetree: separate
WDT:   Started watchdog@3028 with servicing (60s timeout)
MMC:   FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... OK
In:serial@3089
Out:   serial@3089
Err:   serial@3089
Net:   eth0: ethernet@30be
Hit any key to stop autoboot:  0

Signed-off-by: Heiko Thiery 
Reviewed-by: Fabio Estevam 
---
v4:
 - rebase on current master to fix merge conflicts
 - remove config options from defconfig
 - enable SPL_DM_SERIAL
 - include imx8mn-ddr4-evk-u-boot.dtsi in imx8mn-ddr3l-evk-u-boot.dtsi
v3:
 - fix config option description in Kconfig (TARGET_IMX8MN_DDR3L_EVK)
v2:
 - change license formatting (thanks Marcel)

 arch/arm/dts/imx8mn-ddr3l-evk-u-boot.dtsi |  34 +
 arch/arm/dts/imx8mn-ddr3l-evk.dts | 114 +++
 arch/arm/dts/imx8mn-u-boot.dtsi   |  12 +
 arch/arm/mach-imx/imx8m/Kconfig   |   7 +
 board/freescale/imx8mn_evk/Kconfig|   2 +-
 board/freescale/imx8mn_evk/Makefile   |   1 +
 board/freescale/imx8mn_evk/ddr3l_timing.c | 943 ++
 board/freescale/imx8mn_evk/spl.c  |   9 +
 configs/imx8mn_ddr3l_evk_defconfig|  95 +++
 include/configs/imx8mn_evk.h  |   4 +
 10 files changed, 1220 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/imx8mn-ddr3l-evk-u-boot.dtsi
 create mode 100644 arch/arm/dts/imx8mn-ddr3l-evk.dts
 create mode 100644 board/freescale/imx8mn_evk/ddr3l_timing.c
 create mode 100644 configs/imx8mn_ddr3l_evk_defconfig

diff --git a/arch/arm/dts/imx8mn-ddr3l-evk-u-boot.dtsi 
b/arch/arm/dts/imx8mn-ddr3l-evk-u-boot.dtsi
new file mode 100644
index 00..b9192515e5
--- /dev/null
+++ b/arch/arm/dts/imx8mn-ddr3l-evk-u-boot.dtsi
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include "imx8mn-u-boot.dtsi"
+#include "imx8mn-ddr4-evk-u-boot.dtsi"
+
+
+&{/soc@0} {
+   u-boot,dm-pre-reloc;
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+   u-boot,dm-pre-reloc;
+   /delete-property/ assigned-clocks;
+   /delete-property/ assigned-clock-parents;
+   /delete-property/ assigned-clock-rates;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+&{/soc@0/bus@3080/i2c@30a2/pmic@25} {
+   u-boot,dm-spl;
+};
+
+&{/soc@0/bus@3080/i2c@30a2/pmic@25/regulators} {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
diff --git a/arch/arm/dts/imx8mn-ddr3l-evk.dts 
b/arch/arm/dts/imx8mn-ddr3l-evk.dts
new file mode 100644
index 00..4cdc03c8f2
--- /dev/null
+++ b/arch/arm/dts/imx8mn-ddr3l-evk.dts
@@ -0,0 +1,114 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+/dts-v1/;
+
+#include "imx8mn.dtsi"
+#include "imx8mn-evk.dtsi"
+#include 
+
+/ {
+   model = "NXP i.MX8MNano DDR3L EVK board";
+   compatible = "fsl,imx8mn-ddr3l-evk", "fsl,imx8mn";
+};
+
+_0 {
+   cpu-supply = <>;
+};
+
+_1 {
+   cpu-supply = <>;
+};
+
+_2 {
+   cpu-supply = <>;
+};
+
+_3 {
+   cpu-supply = <>;
+};
+
+ {
+   pmic: pmic@25 {
+   compatible = "nxp,pca9450b";
+   reg = <0x25>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_pmic>;
+   interrupt-parent = <>;
+   interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
+
+   regulators {
+   buck1: BUCK1 {
+   regulator-name = "VDD_SOC_0V9";
+   regulator-min-microvolt = <85>;
+   regulator-max-microvolt = <95>;
+   regulator-boot-on;
+   regulator-always-on;
+   regulator-ramp-delay = <3125>;
+   };
+
+   buck4: BUCK4 {
+   regulator-name = "VDD_3V3";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   regulator-boot-on;
+   regulator-always-on;
+   };
+
+   buck5: BUCK5 {
+   regulator-name = "VDD_1V8";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+ 

Re: [PATCH] misc: Port USB251xB/xBi Hi-Speed Hub Controller Driver from Linux

2022-06-13 Thread Marek Vasut

On 6/13/22 19:23, Stefan Herbrechtsmeier wrote:

Hi Marek,


Hi,

[...]


+
+    if (IS_ENABLED(CONFIG_DM_REGULATOR)) {
+    err = device_get_supply_regulator(dev, "vdd-supply",
+  >vdd);
+    if (err && err != -ENOENT) {
+    dev_err(dev, "Warning: cannot get power supply\n");
+    return err;
+    }
+    }


Shouldn't the gpio and regulator request be part of the probe?


What makes you think that ?


It's more a question regarding the device model design:

of_to_plat - convert device tree data to plat


As far as I can tell, you should be able to obtain reference to a 
regulator here, but not probe the regulator.



+    if (dev_read_u32(dev, "vendor-id", >vendor_id))
+    hub->vendor_id = USB251XB_DEF_VENDOR_ID;
+
+    if (dev_read_u32(dev, "product-id", >product_id))
+    hub->product_id = data->product_id;
+
+    if (dev_read_u32(dev, "device-id", >device_id))
+    hub->device_id = USB251XB_DEF_DEVICE_ID;
+


[snip]


+    if (dev_read_u32(dev, "language-id", >lang_id))
+    hub->lang_id = USB251XB_DEF_LANGUAGE_ID;
+


This doesn't work because the ids are 16 bit [1,2] and the 
dev_read_u32 function checks the size.



+    if (!dev_read_u32(dev, "boost-up", >boost_up))
+    hub->boost_up = USB251XB_DEF_BOOST_UP;


This looks like a 8 bit value [1].


The dev_read_u32() is also capable of reading 0x 16bit value from DT.

What kind of problem are you running into exactly ?


Have you test the values from device tree binding documentation:

vendor-id = /bits/ 16 <0x>;
product-id = /bits/ 16 <0x>;

I get an EOVERFLOW error.


No, I only tested foo = <0x>; .

Can you send a fix ?


Re: [PATCH v5 07/12] efi_loader: disk: a helper function to create efi_disk objects from udevice

2022-06-13 Thread Tom Rini
On Mon, Jun 13, 2022 at 04:54:45PM -0300, Fabio Estevam wrote:
> On Wed, May 18, 2022 at 6:23 AM Neil Armstrong  
> wrote:
> 
> > This change as commit a9bf024b2933bba0e23038892970a18b72dfaeb4 in master 
> > makes Amlogic S905X board libretech-cc to crash:
> 
> This change also causes issues on a kontron-sl-mx8mm and imx8mn ddr3 evk 
> boards.
> 
> The problem on these boards is that serial console garbage is seen:
> 
> Net:   eth0: ethernet@30be
> Hit any key to stop autoboot:  0
> u-boot=> [25;88R
> Unknown command '[25' - try 'help'
> Unknown command '88R' - try 'help'
> 
> These extraneous characters stop the boot process.
> 
> As a workaround, I disabled CONFIG_EFI_LOADER, and then the serial
> garbage does not happen and the board can boot normally.
> 
> Heiko confirmed the same behavior on an imx8mn evk ddr3 board.

What happens if you increase logging so that you can see other errors
that happen as it feels like we're probably overflowing some buffer or
something along the way.

-- 
Tom


signature.asc
Description: PGP signature


Re: cmd: exit: Doesn't function

2022-06-13 Thread Fabio Estevam
[Adding Marek on Cc]

On Mon, Jun 13, 2022 at 5:00 PM Adrian Vovk  wrote:
>
> Hello,
>
> I've run into an issue trying to use a recent commit of u-boot
> (v2022.07-rc3-101-g90189ecd59) with some custom scripts. Basically, I've
> found that the `exit` command does not function whatsoever, and instead it
> just behaves as a no-op (like the `true` command)
>
> I tracked down the issue and found its source. It's 8c4e3b7[1], which
> changed the behavior of the exit command without changing the behavior of
> the command processor to match. The command line code expects exit to
> return values -2 and lower, which it will respond to by exiting[2].
> However, with that commit above, exit will never return a value <= -2,
> which means the command line loop never exits.
>
> I skimmed the mailing list and haven't found any mentions of this bug yet.
> I suspect this is because many of the deployments of u-boot are running
> older versions. However, exit is used rather often in the u-boot scripts
> I've seen, so I think this might become a major issue when board vendors
> start upgrading to newer versions of u-boot.
>
> [1]:
> https://source.denx.de/u-boot/u-boot/-/commit/8c4e3b79bd0bb76eea16869e9666e19047c0d005
> [2]:
> https://source.denx.de/u-boot/u-boot/-/blob/master/common/cli_hush.c#L1901-1904
>
> Thank you,
> Adrian Vovk


cmd: exit: Doesn't function

2022-06-13 Thread Adrian Vovk
Hello,

I've run into an issue trying to use a recent commit of u-boot
(v2022.07-rc3-101-g90189ecd59) with some custom scripts. Basically, I've
found that the `exit` command does not function whatsoever, and instead it
just behaves as a no-op (like the `true` command)

I tracked down the issue and found its source. It's 8c4e3b7[1], which
changed the behavior of the exit command without changing the behavior of
the command processor to match. The command line code expects exit to
return values -2 and lower, which it will respond to by exiting[2].
However, with that commit above, exit will never return a value <= -2,
which means the command line loop never exits.

I skimmed the mailing list and haven't found any mentions of this bug yet.
I suspect this is because many of the deployments of u-boot are running
older versions. However, exit is used rather often in the u-boot scripts
I've seen, so I think this might become a major issue when board vendors
start upgrading to newer versions of u-boot.

[1]:
https://source.denx.de/u-boot/u-boot/-/commit/8c4e3b79bd0bb76eea16869e9666e19047c0d005
[2]:
https://source.denx.de/u-boot/u-boot/-/blob/master/common/cli_hush.c#L1901-1904

Thank you,
Adrian Vovk


Re: [PATCH v5 07/12] efi_loader: disk: a helper function to create efi_disk objects from udevice

2022-06-13 Thread Fabio Estevam
On Wed, May 18, 2022 at 6:23 AM Neil Armstrong  wrote:

> This change as commit a9bf024b2933bba0e23038892970a18b72dfaeb4 in master 
> makes Amlogic S905X board libretech-cc to crash:

This change also causes issues on a kontron-sl-mx8mm and imx8mn ddr3 evk boards.

The problem on these boards is that serial console garbage is seen:

Net:   eth0: ethernet@30be
Hit any key to stop autoboot:  0
u-boot=> [25;88R
Unknown command '[25' - try 'help'
Unknown command '88R' - try 'help'

These extraneous characters stop the boot process.

As a workaround, I disabled CONFIG_EFI_LOADER, and then the serial
garbage does not happen and the board can boot normally.

Heiko confirmed the same behavior on an imx8mn evk ddr3 board.


Re: imx8mn SPL serial output does not work after powerup

2022-06-13 Thread Heiko Thiery
Am Mo., 13. Juni 2022 um 21:43 Uhr schrieb Heiko Thiery
:
>
> Hi,
>
> Am Mo., 13. Juni 2022 um 21:28 Uhr schrieb Fabio Estevam :
> >
> > Hi Heiko,
> >
> > On Mon, Jun 13, 2022 at 4:16 PM Heiko Thiery  wrote:
> >
> > > Can anyone confirm the behavior?
> >
> > imx8mn ddr4 evk prints the SPL part just fine.
> >
> > Take a look at arch/arm/dts/imx8mn-ddr4-evk-u-boot.dtsi .
> >
> > It passes:
> >
> >  {
> >   u-boot,dm-spl;
> > };
> >
> > _uart2 {
> >  u-boot,dm-spl;
> > };
> >
> > Are you doing the same for the imx8mn ddr3 u-boot dtsi?
>
> Indeed these are missing. Now I see the whole output from U-Boot but
> the output from SPL is still missing. When enabloing SPL_DM_SERIAL the
> board does not start.


I now did include the whole "imx8mn-ddr4-evk-u-boot.dtsi" like it is
done in "imx8mn-evk-u-boot.dtsi". Then it works.

> --
> Heiko


Re: imx8mn SPL serial output does not work after powerup

2022-06-13 Thread Michael Nazzareno Trimarchi
Hi

Il lun 13 giu 2022, 21:43 Heiko Thiery  ha scritto:

> Hi,
>
> Am Mo., 13. Juni 2022 um 21:28 Uhr schrieb Fabio Estevam <
> feste...@gmail.com>:
> >
> > Hi Heiko,
> >
> > On Mon, Jun 13, 2022 at 4:16 PM Heiko Thiery 
> wrote:
> >
> > > Can anyone confirm the behavior?
> >
> > imx8mn ddr4 evk prints the SPL part just fine.
> >
> > Take a look at arch/arm/dts/imx8mn-ddr4-evk-u-boot.dtsi .
> >
> > It passes:
> >
> >  {
> >   u-boot,dm-spl;
> > };
> >
> > _uart2 {
> >  u-boot,dm-spl;
> > };
> >
> > Are you doing the same for the imx8mn ddr3 u-boot dtsi?
>
> Indeed these are missing. Now I see the whole output from U-Boot but
> the output from SPL is still missing. When enabloing SPL_DM_SERIAL the
> board does not start.
>

Check if you have UART clock enabled in sol

Michael

>
> --
> Heiko
>


Re: imx8mn SPL serial output does not work after powerup

2022-06-13 Thread Heiko Thiery
Hi,

Am Mo., 13. Juni 2022 um 21:28 Uhr schrieb Fabio Estevam :
>
> Hi Heiko,
>
> On Mon, Jun 13, 2022 at 4:16 PM Heiko Thiery  wrote:
>
> > Can anyone confirm the behavior?
>
> imx8mn ddr4 evk prints the SPL part just fine.
>
> Take a look at arch/arm/dts/imx8mn-ddr4-evk-u-boot.dtsi .
>
> It passes:
>
>  {
>   u-boot,dm-spl;
> };
>
> _uart2 {
>  u-boot,dm-spl;
> };
>
> Are you doing the same for the imx8mn ddr3 u-boot dtsi?

Indeed these are missing. Now I see the whole output from U-Boot but
the output from SPL is still missing. When enabloing SPL_DM_SERIAL the
board does not start.

-- 
Heiko


Re: imx8mn SPL serial output does not work after powerup

2022-06-13 Thread Fabio Estevam
Hi Heiko,

On Mon, Jun 13, 2022 at 4:16 PM Heiko Thiery  wrote:

> Can anyone confirm the behavior?

imx8mn ddr4 evk prints the SPL part just fine.

Take a look at arch/arm/dts/imx8mn-ddr4-evk-u-boot.dtsi .

It passes:

 {
  u-boot,dm-spl;
};

_uart2 {
 u-boot,dm-spl;
};

Are you doing the same for the imx8mn ddr3 u-boot dtsi?


imx8mn SPL serial output does not work after powerup

2022-06-13 Thread Heiko Thiery
Hi,

After a powerup the SPL output is not seen.

[Powerup]
Core:  140 devices, 19 uclasses, devicetree: separate
WDT:   Started watchdog@3028 with servicing (60s timeout)
MMC:   FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... *** Warning - bad CRC, using default environment

In:serial@3089
Out:   serial@3089
Err:   serial@3089
Net:   eth0: ethernet@30be
Hit any key to stop autoboot:  0
u-boot=>

Only after a softreset the output from SPL can be seen.

u-boot=> reset
resetting ...

U-Boot SPL 2022.07-rc4-00012-g4b48844ba4 (Jun 13 2022 - 21:06:16 +0200)
Normal Boot
Failed to find clock node. Check device tree
Trying to boot from BOOTROM
image offset 0x8000, pagesize 0x200, ivt offset 0x0
NOTICE:  BL31: v2.6(release):v2.6-5-g9b1a4d832
NOTICE:  BL31: Built : 14:03:53, May 10 2022


U-Boot 2022.07-rc4-00012-g4b48844ba4 (Jun 13 2022 - 21:06:16 +0200)

CPU:   Freescale i.MX8MNano UltraLite Quad rev1.0 at 1200 MHz
Reset cause: WDOG
Model: NXP i.MX8MNano DDR3L EVK board
DRAM:  1 GiB
Core:  140 devices, 19 uclasses, devicetree: separate
WDT:   Started watchdog@3028 with servicing (60s timeout)
MMC:   FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... *** Warning - bad CRC, using default environment

In:serial@3089
Out:   serial@3089
Err:   serial@3089
Net:   eth0: ethernet@30be
Hit any key to stop autoboot:  0
u-boot=>


Can anyone confirm the behavior?

--
Heiko


Re: imx8m(n): garbage on serial line

2022-06-13 Thread Heiko Thiery
Hi Fabio,

Am Mo., 13. Juni 2022 um 19:01 Uhr schrieb Fabio Estevam :
>
> Hi Heiko,
>
> On Fri, Jun 10, 2022 at 7:29 AM Heiko Thiery  wrote:
>
> > Hit any key to stop autoboot:  0
> > u-boot=> [25;88R
> > Unknown command '[25' - try 'help'
> > Unknown command '88R' - try 'help'
>
> git bisect points me to an efi loader commit as the guilty one.
>
> Can you please pass the line below into your imx8mn ddr3l evk board defconfig?
>
> # CONFIG_EFI_LOADER is not set
>
> Do you see serial console garbage in this case?
>
> Just wanted to confirm if the error we are seeing is due to the efi
> loader breakage.

I can confirm that by disabling EFI loader the error is gone.


--
Heiko


[PATCH 3/3] toradex: tdx-cfg-block: extend assembly version

2022-06-13 Thread Philippe Schenker
From: Philippe Schenker 

There are two decimal digits reserved to encode the module version and
revision. This code so far implemented A-Z which used 0-25 of this
range.
This commit extends the range to make use of all 99 numbers. After
capital letters the form with a hashtag and number (e.g. #26) is used.

Examples:

If the assembly version is between zero and 25 the numbering is as follows,
as it also has been before this commit:
0: V0.0A
1: V0.0B
...
25: V0.0Z

New numbering of assembly version:
If the number is between 26 and 99 the new assembly version name is:
26: V0.0#26
27: V0.0#27
...
99: V0.0#99

Signed-off-by: Philippe Schenker 

---

 board/toradex/common/tdx-cfg-block.c | 32 
 board/toradex/common/tdx-common.c| 25 +-
 2 files changed, 48 insertions(+), 9 deletions(-)

diff --git a/board/toradex/common/tdx-cfg-block.c 
b/board/toradex/common/tdx-cfg-block.c
index 9c87289ae9..05f25fe7e6 100644
--- a/board/toradex/common/tdx-cfg-block.c
+++ b/board/toradex/common/tdx-cfg-block.c
@@ -353,6 +353,18 @@ out:
return ret;
 }
 
+static int parse_assembly_string(char *string_to_parse, u16 *assembly)
+{
+   if (string_to_parse[3] >= 'A' && string_to_parse[3] <= 'Z')
+   *assembly = string_to_parse[3] - 'A';
+   else if (string_to_parse[3] == '#')
+   *assembly = dectoul(_to_parse[4], NULL);
+   else
+   return -EINVAL;
+
+   return 0;
+}
+
 static int get_cfgblock_interactive(void)
 {
char message[CONFIG_SYS_CBSIZE];
@@ -360,6 +372,7 @@ static int get_cfgblock_interactive(void)
char it = 'n';
char wb = 'n';
int len = 0;
+   int ret = 0;
 
/* Unknown module by default */
tdx_hw_tag.prodid = 0;
@@ -531,13 +544,18 @@ static int get_cfgblock_interactive(void)
}
 
while (len < 4) {
-   sprintf(message, "Enter the module version (e.g. V1.1B): V");
+   sprintf(message, "Enter the module version (e.g. V1.1B or 
V1.1#26): V");
len = cli_readline(message);
}
 
tdx_hw_tag.ver_major = console_buffer[0] - '0';
tdx_hw_tag.ver_minor = console_buffer[2] - '0';
-   tdx_hw_tag.ver_assembly = console_buffer[3] - 'A';
+
+   ret = parse_assembly_string(console_buffer, _hw_tag.ver_assembly);
+   if (ret) {
+   printf("Parsing module version failed\n");
+   return ret;
+   }
 
while (len < 8) {
sprintf(message, "Enter module serial number: ");
@@ -740,6 +758,7 @@ static int get_cfgblock_carrier_interactive(void)
 {
char message[CONFIG_SYS_CBSIZE];
int len;
+   int ret = 0;
 
printf("Supported carrier boards:\n");
printf("CARRIER BOARD NAME\t\t [ID]\n");
@@ -753,13 +772,18 @@ static int get_cfgblock_carrier_interactive(void)
tdx_car_hw_tag.prodid = dectoul(console_buffer, NULL);
 
do {
-   sprintf(message, "Enter carrier board version (e.g. V1.1B): V");
+   sprintf(message, "Enter carrier board version (e.g. V1.1B or 
V1.1#26): V");
len = cli_readline(message);
} while (len < 4);
 
tdx_car_hw_tag.ver_major = console_buffer[0] - '0';
tdx_car_hw_tag.ver_minor = console_buffer[2] - '0';
-   tdx_car_hw_tag.ver_assembly = console_buffer[3] - 'A';
+
+   ret = parse_assembly_string(console_buffer, 
_car_hw_tag.ver_assembly);
+   if (ret) {
+   printf("Parsing module version failed\n");
+   return ret;
+   }
 
while (len < 8) {
sprintf(message, "Enter carrier board serial number: ");
diff --git a/board/toradex/common/tdx-common.c 
b/board/toradex/common/tdx-common.c
index 94e603c14f..5ad5d00a0d 100644
--- a/board/toradex/common/tdx-common.c
+++ b/board/toradex/common/tdx-common.c
@@ -24,7 +24,7 @@
 
 #define SERIAL_STR_LEN 8
 #define MODULE_VER_STR_LEN 4 // V1.1
-#define MODULE_REV_STR_LEN 1 // [A-Z]
+#define MODULE_REV_STR_LEN 3 // [A-Z] or #[26-99]
 
 #ifdef CONFIG_TDX_CFG_BLOCK
 static char tdx_serial_str[SERIAL_STR_LEN + 1];
@@ -83,6 +83,21 @@ void get_board_serial(struct tag_serialnr *serialnr)
 }
 #endif /* CONFIG_SERIAL_TAG */
 
+static const char *get_board_assembly(u16 ver_assembly)
+{
+   static char ver_name[MODULE_REV_STR_LEN + 1];
+
+   if (ver_assembly < 26) {
+   ver_name[0] = (char)ver_assembly + 'A';
+   ver_name[1] = '\0';
+   } else {
+   snprintf(ver_name, sizeof(ver_name),
+"#%u", ver_assembly);
+   }
+
+   return ver_name;
+}
+
 int show_board_info(void)
 {
unsigned char ethaddr[6];
@@ -96,10 +111,10 @@ int show_board_info(void)
snprintf(tdx_serial_str, sizeof(tdx_serial_str),
 "%08u", tdx_serial);
snprintf(tdx_board_rev_str, sizeof(tdx_board_rev_str),
-"V%1d.%1d%c",
+  

[PATCH 2/3] toradex: tdx-cfg-block: use defines for string length

2022-06-13 Thread Philippe Schenker
From: Philippe Schenker 

With those defines the length can be reused and is in one place
extendable.

Signed-off-by: Philippe Schenker 
---

 board/toradex/common/tdx-common.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/board/toradex/common/tdx-common.c 
b/board/toradex/common/tdx-common.c
index 2207818447..94e603c14f 100644
--- a/board/toradex/common/tdx-common.c
+++ b/board/toradex/common/tdx-common.c
@@ -22,13 +22,17 @@
 
 #define TORADEX_OUI 0x00142dUL
 
+#define SERIAL_STR_LEN 8
+#define MODULE_VER_STR_LEN 4 // V1.1
+#define MODULE_REV_STR_LEN 1 // [A-Z]
+
 #ifdef CONFIG_TDX_CFG_BLOCK
-static char tdx_serial_str[9];
-static char tdx_board_rev_str[6];
+static char tdx_serial_str[SERIAL_STR_LEN + 1];
+static char tdx_board_rev_str[MODULE_VER_STR_LEN + MODULE_REV_STR_LEN + 1];
 
 #ifdef CONFIG_TDX_CFG_BLOCK_EXTRA
-static char tdx_car_serial_str[9];
-static char tdx_car_rev_str[6];
+static char tdx_car_serial_str[SERIAL_STR_LEN + 1];
+static char tdx_car_rev_str[MODULE_VER_STR_LEN + MODULE_REV_STR_LEN + 1];
 static char *tdx_carrier_board_name;
 #endif
 
-- 
2.36.1



[PATCH 1/3] toradex: tdx-cfg-block: use only snprintf

2022-06-13 Thread Philippe Schenker
From: Philippe Schenker 

Prevent memory issues that could appear with sprintf. Replace all
sprintf occurences with snprintf.

Signed-off-by: Philippe Schenker 
---

 board/toradex/common/tdx-common.c | 27 +++
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/board/toradex/common/tdx-common.c 
b/board/toradex/common/tdx-common.c
index 9db4553e0f..2207818447 100644
--- a/board/toradex/common/tdx-common.c
+++ b/board/toradex/common/tdx-common.c
@@ -89,11 +89,13 @@ int show_board_info(void)
tdx_eth_addr.nic = htonl(tdx_serial << 8);
checkboard();
} else {
-   sprintf(tdx_serial_str, "%08u", tdx_serial);
-   sprintf(tdx_board_rev_str, "V%1d.%1d%c",
-   tdx_hw_tag.ver_major,
-   tdx_hw_tag.ver_minor,
-   (char)tdx_hw_tag.ver_assembly + 'A');
+   snprintf(tdx_serial_str, sizeof(tdx_serial_str),
+"%08u", tdx_serial);
+   snprintf(tdx_board_rev_str, sizeof(tdx_board_rev_str),
+"V%1d.%1d%c",
+tdx_hw_tag.ver_major,
+tdx_hw_tag.ver_minor,
+(char)tdx_hw_tag.ver_assembly + 'A');
 
env_set("serial#", tdx_serial_str);
 
@@ -109,12 +111,13 @@ int show_board_info(void)
tdx_carrier_board_name = (char *)
toradex_carrier_boards[tdx_car_hw_tag.prodid];
 
-   sprintf(tdx_car_serial_str, "%08u", tdx_car_serial);
-   sprintf(tdx_car_rev_str, "V%1d.%1d%c",
-   tdx_car_hw_tag.ver_major,
-   tdx_car_hw_tag.ver_minor,
-   (char)tdx_car_hw_tag.ver_assembly +
-   'A');
+   snprintf(tdx_car_serial_str, sizeof(tdx_car_serial_str),
+"%08u", tdx_car_serial);
+   snprintf(tdx_car_rev_str, sizeof(tdx_car_rev_str),
+"V%1d.%1d%c",
+tdx_car_hw_tag.ver_major,
+tdx_car_hw_tag.ver_minor,
+(char)tdx_car_hw_tag.ver_assembly + 'A');
 
env_set("carrier_serial#", tdx_car_serial_str);
printf("Carrier: Toradex %s %s, Serial# %s\n",
@@ -170,7 +173,7 @@ int ft_common_board_setup(void *blob, struct bd_info *bd)
if (tdx_hw_tag.ver_major) {
char prod_id[5];
 
-   sprintf(prod_id, "%04u", tdx_hw_tag.prodid);
+   snprintf(prod_id, sizeof(prod_id), "%04u", tdx_hw_tag.prodid);
fdt_setprop(blob, 0, "toradex,product-id", prod_id, 5);
 
fdt_setprop(blob, 0, "toradex,board-rev", tdx_board_rev_str,
-- 
2.36.1



[PATCH] toradex: tdx-cfg-block: extend assembly version

2022-06-13 Thread Philippe Schenker
From: Philippe Schenker 

There are two decimal digits reserved to encode the module version and
revision. This code so far implemented A-Z which used 0-25 of this
range.
This commit extends the range to make use of all 99 numbers. After
capital letters the form with a hashtag and number (e.g. #26) is used.

Examples:

If the assembly version is between zero and 25 the numbering is as follows,
as it also has been before this commit:
0: V0.0A
1: V0.0B
...
25: V0.0Z

New numbering of assembly version:
If the number is between 26 and 99 the new assembly version name is:
26: V0.0#26
27: V0.0#27
...
99: V0.0#99

Signed-off-by: Philippe Schenker 

---

 board/toradex/common/tdx-cfg-block.c | 32 
 board/toradex/common/tdx-common.c| 25 +-
 2 files changed, 48 insertions(+), 9 deletions(-)

diff --git a/board/toradex/common/tdx-cfg-block.c 
b/board/toradex/common/tdx-cfg-block.c
index 9c87289ae9..05f25fe7e6 100644
--- a/board/toradex/common/tdx-cfg-block.c
+++ b/board/toradex/common/tdx-cfg-block.c
@@ -353,6 +353,18 @@ out:
return ret;
 }
 
+static int parse_assembly_string(char *string_to_parse, u16 *assembly)
+{
+   if (string_to_parse[3] >= 'A' && string_to_parse[3] <= 'Z')
+   *assembly = string_to_parse[3] - 'A';
+   else if (string_to_parse[3] == '#')
+   *assembly = dectoul(_to_parse[4], NULL);
+   else
+   return -EINVAL;
+
+   return 0;
+}
+
 static int get_cfgblock_interactive(void)
 {
char message[CONFIG_SYS_CBSIZE];
@@ -360,6 +372,7 @@ static int get_cfgblock_interactive(void)
char it = 'n';
char wb = 'n';
int len = 0;
+   int ret = 0;
 
/* Unknown module by default */
tdx_hw_tag.prodid = 0;
@@ -531,13 +544,18 @@ static int get_cfgblock_interactive(void)
}
 
while (len < 4) {
-   sprintf(message, "Enter the module version (e.g. V1.1B): V");
+   sprintf(message, "Enter the module version (e.g. V1.1B or 
V1.1#26): V");
len = cli_readline(message);
}
 
tdx_hw_tag.ver_major = console_buffer[0] - '0';
tdx_hw_tag.ver_minor = console_buffer[2] - '0';
-   tdx_hw_tag.ver_assembly = console_buffer[3] - 'A';
+
+   ret = parse_assembly_string(console_buffer, _hw_tag.ver_assembly);
+   if (ret) {
+   printf("Parsing module version failed\n");
+   return ret;
+   }
 
while (len < 8) {
sprintf(message, "Enter module serial number: ");
@@ -740,6 +758,7 @@ static int get_cfgblock_carrier_interactive(void)
 {
char message[CONFIG_SYS_CBSIZE];
int len;
+   int ret = 0;
 
printf("Supported carrier boards:\n");
printf("CARRIER BOARD NAME\t\t [ID]\n");
@@ -753,13 +772,18 @@ static int get_cfgblock_carrier_interactive(void)
tdx_car_hw_tag.prodid = dectoul(console_buffer, NULL);
 
do {
-   sprintf(message, "Enter carrier board version (e.g. V1.1B): V");
+   sprintf(message, "Enter carrier board version (e.g. V1.1B or 
V1.1#26): V");
len = cli_readline(message);
} while (len < 4);
 
tdx_car_hw_tag.ver_major = console_buffer[0] - '0';
tdx_car_hw_tag.ver_minor = console_buffer[2] - '0';
-   tdx_car_hw_tag.ver_assembly = console_buffer[3] - 'A';
+
+   ret = parse_assembly_string(console_buffer, 
_car_hw_tag.ver_assembly);
+   if (ret) {
+   printf("Parsing module version failed\n");
+   return ret;
+   }
 
while (len < 8) {
sprintf(message, "Enter carrier board serial number: ");
diff --git a/board/toradex/common/tdx-common.c 
b/board/toradex/common/tdx-common.c
index 94e603c14f..5ad5d00a0d 100644
--- a/board/toradex/common/tdx-common.c
+++ b/board/toradex/common/tdx-common.c
@@ -24,7 +24,7 @@
 
 #define SERIAL_STR_LEN 8
 #define MODULE_VER_STR_LEN 4 // V1.1
-#define MODULE_REV_STR_LEN 1 // [A-Z]
+#define MODULE_REV_STR_LEN 3 // [A-Z] or #[26-99]
 
 #ifdef CONFIG_TDX_CFG_BLOCK
 static char tdx_serial_str[SERIAL_STR_LEN + 1];
@@ -83,6 +83,21 @@ void get_board_serial(struct tag_serialnr *serialnr)
 }
 #endif /* CONFIG_SERIAL_TAG */
 
+static const char *get_board_assembly(u16 ver_assembly)
+{
+   static char ver_name[MODULE_REV_STR_LEN + 1];
+
+   if (ver_assembly < 26) {
+   ver_name[0] = (char)ver_assembly + 'A';
+   ver_name[1] = '\0';
+   } else {
+   snprintf(ver_name, sizeof(ver_name),
+"#%u", ver_assembly);
+   }
+
+   return ver_name;
+}
+
 int show_board_info(void)
 {
unsigned char ethaddr[6];
@@ -96,10 +111,10 @@ int show_board_info(void)
snprintf(tdx_serial_str, sizeof(tdx_serial_str),
 "%08u", tdx_serial);
snprintf(tdx_board_rev_str, sizeof(tdx_board_rev_str),
-"V%1d.%1d%c",
+  

Re: [PATCH] misc: Port USB251xB/xBi Hi-Speed Hub Controller Driver from Linux

2022-06-13 Thread Stefan Herbrechtsmeier

Hi Marek,

Am 13.06.2022 um 18:00 schrieb Marek Vasut:

On 6/13/22 17:39, Stefan Herbrechtsmeier wrote:

Hi Marek,


Hi,

sorry for the late comments but I think the driver doesn't work as 
expected.


How come ? It works on my board.


Have you test with 16 bit property data?



[...]


+
+    if (IS_ENABLED(CONFIG_DM_REGULATOR)) {
+    err = device_get_supply_regulator(dev, "vdd-supply",
+  >vdd);
+    if (err && err != -ENOENT) {
+    dev_err(dev, "Warning: cannot get power supply\n");
+    return err;
+    }
+    }


Shouldn't the gpio and regulator request be part of the probe?


What makes you think that ?


It's more a question regarding the device model design:

of_to_plat - convert device tree data to plat




+    if (dev_read_u32(dev, "vendor-id", >vendor_id))
+    hub->vendor_id = USB251XB_DEF_VENDOR_ID;
+
+    if (dev_read_u32(dev, "product-id", >product_id))
+    hub->product_id = data->product_id;
+
+    if (dev_read_u32(dev, "device-id", >device_id))
+    hub->device_id = USB251XB_DEF_DEVICE_ID;
+


[snip]


+    if (dev_read_u32(dev, "language-id", >lang_id))
+    hub->lang_id = USB251XB_DEF_LANGUAGE_ID;
+


This doesn't work because the ids are 16 bit [1,2] and the 
dev_read_u32 function checks the size.



+    if (!dev_read_u32(dev, "boost-up", >boost_up))
+    hub->boost_up = USB251XB_DEF_BOOST_UP;


This looks like a 8 bit value [1].


The dev_read_u32() is also capable of reading 0x 16bit value from DT.

What kind of problem are you running into exactly ?


Have you test the values from device tree binding documentation:

vendor-id = /bits/ 16 <0x>;
product-id = /bits/ 16 <0x>;

I get an EOVERFLOW error.



Re: imx8m(n): garbage on serial line

2022-06-13 Thread Fabio Estevam
Hi Heiko,

On Fri, Jun 10, 2022 at 7:29 AM Heiko Thiery  wrote:

> Hit any key to stop autoboot:  0
> u-boot=> [25;88R
> Unknown command '[25' - try 'help'
> Unknown command '88R' - try 'help'

git bisect points me to an efi loader commit as the guilty one.

Can you please pass the line below into your imx8mn ddr3l evk board defconfig?

# CONFIG_EFI_LOADER is not set

Do you see serial console garbage in this case?

Just wanted to confirm if the error we are seeing is due to the efi
loader breakage.


Re: imx8m(n): garbage on serial line

2022-06-13 Thread Fabio Estevam
On Mon, Jun 13, 2022 at 11:27 AM Fabio Estevam  wrote:

> U-Boot 2022.07-rc4-7-g57bd363de7 (Jun 13 2022 - 11:18:10 -0300)
>
> CPU:   Freescale i.MX8MMQ rev1.0 1600 MHz (running at 1200 MHz)
> CPU:   Industrial temperature grade (-40C to 105C) at 60C
> Reset cause: POR
> Model: Kontron i.MX8MM N801X S
> DRAM:  4 GiB
> Core:  175 devices, 25 uclasses, devicetree: separate
> WDT:   Not starting watchdog@3028
> MMC:   FSL_SDHC: 0, FSL_SDHC: 1
> Loading Environment from SPIFlash... SF: Detected mx25r1635f with page
> size 256 Bytes, erase size 64 KiB, total 2 MiB
> OK
> In:serial
> Out:   serial
> Err:   serial
> Net:   Could not get PHY for FEC0: addr 0
> No ethernet found.
>
> Hit any key to stop autoboot:  0
> => [55;203R
> Unknown command '[55' - try 'help'
> Unknown command '203R' - try 'help'
>
> and the serial garbage is seen.

I managed to bisect it, and the serial console garbage is caused by:

commit a9bf024b2933bba0e23038892970a18b72dfaeb4
Author: AKASHI Takahiro 
Date:   Tue Apr 19 10:05:12 2022 +0900

efi_loader: disk: a helper function to create efi_disk objects from udevice

Add efi_disk_probe() function.
This function creates an efi_disk object for a raw disk device (UCLASS_BLK)
and additional objects for related partitions (UCLASS_PARTITION).

So this function is expected to be called through driver model's "probe"
interface every time one raw disk device is detected and activated.
We assume that partition devices (UCLASS_PARTITION) have been created
when this function is invoked.

Signed-off-by: AKASHI Takahiro 

Akashi-san, any ideas?


Re: Pull request for efi-2022-07-rc5

2022-06-13 Thread Tom Rini
On Mon, Jun 13, 2022 at 08:25:55AM +0200, Heinrich Schuchardt wrote:

> 
> Dear Tom,
> 
> The following changes since commit 57bd363de7b95bececd40a0c8dbb2fcf4d8d3b21:
> 
>   Merge https://source.denx.de/u-boot/custodians/u-boot-usb (2022-06-08
> 08:25:30 -0400)
> 
> are available in the Git repository at:
> 
>   https://source.denx.de/u-boot/custodians/u-boot-efi.git
> tags/efi-2022-07-rc5
> 
> for you to fetch changes up to 72fa9cd59edcf99cb32c05604d2a904018acd30a:
> 
>   efi_loader: create boot options without file path (2022-06-12
> 13:02:34 +0200)
> 
> Gitlab reported no issues:
> https://source.denx.de/u-boot/custodians/u-boot-efi/-/pipelines/12278
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] misc: Port USB251xB/xBi Hi-Speed Hub Controller Driver from Linux

2022-06-13 Thread Marek Vasut

On 6/13/22 17:39, Stefan Herbrechtsmeier wrote:

Hi Marek,


Hi,

sorry for the late comments but I think the driver doesn't work as 
expected.


How come ? It works on my board.

[...]


+
+    if (IS_ENABLED(CONFIG_DM_REGULATOR)) {
+    err = device_get_supply_regulator(dev, "vdd-supply",
+  >vdd);
+    if (err && err != -ENOENT) {
+    dev_err(dev, "Warning: cannot get power supply\n");
+    return err;
+    }
+    }


Shouldn't the gpio and regulator request be part of the probe?


What makes you think that ?


+    if (dev_read_u32(dev, "vendor-id", >vendor_id))
+    hub->vendor_id = USB251XB_DEF_VENDOR_ID;
+
+    if (dev_read_u32(dev, "product-id", >product_id))
+    hub->product_id = data->product_id;
+
+    if (dev_read_u32(dev, "device-id", >device_id))
+    hub->device_id = USB251XB_DEF_DEVICE_ID;
+


[snip]


+    if (dev_read_u32(dev, "language-id", >lang_id))
+    hub->lang_id = USB251XB_DEF_LANGUAGE_ID;
+


This doesn't work because the ids are 16 bit [1,2] and the dev_read_u32 
function checks the size.



+    if (!dev_read_u32(dev, "boost-up", >boost_up))
+    hub->boost_up = USB251XB_DEF_BOOST_UP;


This looks like a 8 bit value [1].


The dev_read_u32() is also capable of reading 0x 16bit value from DT.

What kind of problem are you running into exactly ?


Re: [PATCH] misc: Port USB251xB/xBi Hi-Speed Hub Controller Driver from Linux

2022-06-13 Thread Stefan Herbrechtsmeier

Hi Marek,

sorry for the late comments but I think the driver doesn't work as expected.

Am 10.04.2022 um 06:27 schrieb Marek Vasut:

This patch adds a driver for configuration of the Microchip USB251xB/xBi
USB 2.0 hub controller series with USB 2.0 upstream connectivity, SMBus
configuration interface and two to four USB 2.0 downstream ports.

This is ported from Linux as of Linux kernel commit
5c2b9c61ae5d8 ("usb: usb251xb: add boost-up property support")

Signed-off-by: Marek Vasut 
Cc: Bin Meng 
Cc: Michal Simek 
Cc: Simon Glass 
---
  drivers/misc/Kconfig|   9 +
  drivers/misc/Makefile   |   1 +
  drivers/misc/usb251xb.c | 605 
  3 files changed, 615 insertions(+)
  create mode 100644 drivers/misc/usb251xb.c

diff --git a/drivers/misc/usb251xb.c b/drivers/misc/usb251xb.c
new file mode 100644
index 000..077edc25045
--- /dev/null
+++ b/drivers/misc/usb251xb.c
@@ -0,0 +1,605 @@


[snip]


+static int usb251xb_of_to_plat(struct udevice *dev)
+{
+   struct usb251xb_data *data =
+   (struct usb251xb_data *)dev_get_driver_data(dev);
+   struct usb251xb *hub = dev_get_priv(dev);
+   char str[USB251XB_STRING_BUFSIZE / 2];
+   const char *cproperty_char;
+   u32 property_u32 = 0;
+   int len, err;
+
+   if (dev_read_bool(dev, "skip-config"))
+   hub->skip_config = 1;
+   else
+   hub->skip_config = 0;
+
+   err = gpio_request_by_name(dev, "reset-gpios", 0, >gpio_reset,
+  GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
+   if (err && err != -ENOENT) {
+   dev_err(dev, "unable to request GPIO reset pin (%d)\n", err);
+   return err;
+   }
+
+   if (IS_ENABLED(CONFIG_DM_REGULATOR)) {
+   err = device_get_supply_regulator(dev, "vdd-supply",
+ >vdd);
+   if (err && err != -ENOENT) {
+   dev_err(dev, "Warning: cannot get power supply\n");
+   return err;
+   }
+   }


Shouldn't the gpio and regulator request be part of the probe?


+
+   if (dev_read_u32(dev, "vendor-id", >vendor_id))
+   hub->vendor_id = USB251XB_DEF_VENDOR_ID;
+
+   if (dev_read_u32(dev, "product-id", >product_id))
+   hub->product_id = data->product_id;
+
+   if (dev_read_u32(dev, "device-id", >device_id))
+   hub->device_id = USB251XB_DEF_DEVICE_ID;
+


[snip]


+   if (dev_read_u32(dev, "language-id", >lang_id))
+   hub->lang_id = USB251XB_DEF_LANGUAGE_ID;
+


This doesn't work because the ids are 16 bit [1,2] and the dev_read_u32 
function checks the size.



+   if (!dev_read_u32(dev, "boost-up", >boost_up))
+   hub->boost_up = USB251XB_DEF_BOOST_UP;


This looks like a 8 bit value [1].

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/misc/usb251xb.c
[2] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/usb/usb251xb.txt


Regards,
  Stefan


Re: Boot regression on am335x-hs-evm

2022-06-13 Thread Andrew Davis

On 6/13/22 9:20 AM, Tom Rini wrote:

On Mon, Jun 13, 2022 at 02:51:03PM +0200, LABBE Corentin wrote:

Le Fri, Jun 10, 2022 at 11:48:34AM -0400, Tom Rini a écrit :

On Fri, Jun 10, 2022 at 05:45:04PM +0200, LABBE Corentin wrote:

Le Fri, Jun 10, 2022 at 11:01:47AM -0400, Tom Rini a écrit :

On Fri, Jun 10, 2022 at 04:51:12PM +0200, LABBE Corentin wrote:

Le Fri, Jun 10, 2022 at 08:16:10AM -0400, Tom Rini a écrit :

On Fri, Jun 10, 2022 at 11:59:23AM +0200, LABBE Corentin wrote:

Hello

I hit a boot regression on am335x-hs-evm.
On current uboot, the board does not boot at all.
This board uses both MLO and u-boot.img and only MLO was the problem.

After a bisect, I found that e41651fffda7 ("dm: Support parent devices with 
of-platdata") was the problem.
Reverting this patch lead to a success boot.

I cutdown the revert to a minimal fix:
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -120,6 +120,7 @@ int lists_bind_drivers(struct udevice *parent, bool 
pre_reloc_only)
 int ret;
  
 ret = bind_drivers_pass(parent, pre_reloc_only);

+   return ret;
 if (!ret)
 break;
 if (ret != -EAGAIN && !result)

I cannot debug further since printf() is not working at this stage.

Since I wanted to know which error was badly handled, I tried to do this:
--- a/arch/arm/mach-omap2/sec-common.c
+++ b/arch/arm/mach-omap2/sec-common.c
@@ -111,6 +111,8 @@ static u32 find_sig_start(char *image, size_t size)
 return 0;
  }
  
+extern int errorcount;

+
  int secure_boot_verify_image(void **image, size_t *size)
  {
 int result = 1;
@@ -178,6 +180,7 @@ auth_exit:
  * via YMODEM. This is done to avoid disturbing the YMODEM serial
  * protocol transactions.
  */
+   printf("ERRORCOUNT %d\n", errorcount);
 if (!(IS_ENABLED(CONFIG_SPL_BUILD) &&
   IS_ENABLED(CONFIG_SPL_YMODEM_SUPPORT) &&
   spl_boot_device() == BOOT_DEVICE_UART))
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -20,6 +20,10 @@
  #include 
  #include 
  
+static int _errorcount;

+int errorlist[1024];
+int errorcount;
+
  struct driver *lists_driver_lookup_name(const char *name)
  {
 struct driver *drv =
@@ -120,8 +124,9 @@ int lists_bind_drivers(struct udevice *parent, bool 
pre_reloc_only)
 int ret;
  
 ret = bind_drivers_pass(parent, pre_reloc_only);

-   if (!ret)
-   break;
+   errorlist[_errorcount] = ret;
+   _errorcount++;
+   errorcount = _errorcount;
 if (ret != -EAGAIN && !result)
 result = ret;
 }

But errorcount is always 0 which is puzzling me since according to my think, 
lists_bind_drivers() is ran before secure_boot_verify_image().

Any idea on how to debug further ?


You should be able to enable DEBUG_UART and get output that way.  But
it's likely something related to the space constraints of the HS chip
rather than GP.



Hello

Thanks for your suggestion, I successfully got futher with:
diff --git a/drivers/core/lists.c b/drivers/core/lists.c
index b23ee3030e..415ba814f1 100644
--- a/drivers/core/lists.c
+++ b/drivers/core/lists.c
@@ -111,6 +111,8 @@ int lists_bind_drivers(struct udevice *parent, bool 
pre_reloc_only)
 int result = 0;
 int pass;
  
+   debug_uart_init();

+
 /*
  * 10 passes is 10 levels deep in the devicetree, which is plenty. If
  * OF_PLATDATA_PARENT is not enabled, then bind_drivers_pass() will
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index b4805a2e4e..7ab059b4ea 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -158,6 +158,7 @@ config TPL_DM_SERIAL
  
  config DEBUG_UART

 bool "Enable an early debug UART for debugging"
+   default y
 help
   The debug UART is intended for use very early in U-Boot to debug
   problems when an ICE or other debug mechanism is not available.
@@ -185,7 +186,7 @@ config DEBUG_UART
  choice
 prompt "Select which UART will provide the debug UART"
 depends on DEBUG_UART
-   default DEBUG_UART_NS16550
+   default DEBUG_UART_OMAP
  
  config DEBUG_UART_ALTERA_JTAGUART

 bool "Altera JTAG UART"
@@ -406,7 +407,7 @@ endchoice
  config DEBUG_UART_BASE
 hex "Base address of UART"
 depends on DEBUG_UART
-   default 0 if DEBUG_UART_SANDBOX
+   default 0x44e09000
 help
   This is the base address of your UART for memory-mapped UARTs.
  
@@ -416,7 +417,7 @@ config DEBUG_UART_BASE

  config DEBUG_UART_CLOCK
 int "UART input clock"
 depends on DEBUG_UART
-   default 0 if DEBUG_UART_SANDBOX
+   default 4800
 help
   The UART input clock determines the speed of the internal UART
   circuitry. The baud rate is derived from this by dividing 

Re: [PATCH V2 02/17] imx: imx8m[m/n]_beacon: Enable SPL_DM_SERIAL

2022-06-13 Thread Adam Ford
On Sat, Jun 11, 2022 at 6:38 AM Peng Fan (OSS)  wrote:
>
> From: Peng Fan 
>
> Enable CONFIG_SPL_DM_SERIAL. uart2 and its pinmux was already
> marked with u-boot,dm-spl.
> Move preloader_console_init after spl_init to make sure driver
> model work.

For what it's worth, the series doesn't appear to apply cleanly on the
current master, but I tested a Nano in addition to the Mini that I
tested before.

>
> Signed-off-by: Peng Fan 
> Tested-by: Adam Ford  #imx8mm_beacon

Tested-by: Adam Ford  #imx8mn_beacon

> Reviewed-by: Fabio Estevam 
> ---
>  board/beacon/imx8mm/spl.c  | 12 ++--
>  board/beacon/imx8mn/spl.c  | 11 ++-
>  configs/imx8mm_beacon_defconfig|  1 -
>  configs/imx8mn_beacon_2g_defconfig |  1 -
>  configs/imx8mn_beacon_defconfig|  1 -
>  include/configs/imx8mm_beacon.h|  2 --
>  include/configs/imx8mn_beacon.h|  2 --
>  7 files changed, 4 insertions(+), 26 deletions(-)
>
> diff --git a/board/beacon/imx8mm/spl.c b/board/beacon/imx8mm/spl.c
> index 12266b22a42..f92b4c3ed0a 100644
> --- a/board/beacon/imx8mm/spl.c
> +++ b/board/beacon/imx8mm/spl.c
> @@ -59,14 +59,8 @@ int board_fit_config_name_match(const char *name)
>  }
>  #endif
>
> -#define UART_PAD_CTRL  (PAD_CTL_DSE6 | PAD_CTL_FSEL1)
>  #define WDOG_PAD_CTRL  (PAD_CTL_DSE6 | PAD_CTL_ODE | PAD_CTL_PUE | 
> PAD_CTL_PE)
>
> -static iomux_v3_cfg_t const uart_pads[] = {
> -   IMX8MM_PAD_UART2_RXD_UART2_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
> -   IMX8MM_PAD_UART2_TXD_UART2_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
> -};
> -
>  static iomux_v3_cfg_t const wdog_pads[] = {
> IMX8MM_PAD_GPIO1_IO02_WDOG1_WDOG_B  | MUX_PAD_CTRL(WDOG_PAD_CTRL),
>  };
> @@ -79,8 +73,6 @@ int board_early_init_f(void)
>
> set_wdog_reset(wdog);
>
> -   imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads));
> -
> return 0;
>  }
>
> @@ -128,8 +120,6 @@ void board_init_f(ulong dummy)
>
> timer_init();
>
> -   preloader_console_init();
> -
> /* Clear the BSS. */
> memset(__bss_start, 0, __bss_end - __bss_start);
>
> @@ -139,6 +129,8 @@ void board_init_f(ulong dummy)
> hang();
> }
>
> +   preloader_console_init();
> +
> ret = uclass_get_device_by_name(UCLASS_CLK,
> "clock-controller@3038",
> );
> diff --git a/board/beacon/imx8mn/spl.c b/board/beacon/imx8mn/spl.c
> index bb51be01c52..4563446db19 100644
> --- a/board/beacon/imx8mn/spl.c
> +++ b/board/beacon/imx8mn/spl.c
> @@ -68,7 +68,6 @@ int board_fit_config_name_match(const char *name)
>  }
>  #endif
>
> -#define UART_PAD_CTRL  (PAD_CTL_DSE6 | PAD_CTL_FSEL1)
>  #define WDOG_PAD_CTRL  (PAD_CTL_DSE6 | PAD_CTL_ODE | PAD_CTL_PUE | 
> PAD_CTL_PE)
>  #define PWM1_PAD_CTRL (PAD_CTL_FSEL2 | PAD_CTL_DSE6)
>
> @@ -76,11 +75,6 @@ static iomux_v3_cfg_t const pwm_pads[] = {
> IMX8MN_PAD_GPIO1_IO01__PWM1_OUT | MUX_PAD_CTRL(PWM1_PAD_CTRL),
>  };
>
> -static iomux_v3_cfg_t const uart_pads[] = {
> -   IMX8MN_PAD_UART2_RXD__UART2_DCE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
> -   IMX8MN_PAD_UART2_TXD__UART2_DCE_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
> -};
> -
>  static iomux_v3_cfg_t const wdog_pads[] = {
> IMX8MN_PAD_GPIO1_IO02__WDOG1_WDOG_B  | MUX_PAD_CTRL(WDOG_PAD_CTRL),
>  };
> @@ -95,7 +89,6 @@ int board_early_init_f(void)
> imx_iomux_v3_setup_multiple_pads(wdog_pads, ARRAY_SIZE(wdog_pads));
> set_wdog_reset(wdog);
>
> -   imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads));
> init_uart_clk(1);
>
> return 0;
> @@ -114,14 +107,14 @@ void board_init_f(ulong dummy)
>
> timer_init();
>
> -   preloader_console_init();
> -
> ret = spl_init();
> if (ret) {
> debug("spl_init() failed: %d\n", ret);
> hang();
> }
>
> +   preloader_console_init();
> +
> enable_tzc380();
>
> /* DDR initialization */
> diff --git a/configs/imx8mm_beacon_defconfig b/configs/imx8mm_beacon_defconfig
> index 417ece1ef8c..e1acf7e8810 100644
> --- a/configs/imx8mm_beacon_defconfig
> +++ b/configs/imx8mm_beacon_defconfig
> @@ -125,7 +125,6 @@ CONFIG_SPL_DM_REGULATOR_FIXED=y
>  CONFIG_DM_REGULATOR_GPIO=y
>  CONFIG_CONS_INDEX=2
>  CONFIG_DM_SERIAL=y
> -# CONFIG_SPL_DM_SERIAL is not set
>  CONFIG_MXC_UART=y
>  CONFIG_SPI=y
>  CONFIG_DM_SPI=y
> diff --git a/configs/imx8mn_beacon_2g_defconfig 
> b/configs/imx8mn_beacon_2g_defconfig
> index 5b9b3715b34..cadef45028d 100644
> --- a/configs/imx8mn_beacon_2g_defconfig
> +++ b/configs/imx8mn_beacon_2g_defconfig
> @@ -127,7 +127,6 @@ CONFIG_DM_REGULATOR_FIXED=y
>  CONFIG_DM_REGULATOR_GPIO=y
>  CONFIG_DM_RESET=y
>  CONFIG_DM_SERIAL=y
> -# CONFIG_SPL_DM_SERIAL is not set
>  CONFIG_MXC_UART=y
>  CONFIG_SPI=y
>  CONFIG_DM_SPI=y
> diff --git a/configs/imx8mn_beacon_defconfig b/configs/imx8mn_beacon_defconfig
> index b296898d6db..357109e32e5 100644
> --- 

Re: imx8m(n): garbage on serial line

2022-06-13 Thread Heiko Thiery
Hi Fabio,

Am Mo., 13. Juni 2022 um 16:27 Uhr schrieb Fabio Estevam :
>
> Hi Heiko,
>
> On Mon, Jun 13, 2022 at 10:54 AM Heiko Thiery  wrote:
>
> > This is the output on the kontron bl-imx8m board:
> >
> > U-Boot SPL 2022.07-rc4-7-g8c3f838be2 (Jun 13 2022 - 15:36:08 +0200)
> > Kontron SL i.MX8MM (N801X) module, 1 GB RAM detected
> > Touch controller detected, assuming LVDS panel...
> > Normal Boot
> > WDT:   Not starting watchdog@3028
> > Trying to boot from MMC2
> > NOTICE:  BL31: v2.4(release):v2.4
>
> Just tried with the same v2.4 TF-A version:
>
> U-Boot SPL 2022.07-rc4-7-g57bd363de7 (Jun 13 2022 - 11:18:10 -0300)
> Kontron SL i.MX8MM (N801X) module, 4 GB RAM detected
> Normal Boot
> WDT:   Not starting watchdog@3028
> Trying to boot from MMC1
> NOTICE:  BL31: v2.4(release):v2.4
> NOTICE:  BL31: Built : 11:17:34, Jun 13 2022
>
>
> U-Boot 2022.07-rc4-7-g57bd363de7 (Jun 13 2022 - 11:18:10 -0300)
>
> CPU:   Freescale i.MX8MMQ rev1.0 1600 MHz (running at 1200 MHz)
> CPU:   Industrial temperature grade (-40C to 105C) at 60C
> Reset cause: POR
> Model: Kontron i.MX8MM N801X S
> DRAM:  4 GiB
> Core:  175 devices, 25 uclasses, devicetree: separate
> WDT:   Not starting watchdog@3028
> MMC:   FSL_SDHC: 0, FSL_SDHC: 1
> Loading Environment from SPIFlash... SF: Detected mx25r1635f with page
> size 256 Bytes, erase size 64 KiB, total 2 MiB
> OK
> In:serial
> Out:   serial
> Err:   serial
> Net:   Could not get PHY for FEC0: addr 0
> No ethernet found.
>
> Hit any key to stop autoboot:  0
> => [55;203R
> Unknown command '[55' - try 'help'
> Unknown command '203R' - try 'help'
>
> and the serial garbage is seen.
>
> My version has 4GiB of RAM, yours has only 1GiB.
>
> Could this make a difference?


I can hardly imagine it. I don't have an explanation for it.

>
> Thanks


Re: [PATCH V3 1/2] mtd: allow getting MTD device associated with a specific DT node

2022-06-13 Thread Miquel Raynal
Hi Rafał,

zaj...@gmail.com wrote on Mon, 13 Jun 2022 16:15:34 +0200:

> On 13.06.2022 16:04, Miquel Raynal wrote:
> >> @@ -1154,6 +1154,34 @@ int __get_mtd_device(struct mtd_info *mtd)
> >>   }
> >>   EXPORT_SYMBOL_GPL(__get_mtd_device);  
> >>   >> +/**  
> >> + * of_get_mtd_device_by_node - obtain an MTD device associated with a 
> >> given node
> >> + *
> >> + * @np: device tree node
> >> + */
> >> +struct mtd_info *of_get_mtd_device_by_node(struct device_node *np)  
> > 
> > Shall we try to use a more of-agnostic syntax or is it too complex here?  
> 
> I need some extra hint, please. This is how many similar functions look
> like:

I know most implementation today use of_ functions directly but it
seems like there is a global move towards fwnodes now, and I was
wondering if using those instead (which might also apply to other types
of "nodes" than DT ones) could be possible.

But looking into existing implementations, I came across the pwm implem
which features:
- of_pwm_get()
- acpi_pwm_get()

And finally a fwnode_pwm_get() which does:

if (is_of_node())
of_pwm_get():
else if (is_acpi_node())
acpi_pwm_get();

So actually my suggestion is meaningless. I'm fine with the current
approach.

Acked-by: Miquel Raynal 


> 
> $ grep -E -r "(get|find).*_by_node" ./include/*
> ./include/drm/drm_mipi_dsi.h:struct mipi_dsi_host 
> *of_find_mipi_dsi_host_by_node(struct device_node *node);
> ./include/drm/drm_mipi_dsi.h:struct mipi_dsi_device 
> *of_find_mipi_dsi_device_by_node(struct device_node *np);
> ./include/linux/usb/phy.h:extern struct usb_phy 
> *devm_usb_get_phy_by_node(struct device *dev,
> ./include/linux/usb/phy.h:static inline struct usb_phy 
> *devm_usb_get_phy_by_node(struct device *dev,
> ./include/linux/extcon.h:struct extcon_dev *extcon_find_edev_by_node(struct 
> device_node *node);
> ./include/linux/extcon.h:static inline struct extcon_dev 
> *extcon_find_edev_by_node(struct device_node *node)
> ./include/linux/of_net.h:extern struct net_device 
> *of_find_net_device_by_node(struct device_node *np);
> ./include/linux/of_net.h:static inline struct net_device 
> *of_find_net_device_by_node(struct device_node *np)
> ./include/linux/devfreq.h:struct devfreq *devfreq_get_devfreq_by_node(struct 
> device_node *node);
> ./include/linux/devfreq.h:static inline struct devfreq 
> *devfreq_get_devfreq_by_node(struct device_node *node)
> ./include/linux/of_platform.h:extern struct platform_device 
> *of_find_device_by_node(struct device_node *np);
> ./include/linux/of_platform.h:static inline struct platform_device 
> *of_find_device_by_node(struct device_node *np)
> ./include/linux/backlight.h:struct backlight_device 
> *of_find_backlight_by_node(struct device_node *node);
> ./include/linux/backlight.h:of_find_backlight_by_node(struct device_node 
> *node)
> ./include/linux/i2c.h:struct i2c_client *of_find_i2c_device_by_node(struct 
> device_node *node);
> ./include/linux/i2c.h:struct i2c_adapter *of_find_i2c_adapter_by_node(struct 
> device_node *node);
> ./include/linux/i2c.h:struct i2c_adapter *of_get_i2c_adapter_by_node(struct 
> device_node *node);
> ./include/linux/i2c.h:static inline struct i2c_client 
> *of_find_i2c_device_by_node(struct device_node *node)
> ./include/linux/i2c.h:static inline struct i2c_adapter 
> *of_find_i2c_adapter_by_node(struct device_node *node)
> ./include/linux/i2c.h:static inline struct i2c_adapter 
> *of_get_i2c_adapter_by_node(struct device_node *node)
> 
> 
> >> +{
> >> +  struct mtd_info *mtd = NULL;
> >> +  struct mtd_info *tmp;
> >> +  int err;
> >> +
> >> +  mutex_lock(_table_mutex);
> >> +
> >> +  err = -ENODEV;
> >> +  mtd_for_each_device(tmp) {
> >> +  if (mtd_get_of_node(tmp) == np) {
> >> +  mtd = tmp;
> >> +  err = __get_mtd_device(mtd);
> >> +  break;
> >> +  }
> >> +  }
> >> +
> >> +  mutex_unlock(_table_mutex);
> >> +
> >> +  return err ? ERR_PTR(err) : mtd;
> >> +}
> >> +EXPORT_SYMBOL_GPL(of_get_mtd_device_by_node);
> >> +
> >>   /**
> >>*   get_mtd_device_nm - obtain a validated handle for an MTD device 
> >> by
> >>*   device name  
> 


Thanks,
Miquèl


Re: imx8m(n): garbage on serial line

2022-06-13 Thread Fabio Estevam
Hi Heiko,

On Mon, Jun 13, 2022 at 10:54 AM Heiko Thiery  wrote:

> This is the output on the kontron bl-imx8m board:
>
> U-Boot SPL 2022.07-rc4-7-g8c3f838be2 (Jun 13 2022 - 15:36:08 +0200)
> Kontron SL i.MX8MM (N801X) module, 1 GB RAM detected
> Touch controller detected, assuming LVDS panel...
> Normal Boot
> WDT:   Not starting watchdog@3028
> Trying to boot from MMC2
> NOTICE:  BL31: v2.4(release):v2.4

Just tried with the same v2.4 TF-A version:

U-Boot SPL 2022.07-rc4-7-g57bd363de7 (Jun 13 2022 - 11:18:10 -0300)
Kontron SL i.MX8MM (N801X) module, 4 GB RAM detected
Normal Boot
WDT:   Not starting watchdog@3028
Trying to boot from MMC1
NOTICE:  BL31: v2.4(release):v2.4
NOTICE:  BL31: Built : 11:17:34, Jun 13 2022


U-Boot 2022.07-rc4-7-g57bd363de7 (Jun 13 2022 - 11:18:10 -0300)

CPU:   Freescale i.MX8MMQ rev1.0 1600 MHz (running at 1200 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 60C
Reset cause: POR
Model: Kontron i.MX8MM N801X S
DRAM:  4 GiB
Core:  175 devices, 25 uclasses, devicetree: separate
WDT:   Not starting watchdog@3028
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
Loading Environment from SPIFlash... SF: Detected mx25r1635f with page
size 256 Bytes, erase size 64 KiB, total 2 MiB
OK
In:serial
Out:   serial
Err:   serial
Net:   Could not get PHY for FEC0: addr 0
No ethernet found.

Hit any key to stop autoboot:  0
=> [55;203R
Unknown command '[55' - try 'help'
Unknown command '203R' - try 'help'

and the serial garbage is seen.

My version has 4GiB of RAM, yours has only 1GiB.

Could this make a difference?

Thanks


Re: Boot regression on am335x-hs-evm

2022-06-13 Thread Tom Rini
On Mon, Jun 13, 2022 at 02:51:03PM +0200, LABBE Corentin wrote:
> Le Fri, Jun 10, 2022 at 11:48:34AM -0400, Tom Rini a écrit :
> > On Fri, Jun 10, 2022 at 05:45:04PM +0200, LABBE Corentin wrote:
> > > Le Fri, Jun 10, 2022 at 11:01:47AM -0400, Tom Rini a écrit :
> > > > On Fri, Jun 10, 2022 at 04:51:12PM +0200, LABBE Corentin wrote:
> > > > > Le Fri, Jun 10, 2022 at 08:16:10AM -0400, Tom Rini a écrit :
> > > > > > On Fri, Jun 10, 2022 at 11:59:23AM +0200, LABBE Corentin wrote:
> > > > > > > Hello
> > > > > > > 
> > > > > > > I hit a boot regression on am335x-hs-evm.
> > > > > > > On current uboot, the board does not boot at all.
> > > > > > > This board uses both MLO and u-boot.img and only MLO was the 
> > > > > > > problem.
> > > > > > > 
> > > > > > > After a bisect, I found that e41651fffda7 ("dm: Support parent 
> > > > > > > devices with of-platdata") was the problem.
> > > > > > > Reverting this patch lead to a success boot.
> > > > > > > 
> > > > > > > I cutdown the revert to a minimal fix:
> > > > > > > --- a/drivers/core/lists.c
> > > > > > > +++ b/drivers/core/lists.c
> > > > > > > @@ -120,6 +120,7 @@ int lists_bind_drivers(struct udevice 
> > > > > > > *parent, bool pre_reloc_only)
> > > > > > > int ret;
> > > > > > >  
> > > > > > > ret = bind_drivers_pass(parent, pre_reloc_only);
> > > > > > > +   return ret;
> > > > > > > if (!ret)
> > > > > > > break;
> > > > > > > if (ret != -EAGAIN && !result)
> > > > > > > 
> > > > > > > I cannot debug further since printf() is not working at this 
> > > > > > > stage.
> > > > > > > 
> > > > > > > Since I wanted to know which error was badly handled, I tried to 
> > > > > > > do this:
> > > > > > > --- a/arch/arm/mach-omap2/sec-common.c
> > > > > > > +++ b/arch/arm/mach-omap2/sec-common.c
> > > > > > > @@ -111,6 +111,8 @@ static u32 find_sig_start(char *image, size_t 
> > > > > > > size)
> > > > > > > return 0;
> > > > > > >  }
> > > > > > >  
> > > > > > > +extern int errorcount;
> > > > > > > +
> > > > > > >  int secure_boot_verify_image(void **image, size_t *size)
> > > > > > >  {
> > > > > > > int result = 1;
> > > > > > > @@ -178,6 +180,7 @@ auth_exit:
> > > > > > >  * via YMODEM. This is done to avoid disturbing the 
> > > > > > > YMODEM serial
> > > > > > >  * protocol transactions.
> > > > > > >  */
> > > > > > > +   printf("ERRORCOUNT %d\n", errorcount);
> > > > > > > if (!(IS_ENABLED(CONFIG_SPL_BUILD) &&
> > > > > > >   IS_ENABLED(CONFIG_SPL_YMODEM_SUPPORT) &&
> > > > > > >   spl_boot_device() == BOOT_DEVICE_UART))
> > > > > > > --- a/drivers/core/lists.c
> > > > > > > +++ b/drivers/core/lists.c
> > > > > > > @@ -20,6 +20,10 @@
> > > > > > >  #include 
> > > > > > >  #include 
> > > > > > >  
> > > > > > > +static int _errorcount;
> > > > > > > +int errorlist[1024];
> > > > > > > +int errorcount;
> > > > > > > +
> > > > > > >  struct driver *lists_driver_lookup_name(const char *name)
> > > > > > >  {
> > > > > > > struct driver *drv =
> > > > > > > @@ -120,8 +124,9 @@ int lists_bind_drivers(struct udevice 
> > > > > > > *parent, bool pre_reloc_only)
> > > > > > > int ret;
> > > > > > >  
> > > > > > > ret = bind_drivers_pass(parent, pre_reloc_only);
> > > > > > > -   if (!ret)
> > > > > > > -   break;
> > > > > > > +   errorlist[_errorcount] = ret;
> > > > > > > +   _errorcount++;
> > > > > > > +   errorcount = _errorcount;
> > > > > > > if (ret != -EAGAIN && !result)
> > > > > > > result = ret;
> > > > > > > }
> > > > > > > 
> > > > > > > But errorcount is always 0 which is puzzling me since according 
> > > > > > > to my think, lists_bind_drivers() is ran before 
> > > > > > > secure_boot_verify_image().
> > > > > > > 
> > > > > > > Any idea on how to debug further ?
> > > > > > 
> > > > > > You should be able to enable DEBUG_UART and get output that way.  
> > > > > > But
> > > > > > it's likely something related to the space constraints of the HS 
> > > > > > chip
> > > > > > rather than GP.
> > > > > > 
> > > > > 
> > > > > Hello
> > > > > 
> > > > > Thanks for your suggestion, I successfully got futher with:
> > > > > diff --git a/drivers/core/lists.c b/drivers/core/lists.c
> > > > > index b23ee3030e..415ba814f1 100644
> > > > > --- a/drivers/core/lists.c
> > > > > +++ b/drivers/core/lists.c
> > > > > @@ -111,6 +111,8 @@ int lists_bind_drivers(struct udevice *parent, 
> > > > > bool pre_reloc_only)
> > > > > int result = 0;
> > > > > int pass;
> > > > >  
> > > > > +   debug_uart_init();
> > > > > +
> > > > > /*
> > > > >  * 10 passes is 10 levels deep in the devicetree, which is 
> > > > > plenty. If
> > > > >  * OF_PLATDATA_PARENT is not enabled, then 
> > > > > 

Re: [PATCH V3 1/2] mtd: allow getting MTD device associated with a specific DT node

2022-06-13 Thread Rafał Miłecki

On 13.06.2022 16:04, Miquel Raynal wrote:

@@ -1154,6 +1154,34 @@ int __get_mtd_device(struct mtd_info *mtd)
  }
  EXPORT_SYMBOL_GPL(__get_mtd_device);
  
+/**

+ * of_get_mtd_device_by_node - obtain an MTD device associated with a given 
node
+ *
+ * @np: device tree node
+ */
+struct mtd_info *of_get_mtd_device_by_node(struct device_node *np)


Shall we try to use a more of-agnostic syntax or is it too complex here?


I need some extra hint, please. This is how many similar functions look
like:

$ grep -E -r "(get|find).*_by_node" ./include/*
./include/drm/drm_mipi_dsi.h:struct mipi_dsi_host 
*of_find_mipi_dsi_host_by_node(struct device_node *node);
./include/drm/drm_mipi_dsi.h:struct mipi_dsi_device 
*of_find_mipi_dsi_device_by_node(struct device_node *np);
./include/linux/usb/phy.h:extern struct usb_phy 
*devm_usb_get_phy_by_node(struct device *dev,
./include/linux/usb/phy.h:static inline struct usb_phy 
*devm_usb_get_phy_by_node(struct device *dev,
./include/linux/extcon.h:struct extcon_dev *extcon_find_edev_by_node(struct 
device_node *node);
./include/linux/extcon.h:static inline struct extcon_dev 
*extcon_find_edev_by_node(struct device_node *node)
./include/linux/of_net.h:extern struct net_device 
*of_find_net_device_by_node(struct device_node *np);
./include/linux/of_net.h:static inline struct net_device 
*of_find_net_device_by_node(struct device_node *np)
./include/linux/devfreq.h:struct devfreq *devfreq_get_devfreq_by_node(struct 
device_node *node);
./include/linux/devfreq.h:static inline struct devfreq 
*devfreq_get_devfreq_by_node(struct device_node *node)
./include/linux/of_platform.h:extern struct platform_device 
*of_find_device_by_node(struct device_node *np);
./include/linux/of_platform.h:static inline struct platform_device 
*of_find_device_by_node(struct device_node *np)
./include/linux/backlight.h:struct backlight_device 
*of_find_backlight_by_node(struct device_node *node);
./include/linux/backlight.h:of_find_backlight_by_node(struct device_node *node)
./include/linux/i2c.h:struct i2c_client *of_find_i2c_device_by_node(struct 
device_node *node);
./include/linux/i2c.h:struct i2c_adapter *of_find_i2c_adapter_by_node(struct 
device_node *node);
./include/linux/i2c.h:struct i2c_adapter *of_get_i2c_adapter_by_node(struct 
device_node *node);
./include/linux/i2c.h:static inline struct i2c_client 
*of_find_i2c_device_by_node(struct device_node *node)
./include/linux/i2c.h:static inline struct i2c_adapter 
*of_find_i2c_adapter_by_node(struct device_node *node)
./include/linux/i2c.h:static inline struct i2c_adapter 
*of_get_i2c_adapter_by_node(struct device_node *node)



+{
+   struct mtd_info *mtd = NULL;
+   struct mtd_info *tmp;
+   int err;
+
+   mutex_lock(_table_mutex);
+
+   err = -ENODEV;
+   mtd_for_each_device(tmp) {
+   if (mtd_get_of_node(tmp) == np) {
+   mtd = tmp;
+   err = __get_mtd_device(mtd);
+   break;
+   }
+   }
+
+   mutex_unlock(_table_mutex);
+
+   return err ? ERR_PTR(err) : mtd;
+}
+EXPORT_SYMBOL_GPL(of_get_mtd_device_by_node);
+
  /**
   *get_mtd_device_nm - obtain a validated handle for an MTD device by
   *device name




Re: [PATCH V3 1/2] mtd: allow getting MTD device associated with a specific DT node

2022-06-13 Thread Miquel Raynal
Hi Rafał,

zaj...@gmail.com wrote on Sat, 11 Jun 2022 22:46:50 +0200:

> From: Rafał Miłecki 
> 
> MTD subsystem API allows interacting with MTD devices (e.g. reading,
> writing, handling bad blocks). So far a random driver could get MTD
> device only by its name (get_mtd_device_nm()). This change allows
> getting them also by a DT node.
> 
> This API is required for drivers handling DT defined MTD partitions in a
> specific way (e.g. U-Boot (sub)partition with environment variables).
> 
> Signed-off-by: Rafał Miłecki 
> ---
> V3: First introduction of of_get_mtd_device_by_node()
> 
> mtd maintainers: please let know how would you like this patch
> processed. Would that be OK for you to Review/Ack it and let it go
> through NVMEM tree?

Yes

> ---
>  drivers/mtd/mtdcore.c   | 28 
>  include/linux/mtd/mtd.h |  1 +
>  2 files changed, 29 insertions(+)
> 
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index 9eb0680db312..7dc214271c85 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -1154,6 +1154,34 @@ int __get_mtd_device(struct mtd_info *mtd)
>  }
>  EXPORT_SYMBOL_GPL(__get_mtd_device);
>  
> +/**
> + * of_get_mtd_device_by_node - obtain an MTD device associated with a given 
> node
> + *
> + * @np: device tree node
> + */
> +struct mtd_info *of_get_mtd_device_by_node(struct device_node *np)

Shall we try to use a more of-agnostic syntax or is it too complex here?

> +{
> + struct mtd_info *mtd = NULL;
> + struct mtd_info *tmp;
> + int err;
> +
> + mutex_lock(_table_mutex);
> +
> + err = -ENODEV;
> + mtd_for_each_device(tmp) {
> + if (mtd_get_of_node(tmp) == np) {
> + mtd = tmp;
> + err = __get_mtd_device(mtd);
> + break;
> + }
> + }
> +
> + mutex_unlock(_table_mutex);
> +
> + return err ? ERR_PTR(err) : mtd;
> +}
> +EXPORT_SYMBOL_GPL(of_get_mtd_device_by_node);
> +
>  /**
>   *   get_mtd_device_nm - obtain a validated handle for an MTD device by
>   *   device name
> diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
> index 955aee14b0f7..6fc841ceef31 100644
> --- a/include/linux/mtd/mtd.h
> +++ b/include/linux/mtd/mtd.h
> @@ -677,6 +677,7 @@ extern int mtd_device_unregister(struct mtd_info *master);
>  extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num);
>  extern int __get_mtd_device(struct mtd_info *mtd);
>  extern void __put_mtd_device(struct mtd_info *mtd);
> +extern struct mtd_info *of_get_mtd_device_by_node(struct device_node *np);
>  extern struct mtd_info *get_mtd_device_nm(const char *name);
>  extern void put_mtd_device(struct mtd_info *mtd);
>  


Thanks,
Miquèl


Re: [PATCH] clk: imx8mp: Fix 32k clock name

2022-06-13 Thread Marek Vasut

On 6/13/22 15:41, ZHIZHIKIN Andrey wrote:

Hello Marek,


-Original Message-
From: U-Boot  On Behalf Of Marek Vasut
Sent: Monday, June 13, 2022 3:22 PM
To: u-boot@lists.denx.de
Cc: Marek Vasut ; Fabio Estevam ; Peng Fan
; Stefano Babic 
Subject: [PATCH] clk: imx8mp: Fix 32k clock name

The 32 kHz oscillator clock name is 'clock-osc-32k' instead of 'osc_32k'.
Fix the name to prevent the following warning:

"
clk_register: failed to get osc_32k device (parent of usb_root_clk)
"

Fixes: 7a2c3be95a5 ("clk: imx8mp: Fill in DWC3 USB, USB PHY, HSIOMIX clock")
Signed-off-by: Marek Vasut 
Cc: Fabio Estevam 
Cc: Peng Fan 
Cc: Stefano Babic 


I've already submitted a series to address this issue and the one for
ECSPI clocks, see [1].

You're also on Cc: to that series, so you can take a look at it and
decide whether it is suitable or not.


Even better, thanks.


[PATCH v2] watchdog: add amlogic watchdog support

2022-06-13 Thread Philippe Boos
Add support for hardware watchdog timer for Amlogic SoCs.
This driver has been heavily inspired by his Linux equivalent
(meson_gxbb_wdt.c).

Reviewed-by: Jerome Brunet 
Reviewed-by: Neil Armstrong 

Signed-off-by: Philippe Boos 

---

Your recommendations have been implemented. I let you check this version 2.
The reset works well when triggered by the wdt command in u-boot.

This watchdog driver has been tested on a GXL libretech-cc board and also on
a custom G12a board. I did the following test cases:
 * boot with a faulty boot command, then we reach watchdog reset successfully,
 * boot a Linux kernel with and without watchdog support, and check if it is
   working as expected.


 MAINTAINERS   |   1 +
 doc/board/amlogic/index.rst   |   2 +
 drivers/watchdog/Kconfig  |   7 ++
 drivers/watchdog/Makefile |   1 +
 drivers/watchdog/meson_gxbb_wdt.c | 136 ++
 5 files changed, 147 insertions(+)
 create mode 100644 drivers/watchdog/meson_gxbb_wdt.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 28e4d38238..ab3ef041f7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -160,6 +160,7 @@ F:  drivers/spi/meson_spifc.c
 F: drivers/pinctrl/meson/
 F: drivers/power/domain/meson-gx-pwrc-vpu.c
 F: drivers/video/meson/
+F: drivers/watchdog/meson_gxbb_wdt.c
 F: include/configs/meson64.h
 F: include/configs/meson64_android.h
 F: doc/board/amlogic/
diff --git a/doc/board/amlogic/index.rst b/doc/board/amlogic/index.rst
index 9c7fadf2c0..cc2ba50889 100644
--- a/doc/board/amlogic/index.rst
+++ b/doc/board/amlogic/index.rst
@@ -73,6 +73,8 @@ This matrix concerns the actual source code version.
 
+---+---+-+--+-++-+--+
 | PCIe (+NVMe)  | *N/A* | *N/A*   | *N/A*| 
**Yes** | **Yes**| **Yes** | **Yes**  |
 
+---+---+-+--+-++-+--+
+| Watchdog  | *N/A* | **Yes** | *N/A*| 
*N/A*   | *N/A*  | *N/A*   | *N/A*|
++---+---+-+--+-++-+--+
 
 Boot Documentation
 --
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index c3eb8a8aec..da0fa5396f 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -175,6 +175,13 @@ config WDT_MAX6370
help
  Select this to enable max6370 watchdog timer.
 
+config WDT_MESON_GXBB
+   bool "Amlogic watchdog timer support"
+   depends on WDT
+   help
+ Select this to enable Meson watchdog timer,
+ which can be found on some Amlogic platforms.
+
 config WDT_MPC8xx
bool "MPC8xx watchdog timer support"
depends on WDT && MPC8xx
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 1f6199beca..0e2f582a5f 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_WDT_ORION) += orion_wdt.o
 obj-$(CONFIG_WDT_CDNS) += cdns_wdt.o
 obj-$(CONFIG_WDT_GPIO) += gpio_wdt.o
 obj-$(CONFIG_WDT_MAX6370) += max6370_wdt.o
+obj-$(CONFIG_WDT_MESON_GXBB) += meson_gxbb_wdt.o
 obj-$(CONFIG_WDT_MPC8xx) += mpc8xx_wdt.o
 obj-$(CONFIG_WDT_MT7620) += mt7620_wdt.o
 obj-$(CONFIG_WDT_MT7621) += mt7621_wdt.o
diff --git a/drivers/watchdog/meson_gxbb_wdt.c 
b/drivers/watchdog/meson_gxbb_wdt.c
new file mode 100644
index 00..6ab005813f
--- /dev/null
+++ b/drivers/watchdog/meson_gxbb_wdt.c
@@ -0,0 +1,136 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2022 BayLibre, SAS.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define GXBB_WDT_CTRL_REG  0x0
+#define GXBB_WDT_TCNT_REG  0x8
+#define GXBB_WDT_RSET_REG  0xc
+
+#define GXBB_WDT_CTRL_SYS_RESET_NOWBIT(26)
+#define GXBB_WDT_CTRL_CLKDIV_ENBIT(25)
+#define GXBB_WDT_CTRL_CLK_EN   BIT(24)
+#define GXBB_WDT_CTRL_EE_RESET BIT(21)
+#define GXBB_WDT_CTRL_EN   BIT(18)
+
+#define GXBB_WDT_CTRL_DIV_MASK GENMASK(17, 0)
+#define GXBB_WDT_TCNT_SETUP_MASK   GENMASK(15, 0)
+
+
+struct amlogic_wdt_priv {
+   void __iomem *reg_base;
+};
+
+static int amlogic_wdt_set_timeout(struct udevice *dev, u64 timeout_ms)
+{
+   struct amlogic_wdt_priv *data = dev_get_priv(dev);
+
+   if (timeout_ms > GXBB_WDT_TCNT_SETUP_MASK) {
+   dev_warn(dev, "%s: timeout_ms=%llu: maximum watchdog timeout 
exceeded\n",
+__func__, timeout_ms);
+   timeout_ms = GXBB_WDT_TCNT_SETUP_MASK;
+   }
+
+   writel(timeout_ms, data->reg_base + GXBB_WDT_TCNT_REG);
+

Re: imx8m(n): garbage on serial line

2022-06-13 Thread Heiko Thiery
Hi Fabio,


Am Sa., 11. Juni 2022 um 13:10 Uhr schrieb Fabio Estevam :
>
> Hi Heiko,
>
> On Sat, Jun 11, 2022 at 3:12 AM Heiko Thiery  wrote:
>
> > It took me some effort to get the current u-boot running on my imx8mq.
> > But finally it works and I do not see this garbage on the imx8mq. Next
> > week I will check on the kontron_sl_imx8mm.


This is the output on the kontron bl-imx8m board:

U-Boot SPL 2022.07-rc4-7-g8c3f838be2 (Jun 13 2022 - 15:36:08 +0200)
Kontron SL i.MX8MM (N801X) module, 1 GB RAM detected
Touch controller detected, assuming LVDS panel...
Normal Boot
WDT:   Not starting watchdog@3028
Trying to boot from MMC2
NOTICE:  BL31: v2.4(release):v2.4
NOTICE:  BL31: Built : 15:09:24, Sep 10 2021


U-Boot 2022.07-rc4-7-g8c3f838be2 (Jun 13 2022 - 15:36:08 +0200)

CPU:   Freescale i.MX8MMQ rev1.0 1600 MHz (running at 1200 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 46C
Reset cause: POR
Model: Kontron i.MX8MM N801X S LVDS
DRAM:  1 GiB
Core:  178 devices, 25 uclasses, devicetree: separate
WDT:   Not starting watchdog@3028
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
Loading Environment from SPIFlash... SF: Detected mx25r1635f with page
size 256 Bytes, erase size 64 KiB, total 2 MiB
OK
In:serial
Out:   serial
Err:   serial
Net:   Could not get PHY for FEC0: addr 0
No ethernet found.

Hit any key to stop autoboot:  0
=>



Here I cannot see the extra serial-in garbage ;-/

>
> Thanks, appreciated it!

-- 
Heiko


[PATCH v2] i2c: nuvoton: Add NPCM7xx i2c driver

2022-06-13 Thread Jim Liu
Add Nuvoton BMC NPCM750 i2c driver

Signed-off-by: Jim Liu 
---
Changes for v2:
   - use debug output in reset function
   - use clr/setbits_8
---
 drivers/i2c/Kconfig|   5 +
 drivers/i2c/Makefile   |   1 +
 drivers/i2c/npcm-i2c.c | 631 +
 3 files changed, 637 insertions(+)
 create mode 100644 drivers/i2c/npcm-i2c.c

diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index d25c5736ef..7e113b289e 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -447,6 +447,11 @@ config SYS_I2C_NEXELL
  have several I2C ports and all are provided, controlled by the
  device tree.
 
+config SYS_I2C_NPCM
+   bool "Nuvoton NPCM I2C driver"
+   help
+ Support for Nuvoton I2C controller driver.
+
 config SYS_I2C_OCORES
bool "ocores I2C driver"
depends on DM_I2C
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index 9d41f379bb..7e046f809a 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_SYS_I2C_MV) += mv_i2c.o
 obj-$(CONFIG_SYS_I2C_MVTWSI) += mvtwsi.o
 obj-$(CONFIG_SYS_I2C_MXC) += mxc_i2c.o
 obj-$(CONFIG_SYS_I2C_NEXELL) += nx_i2c.o
+obj-$(CONFIG_SYS_I2C_NPCM) += npcm_i2c.o
 obj-$(CONFIG_SYS_I2C_OCORES) += ocores_i2c.o
 obj-$(CONFIG_SYS_I2C_OCTEON) += octeon_i2c.o
 obj-$(CONFIG_SYS_I2C_OMAP24XX) += omap24xx_i2c.o
diff --git a/drivers/i2c/npcm-i2c.c b/drivers/i2c/npcm-i2c.c
new file mode 100644
index 00..dfac6483de
--- /dev/null
+++ b/drivers/i2c/npcm-i2c.c
@@ -0,0 +1,631 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2021 Nuvoton Technology Corp.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define I2C_FREQ_100K  10
+#define NPCM_I2C_TIMEOUT_MS10
+#define NPCM7XX_I2CSEGCTL_INIT_VAL 0x0333F000
+#define NPCM8XX_I2CSEGCTL_INIT_VAL 0x9333F000
+
+/* SCLFRQ min/max field values  */
+#define SCLFRQ_MIN 10
+#define SCLFRQ_MAX 511
+
+/* SMBCTL1 */
+#define SMBCTL1_START  BIT(0)
+#define SMBCTL1_STOP   BIT(1)
+#define SMBCTL1_INTEN  BIT(2)
+#define SMBCTL1_ACKBIT(4)
+#define SMBCTL1_STASTREBIT(7)
+
+/* SMBCTL2 */
+#define SMBCTL2_ENABLE BIT(0)
+
+/* SMBCTL3 */
+#define SMBCTL3_SCL_LVLBIT(7)
+#define SMBCTL3_SDA_LVLBIT(6)
+
+/* SMBCST */
+#define SMBCST_BB  BIT(1)
+#define SMBCST_TGSCL   BIT(5)
+
+/* SMBST */
+#define SMBST_XMIT BIT(0)
+#define SMBST_MASTER   BIT(1)
+#define SMBST_STASTR   BIT(3)
+#define SMBST_NEGACK   BIT(4)
+#define SMBST_BER  BIT(5)
+#define SMBST_SDASTBIT(6)
+
+/* SMBCST3 in bank0 */
+#define SMBCST3_EO_BUSYBIT(7)
+
+/* SMBFIF_CTS in bank1 */
+#define SMBFIF_CTS_CLR_FIFOBIT(6)
+
+#define SMBFIF_CTL_FIFO_EN BIT(4)
+#define SMBCTL3_BNK_SELBIT(5)
+
+enum {
+   I2C_ERR_NACK = 1,
+   I2C_ERR_BER,
+   I2C_ERR_TIMEOUT,
+};
+
+struct smb_bank0_regs {
+   u8 addr3;
+   u8 addr7;
+   u8 addr4;
+   u8 addr8;
+   u16 addr5;
+   u16 addr6;
+   u8 cst2;
+   u8 cst3;
+   u8 ctl4;
+   u8 ctl5;
+   u8 scllt;
+   u8 fif_ctl;
+   u8 sclht;
+};
+
+struct smb_bank1_regs {
+   u8 fif_cts;
+   u8 fair_per;
+   u16 txf_ctl;
+   u32 t_out;
+   u8 cst2;
+   u8 cst3;
+   u16 txf_sts;
+   u16 rxf_sts;
+   u8 rxf_ctl;
+};
+
+struct npcm_i2c_regs {
+   u16 sda;
+   u16 st;
+   u16 cst;
+   u16 ctl1;
+   u16 addr;
+   u16 ctl2;
+   u16 addr2;
+   u16 ctl3;
+   union {
+   struct smb_bank0_regs bank0;
+   struct smb_bank1_regs bank1;
+   };
+
+};
+
+struct npcm_i2c_bus {
+   struct npcm_i2c_regs *reg;
+   int num;
+   u32 apb_clk;
+   u32 freq;
+   bool started;
+};
+
+static void npcm_dump_regs(struct npcm_i2c_bus *bus)
+{
+   struct npcm_i2c_regs *reg = bus->reg;
+
+   printf("\n");
+   printf("SMBST=0x%x\n", readb(>st));
+   printf("SMBCST=0x%x\n", readb(>cst));
+   printf("SMBCTL1=0x%x\n", readb(>ctl1));
+   printf("\n");
+}
+
+static int npcm_i2c_check_sda(struct npcm_i2c_bus *bus)
+{
+   struct npcm_i2c_regs *reg = bus->reg;
+   ulong start_time;
+   int err = I2C_ERR_TIMEOUT;
+   u8 val;
+
+   start_time = get_timer(0);
+   /* wait SDAST to be 1 */
+   while (get_timer(start_time) < NPCM_I2C_TIMEOUT_MS) {
+   val = readb(>st);
+   if (val & SMBST_NEGACK) {
+   err = I2C_ERR_NACK;
+   break;
+   }
+   if (val & SMBST_BER) {
+   err = I2C_ERR_BER;
+   break;
+   }
+   if (val & SMBST_SDAST) {
+   err = 0;
+   break;
+   }
+   }
+

RE: [PATCH] clk: imx8mp: Fix 32k clock name

2022-06-13 Thread ZHIZHIKIN Andrey
Hello Marek,

> -Original Message-
> From: U-Boot  On Behalf Of Marek Vasut
> Sent: Monday, June 13, 2022 3:22 PM
> To: u-boot@lists.denx.de
> Cc: Marek Vasut ; Fabio Estevam ; Peng Fan
> ; Stefano Babic 
> Subject: [PATCH] clk: imx8mp: Fix 32k clock name
> 
> The 32 kHz oscillator clock name is 'clock-osc-32k' instead of 'osc_32k'.
> Fix the name to prevent the following warning:
> 
> "
> clk_register: failed to get osc_32k device (parent of usb_root_clk)
> "
> 
> Fixes: 7a2c3be95a5 ("clk: imx8mp: Fill in DWC3 USB, USB PHY, HSIOMIX clock")
> Signed-off-by: Marek Vasut 
> Cc: Fabio Estevam 
> Cc: Peng Fan 
> Cc: Stefano Babic 

I've already submitted a series to address this issue and the one for
ECSPI clocks, see [1].

You're also on Cc: to that series, so you can take a look at it and
decide whether it is suitable or not.

> ---
>  drivers/clk/imx/clk-imx8mp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/imx/clk-imx8mp.c b/drivers/clk/imx/clk-imx8mp.c
> index cbed86a6843..9c7857bbb3a 100644
> --- a/drivers/clk/imx/clk-imx8mp.c
> +++ b/drivers/clk/imx/clk-imx8mp.c
> @@ -300,7 +300,7 @@ static int imx8mp_clk_probe(struct udevice *dev)
>   clk_dm(IMX8MP_CLK_UART2_ROOT, imx_clk_gate4("uart2_root_clk", "uart2",
> base + 0x44a0, 0));
>   clk_dm(IMX8MP_CLK_UART3_ROOT, imx_clk_gate4("uart3_root_clk", "uart3",
> base + 0x44b0, 0));
>   clk_dm(IMX8MP_CLK_UART4_ROOT, imx_clk_gate4("uart4_root_clk", "uart4",
> base + 0x44c0, 0));
> - clk_dm(IMX8MP_CLK_USB_ROOT, imx_clk_gate4("usb_root_clk", "osc_32k", 
> base
> + 0x44d0, 0));
> + clk_dm(IMX8MP_CLK_USB_ROOT, imx_clk_gate4("usb_root_clk", 
> "clock-osc-32k",
> base + 0x44d0, 0));
>   clk_dm(IMX8MP_CLK_USB_PHY_ROOT, imx_clk_gate4("usb_phy_root_clk",
> "usb_phy_ref", base + 0x44f0, 0));
>   clk_dm(IMX8MP_CLK_USDHC1_ROOT, imx_clk_gate4("usdhc1_root_clk", 
> "usdhc1",
> base + 0x4510, 0));
>   clk_dm(IMX8MP_CLK_USDHC2_ROOT, imx_clk_gate4("usdhc2_root_clk", 
> "usdhc2",
> base + 0x4520, 0));
> --
> 2.35.1

-- andrey

Link: [1]: 
https://lore.kernel.org/u-boot/20220603151522.6643-1-andrey.zhizhi...@leica-geosystems.com/



[PATCH] clk: imx8mp: Fix ECSPI clock selects

2022-06-13 Thread Marek Vasut
The 24 MHz oscillator clock name is 'clock-osc-24m' with all dashes
instead of 'clock-osc_24m' with underscore. Fix the name.

Fixes: 87f958810fc ("clk: imx8mp: Add ECSPI clocks")
Signed-off-by: Marek Vasut 
Cc: Elmar Albert 
Cc: Fabio Estevam 
Cc: Peng Fan 
Cc: Stefano Babic 
---
 drivers/clk/imx/clk-imx8mp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/imx/clk-imx8mp.c b/drivers/clk/imx/clk-imx8mp.c
index ac727b7e404..cbed86a6843 100644
--- a/drivers/clk/imx/clk-imx8mp.c
+++ b/drivers/clk/imx/clk-imx8mp.c
@@ -122,15 +122,15 @@ static const char *imx8mp_gic_sels[] = {"clock-osc-24m", 
"sys_pll2_200m", "sys_p
"sys_pll2_100m", "sys_pll1_800m",
"sys_pll2_500m", "clk_ext4", 
"audio_pll2_out" };
 
-static const char *imx8mp_ecspi1_sels[] = {"clock-osc_24m", "sys_pll2_200m", 
"sys_pll1_40m",
+static const char *imx8mp_ecspi1_sels[] = {"clock-osc-24m", "sys_pll2_200m", 
"sys_pll1_40m",
  "sys_pll1_160m", 
"sys_pll1_800m", "sys_pll3_out",
  "sys_pll2_250m", 
"audio_pll2_out", };
 
-static const char *imx8mp_ecspi2_sels[] = {"clock-osc_24m", "sys_pll2_200m", 
"sys_pll1_40m",
+static const char *imx8mp_ecspi2_sels[] = {"clock-osc-24m", "sys_pll2_200m", 
"sys_pll1_40m",
  "sys_pll1_160m", 
"sys_pll1_800m", "sys_pll3_out",
  "sys_pll2_250m", 
"audio_pll2_out", };
 
-static const char *imx8mp_ecspi3_sels[] = {"clock-osc_24m", "sys_pll2_200m", 
"sys_pll1_40m",
+static const char *imx8mp_ecspi3_sels[] = {"clock-osc-24m", "sys_pll2_200m", 
"sys_pll1_40m",
  "sys_pll1_160m", 
"sys_pll1_800m", "sys_pll3_out",
  "sys_pll2_250m", 
"audio_pll2_out", };
 
-- 
2.35.1



[PATCH] clk: imx8mp: Fix 32k clock name

2022-06-13 Thread Marek Vasut
The 32 kHz oscillator clock name is 'clock-osc-32k' instead of 'osc_32k'.
Fix the name to prevent the following warning:

"
clk_register: failed to get osc_32k device (parent of usb_root_clk)
"

Fixes: 7a2c3be95a5 ("clk: imx8mp: Fill in DWC3 USB, USB PHY, HSIOMIX clock")
Signed-off-by: Marek Vasut 
Cc: Fabio Estevam 
Cc: Peng Fan 
Cc: Stefano Babic 
---
 drivers/clk/imx/clk-imx8mp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/imx/clk-imx8mp.c b/drivers/clk/imx/clk-imx8mp.c
index cbed86a6843..9c7857bbb3a 100644
--- a/drivers/clk/imx/clk-imx8mp.c
+++ b/drivers/clk/imx/clk-imx8mp.c
@@ -300,7 +300,7 @@ static int imx8mp_clk_probe(struct udevice *dev)
clk_dm(IMX8MP_CLK_UART2_ROOT, imx_clk_gate4("uart2_root_clk", "uart2", 
base + 0x44a0, 0));
clk_dm(IMX8MP_CLK_UART3_ROOT, imx_clk_gate4("uart3_root_clk", "uart3", 
base + 0x44b0, 0));
clk_dm(IMX8MP_CLK_UART4_ROOT, imx_clk_gate4("uart4_root_clk", "uart4", 
base + 0x44c0, 0));
-   clk_dm(IMX8MP_CLK_USB_ROOT, imx_clk_gate4("usb_root_clk", "osc_32k", 
base + 0x44d0, 0));
+   clk_dm(IMX8MP_CLK_USB_ROOT, imx_clk_gate4("usb_root_clk", 
"clock-osc-32k", base + 0x44d0, 0));
clk_dm(IMX8MP_CLK_USB_PHY_ROOT, imx_clk_gate4("usb_phy_root_clk", 
"usb_phy_ref", base + 0x44f0, 0));
clk_dm(IMX8MP_CLK_USDHC1_ROOT, imx_clk_gate4("usdhc1_root_clk", 
"usdhc1", base + 0x4510, 0));
clk_dm(IMX8MP_CLK_USDHC2_ROOT, imx_clk_gate4("usdhc2_root_clk", 
"usdhc2", base + 0x4520, 0));
-- 
2.35.1



Re: Boot regression on am335x-hs-evm

2022-06-13 Thread LABBE Corentin
Le Fri, Jun 10, 2022 at 11:48:34AM -0400, Tom Rini a écrit :
> On Fri, Jun 10, 2022 at 05:45:04PM +0200, LABBE Corentin wrote:
> > Le Fri, Jun 10, 2022 at 11:01:47AM -0400, Tom Rini a écrit :
> > > On Fri, Jun 10, 2022 at 04:51:12PM +0200, LABBE Corentin wrote:
> > > > Le Fri, Jun 10, 2022 at 08:16:10AM -0400, Tom Rini a écrit :
> > > > > On Fri, Jun 10, 2022 at 11:59:23AM +0200, LABBE Corentin wrote:
> > > > > > Hello
> > > > > > 
> > > > > > I hit a boot regression on am335x-hs-evm.
> > > > > > On current uboot, the board does not boot at all.
> > > > > > This board uses both MLO and u-boot.img and only MLO was the 
> > > > > > problem.
> > > > > > 
> > > > > > After a bisect, I found that e41651fffda7 ("dm: Support parent 
> > > > > > devices with of-platdata") was the problem.
> > > > > > Reverting this patch lead to a success boot.
> > > > > > 
> > > > > > I cutdown the revert to a minimal fix:
> > > > > > --- a/drivers/core/lists.c
> > > > > > +++ b/drivers/core/lists.c
> > > > > > @@ -120,6 +120,7 @@ int lists_bind_drivers(struct udevice *parent, 
> > > > > > bool pre_reloc_only)
> > > > > > int ret;
> > > > > >  
> > > > > > ret = bind_drivers_pass(parent, pre_reloc_only);
> > > > > > +   return ret;
> > > > > > if (!ret)
> > > > > > break;
> > > > > > if (ret != -EAGAIN && !result)
> > > > > > 
> > > > > > I cannot debug further since printf() is not working at this stage.
> > > > > > 
> > > > > > Since I wanted to know which error was badly handled, I tried to do 
> > > > > > this:
> > > > > > --- a/arch/arm/mach-omap2/sec-common.c
> > > > > > +++ b/arch/arm/mach-omap2/sec-common.c
> > > > > > @@ -111,6 +111,8 @@ static u32 find_sig_start(char *image, size_t 
> > > > > > size)
> > > > > > return 0;
> > > > > >  }
> > > > > >  
> > > > > > +extern int errorcount;
> > > > > > +
> > > > > >  int secure_boot_verify_image(void **image, size_t *size)
> > > > > >  {
> > > > > > int result = 1;
> > > > > > @@ -178,6 +180,7 @@ auth_exit:
> > > > > >  * via YMODEM. This is done to avoid disturbing the YMODEM 
> > > > > > serial
> > > > > >  * protocol transactions.
> > > > > >  */
> > > > > > +   printf("ERRORCOUNT %d\n", errorcount);
> > > > > > if (!(IS_ENABLED(CONFIG_SPL_BUILD) &&
> > > > > >   IS_ENABLED(CONFIG_SPL_YMODEM_SUPPORT) &&
> > > > > >   spl_boot_device() == BOOT_DEVICE_UART))
> > > > > > --- a/drivers/core/lists.c
> > > > > > +++ b/drivers/core/lists.c
> > > > > > @@ -20,6 +20,10 @@
> > > > > >  #include 
> > > > > >  #include 
> > > > > >  
> > > > > > +static int _errorcount;
> > > > > > +int errorlist[1024];
> > > > > > +int errorcount;
> > > > > > +
> > > > > >  struct driver *lists_driver_lookup_name(const char *name)
> > > > > >  {
> > > > > > struct driver *drv =
> > > > > > @@ -120,8 +124,9 @@ int lists_bind_drivers(struct udevice *parent, 
> > > > > > bool pre_reloc_only)
> > > > > > int ret;
> > > > > >  
> > > > > > ret = bind_drivers_pass(parent, pre_reloc_only);
> > > > > > -   if (!ret)
> > > > > > -   break;
> > > > > > +   errorlist[_errorcount] = ret;
> > > > > > +   _errorcount++;
> > > > > > +   errorcount = _errorcount;
> > > > > > if (ret != -EAGAIN && !result)
> > > > > > result = ret;
> > > > > > }
> > > > > > 
> > > > > > But errorcount is always 0 which is puzzling me since according to 
> > > > > > my think, lists_bind_drivers() is ran before 
> > > > > > secure_boot_verify_image().
> > > > > > 
> > > > > > Any idea on how to debug further ?
> > > > > 
> > > > > You should be able to enable DEBUG_UART and get output that way.  But
> > > > > it's likely something related to the space constraints of the HS chip
> > > > > rather than GP.
> > > > > 
> > > > 
> > > > Hello
> > > > 
> > > > Thanks for your suggestion, I successfully got futher with:
> > > > diff --git a/drivers/core/lists.c b/drivers/core/lists.c
> > > > index b23ee3030e..415ba814f1 100644
> > > > --- a/drivers/core/lists.c
> > > > +++ b/drivers/core/lists.c
> > > > @@ -111,6 +111,8 @@ int lists_bind_drivers(struct udevice *parent, bool 
> > > > pre_reloc_only)
> > > > int result = 0;
> > > > int pass;
> > > >  
> > > > +   debug_uart_init();
> > > > +
> > > > /*
> > > >  * 10 passes is 10 levels deep in the devicetree, which is 
> > > > plenty. If
> > > >  * OF_PLATDATA_PARENT is not enabled, then bind_drivers_pass() 
> > > > will
> > > > diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
> > > > index b4805a2e4e..7ab059b4ea 100644
> > > > --- a/drivers/serial/Kconfig
> > > > +++ b/drivers/serial/Kconfig
> > > > @@ -158,6 +158,7 @@ config TPL_DM_SERIAL
> > > >  
> > > >  config DEBUG_UART
> > > > bool "Enable an 

Re: [PATCH v5 10/23] FWU: cmd: Add a command to read FWU metadata

2022-06-13 Thread Sughosh Ganu
hi Ilias,

On Fri, 10 Jun 2022 at 17:37, Ilias Apalodimas
 wrote:
>
> On Thu, Jun 09, 2022 at 05:59:57PM +0530, Sughosh Ganu wrote:
> > Add a command to read the metadata as specified in the FWU
> > specification and print the fields of the metadata.
> >
> > Signed-off-by: Sughosh Ganu 
> > ---
> >  cmd/Kconfig |  7 +
> >  cmd/Makefile|  1 +
> >  cmd/fwu_mdata.c | 74 +
> >  3 files changed, 82 insertions(+)
> >  create mode 100644 cmd/fwu_mdata.c
> >
> > diff --git a/cmd/Kconfig b/cmd/Kconfig
> > index 09193b61b9..275becd837 100644
> > --- a/cmd/Kconfig
> > +++ b/cmd/Kconfig
> > @@ -144,6 +144,13 @@ config CMD_CPU
> > internal name) and clock frequency. Other information may be
> > available depending on the CPU driver.
> >
> > +config CMD_FWU_METADATA
> > + bool "fwu metadata read"
> > + depends on FWU_MULTI_BANK_UPDATE
> > + default y if FWU_MULTI_BANK_UPDATE
> > + help
> > +   Command to read the metadata and dump it's contents
> > +
> >  config CMD_LICENSE
> >   bool "license"
> >   select BUILD_BIN2C
> > diff --git a/cmd/Makefile b/cmd/Makefile
> > index 5e43a1e022..259a93bc65 100644
> > --- a/cmd/Makefile
> > +++ b/cmd/Makefile
> > @@ -76,6 +76,7 @@ obj-$(CONFIG_CMD_FPGA) += fpga.o
> >  obj-$(CONFIG_CMD_FPGAD) += fpgad.o
> >  obj-$(CONFIG_CMD_FS_GENERIC) += fs.o
> >  obj-$(CONFIG_CMD_FUSE) += fuse.o
> > +obj-$(CONFIG_CMD_FWU_METADATA) += fwu_mdata.o
> >  obj-$(CONFIG_CMD_GETTIME) += gettime.o
> >  obj-$(CONFIG_CMD_GPIO) += gpio.o
> >  obj-$(CONFIG_CMD_HVC) += smccc.o
> > diff --git a/cmd/fwu_mdata.c b/cmd/fwu_mdata.c
> > new file mode 100644
> > index 00..bc20ca26a3
> > --- /dev/null
> > +++ b/cmd/fwu_mdata.c
> > @@ -0,0 +1,74 @@
> > +/* SPDX-License-Identifier: GPL-2.0+ */
> > +/*
> > + * Copyright (c) 2022, Linaro Limited
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +
> > +static void print_mdata(struct fwu_mdata *mdata)
> > +{
> > + int i, j;
> > + struct fwu_image_entry *img_entry;
> > + struct fwu_image_bank_info *img_info;
> > + u32 nimages, nbanks;
>
> nit but we don't really need those two.  Just use the define.

Okay. Will change.

>
> > +
> > + printf("\tFWU Metadata\n");
> > + printf("crc32: %#x\n", mdata->crc32);
> > + printf("version: %#x\n", mdata->version);
> > + printf("active_index: %#x\n", mdata->active_index);
> > + printf("previous_active_index: %#x\n", mdata->previous_active_index);
> > +
> > + nimages = CONFIG_FWU_NUM_IMAGES_PER_BANK;
> > + nbanks = CONFIG_FWU_NUM_BANKS;
> > + printf("\tImage Info\n");
> > + for (i = 0; i < nimages; i++) {
> > + img_entry = >img_entry[i];
> > + printf("\nImage Type Guid: %pUL\n", 
> > _entry->image_type_uuid);
> > + printf("Location Guid: %pUL\n", _entry->location_uuid);
> > + for (j = 0; j < nbanks; j++) {
> > + img_info = _entry->img_bank_info[j];
> > + printf("Image Guid:  %pUL\n", _info->image_uuid);
> > + printf("Image Acceptance: %#x\n", img_info->accepted);
>
> Can we do 'yes/no' on the image acceptance please?

Okay. Will change.

-sughosh

>
> > + }
> > + }
> > +}
> > +
> > +int do_fwu_mdata_read(struct cmd_tbl *cmdtp, int flag,
> > +  int argc, char * const argv[])
> > +{
> > + struct udevice *dev;
> > + int ret = CMD_RET_SUCCESS;
> > + struct fwu_mdata *mdata = NULL;
> > +
> > + if (uclass_get_device(UCLASS_FWU_MDATA, 0, ) || !dev) {
> > + log_err("Unable to get FWU metadata device\n");
> > + return CMD_RET_FAILURE;
> > + }
> > +
> > + ret = fwu_get_mdata();
> > + if (ret < 0) {
> > + log_err("Unable to get valid FWU metadata\n");
> > + ret = CMD_RET_FAILURE;
> > + goto out;
> > + }
> > +
> > + print_mdata(mdata);
> > +
> > +out:
> > + free(mdata);
> > + return ret;
> > +}
> > +
> > +U_BOOT_CMD(
> > + fwu_mdata_read, 1,  1,  do_fwu_mdata_read,
> > + "Read and print FWU metadata",
> > + ""
> > +);
> > --
> > 2.25.1
> >
>
> Regards
> /Ilias


Re: [PATCH v5 06/23] FWU: stm32mp1: Add helper functions for accessing FWU metadata

2022-06-13 Thread Sughosh Ganu
hi Ilias,

On Fri, 10 Jun 2022 at 17:23, Ilias Apalodimas
 wrote:
>
> Hi Sughosh,
>
> On Thu, Jun 09, 2022 at 05:59:53PM +0530, Sughosh Ganu wrote:
> > Add helper functions needed for accessing the FWU metadata which
> > contains information on the updatable images. These functions have
> > been added for the STM32MP157C-DK2 board which has the updatable
> > images on the uSD card, formatted as GPT partitions.
> >
> > Signed-off-by: Sughosh Ganu 
> > ---
> >  board/st/stm32mp1/stm32mp1.c | 115 +++
> >  include/fwu.h|   2 +
> >  2 files changed, 117 insertions(+)
> >
> > diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> > index 62d98ad776..e68bf09955 100644
> > --- a/board/st/stm32mp1/stm32mp1.c
> > +++ b/board/st/stm32mp1/stm32mp1.c
> > @@ -7,9 +7,11 @@
> >
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -25,9 +27,11 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -967,3 +971,114 @@ static void board_copro_image_process(ulong fw_image, 
> > size_t fw_size)
> >  }
> >
> >  U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_COPRO, board_copro_image_process);
> > +
> > +#if defined(CONFIG_FWU_MULTI_BANK_UPDATE)
> > +#include 
> > +#include 
> > +
> > +static int get_gpt_dfu_identifier(struct blk_desc *desc, efi_guid_t 
> > *image_guid)
> > +{
> > + int i;
> > + struct disk_partition info;
> > + efi_guid_t unique_part_guid;
> > +
> > + for (i = 1; i < MAX_SEARCH_PARTITIONS; i++) {
> > + if (part_get_info(desc, i, ))
> > + continue;
> > + uuid_str_to_bin(info.uuid, unique_part_guid.b,
> > + UUID_STR_FORMAT_GUID);
> > +
> > + if (!guidcmp(_part_guid, image_guid))
> > + return i;
> > + }
> > +
> > + log_err("No partition found with image_guid %pUs\n", image_guid);
> > + return -ENOENT;
> > +}
> > +
> > +static int gpt_plat_get_alt_num(struct blk_desc *desc, efi_guid_t 
> > *image_guid,
> > + int *alt_num)
>
> Does this really need to be defined per platform?
>
> Most of the stuff in here are generic apart from the info of were  the
> metadata is stored.  So wouldn't it better to move this in the generic API
> and add an argument for the dfu device type?
>
> The platform portion would then just call this function with an extra arg
> e.g DFU_DEV_MMC

Yes, it makes sense. I will make the change that you suggest. Thanks.

-sughosh

>
> > +{
> > + int ret = -1;
> > + int i, part, dev_num;
> > + int nalt;
> > + struct dfu_entity *dfu;
> > +
> > + dev_num = desc->devnum;
> > + part = get_gpt_dfu_identifier(desc, image_guid);
> > + if (part < 0)
> > + return -ENOENT;
> > +
> > + dfu_init_env_entities(NULL, NULL);
>
> [...]
>
>
> Regards
> /Ilias


[PATCH] spi: nxp_fspi: Fix clock imbalance

2022-06-13 Thread Marek Vasut
The nxp_fspi_default_setup() is only ever called from nxp_fspi_probe(),
where the IP clock are initially disabled. Drop the second disabling of
clock to prevent clock enable/disable imbalance reported by clock core:

"
clk qspi_root_clk already disabled
"

Signed-off-by: Marek Vasut 
Cc: Fabio Estevam 
Cc: Peng Fan 
Cc: Stefano Babic 
---
 drivers/spi/nxp_fspi.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/spi/nxp_fspi.c b/drivers/spi/nxp_fspi.c
index 607c953987b..579d6bac9b1 100644
--- a/drivers/spi/nxp_fspi.c
+++ b/drivers/spi/nxp_fspi.c
@@ -866,9 +866,6 @@ static int nxp_fspi_default_setup(struct nxp_fspi *f)
u32 reg;
 
 #if CONFIG_IS_ENABLED(CLK)
-   /* disable and unprepare clock to avoid glitch pass to controller */
-   nxp_fspi_clk_disable_unprep(f);
-
/* the default frequency, we will change it later if necessary. */
ret = clk_set_rate(>clk, 2000);
if (ret < 0)
-- 
2.35.1



Re: [PATCH v5 11/23] mkeficapsule: Add support for generating empty capsules

2022-06-13 Thread Sughosh Ganu
On Thu, 9 Jun 2022 at 21:58, Heinrich Schuchardt  wrote:
>
> On 6/9/22 14:29, Sughosh Ganu wrote:
> > The Dependable Boot specification[1] describes the structure of the
> > firmware accept and revert capsules. These are empty capsules which
> > are used for signalling the acceptance or rejection of the updated
> > firmware by the OS. Add support for generating these empty capsules.
> >
> > [1] - 
> > https://git.codelinaro.org/linaro/dependable-boot/mbfw/uploads/6f7ddfe3be24e18d4319e108a758d02e/mbfw.pdf
> >
> > Signed-off-by: Sughosh Ganu 
> > ---
> >   doc/mkeficapsule.1   |  29 ++---
> >   tools/eficapsule.h   |   8 +++
> >   tools/mkeficapsule.c | 139 +--
> >   3 files changed, 151 insertions(+), 25 deletions(-)



> > diff --git a/tools/mkeficapsule.c b/tools/mkeficapsule.c
> > index 5f74d23b9e..e8eb6b070d 100644
> > --- a/tools/mkeficapsule.c
> > +++ b/tools/mkeficapsule.c
> > @@ -29,7 +29,16 @@ static const char *tool_name = "mkeficapsule";
> >   efi_guid_t efi_guid_fm_capsule = EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID;
> >   efi_guid_t efi_guid_cert_type_pkcs7 = EFI_CERT_TYPE_PKCS7_GUID;
> >
> > -static const char *opts_short = "g:i:I:v:p:c:m:dh";
> > +static const char *opts_short = "g:i:I:v:p:c:m:dhAR";
> > +
> > +static bool empty_capsule;
> > +static unsigned char capsule;
> > +
> > +enum {
> > + CAPSULE_NORMAL_BLOB = 0,
> > + CAPSULE_ACCEPT,
> > + CAPSULE_REVERT,
> > +} capsule_type;
> >
> >   static struct option options[] = {
> >   {"guid", required_argument, NULL, 'g'},
> > @@ -39,24 +48,47 @@ static struct option options[] = {
> >   {"certificate", required_argument, NULL, 'c'},
> >   {"monotonic-count", required_argument, NULL, 'm'},
> >   {"dump-sig", no_argument, NULL, 'd'},
> > + {"fw-accept", no_argument, NULL, 'A'},
> > + {"fw-revert", no_argument, NULL, 'R'},
> >   {"help", no_argument, NULL, 'h'},
> >   {NULL, 0, NULL, 0},
> >   };
> >
> >   static void print_usage(void)
> >   {
> > - fprintf(stderr, "Usage: %s [options]  \n"
> > - "Options:\n"
> > -
> > - "\t-g, --guid guid for image blob type\n"
> > - "\t-i, --index  update image index\n"
> > - "\t-I, --instanceupdate hardware instance\n"
> > - "\t-p, --private-key   private key file\n"
> > - "\t-c, --certificate  signer's certificate 
> > file\n"
> > - "\t-m, --monotonic-count  monotonic count\n"
> > - "\t-d, --dump_sig  dump signature (*.p7)\n"
> > - "\t-h, --help  print a help message\n",
> > - tool_name);
> > + if (empty_capsule) {
> > + if (capsule == CAPSULE_ACCEPT) {
> > + fprintf(stderr, "Usage: %s [options] \n",
>
> My expectation is that this function always provides the same output.
>
> If different scenarios allow only specific combinations of arguments you
> may describe it here.

Okay

>
>
> > + tool_name);
> > + fprintf(stderr, "Options:\n"
> > + "\t-A, --fw-accept firmware 
> > accept capsule\n"
> > + "\t-g, --guid guid for image 
> > blob type\n"
> > + "\t-h, --help  print a help 
> > message\n"
> > + );
> > + } else {
> > + fprintf(stderr, "Usage: %s [options] \n",
> > + tool_name);
> > + fprintf(stderr, "Options:\n"
> > + "\t-R, --fw-revert firmware 
> > revert capsule\n"
> > + "\t-h, --help  print a help 
> > message\n"
> > + );
> > + }
> > + } else {
> > + fprintf(stderr, "Usage: %s [options]   > file>\n"
> > + "Options:\n"
> > +
> > + "\t-g, --guid guid for image blob 
> > type\n"
> > + "\t-i, --index  update image index\n"
> > + "\t-I, --instanceupdate hardware 
> > instance\n"
> > + "\t-p, --private-key   private key 
> > file\n"
> > + "\t-c, --certificate  signer's 
> > certificate file\n"
> > + "\t-m, --monotonic-count  monotonic 
> > count\n"
> > + "\t-d, --dump_sig  dump signature 
> > (*.p7)\n"
> > + "\t-A, --fw-accept firmware accept 
> > capsule\n"
>
> "\t-A, --fw-accept firmware accept capsule, requires GUID\n"
>
> > + "\t-R, --fw-revert firmware revert 
> > capsule\n"
>
> "\t-R, --fw-revert firmware revert capsule, takes no GUID\n"
>
> > + "\t-h, --help  print a help 
> > message\n",
> 

Re: [PATCH 08/15] arm: samsung: Remove dead LCD code

2022-06-13 Thread Minkyu Kang
Dear Tom,

On Sat, 11 Jun 2022 at 12:03, Tom Rini  wrote:

> Since bb5930d5c97f ("exynos: video: Convert several boards to driver
> model for video") there have been no callers of any of the exynos_lcd_*
> family of functions.  Remove these from the boards, and then remove
> unused logo and related code as well.
>
> Signed-off-by: Tom Rini 
> ---
>  arch/arm/mach-exynos/include/mach/system.h |1 -
>  board/samsung/trats/trats.c|   23 -
>  board/samsung/trats2/trats2.c  |   35 -
>  board/samsung/universal_c210/universal.c   |  107 -
>  drivers/video/Makefile |1 -
>  drivers/video/s6e8ax0.c|  265 -
>  include/configs/s5pc210_universal.h|2 -
>  include/configs/trats.h|2 -
>  include/configs/trats2.h   |2 -
>  lib/Makefile   |1 -
>  lib/tizen/Makefile |6 -
>  lib/tizen/tizen.c  |   34 -
>  lib/tizen/tizen_logo_16bpp.h   | 7934 
>  lib/tizen/tizen_logo_16bpp_gzip.h  |  647 --
>  14 files changed, 9060 deletions(-)
>  delete mode 100644 drivers/video/s6e8ax0.c
>  delete mode 100644 lib/tizen/Makefile
>  delete mode 100644 lib/tizen/tizen.c
>  delete mode 100644 lib/tizen/tizen_logo_16bpp.h
>  delete mode 100644 lib/tizen/tizen_logo_16bpp_gzip.h
>
>
Reviewed-by: Minkyu Kang 

-- 
Thanks,
Minkyu Kang.


Re: [PATCH 1/3] arm: apple: nvme: Add SART support and RTKit buffer management

2022-06-13 Thread Mark Kettenis
> Date: Sun, 12 Jun 2022 20:35:59 +0200 (CEST)
> From: Mark Kettenis 
> 
> > From: Janne Grunau 
> > Date: Sun, 12 Jun 2022 18:00:27 +0200
> > 
> > The NVMe firmware in the macOS 13 beta blocks or crashes with u-boot's
> > current minimal RTKit implementation. It does not provide buffers for
> > the firmware's buffer requests. The ANS2 firmware included in macOS 11
> > and 12 tolerates this. The firmware included in the first macOS 13 beta
> > requires buffers for the crashlog and ioreport endpoints to function.
> > 
> > In the case of the NVMe the buffers are physical memory. Access to
> > physical memory is guarded by what Apple calls SART.
> > Import m1n1's SART driver (exclusively used for the NVMe controller).
> > Implement buffer management helpers for RTKit. These are generic since
> > other devices (none in u-boot so far) require different handling.
> > 
> > Signed-off-by: Janne Grunau 
> 
> Thanks for taking care of this.
> 
> Reviewed-by: Mark Kettenis 
> Tested-by: Mark Kettenis 

As Sven pointed out on IRC, the "apple,sart2" and "apple,sart3"
compatibles are not part of the official device tree bindings.  They
should be replaced with "apple,t8103-sart" and "apple,t6000-sart".  So
we'll need a v2 of this.

You can keep my Reviewed-by: and Tested-by: tags.

Cheers,

Mark

> > ---
> > 
> >  arch/arm/include/asm/arch-apple/rtkit.h |  22 ++-
> >  arch/arm/include/asm/arch-apple/sart.h  |  22 +++
> >  arch/arm/mach-apple/Makefile|   1 +
> >  arch/arm/mach-apple/rtkit.c | 159 +---
> >  arch/arm/mach-apple/sart.c  | 230 
> >  drivers/nvme/nvme_apple.c   |  72 +++-
> >  6 files changed, 474 insertions(+), 32 deletions(-)
> >  create mode 100644 arch/arm/include/asm/arch-apple/sart.h
> >  create mode 100644 arch/arm/mach-apple/sart.c
> > 
> > diff --git a/arch/arm/include/asm/arch-apple/rtkit.h 
> > b/arch/arm/include/asm/arch-apple/rtkit.h
> > index 51f77f298c09..eff18ddb9d21 100644
> > --- a/arch/arm/include/asm/arch-apple/rtkit.h
> > +++ b/arch/arm/include/asm/arch-apple/rtkit.h
> > @@ -7,5 +7,23 @@
> >  #define APPLE_RTKIT_PWR_STATE_QUIESCED 0x10
> >  #define APPLE_RTKIT_PWR_STATE_ON   0x20
> >  
> > -int apple_rtkit_init(struct mbox_chan *);
> > -int apple_rtkit_shutdown(struct mbox_chan *, int);
> > +struct apple_rtkit_buffer {
> > +   void *buffer;
> > +   u64 dva;
> > +   size_t size;
> > +   bool is_mapped;
> > +};
> > +
> > +typedef int (*apple_rtkit_shmem_setup)(void *cookie,
> > +  struct apple_rtkit_buffer *buf);
> > +typedef void (*apple_rtkit_shmem_destroy)(void *cookie,
> > + struct apple_rtkit_buffer *buf);
> > +
> > +struct apple_rtkit;
> > +
> > +struct apple_rtkit *apple_rtkit_init(struct mbox_chan *chan, void *cookie,
> > +apple_rtkit_shmem_setup shmem_setup,
> > +apple_rtkit_shmem_destroy shmem_destroy);
> > +void apple_rtkit_free(struct apple_rtkit *rtk);
> > +int apple_rtkit_boot(struct apple_rtkit *rtk);
> > +int apple_rtkit_shutdown(struct apple_rtkit *rtk, int pwrstate);
> > diff --git a/arch/arm/include/asm/arch-apple/sart.h 
> > b/arch/arm/include/asm/arch-apple/sart.h
> > new file mode 100644
> > index ..b99bdeafc0b3
> > --- /dev/null
> > +++ b/arch/arm/include/asm/arch-apple/sart.h
> > @@ -0,0 +1,22 @@
> > +/* SPDX-License-Identifier: MIT
> > + *
> > + * The sart code is copied from m1n1 (https://github.com/AsahiLinux/m1n1) 
> > and
> > + * licensed as MIT.
> > + *
> > + * (C) Copyright 2022 The Asahi Linux Contributors
> > + */
> > +
> > +#ifndef SART_H
> > +#define SART_H
> > +
> > +#include 
> > +
> > +struct apple_sart;
> > +
> > +struct apple_sart *sart_init(ofnode node);
> > +void sart_free(struct apple_sart *sart);
> > +
> > +bool sart_add_allowed_region(struct apple_sart *sart, void *paddr, size_t 
> > sz);
> > +bool sart_remove_allowed_region(struct apple_sart *sart, void *paddr, 
> > size_t sz);
> > +
> > +#endif
> > diff --git a/arch/arm/mach-apple/Makefile b/arch/arm/mach-apple/Makefile
> > index 52f30a777b2c..50b465b9473f 100644
> > --- a/arch/arm/mach-apple/Makefile
> > +++ b/arch/arm/mach-apple/Makefile
> > @@ -3,3 +3,4 @@
> >  obj-y += board.o
> >  obj-y += lowlevel_init.o
> >  obj-y += rtkit.o
> > +obj-$(CONFIG_NVME_APPLE) += sart.o
> > diff --git a/arch/arm/mach-apple/rtkit.c b/arch/arm/mach-apple/rtkit.c
> > index 2dcb8bdd3e44..da7771844230 100644
> > --- a/arch/arm/mach-apple/rtkit.c
> > +++ b/arch/arm/mach-apple/rtkit.c
> > @@ -17,6 +17,7 @@
> >  #define APPLE_RTKIT_EP_SYSLOG 2
> >  #define APPLE_RTKIT_EP_DEBUG 3
> >  #define APPLE_RTKIT_EP_IOREPORT 4
> > +#define APPLE_RTKIT_EP_TRACEKIT 10
> >  
> >  /* Messages for management endpoint. */
> >  #define APPLE_RTKIT_MGMT_TYPE GENMASK(59, 52)
> > @@ -51,7 +52,102 @@
> >  #define APPLE_RTKIT_BUFFER_REQUEST_SIZE GENMASK(51, 44)
> >  #define APPLE_RTKIT_BUFFER_REQUEST_IOVA 

Re: [PATCH 11/15] video: Migrate exynos display options to Kconfig

2022-06-13 Thread Minkyu Kang
Dear Tom,

On Sat, 11 Jun 2022 at 12:01, Tom Rini  wrote:

> Following how it's done for the majority of drivers, add a new
> VIDEO_EXYNOS option and Kconfig file under drivers/video/exynos and list
> the current options there.
>
> Cc: Anatolij Gustschin 
> Cc: Jaehoon Chung 
> Cc: Minkyu Kang 
> Signed-off-by: Tom Rini 
> ---
> It would be good to have help options here, but I don't know the
> underlying parts, so what to add would be appreciated, or done as a
> follow-up.  On a related note, the drivers themselves should be under
> something in the top-level MAINTAINERS file as they are not currently.
> ---
>  configs/peach-pi_defconfig  |  3 +++
>  configs/peach-pit_defconfig |  3 +++
>  configs/snow_defconfig  |  3 +++
>  configs/spring_defconfig|  3 +++
>  drivers/video/Kconfig   |  2 ++
>  drivers/video/exynos/Kconfig| 20 
>  include/configs/exynos5-dt-common.h |  7 ---
>  include/configs/peach-pi.h  |  7 ---
>  include/configs/smdk5250.h  |  3 ---
>  include/configs/smdk5420.h  |  3 ---
>  include/configs/trats.h |  1 -
>  include/configs/trats2.h|  1 -
>  12 files changed, 34 insertions(+), 22 deletions(-)
>  create mode 100644 drivers/video/exynos/Kconfig
>
>
Reviewed-by: Minkyu Kang 

-- 
Thanks,
Minkyu Kang.


Re: [PATCH 09/15] arm: exynos: Remove old pwm backlight driver

2022-06-13 Thread Minkyu Kang
Dear Tom,

On Sat, 11 Jun 2022 at 12:01, Tom Rini  wrote:

> Remove the unused older exynos pwm backlight driver.
>
> Signed-off-by: Tom Rini 
> ---
>  .../mach-exynos/include/mach/pwm_backlight.h  | 20 -
>  drivers/video/exynos/exynos_pwm_bl.c  | 44 ---
>  2 files changed, 64 deletions(-)
>  delete mode 100644 arch/arm/mach-exynos/include/mach/pwm_backlight.h
>  delete mode 100644 drivers/video/exynos/exynos_pwm_bl.c
>
>
Reviewed-by: Minkyu Kang 

-- 
Thanks,
Minkyu Kang.


[PATCH 6/6] ARM: dts: stm32: Add DHCOR based DRC Compact board

2022-06-13 Thread Marek Vasut
Add DT for DH DRC Compact unit, which is a universal controller device.
The system has two ethernet ports, one CAN, RS485 and RS232, USB, uSD
card slot, eMMC and SDIO Wi-Fi.

Signed-off-by: Marek Vasut 
Cc: Patrice Chotard 
Cc: Patrick Delaunay 
---
 arch/arm/dts/Makefile |   3 +-
 .../arm/dts/stm32mp153c-dhcor-drc-compact.dts |  30 ++
 .../stm32mp15xx-dhcor-drc-compact-u-boot.dtsi | 120 +++
 .../arm/dts/stm32mp15xx-dhcor-drc-compact.dts |  16 +
 .../dts/stm32mp15xx-dhcor-drc-compact.dtsi| 326 ++
 .../dh_stm32mp1/u-boot-dhcor.its  |  15 +
 configs/stm32mp15_dhcor_basic_defconfig   |   1 +
 7 files changed, 510 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/stm32mp153c-dhcor-drc-compact.dts
 create mode 100644 arch/arm/dts/stm32mp15xx-dhcor-drc-compact-u-boot.dtsi
 create mode 100644 arch/arm/dts/stm32mp15xx-dhcor-drc-compact.dts
 create mode 100644 arch/arm/dts/stm32mp15xx-dhcor-drc-compact.dtsi

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 0a2713c06a3..8a314210da6 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1172,7 +1172,8 @@ dtb-$(CONFIG_STM32MP15x) += \
stm32mp15xx-dhcom-drc02.dtb \
stm32mp15xx-dhcom-pdk2.dtb \
stm32mp15xx-dhcom-picoitx.dtb \
-   stm32mp15xx-dhcor-avenger96.dtb
+   stm32mp15xx-dhcor-avenger96.dtb \
+   stm32mp15xx-dhcor-drc-compact.dtb
 
 dtb-$(CONFIG_SOC_K3_AM6) += \
k3-am654-base-board.dtb \
diff --git a/arch/arm/dts/stm32mp153c-dhcor-drc-compact.dts 
b/arch/arm/dts/stm32mp153c-dhcor-drc-compact.dts
new file mode 100644
index 000..c8b9818499e
--- /dev/null
+++ b/arch/arm/dts/stm32mp153c-dhcor-drc-compact.dts
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
+/*
+ * Copyright (C) 2022 Marek Vasut 
+ *
+ * DHCOR STM32MP1 variant:
+ * DHCR-STM32MP153C-C065-R051-V33-SPI-I-01LG
+ * DHCOR PCB number: 586-100 or newer
+ * DRC Compact PCB number: 627-100 or newer
+ */
+
+/dts-v1/;
+
+#include "stm32mp153.dtsi"
+#include "stm32mp15xc.dtsi"
+#include "stm32mp15xx-dhcor-som.dtsi"
+#include "stm32mp15xx-dhcor-drc-compact.dtsi"
+
+/ {
+   model = "DH electronics STM32MP153C DHCOR DRC Compact";
+   compatible = "dh,stm32mp153c-dhcor-drc-compact",
+"dh,stm32mp153c-dhcor-som",
+"st,stm32mp153";
+};
+
+_can1 {
+   pinctrl-names = "default", "sleep";
+   pinctrl-0 = <_can1_pins_c>;
+   pinctrl-1 = <_can1_sleep_pins_c>;
+   status = "okay";
+};
diff --git a/arch/arm/dts/stm32mp15xx-dhcor-drc-compact-u-boot.dtsi 
b/arch/arm/dts/stm32mp15xx-dhcor-drc-compact-u-boot.dtsi
new file mode 100644
index 000..407fed56167
--- /dev/null
+++ b/arch/arm/dts/stm32mp15xx-dhcor-drc-compact-u-boot.dtsi
@@ -0,0 +1,120 @@
+// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
+/*
+ * Copyright (C) 2022 Marek Vasut 
+ */
+
+#include "stm32mp15xx-dhcor-u-boot.dtsi"
+
+/delete-node/ 
+
+/ {
+   aliases {
+   mmc0 = 
+   mmc1 = 
+   usb0 = _hs;
+   ethernet1 = 
+   };
+
+   config {
+   dh,board-coding-gpios = < 9 0>, < 8 0>, < 3 
0>;
+   };
+
+   /* This is actually on FMC2, but we do not have bus driver for that */
+   ks8851: ks8851mll@6400 {
+   compatible = "micrel,ks8851-mll";
+   reg = <0x6400 0x2>;
+   };
+};
+
+ {
+   phy-reset-gpios = < 2 GPIO_ACTIVE_LOW>;
+
+   mdio0 {
+   ethernet-phy@7 {
+   reset-gpios = < 2 GPIO_ACTIVE_LOW>;
+   reset-assert-us = <11000>;
+   reset-deassert-us = <1000>;
+   };
+   };
+};
+
+ {
+   /* These should bound to FMC2 bus driver, but we do not have one */
+   pinctrl-0 = <_pins_b>;
+   pinctrl-1 = <_sleep_pins_b>;
+   pinctrl-names = "default", "sleep";
+};
+
+ {
+   u-boot,dm-spl;
+   st,use-ckin;
+   st,cmd-gpios = < 2 0>;
+   st,ck-gpios = < 12 0>;
+   st,ckin-gpios = < 4 0>;
+};
+
+_b4_pins_a {
+   u-boot,dm-spl;
+   pins1 {
+   u-boot,dm-spl;
+   };
+   pins2 {
+   u-boot,dm-spl;
+   };
+};
+
+_dir_pins_b {
+   u-boot,dm-spl;
+   pins1 {
+   u-boot,dm-spl;
+   };
+   pins2 {
+   u-boot,dm-spl;
+   };
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+_b4_pins_a {
+   u-boot,dm-spl;
+   pins1 {
+   u-boot,dm-spl;
+   };
+   pins2 {
+   u-boot,dm-spl;
+   };
+};
+
+_d47_pins_c {
+   u-boot,dm-spl;
+   pins {
+   u-boot,dm-spl;
+   };
+};
+
+ {  /* SDIO Wi-Fi */
+   status = "disabled";
+};
+
+ {
+   u-boot,dm-pre-reloc;
+};
+
+_pins_d {
+   u-boot,dm-pre-reloc;
+   pins1 {
+   u-boot,dm-pre-reloc;
+   };
+   pins2 {
+   u-boot,dm-pre-reloc;
+   /delete-property/ 

[PATCH 5/6] ARM: dts: stm32: Add alternate pinmux for SPI2 pins

2022-06-13 Thread Marek Vasut
Add another mux option for SPI2 pins, this is used on DRC Compact board.

Signed-off-by: Marek Vasut 
Cc: Patrice Chotard 
Cc: Patrick Delaunay 
---
 arch/arm/dts/stm32mp15-pinctrl.dtsi | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/arch/arm/dts/stm32mp15-pinctrl.dtsi 
b/arch/arm/dts/stm32mp15-pinctrl.dtsi
index e0965c5936e..b92a149a186 100644
--- a/arch/arm/dts/stm32mp15-pinctrl.dtsi
+++ b/arch/arm/dts/stm32mp15-pinctrl.dtsi
@@ -1778,6 +1778,21 @@
};
};
 
+   spi2_pins_b: spi2-1 {
+   pins1 {
+   pinmux = , /* SPI1_SCK */
+; /* SPI1_MOSI */
+   bias-disable;
+   drive-push-pull;
+   slew-rate = <1>;
+   };
+
+   pins2 {
+   pinmux = ; /* SPI1_MISO */
+   bias-disable;
+   };
+   };
+
spi4_pins_a: spi4-0 {
pins {
pinmux = , /* SPI4_SCK */
-- 
2.35.1



[PATCH 4/6] ARM: dts: stm32: Add alternate pinmux for CAN1 pins

2022-06-13 Thread Marek Vasut
Add another mux option for CAN1 pins, this is used on DRC Compact board.

Signed-off-by: Marek Vasut 
Cc: Patrice Chotard 
Cc: Patrick Delaunay 
---
 arch/arm/dts/stm32mp15-pinctrl.dtsi | 20 
 1 file changed, 20 insertions(+)

diff --git a/arch/arm/dts/stm32mp15-pinctrl.dtsi 
b/arch/arm/dts/stm32mp15-pinctrl.dtsi
index 6a5b4016f66..e0965c5936e 100644
--- a/arch/arm/dts/stm32mp15-pinctrl.dtsi
+++ b/arch/arm/dts/stm32mp15-pinctrl.dtsi
@@ -929,6 +929,26 @@
};
};
 
+   m_can1_pins_c: m-can1-2 {
+   pins1 {
+   pinmux = ; /* CAN1_TX */
+   slew-rate = <1>;
+   drive-push-pull;
+   bias-disable;
+   };
+   pins2 {
+   pinmux = ; /* CAN1_RX */
+   bias-disable;
+   };
+   };
+
+   m_can1_sleep_pins_c: m_can1-sleep-2 {
+   pins {
+   pinmux = , /* CAN1_TX */
+; /* CAN1_RX */
+   };
+   };
+
m_can2_pins_a: m-can2-0 {
pins1 {
pinmux = ; /* CAN2_TX */
-- 
2.35.1



[PATCH 3/6] ARM: dts: stm32: Add alternate pinmux for UART5 pins

2022-06-13 Thread Marek Vasut
Add another mux option for UART5 pins, this is used on DRC Compact board.

Signed-off-by: Marek Vasut 
Cc: Patrice Chotard 
Cc: Patrick Delaunay 
---
 arch/arm/dts/stm32mp15-pinctrl.dtsi | 13 +
 1 file changed, 13 insertions(+)

diff --git a/arch/arm/dts/stm32mp15-pinctrl.dtsi 
b/arch/arm/dts/stm32mp15-pinctrl.dtsi
index dc329bf531e..6a5b4016f66 100644
--- a/arch/arm/dts/stm32mp15-pinctrl.dtsi
+++ b/arch/arm/dts/stm32mp15-pinctrl.dtsi
@@ -1865,6 +1865,19 @@
};
};
 
+   uart5_pins_a: uart5-0 {
+   pins1 {
+   pinmux = ; /* UART5_TX */
+   bias-disable;
+   drive-push-pull;
+   slew-rate = <0>;
+   };
+   pins2 {
+   pinmux = ; /* UART5_RX */
+   bias-disable;
+   };
+   };
+
uart7_pins_a: uart7-0 {
pins1 {
pinmux = ; /* UART7_TX */
-- 
2.35.1



[PATCH 2/6] ARM: dts: stm32: Add alternate pinmux for UART4 pins

2022-06-13 Thread Marek Vasut
Add another mux option for UART4 pins, this is used on DRC Compact board.

Signed-off-by: Marek Vasut 
Cc: Patrice Chotard 
Cc: Patrick Delaunay 
---
 arch/arm/dts/stm32mp15-pinctrl.dtsi | 30 +
 1 file changed, 30 insertions(+)

diff --git a/arch/arm/dts/stm32mp15-pinctrl.dtsi 
b/arch/arm/dts/stm32mp15-pinctrl.dtsi
index 823ef2e2aab..dc329bf531e 100644
--- a/arch/arm/dts/stm32mp15-pinctrl.dtsi
+++ b/arch/arm/dts/stm32mp15-pinctrl.dtsi
@@ -1835,6 +1835,36 @@
};
};
 
+   uart4_pins_d: uart4-3 {
+   pins1 {
+   pinmux = ; /* UART4_TX */
+   bias-disable;
+   drive-push-pull;
+   slew-rate = <0>;
+   };
+   pins2 {
+   pinmux = ; /* UART4_RX */
+   bias-disable;
+   };
+   };
+
+   uart4_idle_pins_d: uart4-idle-3 {
+   pins1 {
+   pinmux = ; /* UART4_TX */
+   };
+   pins2 {
+   pinmux = ; /* UART4_RX */
+   bias-disable;
+   };
+   };
+
+   uart4_sleep_pins_d: uart4-sleep-3 {
+   pins {
+   pinmux = , /* UART4_TX */
+; /* UART4_RX */
+   };
+   };
+
uart7_pins_a: uart7-0 {
pins1 {
pinmux = ; /* UART7_TX */
-- 
2.35.1



[PATCH 1/6] ARM: dts: stm32: Add alternate pinmux for UART3 pins

2022-06-13 Thread Marek Vasut
Add another mux option for UART3 pins, this is used on DRC Compact board.

Signed-off-by: Marek Vasut 
Cc: Patrice Chotard 
Cc: Patrick Delaunay 
---
 arch/arm/dts/stm32mp15-pinctrl.dtsi | 41 +
 1 file changed, 41 insertions(+)

diff --git a/arch/arm/dts/stm32mp15-pinctrl.dtsi 
b/arch/arm/dts/stm32mp15-pinctrl.dtsi
index f0d66d8c6e3..823ef2e2aab 100644
--- a/arch/arm/dts/stm32mp15-pinctrl.dtsi
+++ b/arch/arm/dts/stm32mp15-pinctrl.dtsi
@@ -2134,6 +2134,47 @@
};
};
 
+   usart3_pins_e: usart3-4 {
+   pins1 {
+   pinmux = , /* USART3_TX */
+; /* USART3_RTS */
+   bias-disable;
+   drive-push-pull;
+   slew-rate = <0>;
+   };
+   pins2 {
+   pinmux = , /* USART3_RX */
+; /* 
USART3_CTS_NSS */
+   bias-pull-up;
+   };
+   };
+
+   usart3_idle_pins_e: usart3-idle-4 {
+   pins1 {
+   pinmux = , /* USART3_TX 
*/
+; /* 
USART3_CTS_NSS */
+   };
+   pins2 {
+   pinmux = ; /* USART3_RTS */
+   bias-disable;
+   drive-push-pull;
+   slew-rate = <0>;
+   };
+   pins3 {
+   pinmux = ; /* USART3_RX */
+   bias-pull-up;
+   };
+   };
+
+   usart3_sleep_pins_e: usart3-sleep-4 {
+   pins {
+   pinmux = , /* USART3_TX 
*/
+, /* USART3_RTS 
*/
+, /* 
USART3_CTS_NSS */
+; /* USART3_RX 
*/
+   };
+   };
+
usbotg_hs_pins_a: usbotg-hs-0 {
pins {
pinmux = ; /* OTG_ID */
-- 
2.35.1



Re: [PATCH] intel: n5x: ddr: update license

2022-06-13 Thread Marek Vasut

On 6/13/22 03:35, Chee, Tien Fong wrote:
[...]

On 6/10/22 13:23, tien.fong.c...@intel.com wrote:

From: Tien Fong Chee 

All the source code of sdram_n5x.c are from Intel, update the license
to use both GPL2.0 and BSD-3 Clause because this copy of code may used
for open source and internal project.

Signed-off-by: Tien Fong Chee 


That's still fine, since nobody did any other changes to this driver yet.

Do you plan to collect those socfpga patches yourself and send a PR for next ?


Yes, that's my next plan after submitting this patch for review.


Excellent, thanks!


Re: [PATCH v6 1/6] efi_loader: menu-driven addition of UEFI boot option

2022-06-13 Thread Masahisa Kojima
Hi Akashi-san,

On Mon, 6 Jun 2022 at 09:39, Masahisa Kojima  wrote:
>
> On Wed, 25 May 2022 at 10:39, Takahiro Akashi
>  wrote:
> >
> > On Mon, May 16, 2022 at 08:00:37PM +0900, Masahisa Kojima wrote:
> > > This commit supports the menu-driven UEFI boot option addition.
> > > User can select the block device volume having
> > > efi_simple_file_system_protocol and select the file corresponding
> > > to the Boot variable. Then user enter the label of the BOOT
> > > variable in utf8.
> > >
> > > Signed-off-by: Masahisa Kojima 
> > > ---
> > > Changes in v6:
> > > - fix typos
> > > - modify volume name to match U-Boot syntax
> > > - compile in CONFIG_EFI_LOADER=n and CONFIG_CMD_BOOTEFI_BOOTMGR=n
> >
> > Is this correct?
>
> Sorry for the lack of information. I would like to say that build test in
> the following configurations.
> - CONFIG_EFI_LOADER=n,  CONFIG_CMD_BOOTEFI_BOOTMGR=n
> - CONFIG_EFI_LOADER=y, CONFIG_CMD_BOOTEFI_BOOTMGR=n
> >
> > > - simplify u16_strncmp() usage
> > > - support "a\b.efi" file path, use link list to handle filepath
> > > - modify length check condition
> > > - UEFI related menu items only appears with CONFIG_AUTOBOOT_MENU_SHOW=y
> >
> > Why?
> > I think that the feature is useful even without AUTOBOOT.
> > As you know, efidebug is seen as a debugging tool and is not expected
> > to be enabled in production systems.
> >
> > So the feature you're adding is the only available UI for boot manager.
> > What I recommend is
> > - to create a boot manager maintenance as a standalone U-Boot command,
> > - to add an bootmenu entry for invoking the command
>
> I agree.
>
> >
> > > Changes in v5:
> > > - remove forward declarations
> > > - add const qualifier for menu items
> > > - fix the possible unaligned access for directory info access
> > > - split into three commit 1)add boot option 2) delete boot option 
> > > 3)change boot order
> > >   This commit is 1)add boot option.
> > > - fix file name buffer allocation size, it should be 
> > > EFI_BOOTMENU_FILE_PATH_MAX * sizeof(u16)
> > > - fix wrong size checking for file selection
> > >
> > > Chanes in v4:
> > > - UEFI boot option maintenance menu is integrated into bootmenu
> > > - display the simplified volume name(e.g. usb0:1, nvme1:2) for the
> > >   volume selection
> > > - instead of extending lib/efi_loader/efi_bootmgr.c, newly create
> > >   lib/efi_loader/efi_bootmenu_maintenance.c and implement boot
> > >   variable maintenance into it.
> > >
> > > Changes in RFC v3:
> > >  not included in v3 series
> > >
> > > Changes in RFC v2:
> > > - enable utf8 user input for boot option name
> > > - create lib/efi_loader/efi_console.c::efi_console_get_u16_string() for
> > >   utf8 user input handling
> > > - use u16_strlcat instead of u16_strcat
> > > - remove the EFI_CALLs, and newly create or expose the following
> > >   xxx_int() functions.
> > > efi_locate_handle_buffer_int(), efi_open_volume_int(),
> > > efi_file_open_int(), efi_file_close_int(), efi_file_read_int() and
> > > efi_file_setpos_int().
> > >   Note that EFI_CALLs still exist for EFI_DEVICE_PATH_TO_TEXT_PROTOCOL
> > >   and EFI_SIMPLE_TEXT_INPUT/OUTPUT_PROTOCOL
> > > - use efi_search_protocol() instead of calling locate_protocol() to get
> > >   the device_path_to_text_protocol interface.
> > > - remove unnecessary puts(ANSI_CLEAR_LINE), this patch is still depends on
> > >   puts(ANSI_CLEAR_CONSOLE)
> > > - skip SetVariable() if the bootorder is not changed
> > >
> > >  cmd/bootmenu.c|  73 +-
> > >  include/efi_loader.h  |  37 +
> > >  lib/efi_loader/Makefile   |   3 +
> > >  lib/efi_loader/efi_bootmenu_maintenance.c | 906 ++
> >
> > I would say that this file should be moved under /cmd as the code does not
> > implement any UEFI specification semantics, but simply provides helper
> > functions for bootmenu command.
>
> OK, I will create a new command for UEFI variable maintenance.
>
> >
> > Or I recommend that the boot manager be implemented as a standalone command
> > (as I insisted serveral times before) and the related maintenance feature
> > be invoked as follows:
> >=> efibootmanager -i (i for interactive)
> >
> > >  lib/efi_loader/efi_boottime.c |  52 +-
> > >  lib/efi_loader/efi_console.c  |  81 ++
> > >  lib/efi_loader/efi_disk.c |  11 +
> > >  lib/efi_loader/efi_file.c |  75 +-
> > >  8 files changed, 1184 insertions(+), 54 deletions(-)
> > >  create mode 100644 lib/efi_loader/efi_bootmenu_maintenance.c
> > >
> > > diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c
> > > index 8859eebea5..4b846332b0 100644
> > > --- a/cmd/bootmenu.c
> > > +++ b/cmd/bootmenu.c
> > > @@ -19,6 +19,12 @@
> > >
> > >  /* maximum bootmenu entries */
> > >  #define MAX_COUNT99
> > > +#if defined(CONFIG_CMD_BOOTEFI_BOOTMGR) && 
> > > defined(CONFIG_AUTOBOOT_MENU_SHOW)
> > > +#define STATIC_ENTRY 2
> > > +#else
> > > +#define 

[PATCH v7 9/9] doc:efimenu: add documentation for efimenu command

2022-06-13 Thread Masahisa Kojima
Add documentation for efimenu command.

Signed-off-by: Masahisa Kojima 
---
Newly created in v7

 doc/usage/cmd/efimenu.rst | 50 +++
 doc/usage/index.rst   |  1 +
 2 files changed, 51 insertions(+)
 create mode 100644 doc/usage/cmd/efimenu.rst

diff --git a/doc/usage/cmd/efimenu.rst b/doc/usage/cmd/efimenu.rst
new file mode 100644
index 00..2bf4f9266e
--- /dev/null
+++ b/doc/usage/cmd/efimenu.rst
@@ -0,0 +1,50 @@
+.. SPDX-License-Identifier: GPL-2.0+
+.. (C) Copyright 2022, Masahisa Kojima 
+
+efimenu command
+
+
+Synopsis
+
+::
+
+efimenu
+
+Description
+---
+
+The "efimenu" command uses U-Boot menu interface and privides
+a menu-driven UEFI variable maintenance feature.
+The "efimenu" has the following menu entries.
+
+Add Boot Option
+Add new UEFI Boot Option.
+User can edit description, file path, and optional_data.
+
+Edit Boot Option
+Edit the existing UEFI Boot Option
+User can edit description, file path, and optional_data.
+
+Change Boot Order
+Change the order of UEFI BootOrder variable.
+
+Delete Boot Option
+Delete the UEFI Boot Option
+
+Configuration
+-
+
+The "efimenu" command is enabled by::
+
+CONFIG_CMD_EFIMENU=y
+
+If CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE is enabled, user can not enter
+U-Boot console. In this case, bootmenu can be used to invoke "efimenu"::
+
+CONFIG_USE_PREBOOT=y
+CONFIG_PREBOOT="setenv bootmenu_0 UEFI Maintenance Menu=efimenu"
+
+See also
+
+* :doc:`bootmenu` provides a simple mechanism for creating menus 
with different boot items
+
diff --git a/doc/usage/index.rst b/doc/usage/index.rst
index c03f4aef9e..053631a746 100644
--- a/doc/usage/index.rst
+++ b/doc/usage/index.rst
@@ -33,6 +33,7 @@ Shell commands
cmd/cbsysinfo
cmd/conitrace
cmd/echo
+   cmd/efimenu
cmd/env
cmd/event
cmd/exception
-- 
2.17.1



[PATCH v7 8/9] doc:bootmenu: add description for UEFI boot support

2022-06-13 Thread Masahisa Kojima
The bootmenu enumerates the UEFI boot options
for boot device selection.
This commit adds the description how the UEFI boot work
in bootmenu. This commit also adds "Synopsis", "Description"
and "Configuration" sections to follow the U-Boot command
documentation format.

Signed-off-by: Masahisa Kojima 
---
Changes in v7:
- update the description what bootmenu do for uefi-related boot menu
- add default behavior when user exits from bootmenu

Changes in v6:
- remove distro boot related contents because the distro boot
support in bootmenu is dropped
- update uefi entry example
- add [delay] argument of bootmenu command
- add description to enable uefi boot entry

Changes in v5:
- follow the cmd documentation format same as other command, add "Synopsis",
  "Description" add "Configuration" sections

Newly created in v4

 doc/usage/cmd/bootmenu.rst | 74 ++
 1 file changed, 74 insertions(+)

diff --git a/doc/usage/cmd/bootmenu.rst b/doc/usage/cmd/bootmenu.rst
index 9430f8c9aa..69435090a2 100644
--- a/doc/usage/cmd/bootmenu.rst
+++ b/doc/usage/cmd/bootmenu.rst
@@ -4,6 +4,15 @@
 bootmenu command
 
 
+Synopsis
+
+::
+
+bootmenu [delay]
+
+Description
+---
+
 The "bootmenu" command uses U-Boot menu interfaces and provides
 a simple mechanism for creating menus with different boot items.
 The cursor keys "Up" and "Down" are used for navigation through
@@ -79,6 +88,55 @@ The above example will be rendered as below::
 The selected menu entry will be highlighted - it will have inverted
 background and text colors.
 
+UEFI boot variable enumeration
+''
+If enabled, the bootmenu command will automatically generate and add
+UEFI-related boot menu entries for the following items.
+
+ * possible bootable media with default file names
+ * user-defined UEFI boot options
+
+The bootmenu automatically enumerates the possible bootable
+media devices supporting EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.
+This auto generated entry is named as " :" format.
+(e.g. "usb 0:1")
+
+The bootmenu displays the UEFI-related menu entries in order of "BootOrder".
+When the user selects the UEFI boot menu entry, the bootmenu sets
+the selected boot variable index to "BootNext" without non-volatile attribute,
+then call the uefi boot manager with the command "bootefi bootmgr".
+
+Example bootmenu is as below::
+
+*** U-Boot Boot Menu ***
+
+   mmc 0:1
+   mmc 0:2
+   debian
+   nvme 0:1
+   ubuntu
+   nvme 0:2
+   usb 0:2
+   U-Boot console
+
+Default behavior when user exits from the bootmenu
+~~
+User can exit from bootmenu by selecting the last entry
+"U-Boot console"/"Quit" or ESC/CTRL+C key.
+
+When the CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE is disabled,
+user exits from the bootmenu and returns to the U-Boot console.
+
+When the CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE is enabled, user can not
+enter the U-Boot console. When the user exits from the bootmenu,
+the bootmenu invokes the following default behabior.
+
+ * if CONFIG_CMD_BOOTEFI_BOOTMGR is enabled, execute "bootefi bootmgr" command
+ * "bootefi bootmgr" fails or is not enabled, then execute "run bootcmt" 
command.
+
+Configuration
+-
+
 The "bootmenu" command is enabled by::
 
 CONFIG_CMD_BOOTMENU=y
@@ -88,3 +146,19 @@ To run the bootmenu at startup add these additional 
settings::
 CONFIG_AUTOBOOT_KEYED=y
 CONFIG_BOOTDELAY=30
 CONFIG_AUTOBOOT_MENU_SHOW=y
+
+UEFI boot variable enumeration is enabled by::
+
+CONFIG_CMD_BOOTEFI_BOOTMGR=y
+
+To improve the product security, entering U-Boot console from bootmenu
+can be disabled by::
+
+CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE=y
+
+To scan the discoverable devices connected to the buses such as
+USB and PCIe prior to bootmenu showing up, CONFIG_PREBOOT can be
+used to run the command before showing the bootmenu, i.e.::
+
+CONFIG_USE_PREBOOT=y
+CONFIG_PREBOOT="pci enum; usb start; scsi scan; nvme scan; virtio scan"
-- 
2.17.1



[PATCH v7 7/9] bootmenu: add removable media entries

2022-06-13 Thread Masahisa Kojima
UEFI specification requires booting from removal media using
a architecture-specific default image name such as BOOTAA64.EFI.
This commit adds the removable media entries into bootmenu,
so that user can select the removable media and boot with
default image.

The bootmenu automatically enumerates the possible bootable
media devices supporting EFI_SIMPLE_FILE_SYSTEM_PROTOCOL,
add it as new UEFI boot option(BOOT) and update BootOrder
variable. This automatically generated UEFI boot option
has the dedicated guid in the optional_data to distinguish it from
the UEFI boot option user adds manually. This optional_data is
removed when the efi bootmgr loads the selected UEFI boot option.

This commit also provides the BOOT variable maintenance feature.
Depending on the system hardware setup, some devices
may not exist at a later system boot, so bootmenu checks the
available device in each bootmenu invocation and automatically
removes the BOOT variable corrensponding to the non-existent
media device.

Signed-off-by: Masahisa Kojima 
---
Changes in v7:
- rename prepare_media_device_entry() to generate_media_device_boot_option()

Changes in v6:
- optional_data size is changed to 16bytes
- check the load option size before comparison
- remove guid included in optional_data of auto generated
  entry when loading

Changes in v5:
- Return EFI_SUCCESS if there is no BootOrder defined
- correctly handle the case if no removable device found
- use guid to identify the automatically generated entry by bootmenu

Newly created in v4

 cmd/bootmenu.c   |  99 +++-
 cmd/efimenu.c| 131 +++
 include/efi_loader.h |  20 +++
 3 files changed, 247 insertions(+), 3 deletions(-)

diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c
index 704d36debe..49544864b1 100644
--- a/cmd/bootmenu.c
+++ b/cmd/bootmenu.c
@@ -221,6 +221,89 @@ static int prepare_bootmenu_entry(struct bootmenu_data 
*menu,
 }
 
 #if (CONFIG_IS_ENABLED(CMD_BOOTEFI_BOOTMGR))
+/**
+ * generate_media_device_boot_option() - generate the media device boot option
+ *
+ * This function enumerates all devices supporting 
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
+ * and generate the bootmenu entries.
+ * This function also provide the BOOT variable maintenance for
+ * the media device entries.
+ *   - Automatically create the BOOT variable for the newly detected 
device,
+ * this BOOT variable is distinguished by the special GUID
+ * stored in the EFI_LOAD_OPTION.optional_data
+ *   - If the device is not attached to the system, the associated BOOT 
variable
+ * is automatically deleted.
+ *
+ * Return: status code
+ */
+static efi_status_t generate_media_device_boot_option(void)
+{
+   u32 i;
+   efi_status_t ret;
+   efi_uintn_t count;
+   efi_handle_t *volume_handles = NULL;
+   struct efimenu_media_boot_option *opt = NULL;
+
+   ret = efi_locate_handle_buffer_int(BY_PROTOCOL, 
_simple_file_system_protocol_guid,
+  NULL, , (efi_handle_t 
**)_handles);
+   if (ret != EFI_SUCCESS)
+   return ret;
+
+   opt = calloc(count, sizeof(struct efimenu_media_boot_option));
+   if (!opt)
+   goto out;
+
+   /* enumerate all devices supporting EFI_SIMPLE_FILE_SYSTEM_PROTOCOL */
+   ret = efimenu_enumerate_boot_option(opt, volume_handles, count);
+   if (ret != EFI_SUCCESS)
+   goto out;
+
+   /*
+* System hardware configuration may vary depending on the user setup.
+* The boot option is automatically added by the bootmenu.
+* If the device is not attached to the system, the boot option needs
+* to be deleted.
+*/
+   ret = efimenu_delete_invalid_boot_option(opt, count);
+   if (ret != EFI_SUCCESS)
+   goto out;
+
+   /* add non-existent boot option */
+   for (i = 0; i < count; i++) {
+   u32 boot_index;
+   u16 var_name[9];
+
+   if (!opt[i].exist) {
+   ret = efimenu_get_unused_bootoption(var_name, 
sizeof(var_name),
+   _index);
+   if (ret != EFI_SUCCESS)
+   goto out;
+
+   ret = efi_set_variable_int(var_name, 
_global_variable_guid,
+  EFI_VARIABLE_NON_VOLATILE |
+  
EFI_VARIABLE_BOOTSERVICE_ACCESS |
+  EFI_VARIABLE_RUNTIME_ACCESS,
+  opt[i].size, opt[i].lo, 
false);
+   if (ret != EFI_SUCCESS)
+   goto out;
+
+   ret = efimenu_append_bootorder(boot_index);
+   if (ret != EFI_SUCCESS)
+   goto out;
+ 

[PATCH v7 6/9] efimenu: add "Delete Boot Option" menu entry

2022-06-13 Thread Masahisa Kojima
This commit adds the menu entry to delete the UEFI boot option.
User moves the entry with UP/DOWN key, changes, then presses
ENTER key to delete the selected boot option.

Signed-off-by: Masahisa Kojima 
---
Changes in v7:
- to stay the boot order list after user delete the entry

no update in v6:

changes in v5:

- split into the separate patch
 cmd/efimenu.c | 61 +++
 1 file changed, 61 insertions(+)

diff --git a/cmd/efimenu.c b/cmd/efimenu.c
index 1be483a082..1c97f265ca 100644
--- a/cmd/efimenu.c
+++ b/cmd/efimenu.c
@@ -1565,6 +1565,66 @@ out:
return ret;
 }
 
+static efi_status_t delete_boot_option(u16 *bootorder, u16 index, efi_uintn_t 
size)
+{
+   u16 varname[9];
+   efi_status_t ret;
+   efi_uintn_t num;
+
+   efi_create_indexed_name(varname, sizeof(varname),
+   "Boot", bootorder[index]);
+   ret = efi_set_variable_int(varname, _global_variable_guid,
+  0, 0, NULL, false);
+   if (ret != EFI_SUCCESS) {
+   log_err("delete boot option(%ls) failed\n", varname);
+   return ret;
+   }
+
+   /* update BootOrder */
+   num = size / sizeof(u16);
+   memmove([index], [index + 1],
+   (num - index - 1) * sizeof(u16));
+   size -= sizeof(u16);
+   ret = efi_set_variable_int(u"BootOrder", _global_variable_guid,
+  EFI_VARIABLE_NON_VOLATILE |
+  EFI_VARIABLE_BOOTSERVICE_ACCESS |
+  EFI_VARIABLE_RUNTIME_ACCESS,
+  size, bootorder, false);
+
+   return ret;
+}
+
+static efi_status_t efimenu_process_delete_boot_option(void *data)
+{
+   int selected;
+   u16 *bootorder;
+   efi_status_t ret;
+   efi_uintn_t num, size;
+
+   while (1) {
+   bootorder = efi_get_var(u"BootOrder", 
_global_variable_guid, );
+   if (!bootorder) {
+   ret = EFI_NOT_FOUND;
+   return ret;
+   }
+
+   num = size / sizeof(u16);
+   ret = efimenu_show_boot_selection(bootorder, num, );
+   if (ret == EFI_SUCCESS)
+   ret = delete_boot_option(bootorder, selected, size);
+
+   if (ret != EFI_SUCCESS)
+   break;
+   }
+
+   free(bootorder);
+
+   /* to stay the parent menu */
+   ret = (ret == EFI_ABORTED) ? EFI_NOT_READY : ret;
+
+   return ret;
+}
+
 static efi_status_t efimenu_init(void)
 {
efi_status_t ret;
@@ -1600,6 +1660,7 @@ static const struct efimenu_item maintenance_menu_items[] 
= {
{"Add Boot Option", efimenu_process_add_boot_option},
{"Edit Boot Option", efimenu_process_edit_boot_option},
{"Change Boot Order", efimenu_process_change_boot_order},
+   {"Delete Boot Option", efimenu_process_delete_boot_option},
{"Quit", efimenu_process_quit},
 };
 
-- 
2.17.1



[PATCH v7 5/9] efimenu: add "Change Boot Order" menu entry

2022-06-13 Thread Masahisa Kojima
This commit adds the menu entry to update UEFI BootOrder variable.
User moves the entry with UP/DOWN key, changes the order
with PLUS/MINUS key, then finalizes the order by ENTER key.

The U-Boot menu framework is well designed for static menu,
this commit implements the own menu display and key handling
for dynamically change the order of menu entry.

Signed-off-by: Masahisa Kojima 
---
Changes in v7:
- use UP/DOWN and PLUS/MINUS key to change to order

no update in v6:

 cmd/efimenu.c | 207 ++
 1 file changed, 207 insertions(+)

diff --git a/cmd/efimenu.c b/cmd/efimenu.c
index 918e9dffa2..1be483a082 100644
--- a/cmd/efimenu.c
+++ b/cmd/efimenu.c
@@ -70,6 +70,13 @@ struct efimenu_file_entry_data {
u16 *file_name;
 };
 
+struct efimenu_boot_order {
+   u32 num;
+   u16 *description;
+   u32 prev_index;
+   struct list_head list;
+};
+
 /**
  * efimenu_print_msg() - print message
  *
@@ -1359,6 +1366,205 @@ out:
return ret;
 }
 
+static void efimenu_display_change_boot_order(struct list_head *bo_list,
+ struct efimenu *efi_menu)
+{
+   bool reverse;
+   struct list_head *pos, *n;
+   struct efimenu_boot_order *entry;
+
+   printf(ANSI_CLEAR_CONSOLE
+  ANSI_CURSOR_POSITION
+ "\n  ** Change Boot Order **\n"
+  ANSI_CURSOR_POSITION
+  "\n"
+  "  Press UP/DOWN to move, +/- to change order\n  ENTER to 
complete, ESC/CTRL+C to quit"
+  ANSI_CURSOR_POSITION,
+  0, 1, efi_menu->count + 5, 1, 4, 1);
+
+   /* draw boot order list */
+   list_for_each_safe(pos, n, bo_list) {
+   entry = list_entry(pos, struct efimenu_boot_order, list);
+   reverse = (entry->num == efi_menu->active);
+   puts(" ");
+   if (reverse)
+   puts(ANSI_COLOR_REVERSE);
+
+   printf("%ls\n", entry->description);
+
+   if (reverse)
+   puts(ANSI_COLOR_RESET);
+   }
+}
+
+static efi_status_t efimenu_choice_change_boot_order(struct list_head *bo_list,
+struct efimenu *efi_menu)
+{
+   int esc = 0;
+   struct list_head *pos, *n;
+   struct efimenu_boot_order *tmp;
+   enum bootmenu_key key = KEY_NONE;
+   struct efimenu_boot_order *entry;
+
+   while (1) {
+   bootmenu_loop(NULL, , );
+
+   switch (key) {
+   case KEY_PLUS:
+   if (efi_menu->active > 0) {
+   list_for_each_safe(pos, n, bo_list) {
+   entry = list_entry(pos, struct 
efimenu_boot_order, list);
+   if (entry->num == efi_menu->active)
+   break;
+   }
+   tmp = list_entry(pos->prev, struct 
efimenu_boot_order, list);
+   entry->num--;
+   tmp->num++;
+   list_del(>list);
+   list_add(>list, >list);
+   }
+   fallthrough;
+   case KEY_UP:
+   if (efi_menu->active > 0)
+   --efi_menu->active;
+   return EFI_NOT_READY;
+   case KEY_MINUS:
+   if (efi_menu->active < efi_menu->count - 1) {
+   list_for_each_safe(pos, n, bo_list) {
+   entry = list_entry(pos, struct 
efimenu_boot_order, list);
+   if (entry->num == efi_menu->active)
+   break;
+   }
+   tmp = list_entry(pos->next, struct 
efimenu_boot_order, list);
+   entry->num++;
+   tmp->num--;
+   list_del(>list);
+   list_add(>list, >list);
+   }
+   fallthrough;
+   case KEY_DOWN:
+   if (efi_menu->active < efi_menu->count - 1)
+   ++efi_menu->active;
+   return EFI_NOT_READY;
+   case KEY_SELECT:
+   return EFI_SUCCESS;
+   case KEY_QUIT:
+   return EFI_ABORTED;
+   default:
+   break;
+   }
+   }
+}
+
+static efi_status_t efimenu_process_change_boot_order(void *data)
+{
+   u32 i;
+   u16 *bootorder;
+   efi_status_t ret;
+   efi_uintn_t num, size;
+   struct list_head bo_list;
+   struct list_head *pos, *n;
+   struct efimenu_boot_order 

[PATCH v7 2/9] efimenu: menu-driven addition of UEFI boot option

2022-06-13 Thread Masahisa Kojima
This commit add the "efimenu" command.
The "efimenu" command implements the menu-driven UEFI boot option
maintenance feature. This commit implements the addition of
new boot option. User can select the block device volume having
efi_simple_file_system_protocol and select the file corresponding
to the Boot variable. User can also enter the description and
optional_data of the BOOT variable in utf8.

This commit adds "include/efi_menu.h", it contains the common
definition to be used from other menus such as UEFI Secure Boot
key management.

Signed-off-by: Masahisa Kojima 
---
Changes in v7:
- add "efimenu" command and uefi variable maintenance code
  moved into cmd/efimenu.c
- create include/efimenu.h to define the common definition for
  the other menu such as UEFI Secure Boot key management
- update boot option edit UI, user can select description, file,
  and optional_data to edit in the same menu like following.

  ** Edit Boot Option **

 Description: debian
 File: virtio 0:1/EFI\debian\grubaa64.efi
 Optional Data: test
 Save
 Quit

- remove exit parameter from efimenu_process_common()
- menu title type is changed from u16 to char
- efimenu_process_common() add menu title string
- reduce printf/puts function call for displaying the menu
- efi_console_get_u16_string() accept 0 length to allow
  optional_data is empty
- efi_console_get_u16_string() the "size" parameter name is changes to "count"
- efimenu is now designed to maintain the UEFI variables, remove autoboot 
related code
- remove one empty line before "Quit" entry
- efimenu_init() processes only the first time

Changes in v6:
- fix typos
- modify volume name to match U-Boot syntax
- compile in CONFIG_EFI_LOADER=n and CONFIG_CMD_BOOTEFI_BOOTMGR=n
- simplify u16_strncmp() usage
- support "a\b.efi" file path, use link list to handle filepath
- modify length check condition
- UEFI related menu items only appears with CONFIG_AUTOBOOT_MENU_SHOW=y

Changes in v5:
- remove forward declarations
- add const qualifier for menu items
- fix the possible unaligned access for directory info access
- split into three commit 1)add boot option 2) delete boot option 3)change boot 
order
  This commit is 1)add boot option.
- fix file name buffer allocation size, it should be EFI_BOOTMENU_FILE_PATH_MAX 
* sizeof(u16)
- fix wrong size checking for file selection

Chanes in v4:
- UEFI boot option maintenance menu is integrated into bootmenu
- display the simplified volume name(e.g. usb0:1, nvme1:2) for the
  volume selection
- instead of extending lib/efi_loader/efi_bootmgr.c, newly create
  lib/efi_loader/efi_bootmenu_maintenance.c and implement boot
  variable maintenance into it.

Changes in RFC v3:
 not included in v3 series

Changes in RFC v2:
- enable utf8 user input for boot option name
- create lib/efi_loader/efi_console.c::efi_console_get_u16_string() for
  utf8 user input handling
- use u16_strlcat instead of u16_strcat
- remove the EFI_CALLs, and newly create or expose the following
  xxx_int() functions.
efi_locate_handle_buffer_int(), efi_open_volume_int(),
efi_file_open_int(), efi_file_close_int(), efi_file_read_int() and
efi_file_setpos_int().
  Note that EFI_CALLs still exist for EFI_DEVICE_PATH_TO_TEXT_PROTOCOL
  and EFI_SIMPLE_TEXT_INPUT/OUTPUT_PROTOCOL
- use efi_search_protocol() instead of calling locate_protocol() to get
  the device_path_to_text_protocol interface.
- remove unnecessary puts(ANSI_CLEAR_LINE), this patch is still depends on
  puts(ANSI_CLEAR_CONSOLE)
- skip SetVariable() if the bootorder is not changed

 cmd/Kconfig   |7 +
 cmd/Makefile  |1 +
 cmd/efimenu.c | 1255 +
 include/efi_loader.h  |   40 ++
 include/efi_menu.h|   91 +++
 lib/efi_loader/efi_boottime.c |   52 +-
 lib/efi_loader/efi_console.c  |   78 ++
 lib/efi_loader/efi_disk.c |   11 +
 lib/efi_loader/efi_file.c |   75 +-
 9 files changed, 1563 insertions(+), 47 deletions(-)
 create mode 100644 cmd/efimenu.c
 create mode 100644 include/efi_menu.h

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 09193b61b9..3c3944c545 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1870,6 +1870,13 @@ config CMD_EFIDEBUG
  particularly for managing boot parameters as  well as examining
  various EFI status for debugging.
 
+config CMD_EFIMENU
+   bool "provide menu-driven uefi variables maintenance feature"
+   depends on CMD_BOOTEFI_BOOTMGR
+   help
+ Enable the 'efimenu' command which provides the menu-driven UEFI
+ variable maintenance feature.
+
 config CMD_EXCEPTION
bool "exception - raise exception"
depends on ARM || RISCV || SANDBOX || X86
diff --git a/cmd/Makefile b/cmd/Makefile
index 5e43a1e022..b8ae08f961 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -63,6 +63,7 @@ obj-$(CONFIG_ENV_IS_IN_EEPROM) += eeprom.o
 obj-$(CONFIG_CMD_EEPROM) += eeprom.o
 obj-$(CONFIG_EFI) += 

[PATCH v7 4/9] menu: add KEY_PLUS and KEY_MINUS handling

2022-06-13 Thread Masahisa Kojima
This is preparation to support menu-driven UEFI BootOrder
variable updated by KEY_PLUS and KEY_MINUS.

Signed-off-by: Masahisa Kojima 
---
Newly created in v7

 common/menu.c  | 6 ++
 include/menu.h | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/common/menu.c b/common/menu.c
index 3e876b55b3..3470f95a98 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -548,4 +548,10 @@ void bootmenu_loop(struct bootmenu_data *menu,
/* ^C was pressed */
if (c == 0x3)
*key = KEY_QUIT;
+
+   if (c == '+')
+   *key = KEY_PLUS;
+
+   if (c == '-')
+   *key = KEY_MINUS;
 }
diff --git a/include/menu.h b/include/menu.h
index e74616cae8..4c32e74ce9 100644
--- a/include/menu.h
+++ b/include/menu.h
@@ -48,6 +48,8 @@ enum bootmenu_key {
KEY_DOWN,
KEY_SELECT,
KEY_QUIT,
+   KEY_PLUS,
+   KEY_MINUS,
 };
 
 void bootmenu_autoboot_loop(struct bootmenu_data *menu,
-- 
2.17.1



[PATCH v7 3/9] efimenu: add "Edit Boot Option" menu entry

2022-06-13 Thread Masahisa Kojima
This commit adds the menu entry to edit the existing
BOOT variable contents.
User selects the item from the boot option list, then
user can edit the description, file path and optional_data.

Note that automatically generated boot option entry by bootmenu
to suppport the removable media device is filtered out and user
can not edit the automatically generated entry.

Signed-off-by: Masahisa Kojima 
---
Newly created in v7

 cmd/efimenu.c | 170 ++
 1 file changed, 170 insertions(+)

diff --git a/cmd/efimenu.c b/cmd/efimenu.c
index fce08900db..918e9dffa2 100644
--- a/cmd/efimenu.c
+++ b/cmd/efimenu.c
@@ -1190,6 +1190,175 @@ out:
return ret;
 }
 
+static efi_status_t efimenu_process_boot_selected(void *data)
+{
+   struct efimenu_boot_selection_data *info = data;
+
+   if (info)
+   *info->selected = info->bootorder_index;
+
+   return EFI_SUCCESS;
+}
+
+static efi_status_t efimenu_show_boot_selection(u16 *bootorder, efi_uintn_t 
count,
+   int *selected)
+{
+   u32 i;
+   efi_status_t ret;
+   efi_uintn_t size, actual_count = 0;
+   void *load_option;
+   struct efi_load_option lo;
+   u16 varname[] = u"Boot";
+   struct efimenu_item *menu_item, *iter;
+
+   menu_item = calloc(count + 1, sizeof(struct efimenu_item));
+   if (!menu_item) {
+   ret = EFI_OUT_OF_RESOURCES;
+   goto out;
+   }
+
+   iter = menu_item;
+   for (i = 0; i < count; i++) {
+   efi_create_indexed_name(varname, sizeof(varname),
+   "Boot", bootorder[i]);
+   load_option = efi_get_var(varname, _global_variable_guid, 
);
+   if (!load_option)
+   continue;
+
+   ret = efi_deserialize_load_option(, load_option, );
+   if (ret != EFI_SUCCESS) {
+   log_warning("Invalid load option for %ls\n", varname);
+   free(load_option);
+   continue;
+   }
+
+   if (size >= sizeof(efi_guid_t) &&
+   !guidcmp(lo.optional_data, 
_guid_bootmenu_auto_generated)) {
+   /*
+* auto generated entry has GUID in optional_data,
+* skip auto generated entry because it will be 
generated
+* again even if it is edited or deleted.
+*/
+   free(load_option);
+   continue;
+   }
+
+   if (lo.attributes & LOAD_OPTION_ACTIVE) {
+   char *buf, *p;
+   struct efimenu_boot_selection_data *info;
+
+   info = calloc(1, sizeof(struct 
efimenu_boot_selection_data));
+   if (!info) {
+   free(load_option);
+   ret = EFI_OUT_OF_RESOURCES;
+   goto out;
+   }
+
+   buf = calloc(1, utf16_utf8_strlen(lo.label) + 1);
+   if (!buf) {
+   free(load_option);
+   free(info);
+   ret = EFI_OUT_OF_RESOURCES;
+   goto out;
+   }
+   p = buf;
+   utf16_utf8_strcpy(, lo.label);
+   info->bootorder_index = i;
+   info->selected = selected;
+   iter->title = buf;
+   iter->func = efimenu_process_boot_selected;
+   iter->data = info;
+   iter++;
+   actual_count++;
+   }
+   free(load_option);
+   }
+
+   /* add "Quit" entry */
+   iter->title = strdup("Quit");
+   iter->func = efimenu_process_quit;
+   iter->data = NULL;
+   actual_count += 1;
+
+   ret = efimenu_process_common(menu_item, actual_count, "  ** Select Boot 
Order **");
+
+out:
+   iter = menu_item;
+   for (i = 0; i < actual_count; i++, iter++) {
+   free(iter->title);
+   free(iter->data);
+   }
+
+   free(menu_item);
+
+   return ret;
+}
+
+static efi_status_t efimenu_process_edit_boot_option(void *data)
+{
+   u16 *bootorder;
+   efi_status_t ret;
+   efi_uintn_t num, size;
+   struct efimenu_boot_option *bo = NULL;
+
+   bootorder = efi_get_var(u"BootOrder", _global_variable_guid, );
+   if (!bootorder) {
+   ret = EFI_NOT_FOUND;
+   return ret;
+   }
+
+   num = size / sizeof(u16);
+   while (1) {
+   int selected;
+   void *load_option;
+   struct efi_load_option lo;
+   u16 varname[] = u"Boot";
+
+ 

[PATCH v7 1/9] efi_loader: expose END device path node

2022-06-13 Thread Masahisa Kojima
This commit exposes the END device path node.

Signed-off-by: Masahisa Kojima 
---
Newly created in v7

 include/efi_loader.h | 3 +++
 lib/efi_loader/efi_device_path.c | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/efi_loader.h b/include/efi_loader.h
index f6651e2c60..c6df29993c 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -798,6 +798,9 @@ ssize_t efi_dp_check_length(const struct efi_device_path 
*dp,
(((_dp)->type == DEVICE_PATH_TYPE_##_type) && \
 ((_dp)->sub_type == DEVICE_PATH_SUB_TYPE_##_subtype))
 
+/* template END node: */
+extern const struct efi_device_path END;
+
 /* Indicate supported runtime services */
 efi_status_t efi_init_runtime_supported(void);
 
diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index 50a988c561..4798cec622 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -30,7 +30,7 @@ const efi_guid_t efi_guid_virtio_dev = U_BOOT_VIRTIO_DEV_GUID;
 #endif
 
 /* template END node: */
-static const struct efi_device_path END = {
+const struct efi_device_path END = {
.type = DEVICE_PATH_TYPE_END,
.sub_type = DEVICE_PATH_SUB_TYPE_END,
.length   = sizeof(END),
-- 
2.17.1



[PATCH v7 0/9] enable menu-driven UEFI variable maintenance

2022-06-13 Thread Masahisa Kojima
This series add the menu-driven UEFI boot variable maintenance
and removable media support in bootmenu.

Different from previous version, thie series adds a new U-Boot
command "efimenu" to invoke the UEFI boot-related variable
maintenance menu.

Note that menu-driven UEFI Secure Boot key management patch series
will follow.

[Major Changes]
- rebased to v2022.07-rc4
- there is detailed changelog in each commit

Masahisa Kojima (9):
  efi_loader: expose END device path node
  efimenu: menu-driven addition of UEFI boot option
  efimenu: add "Edit Boot Option" menu entry
  menu: add KEY_PLUS and KEY_MINUS handling
  efimenu: add "Change Boot Order" menu entry
  efimenu: add "Delete Boot Option" menu entry
  bootmenu: add removable media entries
  doc:bootmenu: add description for UEFI boot support
  doc:efimenu: add documentation for efimenu command

 cmd/Kconfig  |7 +
 cmd/Makefile |1 +
 cmd/bootmenu.c   |   99 +-
 cmd/efimenu.c| 1824 ++
 common/menu.c|6 +
 doc/usage/cmd/bootmenu.rst   |   74 ++
 doc/usage/cmd/efimenu.rst|   50 +
 doc/usage/index.rst  |1 +
 include/efi_loader.h |   63 ++
 include/efi_menu.h   |   91 ++
 include/menu.h   |2 +
 lib/efi_loader/efi_boottime.c|   52 +-
 lib/efi_loader/efi_console.c |   78 ++
 lib/efi_loader/efi_device_path.c |2 +-
 lib/efi_loader/efi_disk.c|   11 +
 lib/efi_loader/efi_file.c|   75 +-
 16 files changed, 2385 insertions(+), 51 deletions(-)
 create mode 100644 cmd/efimenu.c
 create mode 100644 doc/usage/cmd/efimenu.rst
 create mode 100644 include/efi_menu.h

-- 
2.17.1



Re: [SPAM] Re: [PATCH v2] xilinx: zynqmp: Do not use 0 as spl bss start address

2022-06-13 Thread Stefan Herbrechtsmeier

Hi Michal,

Am 13.06.2022 um 10:21 schrieb Stefan Herbrechtsmeier:

Hi Michal,

Am 13.06.2022 um 09:20 schrieb Michal Simek:

Hi,

On 6/10/22 18:48, Xavier Drudis Ferran wrote:

El Fri, Jun 10, 2022 at 04:42:55PM +0200, Stefan Herbrechtsmeier deia:

Hi Michal,

what is the default entry address for the aft / bl31.bin?

I have a bl31.bin with an entry address of 0x1000 and this is inside 
the

BSS.



Me too, load address at 0x1000, but for me in SPL text, not BSS.

I have a litle customized, a little old TF-A  for rk3399 / Rock pi 4
loading at address 0 with entry at 0x1000.

But include/configs/rk3399_common.h sets my
CONFIG_SPL_BSS_START_ADDR=0x40, away from harm.
I had problems booting anyway.

Now I can load U-Boot from MMC with these patches
https://lists.denx.de/pipermail/u-boot/2022-June/485497.html

In particular
CONFIG_ROCKCHIP_SPL_RESERVE_IRAM=0x15000

This is defined in arch/arm/mach-rockchip/Kconfig and says it's
to avoid conflicts with SPL text area, not BSS

But I found other boards with CONFIG_ROCKCHIP_SPL_RESERVE_IRAM=0x4000,
so I thought some low addresses where normal. I don't know.

I had to modify the code loading from SPI because, unlike MMC code, it
thought address 0 meant no destination (I can send those patches when
I have them cleaner if anyone wants them).

I just realised that I have CONFIG_SPL_TEXT_BASE=0x0.  I'm not finding
where that's defined, maybe it's simply because it's not defined
anywhere, so maybe the solution for me would be setting 
CONFIG_SPL_TEXT_BASE

to 0x1000 or something. Or maybe it needs to be at 0x0 because
it is bootrom who is loading it, and it won't look where I define it?
I can't remember whether I tried this.

Maybe you can try to look at the size of a file bl31_0x.bin
that is generated when you build U-boot with BL31 pointing at your
bl31.elf (check u-boot.its if that's not the name for you).

Then set CONFIG_SPL_BSS_START_ADDR to that size + L (L= value of load 
property

in entry atf_1 of u-boot.its). This should leave a hole at the beginning
of U-Boot to make room for your TF-A, and leave BSS elsewhere.

The sources and build scripts for TF-A are public, so maybe one could
look at what's the criteria for putting images at different addresses?



I have no idea what rockchip has to do with memory layout on zynqmp.
Anyway SPL must be placed to OCM that's why text base is at 0xfffc 
where OCM starts and which is also default address where a53s starts.


TF-A can be placed to any address but address which I use in SPL flow 
is 0xfffe5000. PetaLinux which uses FSBL is using different address 
0xfffea000 which is default in TF-A.

In DDR I normally use end of low ddr locations. It means 0x7fxx.

And of course you can't place TFA to location which is used by SPL or 
by u-boot or other SW.


Thanks for the information. I will check why our TF-A is linked to the 
lower DDR and move it back to the default address.


The TF-A was build with debug flag [1]:

> By default, the Arm-trusted firmware builds for OCM space at address
> 0xFFFEA000. But, with DEBUG flag set to 1, it can't fit in OCM, so by
> default with DEBUG=1, it builds for DDR location 0x1000 with build
> flag DEBUG=1 mentioned while building.

Either the CONFIG_SPL_BSS_START_ADDR or the default location of the TF-A 
with DEBUG flag should be changed.


[1] 
https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842107/Arm+Trusted+Firmware


Regards
  Stefan


Re: [SPAM] Re: [PATCH v2] xilinx: zynqmp: Do not use 0 as spl bss start address

2022-06-13 Thread Stefan Herbrechtsmeier

Hi Michal,

Am 13.06.2022 um 09:20 schrieb Michal Simek:

Hi,

On 6/10/22 18:48, Xavier Drudis Ferran wrote:

El Fri, Jun 10, 2022 at 04:42:55PM +0200, Stefan Herbrechtsmeier deia:

Hi Michal,

what is the default entry address for the aft / bl31.bin?

I have a bl31.bin with an entry address of 0x1000 and this is inside the
BSS.



Me too, load address at 0x1000, but for me in SPL text, not BSS.

I have a litle customized, a little old TF-A  for rk3399 / Rock pi 4
loading at address 0 with entry at 0x1000.

But include/configs/rk3399_common.h sets my
CONFIG_SPL_BSS_START_ADDR=0x40, away from harm.
I had problems booting anyway.

Now I can load U-Boot from MMC with these patches
https://lists.denx.de/pipermail/u-boot/2022-June/485497.html

In particular
CONFIG_ROCKCHIP_SPL_RESERVE_IRAM=0x15000

This is defined in arch/arm/mach-rockchip/Kconfig and says it's
to avoid conflicts with SPL text area, not BSS

But I found other boards with CONFIG_ROCKCHIP_SPL_RESERVE_IRAM=0x4000,
so I thought some low addresses where normal. I don't know.

I had to modify the code loading from SPI because, unlike MMC code, it
thought address 0 meant no destination (I can send those patches when
I have them cleaner if anyone wants them).

I just realised that I have CONFIG_SPL_TEXT_BASE=0x0.  I'm not finding
where that's defined, maybe it's simply because it's not defined
anywhere, so maybe the solution for me would be setting 
CONFIG_SPL_TEXT_BASE

to 0x1000 or something. Or maybe it needs to be at 0x0 because
it is bootrom who is loading it, and it won't look where I define it?
I can't remember whether I tried this.

Maybe you can try to look at the size of a file bl31_0x.bin
that is generated when you build U-boot with BL31 pointing at your
bl31.elf (check u-boot.its if that's not the name for you).

Then set CONFIG_SPL_BSS_START_ADDR to that size + L (L= value of load 
property

in entry atf_1 of u-boot.its). This should leave a hole at the beginning
of U-Boot to make room for your TF-A, and leave BSS elsewhere.

The sources and build scripts for TF-A are public, so maybe one could
look at what's the criteria for putting images at different addresses?



I have no idea what rockchip has to do with memory layout on zynqmp.
Anyway SPL must be placed to OCM that's why text base is at 0xfffc 
where OCM starts and which is also default address where a53s starts.


TF-A can be placed to any address but address which I use in SPL flow is 
0xfffe5000. PetaLinux which uses FSBL is using different address 
0xfffea000 which is default in TF-A.

In DDR I normally use end of low ddr locations. It means 0x7fxx.

And of course you can't place TFA to location which is used by SPL or by 
u-boot or other SW.


Thanks for the information. I will check why our TF-A is linked to the 
lower DDR and move it back to the default address.


Regards
  Stefan


Re: [SPAM] Re: [PATCH v2] xilinx: zynqmp: Do not use 0 as spl bss start address

2022-06-13 Thread Michal Simek

Hi,

On 6/10/22 18:48, Xavier Drudis Ferran wrote:

El Fri, Jun 10, 2022 at 04:42:55PM +0200, Stefan Herbrechtsmeier deia:

Hi Michal,

what is the default entry address for the aft / bl31.bin?

I have a bl31.bin with an entry address of 0x1000 and this is inside the
BSS.



Me too, load address at 0x1000, but for me in SPL text, not BSS.

I have a litle customized, a little old TF-A  for rk3399 / Rock pi 4
loading at address 0 with entry at 0x1000.

But include/configs/rk3399_common.h sets my
CONFIG_SPL_BSS_START_ADDR=0x40, away from harm.
I had problems booting anyway.

Now I can load U-Boot from MMC with these patches
https://lists.denx.de/pipermail/u-boot/2022-June/485497.html

In particular
CONFIG_ROCKCHIP_SPL_RESERVE_IRAM=0x15000

This is defined in arch/arm/mach-rockchip/Kconfig and says it's
to avoid conflicts with SPL text area, not BSS

But I found other boards with CONFIG_ROCKCHIP_SPL_RESERVE_IRAM=0x4000,
so I thought some low addresses where normal. I don't know.

I had to modify the code loading from SPI because, unlike MMC code, it
thought address 0 meant no destination (I can send those patches when
I have them cleaner if anyone wants them).

I just realised that I have CONFIG_SPL_TEXT_BASE=0x0.  I'm not finding
where that's defined, maybe it's simply because it's not defined
anywhere, so maybe the solution for me would be setting CONFIG_SPL_TEXT_BASE
to 0x1000 or something. Or maybe it needs to be at 0x0 because
it is bootrom who is loading it, and it won't look where I define it?
I can't remember whether I tried this.

Maybe you can try to look at the size of a file bl31_0x.bin
that is generated when you build U-boot with BL31 pointing at your
bl31.elf (check u-boot.its if that's not the name for you).

Then set CONFIG_SPL_BSS_START_ADDR to that size + L (L= value of load property
in entry atf_1 of u-boot.its). This should leave a hole at the beginning
of U-Boot to make room for your TF-A, and leave BSS elsewhere.

The sources and build scripts for TF-A are public, so maybe one could
look at what's the criteria for putting images at different addresses?



I have no idea what rockchip has to do with memory layout on zynqmp.
Anyway SPL must be placed to OCM that's why text base is at 0xfffc where OCM 
starts and which is also default address where a53s starts.


TF-A can be placed to any address but address which I use in SPL flow is 
0xfffe5000. PetaLinux which uses FSBL is using different address 0xfffea000 
which is default in TF-A.

In DDR I normally use end of low ddr locations. It means 0x7fxx.

And of course you can't place TFA to location which is used by SPL or by u-boot 
or other SW.


Thanks,
Michal


--
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs



Pull request for efi-2022-07-rc5

2022-06-13 Thread Heinrich Schuchardt



Dear Tom,

The following changes since commit 57bd363de7b95bececd40a0c8dbb2fcf4d8d3b21:

  Merge https://source.denx.de/u-boot/custodians/u-boot-usb (2022-06-08
08:25:30 -0400)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-efi.git
tags/efi-2022-07-rc5

for you to fetch changes up to 72fa9cd59edcf99cb32c05604d2a904018acd30a:

  efi_loader: create boot options without file path (2022-06-12
13:02:34 +0200)

Gitlab reported no issues:
https://source.denx.de/u-boot/custodians/u-boot-efi/-/pipelines/12278


Pull request for efi-2022-07-rc5

UEFI:

* Ignore OsIndications if CONFIG_EFI_IGNORE_OSINDICATIONS=y
* Correct UEFI default binary name
* Let efidebug create boot options without file path
* Support booting with a boot option with shortened device only device path


Heinrich Schuchardt (3):
  efi_loader: correctly identify binary name
  efi_loader: allow booting from short dev only DP
  efi_loader: create boot options without file path

Sughosh Ganu (2):
  EFI: Do not consider OsIndications variable if
CONFIG_EFI_IGNORE_OSINDICATIONS is enabled
  EFI: FMP: Use a common GetImageInfo function for FIT and raw images

 include/efi_default_filename.h   | 41 
 lib/efi_loader/efi_bootmgr.c | 12 +++---
 lib/efi_loader/efi_capsule.c |  7 ++--
 lib/efi_loader/efi_device_path.c | 33 -
 lib/efi_loader/efi_firmware.c| 80
+++-
 5 files changed, 73 insertions(+), 100 deletions(-)