Re: [PATCH 2/2] imx93_evk: enable ADC

2023-02-23 Thread Luca Ellero

On 23/02/2023 15:05, Fabio Estevam wrote:

Hi Luca,

On Thu, Feb 23, 2023 at 9:52 AM Luca Ellero  wrote:

Please write a commit log.


Signed-off-by: Luca Ellero 
---
  arch/arm/dts/imx93-11x11-evk.dts  | 4 
  configs/imx93_11x11_evk_defconfig | 1 +
  2 files changed, 5 insertions(+)

diff --git a/arch/arm/dts/imx93-11x11-evk.dts b/arch/arm/dts/imx93-11x11-evk.dts
index b3a5a3d71e..f7ffe7b3d2 100644
--- a/arch/arm/dts/imx93-11x11-evk.dts
+++ b/arch/arm/dts/imx93-11x11-evk.dts
@@ -525,3 +525,7 @@
  &wdog3 {
 status = "okay";
  };
+
+&adc1 {
+   status = "okay";
+};


The nodes should be kept in alphabetical order.

Actually, it would be better if you could sync imx93-11x11-evk.dts
with linux-next, which already contains the adc1 node:

https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/arch/arm64/boot/dts/freescale/imx93-11x11-evk.dts?h=next-20230223#n37

We want to keep U-Boot and Linux devicetree in sync as much as possible.

Thanks


Hi Fabio,
thank you for your reply.
Ok, I will add a comment to the patch and fix DT node.
Should I resend only this patch or both?
Regards

--
Luca Ellero

E-mail: luca.ell...@brickedbrain.com
Internet: www.brickedbrain.com




Re: [PATCH v2 2/2] xilinx: zynqmp: Add missing prototype for board_boot_order

2023-02-23 Thread Michal Simek

Hi,


On 2/24/23 05:53, Ashok Reddy Soma wrote:

From: Algapally Santosh Sagar 

Add missing prototype to fix the sparse warning, warning: no
previous prototype for 'board_boot_order' [-Wmissing-prototypes].

Signed-off-by: Algapally Santosh Sagar 
Signed-off-by: Ashok Reddy Soma 
---

Changes in v2:
  - Moved function prototype from sys_proto.h to include/spl.h

  include/spl.h | 1 +
  1 file changed, 1 insertion(+)

diff --git a/include/spl.h b/include/spl.h
index 827bd25c88..bad12fb01f 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -884,5 +884,6 @@ void spl_perform_fixups(struct spl_image_info *spl_image);
   */
  struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size);
  
+void board_boot_order(u32 *spl_boot_list);

  void spl_save_restore_data(void);
  #endif


The patch is fine but subject not.

Should be something like

spl: Add missing prototype for board_boot_order

M


Re: [PATCH 2/3] rockchip: rk356x: update the dwc3_device register offset

2023-02-23 Thread Jagan Teki
On Thu, Feb 23, 2023 at 10:06 PM Manoj Sai
 wrote:
>
> update the dwc3_device register offset in board_usb_init()
> for rk3568 platforms.
>
> Signed-off-by: Manoj Sai 
> ---

Reviewed-by: Jagan Teki 


Re: [PATCH 3/3] rk3566: radxa-cm3: Enable USB OTG

2023-02-23 Thread Jagan Teki
On Thu, Feb 23, 2023 at 10:06 PM Manoj Sai
 wrote:
>
> Enable USB OTG support and update the fastboot buffer address
> for Radxa Compute Module 3 IO Board.
>
> This would help to use fastboot by default.
>
> Signed-off-by: Manoj Sai 
> ---
>  configs/radxa-cm3-io-rk3566_defconfig | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/configs/radxa-cm3-io-rk3566_defconfig 
> b/configs/radxa-cm3-io-rk3566_defconfig
> index 2100cf2cb2..4d2acef6cd 100644
> --- a/configs/radxa-cm3-io-rk3566_defconfig
> +++ b/configs/radxa-cm3-io-rk3566_defconfig
> @@ -21,6 +21,7 @@ CONFIG_DEBUG_UART_BASE=0xFE66
>  CONFIG_DEBUG_UART_CLOCK=2400
>  CONFIG_SYS_LOAD_ADDR=0xc00800
>  CONFIG_DEBUG_UART=y
> +# CONFIG_ANDROID_BOOT_IMAGE is not set
>  CONFIG_FIT=y
>  CONFIG_FIT_VERBOSE=y
>  CONFIG_SPL_LOAD_FIT=y
> @@ -47,6 +48,7 @@ CONFIG_NET_RANDOM_ETHADDR=y
>  CONFIG_SPL_REGMAP=y
>  CONFIG_SPL_SYSCON=y
>  CONFIG_SPL_CLK=y
> +CONFIG_FASTBOOT_BUF_ADDR=0xc00800

was this address used in bsp or used load addr? add it in
drivers/fastboot/Kconfig

Jagan.


Re: Boot from 64-bit memory address?

2023-02-23 Thread Rick Chen
Hi Philip,

> From: U-Boot  On Behalf Of Bernard, Philip
> Sent: Thursday, February 23, 2023 9:21 AM
> To: u-boot@lists.denx.de
> Subject: Boot from 64-bit memory address?
>
> Hi,
>
> Is it possible to boot from a DRAM memory address beyond the 32-bit boundary? 
> I'm trying to configure a new RISC-V board which has 2GB of DRAM starting at 
> offset 0x40__. I started from the settings for an existing RISC-V 
> board and made

I think it is possible to boot from a DRAM memory beyond the 32-bit
boundary. But maybe you need to modify some code to achieve that.
I have tried to boot an internal AE350-like platform whose DRAM base
is at 0x4.

adjustments for my HW, but when I try to boot, I run into an "out of
memory" error.
>
> From 
> https://u-boot.readthedocs.io/en/latest/develop/uefi/u-boot_on_efi.html#tables
>  I noticed that U-Boot will only use "conventional" memory which is 4GB and 
> below, so it seems like this may not be possible? Looking through the repo, I 
> also noticed that nearly every device is configuring settings like 
> CONFIG_SYS_LOAD_ADDR with a 32-bit value, so I haven't found any examples to 
> emulate for my use case.

CONFIG_SYS_LOAD_ADDR is not important. Maybe you shall notice
CONFIG_SYS_TEXT_BASE and CONFIG_SPL_OPENSBI_LOAD_ADDR which will be
parsed from binman.dtsi
You can change them like this:
load = /bits/64 ;
load = /bits/64 ;

>
> I'm hoping someone knows the mistake I'm making or can confirm that this 
> isn't possible. Appreciate the help.
>
> Best,
> Phil
>
>
> Below is the output from U-Boot:
>
> U-Boot SPL 2022.07 (Feb 23 2023 - 00:50:44 +) Trying to boot from RAM
>
> OpenSBI v1.1
>_  _
>   / __ \  / |  _ \_   _|
> | |  | |_ __   ___ _ __ | (___ | |_) || |
> | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | | __| | |_) |  __/ | | |) |
> | ||_) || |_
>   \/| .__/ \___|_| |_|_/|/_|
> | |
> |_|
>
> Platform Name : test,test
> Platform Features : medeleg
> Platform HART Count   : 1
> Platform IPI Device   : aclint-mswi
> Platform Timer Device : aclint-mtimer @ 100Hz
> Platform Console Device   : uart8250
> Platform HSM Device   : ---
> Platform Reboot Device: ---
> Platform Shutdown Device  : ---
> Firmware Base : 0x8000
> Firmware Size : 276 KB
> Runtime SBI Version   : 1.0
>
> Domain0 Name  : root
> Domain0 Boot HART : 0
> Domain0 HARTs : 0*
> Domain0 Region00  : 0x0200-0x0200 (I)
> Domain0 Region01  : 0x8000-0x8007 ()
> Domain0 Region02  : 0x-0x (R,W,X)
> Domain0 Next Address  : 0x00400120
> Domain0 Next Arg1 : 0x004001267830
> Domain0 Next Mode : S-mode
> Domain0 SysReset  : yes
>
> Boot HART ID  : 0
> Boot HART Domain  : root
> Boot HART Priv Version: v1.10
> Boot HART Base ISA: rv64imafdcb
> Boot HART ISA Extensions  : time
> Boot HART PMP Count   : 8
> Boot HART PMP Granularity : 4
> Boot HART PMP Address Bits: 54
> Boot HART MHPM Count  : 0
> Boot HART MIDELEG : 0x0222
> Boot HART MEDELEG : 0xb109
>
>
> U-Boot 2022.07 (Feb 23 2023 - 00:50:44 +)
>
> CPU:   rv64imafdc
> Model: test,test
> DRAM:  2 GiB
> Core:  11 devices, 8 uclasses, devicetree: separate
> ERROR: Out of memory
> Loading Environment from nowhere... OK
> In:serial@13140
> Out:   serial@13140
> Err:   serial@13140
> Model: test,test
> Net:   No ethernet found.
> Hit any key to stop autoboot:  0
> Moving Image from 0x400600 to 0x400020, end=4000b01c8c ## Flattened 
> Device Tree blob at ff76a1d0
>Booting using the fdt blob at 0xff76a1d0
> ERROR: Failed to allocate 0x100 bytes below 0x1.

Can you dig in where to print this ERROR ?

Thanks,
Rick

> ramdisk - allocation error


Re: [PATCH RFC u-boot-mvebu 00/59] arm: mvebu: Various fixes

2023-02-23 Thread Martin Rowe
> > boot0 - zeroed
> > boot1 - u-boot (with local version 'boot1')
> > user - u-boot (with local version 'user')
> Can you check if boot_ack argument has some effect on the initial
> choice? Or if completely disabling boot partitions (boot_enable to 0)
> have some effect?

boot_ack doesn't appear to do anything. I can only set 0 or 1 and
there's no noticeable change to the boot process.

Setting `mmc partconf 0 0 0 0` with the same setup as described above
results in the same BootROM fallback from BOOT0 to BOOT1, then SPL in
BOOT1 loads u-boot from the user area, which is identical to the `mmc
partconf 0 0 7 0` flow.

> If really EXT_CSD[179] register is completely ignored we may change SPL
> to always boot from BOOT0 (when eMMC with boot partitions is used) and
> if it fails then fallback to BootROM booting.

Is there a way of knowing where the SPL was loaded from? Because it
would make sense to me that if SPL was loaded from BOOT1 to try and
load u-boot from BOOT1 as well, or from BOOT0 if SPL was loaded from
BOOT0, etc. Having u-boot loaded from a different location is not what
I expected and seems like it would cause a lot of confusion,
especially in a failed A/B rollout. BootROM seems to completely ignore
the setting, so I agree that SPL should ignore it as well, but
hardcoding BOOT0 (or even setting the partition as a compile-time
option) is probably not a great outcome.

Two observations that might help here:
1. After reset, running `mmc partconf 0` always shows PARTITION_ACCESS
is set to 0x0, even it it was set to something else prior to reset
2. With the same setup as described above and `mmc partconf 0 0 1 1`
the SPL eventually times out trying to load from the zeroed BOOT0 and
returns to BootROM, which results in u-boot being loaded from BOOT1:
=
BootROM - 1.73

Booting from MMC
BootROM: Bad header at offset 
BootROM: Bad header at offset 0020
Switching BootPartitions.

U-Boot SPL 2023.04-rc2boot1-00098-g93408c61cd-dirty (Feb 23 2023 -
19:43:59 +1000)
High speed PHY - Version: 2.0
EEPROM TLV detection failed: Using static config for Clearfog Pro.
Detected Device ID 6828
board SerDes lanes topology details:
 | Lane # | Speed |  Type   |
 
 |   0|   3   | SATA0   |
 |   1|   0   | SGMII1  |
 |   2|   5   | PCIe1   |
 |   3|   5   | USB3 HOST1  |
 |   4|   5   | PCIe2   |
 |   5|   0   | SGMII2  |
 
High speed PHY - Ended Successfully
mv_ddr: 14.0.0
DDR3 Training Sequence - Switching XBAR Window to FastPath Window
mv_ddr: completed successfully
Trying to boot from MMC1
ERROR: Invalid kwbimage v1
mmc_load_image_raw_sector: mmc block read error
spl: mmc: wrong boot mode
Trying to boot from BOOTROM
Returning to BootROM (return address 0x05c4)...
Timeout waiting card ready
BootROM: Image checksum verification PASSED


U-Boot 2023.04-rc2boot1-00098-g93408c61cd-dirty (Feb 23 2023 - 19:43:59 +1000)

SoC:   MV88F6828-A0 at 1600 MHz
DRAM:  1 GiB (800 MHz, 32-bit, ECC not enabled)
Core:  38 devices, 22 uclasses, devicetree: separate
MMC:   mv_sdh: 0
Loading Environment from MMC... *** Warning - bad CRC, using default environment

Model: SolidRun Clearfog A1
Board: SolidRun Clearfog Pro
Net:
Warning: ethernet@7 (eth1) using random MAC address - be:13:3f:c3:c2:19
eth1: ethernet@7
Warning: ethernet@3 (eth2) using random MAC address - be:4c:72:3e:eb:bc
, eth2: ethernet@3
Warning: ethernet@34000 (eth3) using random MAC address - 86:e7:dd:8d:c5:c1
, eth3: ethernet@34000
Hit any key to stop autoboot:  0
=>
=

> Seems that something in mmc initialization code is buggy. You can try to
> debug it by starting disabling parts of initialization code until you
> find the line/function which makes those BootROM messages "Timeout for
> status update!".

> Hm... Yes, "offset" string is not in your output, so that function is
> not called in SPL. Only in main U-Boot.
>
> What is in SPL called is board_early_init_f() function or
> fdtdec_board_setup() function or also board_late_init() function.
> Pointer to blob is in global variable gd->fdt_blob.
>
> Note that adding new properties/nodes into fdt blob may fail. So always
> check for return values of fdt_*() function! You would probably need to
> call fdt_increase_size() first to make a place for new properties.

> Yes, it has a hook. It is called ft_board_setup() and is called
> immediately before booting linux kernel. Basically in this hook you
> should check if u-boot's blob was patched for eMMC and if yes then patch
> also blob passed as argument in that function, as this blob would be
> used for linux. See Turris Omnia hook for inspiration which fixups
> ethernet node for linux blob based on what is in u-boot blob:
> https://source.denx.de/u-boot/u-boot/-/blob/master/board/CZ.NIC/turris_omnia/turris_omnia.c

Lots of great ideas to look

Re: [PATCH v1] configs: j7200: Merge HS and non-HS defconfigs

2023-02-23 Thread Manorit Chawdhry
On 17:28-20230223, Tom Rini wrote:
> On Wed, Feb 22, 2023 at 09:02:12AM -0600, Andrew Davis wrote:
> > On 2/22/23 1:56 AM, Manorit Chawdhry wrote:
> > > K3 devices have runtime type board detection. Make the default defconfig
> > > include the secure configuration. Then remove the HS specific config.
> > > 
> > > Non-HS devices will continue to boot due to runtime device type detection.
> > > If TI_SECURE_DEV_PKG is not set the build will emit warnings, for non-HS
> > > devices these can be ignored.
> > > 
> > > Signed-off-by: Manorit Chawdhry 
> > > ---
> > 
> > This will help with keeping the HS and non-HS configs in sync :)
> > 
> > Acked-by: Andrew Davis 
> 
> Please re-spin both of these to update the MAINTAINERS file as well.
> 

Hi Tom,

I've respinned the patches for both of them, j721e patch for the same is
in a separate series along with some other fixes required for the board.
I'll update the same there while sending a v2 based on other review
comments.

Regards,
Manorit

> -- 
> Tom




[PATCH v2 2/2] configs: j7200: Merge HS and non-HS defconfigs

2023-02-23 Thread Manorit Chawdhry
K3 devices have runtime type board detection. Make the default defconfig
include the secure configuration. Then remove the HS specific config.

Non-HS devices will continue to boot due to runtime device type detection.
If TI_SECURE_DEV_PKG is not set the build will emit warnings, for non-HS
devices these can be ignored.

Signed-off-by: Manorit Chawdhry 
Acked-by: Andrew Davis 
---
v1->v2:
update MAINTAINERS

 MAINTAINERS|   2 -
 configs/j7200_evm_a72_defconfig|   3 +-
 configs/j7200_evm_r5_defconfig |   1 +
 configs/j7200_hs_evm_a72_defconfig | 205 -
 configs/j7200_hs_evm_r5_defconfig  | 171 
 5 files changed, 3 insertions(+), 379 deletions(-)
 delete mode 100644 configs/j7200_hs_evm_a72_defconfig
 delete mode 100644 configs/j7200_hs_evm_r5_defconfig

diff --git a/MAINTAINERS b/MAINTAINERS
index bdea0704adc0..0516b36f5c16 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1453,8 +1453,6 @@ F:configs/k2g_hs_evm_defconfig
 F: configs/k2l_hs_evm_defconfig
 F: configs/am65x_hs_evm_r5_defconfig
 F: configs/am65x_hs_evm_a53_defconfig
-F: configs/j7200_hs_evm_a72_defconfig
-F: configs/j7200_hs_evm_r5_defconfig
 F: configs/j721e_hs_evm_a72_defconfig
 F: configs/j721e_hs_evm_r5_defconfig
 
diff --git a/configs/j7200_evm_a72_defconfig b/configs/j7200_evm_a72_defconfig
index 053f29b11f54..e588c4ada5cc 100644
--- a/configs/j7200_evm_a72_defconfig
+++ b/configs/j7200_evm_a72_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_ARCH_K3=y
+CONFIG_TI_SECURE_DEVICE=y
 CONFIG_SYS_MALLOC_LEN=0x200
 CONFIG_SYS_MALLOC_F_LEN=0x8000
 CONFIG_SPL_GPIO=y
@@ -32,7 +33,7 @@ CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_LOAD_FIT_ADDRESS=0x8100
 # CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_OF_BOARD_SETUP=y
-CONFIG_BOOTCOMMAND="run findfdt; run envboot; run init_${boot}; run 
boot_rprocs; run get_kern_${boot}; run get_fdt_${boot}; run 
get_overlay_${boot}; run run_kern"
+CONFIG_BOOTCOMMAND="run findfdt; run envboot; run init_${boot}; run 
boot_rprocs; if test ${boot_fit} -eq 1; then run get_fit_${boot}; run 
get_overlaystring; run run_fit; else; run get_kern_${boot}; run 
get_fdt_${boot}; run get_overlay_${boot}; run run_kern; fi;"
 CONFIG_LOGLEVEL=7
 CONFIG_SPL_MAX_SIZE=0xc
 CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
diff --git a/configs/j7200_evm_r5_defconfig b/configs/j7200_evm_r5_defconfig
index dc6c1b6935df..6fbc2e96321d 100644
--- a/configs/j7200_evm_r5_defconfig
+++ b/configs/j7200_evm_r5_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_ARCH_K3=y
+CONFIG_TI_SECURE_DEVICE=y
 CONFIG_SYS_MALLOC_LEN=0x200
 CONFIG_SYS_MALLOC_F_LEN=0x7
 CONFIG_SPL_GPIO=y
diff --git a/configs/j7200_hs_evm_a72_defconfig 
b/configs/j7200_hs_evm_a72_defconfig
deleted file mode 100644
index 782a42b74657..
--- a/configs/j7200_hs_evm_a72_defconfig
+++ /dev/null
@@ -1,205 +0,0 @@
-CONFIG_ARM=y
-CONFIG_ARCH_K3=y
-CONFIG_TI_SECURE_DEVICE=y
-CONFIG_SYS_MALLOC_LEN=0x200
-CONFIG_SYS_MALLOC_F_LEN=0x8000
-CONFIG_SPL_GPIO=y
-CONFIG_SPL_LIBCOMMON_SUPPORT=y
-CONFIG_SPL_LIBGENERIC_SUPPORT=y
-CONFIG_NR_DRAM_BANKS=2
-CONFIG_SOC_K3_J721E=y
-CONFIG_TARGET_J7200_A72_EVM=y
-CONFIG_ENV_SIZE=0x2
-CONFIG_ENV_OFFSET=0x68
-CONFIG_DM_GPIO=y
-CONFIG_SPL_DM_SPI=y
-CONFIG_DEFAULT_DEVICE_TREE="k3-j7200-common-proc-board"
-CONFIG_SPL_TEXT_BASE=0x8008
-CONFIG_SPL_MMC=y
-CONFIG_SPL_SERIAL=y
-CONFIG_SPL_DRIVERS_MISC=y
-CONFIG_SPL_STACK_R_ADDR=0x8200
-CONFIG_ENV_OFFSET_REDUND=0x6A
-CONFIG_SPL_FS_FAT=y
-CONFIG_SPL_LIBDISK_SUPPORT=y
-CONFIG_SPL_SPI_FLASH_SUPPORT=y
-CONFIG_SPL_SPI=y
-# CONFIG_PSCI_RESET is not set
-CONFIG_DISTRO_DEFAULTS=y
-CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
-CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x8048
-# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
-CONFIG_SPL_LOAD_FIT=y
-CONFIG_SPL_LOAD_FIT_ADDRESS=0x8100
-# CONFIG_USE_SPL_FIT_GENERATOR is not set
-CONFIG_OF_BOARD_SETUP=y
-CONFIG_BOOTCOMMAND="run findfdt; run envboot; run init_${boot}; run 
boot_rprocs; run get_fit_${boot}; run get_overlaystring; run run_fit"
-CONFIG_LOGLEVEL=7
-CONFIG_SPL_MAX_SIZE=0xc
-CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
-CONFIG_SPL_BSS_START_ADDR=0x80a0
-CONFIG_SPL_BSS_MAX_SIZE=0x8
-CONFIG_SPL_BOARD_INIT=y
-CONFIG_SPL_SYS_MALLOC_SIMPLE=y
-CONFIG_SPL_STACK_R=y
-CONFIG_SYS_SPL_MALLOC=y
-CONFIG_SYS_SPL_MALLOC_SIZE=0x80
-CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
-CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x1400
-CONFIG_SPL_DMA=y
-CONFIG_SPL_ENV_SUPPORT=y
-CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="u-boot.img"
-CONFIG_SPL_I2C=y
-CONFIG_SPL_DM_MAILBOX=y
-CONFIG_SPL_MTD_SUPPORT=y
-CONFIG_SPL_DM_SPI_FLASH=y
-CONFIG_SPL_NOR_SUPPORT=y
-CONFIG_SPL_DM_RESET=y
-CONFIG_SPL_POWER_DOMAIN=y
-CONFIG_SPL_RAM_SUPPORT=y
-CONFIG_SPL_RAM_DEVICE=y
-# CONFIG_SPL_SPI_FLASH_TINY is not set
-CONFIG_SPL_SPI_FLASH_SFDP_SUPPORT=y
-CONFIG_SPL_SPI_LOAD=y
-CONFIG_SYS_SPI_U_BOOT_OFFS=0x28
-CONFIG_SPL_USB_GADGET=y
-CONFIG_SPL_DFU=y
-CONFIG_SPL_YMODEM_SUPPORT=y
-CONFIG_SYS_MAXARGS

[PATCH v2 1/2] configs: j721s2: merge HS and non-HS defconfigs

2023-02-23 Thread Manorit Chawdhry
K3 devices have runtime type board detection. Make the default defconfig
include the secure configuration. Then remove the HS specific config.

Non-HS devices will continue to boot due to runtime device type detection.
If TI_SECURE_DEV_PKG is not set the build will emit warnings, for non-HS
devices these can be ignored.

Signed-off-by: Manorit Chawdhry 
Acked-by: Andrew Davis 
---
v1->v2:
update MAINTAINERS

 MAINTAINERS |   2 -
 configs/j721s2_evm_a72_defconfig|   3 +-
 configs/j721s2_evm_r5_defconfig |   1 +
 configs/j721s2_hs_evm_a72_defconfig | 213 
 configs/j721s2_hs_evm_r5_defconfig  | 176 ---
 5 files changed, 3 insertions(+), 392 deletions(-)
 delete mode 100644 configs/j721s2_hs_evm_a72_defconfig
 delete mode 100644 configs/j721s2_hs_evm_r5_defconfig

diff --git a/MAINTAINERS b/MAINTAINERS
index b9c505d5faa7..bdea0704adc0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1457,8 +1457,6 @@ F:configs/j7200_hs_evm_a72_defconfig
 F: configs/j7200_hs_evm_r5_defconfig
 F: configs/j721e_hs_evm_a72_defconfig
 F: configs/j721e_hs_evm_r5_defconfig
-F: configs/j721s2_hs_evm_a72_defconfig
-F: configs/j721s2_hs_evm_r5_defconfig
 
 TPM DRIVERS
 M: Ilias Apalodimas 
diff --git a/configs/j721s2_evm_a72_defconfig b/configs/j721s2_evm_a72_defconfig
index 84b4fb083191..c880a8d37158 100644
--- a/configs/j721s2_evm_a72_defconfig
+++ b/configs/j721s2_evm_a72_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_ARCH_K3=y
+CONFIG_TI_SECURE_DEVICE=y
 CONFIG_SYS_MALLOC_LEN=0x200
 CONFIG_SYS_MALLOC_F_LEN=0x8000
 CONFIG_SPL_GPIO=y
@@ -32,7 +33,7 @@ CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_LOAD_FIT_ADDRESS=0x8100
 # CONFIG_USE_SPL_FIT_GENERATOR is not set
 CONFIG_OF_BOARD_SETUP=y
-CONFIG_BOOTCOMMAND="run findfdt; run envboot; run init_${boot}; run 
boot_rprocs; run get_kern_${boot}; run get_fdt_${boot}; run 
get_overlay_${boot}; run run_kern"
+CONFIG_BOOTCOMMAND="run findfdt; run envboot; run init_${boot}; run 
boot_rprocs; if test ${boot_fit} -eq 1; then run get_fit_${boot}; run 
get_overlaystring; run run_fit; else; run get_kern_${boot}; run 
get_fdt_${boot}; run get_overlay_${boot}; run run_kern; fi;"
 CONFIG_LOGLEVEL=7
 CONFIG_SPL_MAX_SIZE=0xc
 CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
diff --git a/configs/j721s2_evm_r5_defconfig b/configs/j721s2_evm_r5_defconfig
index 1f2102a9f91f..51f2da66c9d1 100644
--- a/configs/j721s2_evm_r5_defconfig
+++ b/configs/j721s2_evm_r5_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_ARCH_K3=y
+CONFIG_TI_SECURE_DEVICE=y
 CONFIG_SYS_MALLOC_LEN=0x200
 CONFIG_SYS_MALLOC_F_LEN=0x1
 CONFIG_SPL_GPIO=y
diff --git a/configs/j721s2_hs_evm_a72_defconfig 
b/configs/j721s2_hs_evm_a72_defconfig
deleted file mode 100644
index 9fc90737da80..
--- a/configs/j721s2_hs_evm_a72_defconfig
+++ /dev/null
@@ -1,213 +0,0 @@
-CONFIG_ARM=y
-CONFIG_ARCH_K3=y
-CONFIG_TI_SECURE_DEVICE=y
-CONFIG_SYS_MALLOC_LEN=0x200
-CONFIG_SYS_MALLOC_F_LEN=0x8000
-CONFIG_SPL_GPIO=y
-CONFIG_SPL_LIBCOMMON_SUPPORT=y
-CONFIG_SPL_LIBGENERIC_SUPPORT=y
-CONFIG_NR_DRAM_BANKS=2
-CONFIG_SOC_K3_J721S2=y
-CONFIG_TARGET_J721S2_A72_EVM=y
-CONFIG_ENV_SIZE=0x2
-CONFIG_ENV_OFFSET=0x68
-CONFIG_DM_GPIO=y
-CONFIG_SPL_DM_SPI=y
-CONFIG_DEFAULT_DEVICE_TREE="k3-j721s2-common-proc-board"
-CONFIG_SPL_TEXT_BASE=0x8008
-CONFIG_SPL_MMC=y
-CONFIG_SPL_SERIAL=y
-CONFIG_SPL_DRIVERS_MISC=y
-CONFIG_SPL_STACK_R_ADDR=0x8200
-CONFIG_ENV_OFFSET_REDUND=0x6A
-CONFIG_SPL_FS_FAT=y
-CONFIG_SPL_LIBDISK_SUPPORT=y
-CONFIG_SPL_SPI_FLASH_SUPPORT=y
-CONFIG_SPL_SPI=y
-# CONFIG_PSCI_RESET is not set
-CONFIG_DISTRO_DEFAULTS=y
-CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
-CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x8048
-# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
-CONFIG_SPL_LOAD_FIT=y
-CONFIG_SPL_LOAD_FIT_ADDRESS=0x8100
-# CONFIG_USE_SPL_FIT_GENERATOR is not set
-CONFIG_OF_BOARD_SETUP=y
-CONFIG_BOOTCOMMAND="run findfdt; run envboot; run init_${boot}; run 
boot_rprocs; run get_fit_${boot}; run get_overlaystring; run run_fit"
-CONFIG_LOGLEVEL=7
-CONFIG_SPL_MAX_SIZE=0xc
-CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
-CONFIG_SPL_BSS_START_ADDR=0x80a0
-CONFIG_SPL_BSS_MAX_SIZE=0x8
-CONFIG_SPL_BOARD_INIT=y
-CONFIG_SPL_SYS_MALLOC_SIMPLE=y
-CONFIG_SPL_STACK_R=y
-CONFIG_SYS_SPL_MALLOC=y
-CONFIG_SYS_SPL_MALLOC_SIZE=0x80
-CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
-CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x1400
-CONFIG_SPL_DMA=y
-CONFIG_SPL_ENV_SUPPORT=y
-CONFIG_SPL_FS_LOAD_PAYLOAD_NAME="u-boot.img"
-CONFIG_SPL_I2C=y
-CONFIG_SPL_DM_MAILBOX=y
-CONFIG_SPL_MTD_SUPPORT=y
-CONFIG_SPL_DM_SPI_FLASH=y
-CONFIG_SPL_NOR_SUPPORT=y
-CONFIG_SPL_DM_RESET=y
-CONFIG_SPL_POWER_DOMAIN=y
-CONFIG_SPL_RAM_SUPPORT=y
-CONFIG_SPL_RAM_DEVICE=y
-# CONFIG_SPL_SPI_FLASH_TINY is not set
-CONFIG_SPL_SPI_FLASH_SFDP_SUPPORT=y
-CONFIG_SPL_SPI_LOAD=y
-CONFIG_SYS_SPI_U_BOOT_OFFS=0x28
-CONFIG_SPL_THERMAL=y
-CONFIG_SPL_USB_GADGET=y
-CONFIG_SPL_DFU=y
-CONFIG_SPL_YMODEM_SUPPORT=y
-CONFIG_SYS

[PATCH 4/4] arm64: dts: zynqmp: Enable nand-on-flash-bbt in DT by default

2023-02-23 Thread Ashok Reddy Soma
By default enable nand-on-flash-bbt DT flag, so that driver always refers
to the bad block table(bbt) present on the flash device.

Signed-off-by: Ashok Reddy Soma 
---

 arch/arm/dts/zynqmp-zc1751-xm016-dc2.dts | 2 ++
 arch/arm/dts/zynqmp-zc1751-xm017-dc3.dts | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/arch/arm/dts/zynqmp-zc1751-xm016-dc2.dts 
b/arch/arm/dts/zynqmp-zc1751-xm016-dc2.dts
index 4e6160bcd8..b6bc2f5be0 100644
--- a/arch/arm/dts/zynqmp-zc1751-xm016-dc2.dts
+++ b/arch/arm/dts/zynqmp-zc1751-xm016-dc2.dts
@@ -142,6 +142,7 @@
label = "main-storage-0";
nand-ecc-step-size = <1024>;
nand-ecc-strength = <24>;
+   nand-on-flash-bbt;
 
partition@0 {   /* for testing purpose */
label = "nand-fsbl-uboot";
@@ -178,6 +179,7 @@
label = "main-storage-1";
nand-ecc-step-size = <1024>;
nand-ecc-strength = <24>;
+   nand-on-flash-bbt;
 
partition@0 {   /* for testing purpose */
label = "nand1-fsbl-uboot";
diff --git a/arch/arm/dts/zynqmp-zc1751-xm017-dc3.dts 
b/arch/arm/dts/zynqmp-zc1751-xm017-dc3.dts
index 8a06c2a90a..6021f8b4e1 100644
--- a/arch/arm/dts/zynqmp-zc1751-xm017-dc3.dts
+++ b/arch/arm/dts/zynqmp-zc1751-xm017-dc3.dts
@@ -138,6 +138,7 @@
label = "main-storage-0";
nand-ecc-step-size = <1024>;
nand-ecc-strength = <24>;
+   nand-on-flash-bbt;
 
partition@0 {   /* for testing purpose */
label = "nand-fsbl-uboot";
@@ -174,6 +175,7 @@
label = "main-storage-1";
nand-ecc-step-size = <1024>;
nand-ecc-strength = <24>;
+   nand-on-flash-bbt;
 
partition@0 {   /* for testing purpose */
label = "nand1-fsbl-uboot";
-- 
2.17.1



[PATCH 3/4] arm64: dts: zynqmp: Fix nand dt node

2023-02-23 Thread Ashok Reddy Soma
DC3 nand node is not correct, it is showing all partitions under
controller node directly. Create two sub nand nodes with partitions for
each.

Signed-off-by: Ashok Reddy Soma 
---

 arch/arm/dts/zynqmp-zc1751-xm017-dc3.dts | 117 ++-
 1 file changed, 70 insertions(+), 47 deletions(-)

diff --git a/arch/arm/dts/zynqmp-zc1751-xm017-dc3.dts 
b/arch/arm/dts/zynqmp-zc1751-xm017-dc3.dts
index 13812470ae..8a06c2a90a 100644
--- a/arch/arm/dts/zynqmp-zc1751-xm017-dc3.dts
+++ b/arch/arm/dts/zynqmp-zc1751-xm017-dc3.dts
@@ -128,54 +128,77 @@
arasan,has-mdma;
num-cs = <2>;
 
-   partition@0 {   /* for testing purpose */
-   label = "nand-fsbl-uboot";
-   reg = <0x0 0x0 0x40>;
+   nand@0 {
+   reg = <0x0>;
+   #address-cells = <0x2>;
+   #size-cells = <0x1>;
+   nand-ecc-mode = "soft";
+   nand-ecc-algo = "bch";
+   nand-rb = <0>;
+   label = "main-storage-0";
+   nand-ecc-step-size = <1024>;
+   nand-ecc-strength = <24>;
+
+   partition@0 {   /* for testing purpose */
+   label = "nand-fsbl-uboot";
+   reg = <0x0 0x0 0x40>;
+   };
+   partition@1 {   /* for testing purpose */
+   label = "nand-linux";
+   reg = <0x0 0x40 0x140>;
+   };
+   partition@2 {   /* for testing purpose */
+   label = "nand-device-tree";
+   reg = <0x0 0x180 0x40>;
+   };
+   partition@3 {   /* for testing purpose */
+   label = "nand-rootfs";
+   reg = <0x0 0x1C0 0x140>;
+   };
+   partition@4 {   /* for testing purpose */
+   label = "nand-bitstream";
+   reg = <0x0 0x300 0x40>;
+   };
+   partition@5 {   /* for testing purpose */
+   label = "nand-misc";
+   reg = <0x0 0x340 0xFCC0>;
+   };
};
-   partition@1 {   /* for testing purpose */
-   label = "nand-linux";
-   reg = <0x0 0x40 0x140>;
-   };
-   partition@2 {   /* for testing purpose */
-   label = "nand-device-tree";
-   reg = <0x0 0x180 0x40>;
-   };
-   partition@3 {   /* for testing purpose */
-   label = "nand-rootfs";
-   reg = <0x0 0x1C0 0x140>;
-   };
-   partition@4 {   /* for testing purpose */
-   label = "nand-bitstream";
-   reg = <0x0 0x300 0x40>;
-   };
-   partition@5 {   /* for testing purpose */
-   label = "nand-misc";
-   reg = <0x0 0x340 0xFCC0>;
-   };
-
-   partition@6 {   /* for testing purpose */
-   label = "nand1-fsbl-uboot";
-   reg = <0x1 0x0 0x40>;
-   };
-   partition@7 {   /* for testing purpose */
-   label = "nand1-linux";
-   reg = <0x1 0x40 0x140>;
-   };
-   partition@8 {   /* for testing purpose */
-   label = "nand1-device-tree";
-   reg = <0x1 0x180 0x40>;
-   };
-   partition@9 {   /* for testing purpose */
-   label = "nand1-rootfs";
-   reg = <0x1 0x1C0 0x140>;
-   };
-   partition@10 {  /* for testing purpose */
-   label = "nand1-bitstream";
-   reg = <0x1 0x300 0x40>;
-   };
-   partition@11 {  /* for testing purpose */
-   label = "nand1-misc";
-   reg = <0x1 0x340 0xFCC0>;
+   nand@1 {
+   reg = <0x1>;
+   #address-cells = <0x2>;
+   #size-cells = <0x1>;
+   nand-ecc-mode = "soft";
+   nand-ecc-algo = "bch";
+   nand-rb = <0>;
+   label = "main-storage-1";
+   nand-ecc-step-size = <1024>;
+   nand-ecc-strength = <24>;
+
+   partition@0 {   /* for testing purpose */
+   label = "nand1-fsbl-uboot";
+   reg = <0x0 0x0 0x40>;
+   };
+   partition@1 {   /* for testing purpose */
+   label = "nand1-linux";
+   reg = <0x0 0x40 0x140>;
+   };
+   partition@2 {   /* for testing purpose */
+   label = "nand1-device-tree";
+   reg = <0x0 0x180 0x40>;
+   };
+   partition@3 {   /* for testing purpose */
+   label = "nand1-rootfs";
+   reg = <0x0 0x1C0 0x140>;
+   };
+   partition@4 {   /* for testing purpose */
+ 

[PATCH 2/4] mtd: nand: arasan: Set ofnode value

2023-02-23 Thread Ashok Reddy Soma
Ofnode value is not set, so all the DT properties are not being read
and due to this default values are being used.

Find nand node and set chip->flash_node value.

Signed-off-by: Ashok Reddy Soma 
---

 drivers/mtd/nand/raw/arasan_nfc.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/mtd/nand/raw/arasan_nfc.c 
b/drivers/mtd/nand/raw/arasan_nfc.c
index ddb4cb1cba..99e2681c14 100644
--- a/drivers/mtd/nand/raw/arasan_nfc.c
+++ b/drivers/mtd/nand/raw/arasan_nfc.c
@@ -1230,12 +1230,16 @@ static int arasan_probe(struct udevice *dev)
struct nand_drv *info = &arasan->nand_ctrl;
struct nand_config *nand = &info->config;
struct mtd_info *mtd;
+   ofnode child;
int err = -1;
 
info->reg = (struct nand_regs *)dev_read_addr(dev);
mtd = nand_to_mtd(nand_chip);
nand_set_controller_data(nand_chip, &arasan->nand_ctrl);
 
+   ofnode_for_each_subnode(child, dev_ofnode(dev))
+   nand_set_flash_node(nand_chip, child);
+
 #ifdef CONFIG_SYS_NAND_NO_SUBPAGE_WRITE
nand_chip->options |= NAND_NO_SUBPAGE_WRITE;
 #endif
-- 
2.17.1



[PATCH 1/4] mtd: nand: arasan: Remove hardcoded bbt option

2023-02-23 Thread Ashok Reddy Soma
Bad block table option is hardcoded to read from flash with
NAND_BBT_USE_FLASH option. This decision should be done based on DT
property. Remove this hardcoding, to be able to use DT property.

Signed-off-by: Ashok Reddy Soma 
---

 drivers/mtd/nand/raw/arasan_nfc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/arasan_nfc.c 
b/drivers/mtd/nand/raw/arasan_nfc.c
index 4621bfb03e..ddb4cb1cba 100644
--- a/drivers/mtd/nand/raw/arasan_nfc.c
+++ b/drivers/mtd/nand/raw/arasan_nfc.c
@@ -1248,7 +1248,6 @@ static int arasan_probe(struct udevice *dev)
/* Buffer read/write routines */
nand_chip->read_buf = arasan_nand_read_buf;
nand_chip->write_buf = arasan_nand_write_buf;
-   nand_chip->bbt_options = NAND_BBT_USE_FLASH;
 
writel(0x0, &info->reg->cmd_reg);
writel(0x0, &info->reg->pgm_reg);
-- 
2.17.1



[PATCH 0/4] Fix arasan nand driver issues

2023-02-23 Thread Ashok Reddy Soma
In this patch series
 - Remove hardcoding of NAND_BBT_USE_FLASH in nand->bbt_options
 - Find and update nand ofnode.
 - Fix nand node in zynqmp-zc1751-xm017-dc3.dts file
 - Enable nand-on-flash-bbt flag in zynqmp DT's by default


Ashok Reddy Soma (4):
  mtd: nand: arasan: Remove hardcoded bbt option
  mtd: nand: arasan: Set ofnode value
  arm64: dts: zynqmp: Fix nand dt node
  arm64: dts: zynqmp: Enable nand-on-flash-bbt in DT by default

 arch/arm/dts/zynqmp-zc1751-xm016-dc2.dts |   2 +
 arch/arm/dts/zynqmp-zc1751-xm017-dc3.dts | 119 ++-
 drivers/mtd/nand/raw/arasan_nfc.c|   5 +-
 3 files changed, 78 insertions(+), 48 deletions(-)

-- 
2.17.1



[PATCH v2 1/2] xilinx: zynqmp: Add missing prototype for zynqmp_mmio_write

2023-02-23 Thread Ashok Reddy Soma
From: Algapally Santosh Sagar 

Add missing prototype to fix the sparse warning, warning: no
previous prototype for 'zynqmp_mmio_write' [-Wmissing-prototypes].

Signed-off-by: Algapally Santosh Sagar 
Signed-off-by: Ashok Reddy Soma 
---

(no changes since v1)

 arch/arm/mach-versal-net/include/mach/sys_proto.h | 7 +--
 arch/arm/mach-versal/include/mach/sys_proto.h | 6 +-
 drivers/mmc/zynq_sdhci.c  | 1 +
 drivers/spi/zynqmp_gqspi.c| 5 +
 4 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-versal-net/include/mach/sys_proto.h 
b/arch/arm/mach-versal-net/include/mach/sys_proto.h
index 5bba9030f2..a20cf02712 100644
--- a/arch/arm/mach-versal-net/include/mach/sys_proto.h
+++ b/arch/arm/mach-versal-net/include/mach/sys_proto.h
@@ -8,9 +8,4 @@
 
 void mem_map_fill(void);
 
-static inline int zynqmp_mmio_write(const u32 address, const u32 mask,
-   const u32 value)
-{
-   BUILD_BUG();
-   return -EINVAL;
-}
+int zynqmp_mmio_write(const u32 address, const u32 mask, const u32 value);
diff --git a/arch/arm/mach-versal/include/mach/sys_proto.h 
b/arch/arm/mach-versal/include/mach/sys_proto.h
index 8e5712e0c9..3f01508ecb 100644
--- a/arch/arm/mach-versal/include/mach/sys_proto.h
+++ b/arch/arm/mach-versal/include/mach/sys_proto.h
@@ -13,8 +13,4 @@ enum {
 void tcm_init(u8 mode);
 void mem_map_fill(void);
 
-static inline int zynqmp_mmio_write(const u32 address, const u32 mask, const 
u32 value)
-{
-   BUILD_BUG();
-   return -EINVAL;
-}
+int zynqmp_mmio_write(const u32 address, const u32 mask, const u32 value);
diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c
index 8b559d8a7a..9dc310663f 100644
--- a/drivers/mmc/zynq_sdhci.c
+++ b/drivers/mmc/zynq_sdhci.c
@@ -14,6 +14,7 @@
 #include "mmc_private.h"
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/drivers/spi/zynqmp_gqspi.c b/drivers/spi/zynqmp_gqspi.c
index 335b458cb9..c4aee279aa 100644
--- a/drivers/spi/zynqmp_gqspi.c
+++ b/drivers/spi/zynqmp_gqspi.c
@@ -183,6 +183,11 @@ struct zynqmp_qspi_priv {
const struct spi_mem_op *op;
 };
 
+__weak int zynqmp_mmio_write(const u32 address, const u32 mask, const u32 
value)
+{
+   return 0;
+}
+
 static int zynqmp_qspi_of_to_plat(struct udevice *bus)
 {
struct zynqmp_qspi_plat *plat = dev_get_plat(bus);
-- 
2.17.1



[PATCH v2 0/2] Fix sparse warnings

2023-02-23 Thread Ashok Reddy Soma
Run and fix sparse warnings in below files
 -arch/arm/mach-zynqmp/include/mach/sys_proto.h
 -common/spl/spl.c
 -arch/arm/mach-versal-net/include/mach/sys_proto.h
 -arch/arm/mach-versal/include/mach/sys_proto.h
 -drivers/mmc/zynq_sdhci.c
 -drivers/spi/zynqmp_gqspi.c


Changes in v2:
 - Moved function prototype from sys_proto.h to include/spl.h

Algapally Santosh Sagar (2):
  xilinx: zynqmp: Add missing prototype for zynqmp_mmio_write
  xilinx: zynqmp: Add missing prototype for board_boot_order

 arch/arm/mach-versal-net/include/mach/sys_proto.h | 7 +--
 arch/arm/mach-versal/include/mach/sys_proto.h | 6 +-
 drivers/mmc/zynq_sdhci.c  | 1 +
 drivers/spi/zynqmp_gqspi.c| 5 +
 include/spl.h | 1 +
 5 files changed, 9 insertions(+), 11 deletions(-)

-- 
2.17.1



[PATCH v2 2/2] xilinx: zynqmp: Add missing prototype for board_boot_order

2023-02-23 Thread Ashok Reddy Soma
From: Algapally Santosh Sagar 

Add missing prototype to fix the sparse warning, warning: no
previous prototype for 'board_boot_order' [-Wmissing-prototypes].

Signed-off-by: Algapally Santosh Sagar 
Signed-off-by: Ashok Reddy Soma 
---

Changes in v2:
 - Moved function prototype from sys_proto.h to include/spl.h

 include/spl.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/spl.h b/include/spl.h
index 827bd25c88..bad12fb01f 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -884,5 +884,6 @@ void spl_perform_fixups(struct spl_image_info *spl_image);
  */
 struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size);
 
+void board_boot_order(u32 *spl_boot_list);
 void spl_save_restore_data(void);
 #endif
-- 
2.17.1



Re: Docs for RISC-V

2023-02-23 Thread Nylon Chen
Zong Li  於 2023年2月23日 週四 下午5:11寫道:
>
> On Mon, Feb 6, 2023 at 3:58 PM Leo Liang  wrote:
> >
> > Hi Simon,
> >
> > On Thu, Feb 02, 2023 at 10:25:36AM -0700, Simon Glass wrote:
> > > Hi,
> > >
> > > On Thu, 2 Feb 2023 at 10:18, Simon Glass  wrote:
> > > >
> > > > Hi Rick & Leo,
> > > >
> > > > I see docs for one board at [1] but I'm not sure what to do with 
> > > > unleashed.
> > > >
> > > > It seems to need a 'genimage' tool, going on what I see in CI.
> > > >
> >
> > It does seem like that accroding to "sifive_unleashed_sdcard test.py".
> > (https://source.denx.de/u-boot/custodians/u-boot-riscv/-/jobs/568342)
> >
> > > > Could you adjust it to use binman to output an image suitable for
> > > > writing to an SD card in a single 'dd' step, as Rockchip does?
> > > >
> >
> > I think I will both take a look at it and forward this message to guys at 
> > sifive.
>
> Add Nylon in this thread.
>
> Hi Nylon, I think you took some time to take a look at this, do you
> have any idea about that? Thanks.
Hi Zong,
According to Bin Meng's patch "azure/gitlab: Add tests for SiFive
Unleashed board," the script currently uses the "genimage" tool.

However, if we want to switch to using "binman," I am unsure if it
would be a meaningful change. Perhaps Bin Meng could offer some help
on this?

Hi Bin Meng,
Do you have any ideas regarding this issue?
>
> >
> > > > Also, how about adding a RISC-V section here?
> > > >
> > > > https://u-boot.readthedocs.io/en/latest/arch/index.html
> > > >
> >
> > Sounds great!
> > I will reference what other architectures have and create a RISC-V section.
> >
> > >
> > > Also I notice that this is incorrect:
> > >
> > > https://u-boot.readthedocs.io/en/latest/board/sifive/unleashed.html?highlight=fw_dynamic.bin
> > >
> > > since 'make PLATFORM=generic' gives errors. I think it needs CROSS_COMPILE
> > >
> >
> > There is already an 'export CROSS_COMPILE' in the previous "building" 
> > section
> > before 'make PLATFROM=generic', so I guess that is why CROSS_COMPILE is 
> > omitted in make command.
> >
> > > One other thing...binman output is this:
> > >
> > > binman: Filename 'fw_dynamic.bin' not found in input path (...)
> > >
> > > You should add something to tools/binman/missing-blob-help so that it
> > > tells the user where to find the blob.
> > >
> >
> > Same as the above, I will forward this to guys at sifive to see what they 
> > would like to do.
> >
> >
> > Thanks for all the catches!
> > Best regards,
> > Leo
> >
> > > Thanks again,
> > > Simon
> > >
> > > > Thanks,
> > > > Simon
> > > >
> > > > [1] https://u-boot.readthedocs.io/en/latest/board/sifive/unmatched.html


Re: [PATCH v1 18/24] solidrun: mx6cuboxi: use CONFIG_IS_ENABLED(SATA) instead of CONFIG_CMD_SATA

2023-02-23 Thread Troy Kisky
On Wed, Feb 22, 2023 at 10:13 AM Troy Kisky 
wrote:

> On Wed, Feb 22, 2023 at 8:59 AM Tom Rini  wrote:
>
>> On Tue, Feb 21, 2023 at 05:38:15PM -0800, Troy Kisky wrote:
>>
>> > setup_sata is linked with
>> > obj-$(CONFIG_SATA) += sata.o
>> >
>> > So use SATA instead of CMD_SATA.
>> >
>> > Signed-off-by: Troy Kisky 
>> > ---
>> >
>> >  board/solidrun/mx6cuboxi/mx6cuboxi.c | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c
>> b/board/solidrun/mx6cuboxi/mx6cuboxi.c
>> > index 7c44379ec4a..e31a7e9552f 100644
>> > --- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
>> > +++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
>> > @@ -275,7 +275,7 @@ int board_early_init_f(void)
>> >  {
>> >   setup_iomux_uart();
>> >
>> > -#ifdef CONFIG_CMD_SATA
>> > +#if CONFIG_IS_ENABLED(SATA)
>> >   setup_sata();
>> >  #endif
>> >   setup_fec();
>>
>> Note that wandboard needs a similar fix.
>>
>> --
>> Tom
>>
>
> Hi Tom
>
> The commit script will change
> #ifdef CONFIG_SATA
>
> to
> #if CONFIG_IS_ENABLED(SATA)
>
> This series only changes things that the commit script won't.
>
> BR
> Troy
>

You are right Tom, wandboard is needed too as it uses SPL.
I don't know how it passed CI last time. But it didn't this time.

BR
Troy


[PATCH v2 23/24] doc: Add notes on how to install patman and binman

2023-02-23 Thread Simon Glass
These can be installed with 'pip' now. Add the details for those who are
interested.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 tools/binman/binman.rst | 13 +
 tools/patman/patman.rst | 12 
 2 files changed, 25 insertions(+)

diff --git a/tools/binman/binman.rst b/tools/binman/binman.rst
index 2bcb7d3886f..61a5d8ab5a9 100644
--- a/tools/binman/binman.rst
+++ b/tools/binman/binman.rst
@@ -95,6 +95,19 @@ Binman uses the following terms:
 - binary - an input binary that goes into the image
 
 
+Installation
+
+
+You can install binman using::
+
+   pip install binary-manager
+
+The name is chosen since binman conflicts with an existing package.
+
+If you are using binman within the U-Boot tree, it may be easiest to add a
+symlink from your local `~/.bin` directory to `/path/to/tools/binman/binman`.
+
+
 Relationship to FIT
 ---
 
diff --git a/tools/patman/patman.rst b/tools/patman/patman.rst
index 6113962fb4f..038b651ee87 100644
--- a/tools/patman/patman.rst
+++ b/tools/patman/patman.rst
@@ -41,6 +41,18 @@ In Linux and U-Boot this will also call get_maintainer.pl on 
each of your
 patches automatically (unless you use -m to disable this).
 
 
+Installation
+
+
+You can install patman using::
+
+   pip install patch-manager
+
+The name is chosen since patman conflicts with an existing package.
+
+If you are using patman within the U-Boot tree, it may be easiest to add a
+symlink from your local `~/.bin` directory to `/path/to/tools/patman/patman`.
+
 How to use this tool
 
 
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v2 21/24] binman: Add support for building a binmanu PyPi package

2023-02-23 Thread Simon Glass
Create the necessary files to build this new package.

It is not actually clear whether this is useful, since buildman has no
purpose outside U-Boot.

Move the main program into a function so that it can easily be called by
the PyPi-created script.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 Makefile|  1 +
 tools/binman/pyproject.toml | 29 +
 2 files changed, 30 insertions(+)
 create mode 100644 tools/binman/pyproject.toml

diff --git a/Makefile b/Makefile
index 3951edabce1..27bdbec887b 100644
--- a/Makefile
+++ b/Makefile
@@ -2285,6 +2285,7 @@ _pip:
scripts/make_pip.sh patman ${PIP_ARGS}
scripts/make_pip.sh buildman ${PIP_ARGS}
scripts/make_pip.sh dtoc ${PIP_ARGS}
+   scripts/make_pip.sh binman ${PIP_ARGS}
 
 help:
@echo  'Cleaning targets:'
diff --git a/tools/binman/pyproject.toml b/tools/binman/pyproject.toml
new file mode 100644
index 000..b4b54fbaee6
--- /dev/null
+++ b/tools/binman/pyproject.toml
@@ -0,0 +1,29 @@
+[build-system]
+requires = ["setuptools>=61.0"]
+build-backend = "setuptools.build_meta"
+
+[project]
+name = "binary-manager"
+version = "0.0.2"
+authors = [
+  { name="Simon Glass", email="s...@chromium.org" },
+]
+dependencies = ["pylibfdt", "u_boot_pylib", "dtoc"]
+description = "Binman firmware-packaging tool"
+readme = "README.rst"
+requires-python = ">=3.7"
+classifiers = [
+"Programming Language :: Python :: 3",
+"License :: OSI Approved :: GNU General Public License v2 or later 
(GPLv2+)",
+"Operating System :: OS Independent",
+]
+
+[project.urls]
+"Homepage" = 
"https://u-boot.readthedocs.io/en/latest/develop/package/index.html";
+"Bug Tracker" = "https://source.denx.de/groups/u-boot/-/issues";
+
+[project.scripts]
+binman = "binman.main:start_binman"
+
+[tool.setuptools.package-data]
+patman = ["*.rst"]
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v2 20/24] binman: Use importlib to find the help

2023-02-23 Thread Simon Glass
Use this function so that the help can be found even when binman is
running from a package.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Add new patch to use importlib to find the help

 tools/binman/control.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/binman/control.py b/tools/binman/control.py
index 3e27b72f881..e7f81b9deb5 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -7,6 +7,7 @@
 
 from collections import OrderedDict
 import glob
+import importlib.resources
 import os
 import pkg_resources
 import re
@@ -641,9 +642,8 @@ def Binman(args):
 global state
 
 if args.full_help:
-tools.print_full_help(
-os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), 
'README.rst')
-)
+with importlib.resources.path('binman', 'README.rst') as readme:
+tools.print_full_help(str(readme))
 return 0
 
 # Put these here so that we can import this module without libfdt
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v2 19/24] binman: Hide the 'test' command unless test code is available

2023-02-23 Thread Simon Glass
It doesn't make much sense to expose tests when dtoc is running
outside of the U-Boot git checkout. Hide the option in this case.

Fix a long line while we are here.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Add a patch to hide the test options unless test code is available

 tools/binman/cmdline.py | 34 +-
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/tools/binman/cmdline.py b/tools/binman/cmdline.py
index 986d6f1a315..ef6a05dac15 100644
--- a/tools/binman/cmdline.py
+++ b/tools/binman/cmdline.py
@@ -8,6 +8,11 @@
 import argparse
 from argparse import ArgumentParser
 from binman import state
+import os
+import pathlib
+
+BINMAN_DIR = pathlib.Path(__file__).parent
+HAS_TESTS = (BINMAN_DIR / "ftest.py").exists()
 
 def make_extract_parser(subparsers):
 """make_extract_parser: Make a subparser for the 'extract' command
@@ -163,23 +168,26 @@ controlled by a description in the board device tree.'''
 replace_parser.add_argument('paths', type=str, nargs='*',
 help='Paths within file to replace (wildcard)')
 
-test_parser = subparsers.add_parser('test', help='Run tests')
-test_parser.add_argument('-P', '--processes', type=int,
-help='set number of processes to use for running tests')
-test_parser.add_argument('-T', '--test-coverage', action='store_true',
-default=False, help='run tests and check for 100%% coverage')
-test_parser.add_argument('-X', '--test-preserve-dirs', action='store_true',
-help='Preserve and display test-created input directories; also '
- 'preserve the output directory if a single test is run (pass test 
'
- 'name at the end of the command line')
-test_parser.add_argument('tests', nargs='*',
- help='Test names to run (omit for all)')
+if HAS_TESTS:
+test_parser = subparsers.add_parser('test', help='Run tests')
+test_parser.add_argument('-P', '--processes', type=int,
+help='set number of processes to use for running tests')
+test_parser.add_argument('-T', '--test-coverage', action='store_true',
+default=False, help='run tests and check for 100%% coverage')
+test_parser.add_argument(
+'-X', '--test-preserve-dirs', action='store_true',
+help='Preserve and display test-created input directories; also '
+ 'preserve the output directory if a single test is run (pass '
+ 'test name at the end of the command line')
+test_parser.add_argument('tests', nargs='*',
+ help='Test names to run (omit for all)')
 
 tool_parser = subparsers.add_parser('tool', help='Check bintools')
 tool_parser.add_argument('-l', '--list', action='store_true',
  help='List all known bintools')
-tool_parser.add_argument('-f', '--fetch', action='store_true',
- help='fetch a bintool from a known location (or: 
all/missing)')
+tool_parser.add_argument(
+'-f', '--fetch', action='store_true',
+help='fetch a bintool from a known location (or: all/missing)')
 tool_parser.add_argument('bintools', type=str, nargs='*')
 
 return parser.parse_args(argv)
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v2 17/24] dtoc: Add support for building a dtoc PyPi package

2023-02-23 Thread Simon Glass
Create the necessary files to build this new package.

This is needed for binman.

Move the main program into a function so that it can easily be called by
the PyPi-created script.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 Makefile  |  1 +
 tools/dtoc/README.rst | 15 +++
 tools/dtoc/pyproject.toml | 26 ++
 3 files changed, 42 insertions(+)
 create mode 100644 tools/dtoc/README.rst
 create mode 100644 tools/dtoc/pyproject.toml

diff --git a/Makefile b/Makefile
index 3c1bda50263..3951edabce1 100644
--- a/Makefile
+++ b/Makefile
@@ -2284,6 +2284,7 @@ _pip:
scripts/make_pip.sh u_boot_pylib ${PIP_ARGS}
scripts/make_pip.sh patman ${PIP_ARGS}
scripts/make_pip.sh buildman ${PIP_ARGS}
+   scripts/make_pip.sh dtoc ${PIP_ARGS}
 
 help:
@echo  'Cleaning targets:'
diff --git a/tools/dtoc/README.rst b/tools/dtoc/README.rst
new file mode 100644
index 000..92b39759ed1
--- /dev/null
+++ b/tools/dtoc/README.rst
@@ -0,0 +1,15 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Devicetree-to-C generator
+=
+
+This is a Python program and associated utilities, which supports converting
+devicetree files into C code. It generates header files containing struct
+definitions, as well as C files containing the data. It does not require any
+modification of the devicetree files.
+
+Some high-level libraries are provided for working with devicetree. These may
+be useful in other projects.
+
+This package also includes some U-Boot-specific features, such as creating
+`struct udevice` and `struct uclass` entries for devicetree nodes.
diff --git a/tools/dtoc/pyproject.toml b/tools/dtoc/pyproject.toml
new file mode 100644
index 000..77fe4da2158
--- /dev/null
+++ b/tools/dtoc/pyproject.toml
@@ -0,0 +1,26 @@
+[build-system]
+requires = ["setuptools>=61.0"]
+build-backend = "setuptools.build_meta"
+
+[project]
+name = "dtoc"
+version = "0.0.2"
+authors = [
+  { name="Simon Glass", email="s...@chromium.org" },
+]
+dependencies = ["pylibfdt", "u_boot_pylib"]
+description = "Devicetree-to-C generator"
+readme = "README.rst"
+requires-python = ">=3.7"
+classifiers = [
+"Programming Language :: Python :: 3",
+"License :: OSI Approved :: GNU General Public License v2 or later 
(GPLv2+)",
+"Operating System :: OS Independent",
+]
+
+[project.urls]
+"Homepage" = 
"https://u-boot.readthedocs.io/en/latest/develop/driver-model/of-plat.html";
+"Bug Tracker" = "https://source.denx.de/groups/u-boot/-/issues";
+
+[project.scripts]
+dtoc = "dtoc.main:run_dtoc"
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v2 15/24] dtoc: Move the main code into a function

2023-02-23 Thread Simon Glass
Put this code into a function so it is easy for it be run when packaged.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Add patch to split out the main code into a function

 tools/dtoc/main.py | 100 +++--
 1 file changed, 52 insertions(+), 48 deletions(-)

diff --git a/tools/dtoc/main.py b/tools/dtoc/main.py
index 91521661f46..6c91450410e 100755
--- a/tools/dtoc/main.py
+++ b/tools/dtoc/main.py
@@ -65,58 +65,62 @@ def run_tests(processes, args):
 return (0 if result.wasSuccessful() else 1)
 
 
-def RunTestCoverage():
+def RunTestCoverage(build_dir):
 """Run the tests and check that we get 100% coverage"""
 sys.argv = [sys.argv[0]]
 test_util.run_test_coverage('tools/dtoc/dtoc', '/main.py',
 ['tools/patman/*.py', 'tools/u_boot_pylib/*','*/fdt*', '*test*'],
-args.build_dir)
-
-
-if __name__ != '__main__':
-sys.exit(1)
-
-epilog = '''Generate C code from devicetree files. See of-plat.rst for 
details'''
-
-parser = ArgumentParser(epilog=epilog)
-parser.add_argument('-B', '--build-dir', type=str, default='b',
-help='Directory containing the build output')
-parser.add_argument('-c', '--c-output-dir', action='store',
-  help='Select output directory for C files')
-parser.add_argument('-C', '--h-output-dir', action='store',
-  help='Select output directory for H files (defaults to 
--c-output-di)')
-parser.add_argument('-d', '--dtb-file', action='store',
-  help='Specify the .dtb input file')
-parser.add_argument('-i', '--instantiate', action='store_true', default=False,
-  help='Instantiate devices to avoid needing device_bind()')
-parser.add_argument('--include-disabled', action='store_true',
-  help='Include disabled nodes')
-parser.add_argument('-o', '--output', action='store',
-  help='Select output filename')
-parser.add_argument('-p', '--phase', type=str,
-  help='set phase of U-Boot this invocation is for (spl/tpl)')
-parser.add_argument('-P', '--processes', type=int,
-  help='set number of processes to use for running tests')
-if HAVE_TESTS:
-parser.add_argument('-t', '--test', action='store_true', dest='test',
-default=False, help='run tests')
-parser.add_argument(
-'-T', '--test-coverage', action='store_true',
-default=False, help='run tests and check for 100%% coverage')
-
-parser.add_argument('files', nargs='*')
-args = parser.parse_args()
+build_dir)
 
-# Run our meagre tests
-if HAVE_TESTS and args.test:
-ret_code = run_tests(args.processes, args)
-sys.exit(ret_code)
 
-elif HAVE_TESTS and args.test_coverage:
-RunTestCoverage()
+def run_dtoc():
+epilog = 'Generate C code from devicetree files. See of-plat.rst for 
details'
 
-else:
-dtb_platdata.run_steps(args.files, args.dtb_file, args.include_disabled,
-   args.output,
-   [args.c_output_dir, args.h_output_dir],
-   args.phase, instantiate=args.instantiate)
+parser = ArgumentParser(epilog=epilog)
+parser.add_argument('-B', '--build-dir', type=str, default='b',
+help='Directory containing the build output')
+parser.add_argument('-c', '--c-output-dir', action='store',
+  help='Select output directory for C files')
+parser.add_argument(
+'-C', '--h-output-dir', action='store',
+help='Select output directory for H files (defaults to --c-output-di)')
+parser.add_argument('-d', '--dtb-file', action='store',
+  help='Specify the .dtb input file')
+parser.add_argument(
+'-i', '--instantiate', action='store_true', default=False,
+help='Instantiate devices to avoid needing device_bind()')
+parser.add_argument('--include-disabled', action='store_true',
+  help='Include disabled nodes')
+parser.add_argument('-o', '--output', action='store',
+  help='Select output filename')
+parser.add_argument(
+'-p', '--phase', type=str,
+help='set phase of U-Boot this invocation is for (spl/tpl)')
+parser.add_argument('-P', '--processes', type=int,
+  help='set number of processes to use for running tests')
+if HAVE_TESTS:
+parser.add_argument('-t', '--test', action='store_true', dest='test',
+default=False, help='run tests')
+parser.add_argument(
+'-T', '--test-coverage', action='store_true',
+default=False, help='run tests and check for 100%% coverage')
+parser.add_argument('files', nargs='*')
+args = parser.parse_args()
+
+# Run our meagre tests
+if HAVE_TESTS and args.test:
+ret_code = run_tests(args.processes, args)
+sys.exit(ret_code)
+
+elif HAVE_TESTS and args.test_coverage:
+RunTestC

[PATCH v2 24/24] CI: Add a check for building tools for PyPi

2023-02-23 Thread Simon Glass
Add a simple check that the PyPi packages can be built.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Update the cover letter

 .azure-pipelines.yml | 10 ++
 .gitlab-ci.yml   |  6 ++
 2 files changed, 16 insertions(+)

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 8327edf87aa..6cd93f7f4d2 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -225,6 +225,16 @@ stages:
   # have no matches.
   - script: git grep u-boot,dm- -- '*.dts*' && exit 1 || exit 0
 
+  - job: check_packing_of_python_tools
+displayName: 'Check we can package the Python tools'
+pool:
+  vmImage: $(ubuntu_vm)
+container:
+  image: $(ci_runner_image)
+  options: $(container_option)
+steps:
+  - script: make pip
+
 - stage: test_py
   jobs:
   - job: test_py
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c3ceca2974d..bc64e221efd 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -244,6 +244,12 @@ Check for pre-schema tags:
 # have no matches.
 - git grep u-boot,dm- -- '*.dts*' && exit 1 || exit 0
 
+# Check we can package the Python tools
+Check packing of Python tools:
+  stage: testsuites
+  script:
+- make pip
+
 # Test sandbox with test.py
 sandbox test.py:
   variables:
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v2 22/24] test: Add concurrencytest to the requirements

2023-02-23 Thread Simon Glass
This allows tests to run in parallel and speeds up some tests markedly,
particularly with binman. Add it to the requirements.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 test/py/requirements.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/test/py/requirements.txt b/test/py/requirements.txt
index fae8b59caf4..e241780f923 100644
--- a/test/py/requirements.txt
+++ b/test/py/requirements.txt
@@ -1,5 +1,6 @@
 atomicwrites==1.4.1
 attrs==19.3.0
+concurrencytest==0.1.2
 coverage==4.5.4
 extras==1.0.0
 filelock==3.0.12
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v2 14/24] dtoc: Hide the test options unless test code is available

2023-02-23 Thread Simon Glass
It doesn't make much sense to expose tests when dtoc is running
outside of the U-Boot git checkout. Hide the option in this case.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Add a patch to hide the test options unless test code is available

 tools/dtoc/main.py | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/tools/dtoc/main.py b/tools/dtoc/main.py
index fc9207d1b63..91521661f46 100755
--- a/tools/dtoc/main.py
+++ b/tools/dtoc/main.py
@@ -23,6 +23,7 @@ see doc/driver-model/of-plat.rst
 
 from argparse import ArgumentParser
 import os
+import pathlib
 import sys
 
 # Bring in the patman libraries
@@ -37,6 +38,9 @@ sys.path.insert(0, os.path.join(our_path,
 from dtoc import dtb_platdata
 from u_boot_pylib import test_util
 
+DTOC_DIR = pathlib.Path(__file__).parent
+HAVE_TESTS = (DTOC_DIR / 'test_dtoc.py').exists()
+
 def run_tests(processes, args):
 """Run all the test we have for dtoc
 
@@ -93,19 +97,22 @@ parser.add_argument('-p', '--phase', type=str,
   help='set phase of U-Boot this invocation is for (spl/tpl)')
 parser.add_argument('-P', '--processes', type=int,
   help='set number of processes to use for running tests')
-parser.add_argument('-t', '--test', action='store_true', dest='test',
-  default=False, help='run tests')
-parser.add_argument('-T', '--test-coverage', action='store_true',
-default=False, help='run tests and check for 100%% coverage')
+if HAVE_TESTS:
+parser.add_argument('-t', '--test', action='store_true', dest='test',
+default=False, help='run tests')
+parser.add_argument(
+'-T', '--test-coverage', action='store_true',
+default=False, help='run tests and check for 100%% coverage')
+
 parser.add_argument('files', nargs='*')
 args = parser.parse_args()
 
 # Run our meagre tests
-if args.test:
+if HAVE_TESTS and args.test:
 ret_code = run_tests(args.processes, args)
 sys.exit(ret_code)
 
-elif args.test_coverage:
+elif HAVE_TESTS and args.test_coverage:
 RunTestCoverage()
 
 else:
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v2 18/24] binman: Move the main code into a function

2023-02-23 Thread Simon Glass
Put this code into a function so it is easy for it be run when packaged.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Add patch to split out the main code into a function

 tools/binman/main.py | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/tools/binman/main.py b/tools/binman/main.py
index eef17b7b55f..92d2431aea7 100755
--- a/tools/binman/main.py
+++ b/tools/binman/main.py
@@ -85,7 +85,7 @@ def RunTests(debug, verbosity, processes, test_preserve_dirs, 
args, toolpath):
 
 return (0 if result.wasSuccessful() else 1)
 
-def RunTestCoverage(toolpath):
+def RunTestCoverage(toolpath, build_dir):
 """Run the tests and check that we get 100% coverage"""
 glob_list = control.GetEntryModules(False)
 all_set = set([os.path.splitext(os.path.basename(item))[0]
@@ -97,7 +97,7 @@ def RunTestCoverage(toolpath):
 test_util.run_test_coverage('tools/binman/binman', None,
 ['*test*', '*main.py', 'tools/patman/*', 'tools/dtoc/*',
  'tools/u_boot_pylib/*'],
-args.build_dir, all_set, extra_args or None)
+build_dir, all_set, extra_args or None)
 
 def RunBinman(args):
 """Main entry point to binman once arguments are parsed
@@ -117,7 +117,7 @@ def RunBinman(args):
 
 if args.cmd == 'test':
 if args.test_coverage:
-RunTestCoverage(args.toolpath)
+RunTestCoverage(args.toolpath, args.build_dir)
 else:
 ret_code = RunTests(args.debug, args.verbosity, args.processes,
 args.test_preserve_dirs, args.tests,
@@ -141,8 +141,12 @@ def RunBinman(args):
 return ret_code
 
 
-if __name__ == "__main__":
+def start_binman():
 args = cmdline.ParseArgs(sys.argv[1:])
 
 ret_code = RunBinman(args)
 sys.exit(ret_code)
+
+
+if __name__ == "__main__":
+start_binman()
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v2 13/24] buildman: Add support for building a buildman PyPi package

2023-02-23 Thread Simon Glass
Create the necessary files to build this new package.

It is not actually clear whether this is useful, since buildman has no
purpose outside U-Boot. It is included for completeness, since adding
this later would be more trouble.

Move the main program into a function so that it can easily be called by
the PyPi-created script.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 Makefile  |  1 +
 tools/buildman/pyproject.toml | 29 +
 2 files changed, 30 insertions(+)
 create mode 100644 tools/buildman/pyproject.toml

diff --git a/Makefile b/Makefile
index abd8d60a1bb..3c1bda50263 100644
--- a/Makefile
+++ b/Makefile
@@ -2283,6 +2283,7 @@ pip pip_test pip_release: _pip
 _pip:
scripts/make_pip.sh u_boot_pylib ${PIP_ARGS}
scripts/make_pip.sh patman ${PIP_ARGS}
+   scripts/make_pip.sh buildman ${PIP_ARGS}
 
 help:
@echo  'Cleaning targets:'
diff --git a/tools/buildman/pyproject.toml b/tools/buildman/pyproject.toml
new file mode 100644
index 000..4d75e772ee1
--- /dev/null
+++ b/tools/buildman/pyproject.toml
@@ -0,0 +1,29 @@
+[build-system]
+requires = ["setuptools>=61.0"]
+build-backend = "setuptools.build_meta"
+
+[project]
+name = "buildman"
+version = "0.0.2"
+authors = [
+  { name="Simon Glass", email="s...@chromium.org" },
+]
+dependencies = ["u_boot_pylib", "patch-manager"]
+description = "Buildman build tool for U-Boot"
+readme = "README.rst"
+requires-python = ">=3.7"
+classifiers = [
+"Programming Language :: Python :: 3",
+"License :: OSI Approved :: GNU General Public License v2 or later 
(GPLv2+)",
+"Operating System :: OS Independent",
+]
+
+[project.urls]
+"Homepage" = "https://u-boot.readthedocs.io/en/latest/build/buildman.html";
+"Bug Tracker" = "https://source.denx.de/groups/u-boot/-/issues";
+
+[project.scripts]
+buildman = "buildman.main:run_buildman"
+
+[tool.setuptools.package-data]
+buildman = ["*.rst"]
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v2 12/24] buildman: Use importlib to find the help

2023-02-23 Thread Simon Glass
Use this function so that the help can be found even when buildman is
running from a package.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Add new patch to use importlib to find the help

 tools/buildman/control.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index fe3b6fa335d..07251b52179 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -3,6 +3,7 @@
 #
 
 import multiprocessing
+import importlib.resources
 import os
 import shutil
 import subprocess
@@ -152,9 +153,8 @@ def DoBuildman(options, args, toolchains=None, 
make_func=None, brds=None,
 global builder
 
 if options.full_help:
-tools.print_full_help(
-os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])),
- 'README.rst'))
+with importlib.resources.path('buildman', 'README.rst') as readme:
+tools.print_full_help(str(readme))
 return 0
 
 gitutil.setup()
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v2 09/24] buildman: Move the main code into a function

2023-02-23 Thread Simon Glass
Put this code into a function so it is easy for it be run when packaged.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Add patch to split out the main code into a function

 tools/buildman/main.py | 27 ---
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/tools/buildman/main.py b/tools/buildman/main.py
index 6076ba5d63d..5e1f68d8235 100755
--- a/tools/buildman/main.py
+++ b/tools/buildman/main.py
@@ -46,17 +46,22 @@ def RunTests(skip_net_tests, verboose, args):
 
 return (0 if result.wasSuccessful() else 1)
 
-options, args = cmdline.ParseArgs()
+def run_buildman():
+options, args = cmdline.ParseArgs()
 
-if not options.debug:
-sys.tracebacklimit = 0
+if not options.debug:
+sys.tracebacklimit = 0
 
-# Run our meagre tests
-if options.test:
-RunTests(options.skip_net_tests, options.verbose, args)
+# Run our meagre tests
+if cmdline.HAS_TESTS and options.test:
+RunTests(options.skip_net_tests, options.verbose, args)
 
-# Build selected commits for selected boards
-else:
-bsettings.Setup(options.config_file)
-ret_code = control.DoBuildman(options, args)
-sys.exit(ret_code)
+# Build selected commits for selected boards
+else:
+bsettings.Setup(options.config_file)
+ret_code = control.DoBuildman(options, args)
+sys.exit(ret_code)
+
+
+if __name__ == "__main__":
+run_buildman()
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v2 16/24] dtoc: Use pathlib to find the test directory

2023-02-23 Thread Simon Glass
Update this so that the directory being used is declared at the top of
the file. Use pathlib as it seems to be more modern.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 tools/dtoc/test_dtoc.py | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py
index 0f544f9f54a..597c93e8a87 100755
--- a/tools/dtoc/test_dtoc.py
+++ b/tools/dtoc/test_dtoc.py
@@ -13,6 +13,7 @@ import collections
 import copy
 import glob
 import os
+import pathlib
 import struct
 import unittest
 
@@ -28,7 +29,8 @@ from dtoc.src_scan import get_compat_name
 from u_boot_pylib import test_util
 from u_boot_pylib import tools
 
-OUR_PATH = os.path.dirname(os.path.realpath(__file__))
+DTOC_DIR = pathlib.Path(__file__).parent
+TEST_DATA_DIR = DTOC_DIR / 'test/'
 
 
 HEADER = '''/*
@@ -91,7 +93,7 @@ def get_dtb_file(dts_fname, capture_stderr=False):
 Returns:
 str: Filename of compiled file in output directory
 """
-return fdt_util.EnsureCompiled(os.path.join(OUR_PATH, 'test', dts_fname),
+return fdt_util.EnsureCompiled(str(TEST_DATA_DIR / dts_fname),
capture_stderr=capture_stderr)
 
 
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v2 11/24] buildman: Fix use of a type as a variable

2023-02-23 Thread Simon Glass
Using 'str' as a variable makes it impossible to use it as a type in the
same function. Fix this by using a different name.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Add patch to fix use of a type as a variable

 tools/buildman/control.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index 76e4e2709ac..fe3b6fa335d 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -261,9 +261,9 @@ def DoBuildman(options, args, toolchains=None, 
make_func=None, brds=None,
 count += 1   # Build upstream commit also
 
 if not count:
-str = ("No commits found to process in branch '%s': "
+msg = ("No commits found to process in branch '%s': "
"set branch's upstream or use -c flag" % options.branch)
-sys.exit(col.build(col.RED, str))
+sys.exit(col.build(col.RED, msg))
 if options.work_in_output:
 if len(selected) != 1:
 sys.exit(col.build(col.RED,
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v2 10/24] buildman: Hide the test options unless test code is available

2023-02-23 Thread Simon Glass
It doesn't make much sense to expose tests when buildman is running
outside of the U-Boot git checkout. Hide the option in this case

Signed-off-by: Simon Glass 
---

Changes in v2:
- Add a patch to hide the test options unless test code is available

 tools/buildman/cmdline.py | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/tools/buildman/cmdline.py b/tools/buildman/cmdline.py
index c485994e9fe..e22aaf6c7bc 100644
--- a/tools/buildman/cmdline.py
+++ b/tools/buildman/cmdline.py
@@ -3,6 +3,11 @@
 #
 
 from optparse import OptionParser
+import os
+import pathlib
+
+BUILDMAN_DIR = pathlib.Path(__file__).parent
+HAS_TESTS = os.path.exists(BUILDMAN_DIR / "test.py")
 
 def ParseArgs():
 """Parse command line arguments from sys.argv[]
@@ -101,12 +106,13 @@ def ParseArgs():
   default=False, help='Show a build summary')
 parser.add_option('-S', '--show-sizes', action='store_true',
   default=False, help='Show image size variation in summary')
-parser.add_option('--skip-net-tests', action='store_true', default=False,
-  help='Skip tests which need the network')
 parser.add_option('--step', type='int',
   default=1, help='Only build every n commits (0=just first and last)')
-parser.add_option('-t', '--test', action='store_true', dest='test',
-  default=False, help='run tests')
+if HAS_TESTS:
+parser.add_option('--skip-net-tests', action='store_true', 
default=False,
+  help='Skip tests which need the network')
+parser.add_option('-t', '--test', action='store_true', dest='test',
+  default=False, help='run tests')
 parser.add_option('-T', '--threads', type='int',
   default=None,
   help='Number of builder threads to use (0=single-thread)')
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v2 07/24] patman: Avoid importing test_checkpatch before it is needed

2023-02-23 Thread Simon Glass
Tests are not packaged with patman so this file will not be accessible
when installing with pip. Move the import later in the file, when we
know the file is present.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Add new patch to avoid importing test_checkpatch before it is needed

 tools/patman/__main__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/patman/__main__.py b/tools/patman/__main__.py
index 30632559bb6..48ffbc8eadf 100755
--- a/tools/patman/__main__.py
+++ b/tools/patman/__main__.py
@@ -24,7 +24,6 @@ from patman import func_test
 from patman import gitutil
 from patman import project
 from patman import settings
-from patman import test_checkpatch
 from u_boot_pylib import terminal
 from u_boot_pylib import test_util
 from u_boot_pylib import tools
@@ -146,6 +145,7 @@ if not args.debug:
 # Run our meagre tests
 if args.cmd == 'test':
 from patman import func_test
+from patman import test_checkpatch
 
 result = test_util.run_test_suites(
 'patman', False, False, False, None, None, None,
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v2 06/24] patman: Add support for building a u_boot_tools PyPi package

2023-02-23 Thread Simon Glass
Create the necessary files to build this new package.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 Makefile  |  18 +-
 tools/u_boot_pylib/LICENSE| 339 ++
 tools/u_boot_pylib/README.rst |  15 ++
 tools/u_boot_pylib/pyproject.toml |  22 ++
 4 files changed, 393 insertions(+), 1 deletion(-)
 create mode 100644 tools/u_boot_pylib/LICENSE
 create mode 100644 tools/u_boot_pylib/README.rst
 create mode 100644 tools/u_boot_pylib/pyproject.toml

diff --git a/Makefile b/Makefile
index 54f894dab84..9f008dea0ec 100644
--- a/Makefile
+++ b/Makefile
@@ -522,7 +522,7 @@ env_h := include/generated/environment.h
 no-dot-config-targets := clean clobber mrproper distclean \
 help %docs check% coccicheck \
 ubootversion backup tests check pcheck qcheck tcheck \
-pylint pylint_err
+pylint pylint_err _pip pip pip_test pip_release
 
 config-targets := 0
 mixed-targets  := 0
@@ -2272,6 +2272,17 @@ backup:
F=`basename $(srctree)` ; cd .. ; \
gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F
 
+PHONY += _pip pip pip_release
+
+pip_release: PIP_ARGS="--real"
+pip_test: PIP_ARGS=""
+pip: PIP_ARGS="-n"
+
+pip pip_test pip_release: _pip
+
+_pip:
+   scripts/make_pip.sh u_boot_pylib ${PIP_ARGS}
+
 help:
@echo  'Cleaning targets:'
@echo  '  clean   - Remove most generated files but keep the 
config'
@@ -2305,6 +2316,11 @@ help:
@echo  "  cfg - Don't build, just create the .cfg files"
@echo  "  envtools- Build only the target-side environment 
tools"
@echo  ''
+   @echo  'PyPi / pip targets:'
+   @echo  '  pip - Check building of PyPi packages'
+   @echo  '  pip_test- Build PyPi pakages and upload to test 
server'
+   @echo  '  pip_release - Build PyPi pakages and upload to release 
server'
+   @echo  ''
@echo  'Static analysers'
@echo  '  checkstack  - Generate a list of stack hogs'
@echo  '  coccicheck  - Execute static code analysis with 
Coccinelle'
diff --git a/tools/u_boot_pylib/LICENSE b/tools/u_boot_pylib/LICENSE
new file mode 100644
index 000..d159169d105
--- /dev/null
+++ b/tools/u_boot_pylib/LICENSE
@@ -0,0 +1,339 @@
+GNU GENERAL PUBLIC LICENSE
+   Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid t

[PATCH v2 04/24] patman: Move library functions into a library directory

2023-02-23 Thread Simon Glass
The patman directory has a number of modules which are used by other tools
in U-Boot. This makes it hard to package the tools using pypi since the
common files must be copied along with the tool that uses them.

To address this, move these files into a new u_boot_pylib library. This
can be packaged separately and listed as a dependency of each tool.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 scripts/event_dump.py |  2 +-
 test/run  |  1 +
 tools/binman/bintool.py   |  8 +++
 tools/binman/bintool_test.py  |  8 +++
 tools/binman/btool/lz4.py |  2 +-
 tools/binman/btool/lzma_alone.py  |  2 +-
 tools/binman/cbfs_util.py |  4 ++--
 tools/binman/cbfs_util_test.py|  4 ++--
 tools/binman/control.py   |  6 ++---
 tools/binman/elf.py   |  6 ++---
 tools/binman/elf_test.py  |  8 +++
 tools/binman/entry.py |  6 ++---
 tools/binman/entry_test.py|  2 +-
 tools/binman/etype/_testing.py|  2 +-
 tools/binman/etype/atf_fip.py |  2 +-
 tools/binman/etype/blob.py|  4 ++--
 tools/binman/etype/blob_ext.py|  4 ++--
 tools/binman/etype/blob_ext_list.py   |  4 ++--
 tools/binman/etype/fdtmap.py  |  4 ++--
 tools/binman/etype/files.py   |  2 +-
 tools/binman/etype/fill.py|  2 +-
 tools/binman/etype/fit.py |  2 +-
 tools/binman/etype/fmap.py|  6 ++---
 tools/binman/etype/gbb.py |  4 ++--
 tools/binman/etype/intel_ifwi.py  |  2 +-
 tools/binman/etype/mkimage.py |  2 +-
 tools/binman/etype/null.py|  2 +-
 tools/binman/etype/pre_load.py|  2 +-
 tools/binman/etype/section.py |  6 ++---
 tools/binman/etype/text.py|  2 +-
 tools/binman/etype/u_boot_dtb_with_ucode.py   |  2 +-
 tools/binman/etype/u_boot_elf.py  |  2 +-
 tools/binman/etype/u_boot_env.py  |  2 +-
 tools/binman/etype/u_boot_spl_bss_pad.py  |  2 +-
 tools/binman/etype/u_boot_spl_expanded.py |  2 +-
 tools/binman/etype/u_boot_tpl_bss_pad.py  |  2 +-
 tools/binman/etype/u_boot_tpl_expanded.py |  2 +-
 .../binman/etype/u_boot_tpl_with_ucode_ptr.py |  4 ++--
 tools/binman/etype/u_boot_ucode.py|  2 +-
 tools/binman/etype/u_boot_vpl_bss_pad.py  |  2 +-
 tools/binman/etype/u_boot_vpl_expanded.py |  2 +-
 tools/binman/etype/u_boot_with_ucode_ptr.py   |  4 ++--
 tools/binman/etype/vblock.py  |  2 +-
 tools/binman/fdt_test.py  |  2 +-
 tools/binman/fip_util.py  |  4 ++--
 tools/binman/fip_util_test.py |  4 ++--
 tools/binman/fmap_util.py |  2 +-
 tools/binman/ftest.py |  8 +++
 tools/binman/image.py |  4 ++--
 tools/binman/image_test.py|  2 +-
 tools/binman/main.py  |  7 +++---
 tools/binman/state.py |  4 ++--
 tools/buildman/builder.py |  6 ++---
 tools/buildman/builderthread.py   |  2 +-
 tools/buildman/cfgutil.py |  2 +-
 tools/buildman/control.py |  8 +++
 tools/buildman/func_test.py   |  8 +++
 tools/buildman/main.py|  4 ++--
 tools/buildman/test.py|  8 +++
 tools/buildman/toolchain.py   |  6 ++---
 tools/dtoc/fdt.py |  2 +-
 tools/dtoc/fdt_util.py|  4 ++--
 tools/dtoc/main.py|  5 ++--
 tools/dtoc/test_dtoc.py   |  4 ++--
 tools/dtoc/test_fdt.py|  7 +++---
 tools/dtoc/test_src_scan.py   |  4 ++--
 tools/patman/__init__.py  |  7 +++---
 tools/patman/__main__.py  |  8 +++
 tools/patman/checkpatch.py|  4 ++--
 tools/patman/control.py   |  2 +-
 tools/patman/func_test.py |  6 ++---
 tools/patman/get_maintainer.py|  2 +-
 tools/patman/gitutil.py   |  4 ++--
 tools/patman/patchstream.py   |  2 +-
 tools/patman/series.py|  4 ++--
 tools/patman/status.py|  4 ++--
 tools/patman/test_settings.py |  2 +-
 tools/rmboard.py  |  2 +-
 tools/u_boot_pylib/__init__.py|  4 
 tools/u_boot_pylib/__main__.py| 23 +++
 tools/{patman => u_boot_pylib}/command.py |  2 

[PATCH v2 08/24] patman: Add support for building a patman PyPi package

2023-02-23 Thread Simon Glass
Create the necessary files to build this new package.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Rename the package to patch-manager

 Makefile|  1 +
 tools/patman/pyproject.toml | 29 +
 2 files changed, 30 insertions(+)
 create mode 100644 tools/patman/pyproject.toml

diff --git a/Makefile b/Makefile
index 9f008dea0ec..abd8d60a1bb 100644
--- a/Makefile
+++ b/Makefile
@@ -2282,6 +2282,7 @@ pip pip_test pip_release: _pip
 
 _pip:
scripts/make_pip.sh u_boot_pylib ${PIP_ARGS}
+   scripts/make_pip.sh patman ${PIP_ARGS}
 
 help:
@echo  'Cleaning targets:'
diff --git a/tools/patman/pyproject.toml b/tools/patman/pyproject.toml
new file mode 100644
index 000..c5dc7c7e276
--- /dev/null
+++ b/tools/patman/pyproject.toml
@@ -0,0 +1,29 @@
+[build-system]
+requires = ["setuptools>=61.0"]
+build-backend = "setuptools.build_meta"
+
+[project]
+name = "patch-manager"
+version = "0.0.2"
+authors = [
+  { name="Simon Glass", email="s...@chromium.org" },
+]
+dependencies = ["u_boot_pylib"]
+description = "Patman patch manager"
+readme = "README.rst"
+requires-python = ">=3.7"
+classifiers = [
+"Programming Language :: Python :: 3",
+"License :: OSI Approved :: GNU General Public License v2 or later 
(GPLv2+)",
+"Operating System :: OS Independent",
+]
+
+[project.urls]
+"Homepage" = "https://u-boot.readthedocs.io/en/latest/develop/patman.html";
+"Bug Tracker" = "https://source.denx.de/groups/u-boot/-/issues";
+
+[project.scripts]
+patman = "patman.__main__:run_patman"
+
+[tool.setuptools.package-data]
+patman = ["*.rst"]
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v2 05/24] script: Add a script to build a PyPi package

2023-02-23 Thread Simon Glass
Create a script which can package a tool for use with PyPi and the 'pip'
tool. This involves quite a few steps so is best automated. Future work
will enable use of this for some of the tools in U-Boot.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Drop test files
- Fix removable of the /tmp dir
- Quite a few updates to make things work with the new names

 scripts/make_pip.sh | 117 
 1 file changed, 117 insertions(+)
 create mode 100755 scripts/make_pip.sh

diff --git a/scripts/make_pip.sh b/scripts/make_pip.sh
new file mode 100755
index 000..4602dcf61c8
--- /dev/null
+++ b/scripts/make_pip.sh
@@ -0,0 +1,117 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+
+# Packages a U-Boot tool
+#
+# Usage: make_pip.sh  [--real]
+#
+# Where tool_name is one of patman, buildman, dtoc, binman, u_boot_pylib
+#
+# and --real means to upload to the real server (otherwise the test one is 
used)
+#
+# The username for upload is always __token__ so set TWINE_PASSWORD to your
+# password before running this script:
+#
+# export TWINE_PASSWORD=pypi-xxx
+#
+# To test your new packages:
+#
+# pip install -i https://test.pypi.org/simple/ 
+#
+
+# DO NOT use patman or binman
+
+set -xe
+
+# Repo to upload to
+repo="--repository testpypi"
+
+# Non-empty to do the actual upload
+upload=1
+
+tool="$1"
+shift
+flags="$*"
+
+if [[ "${tool}" =~ ^(patman|buildman|dtoc|binman|u_boot_pylib)$ ]]; then
+   echo "Building dist package for tool ${tool}"
+else
+   echo "Unknown tool ${tool}: use patman, buildman, dtoc or binman"
+   exit 1
+fi
+
+for flag in "${flags}"; do
+   if [ "${flag}" == "--real" ]; then
+   echo "Using real server"
+   repo=
+   fi
+   if [ "${flag}" == "-n" ]; then
+   echo "Doing dry run"
+   upload=
+   fi
+done
+
+if [ -n "${upload}" ]; then
+   if [ -z "${TWINE_PASSWORD}" ]; then
+   echo "Please set TWINE_PASSWORD to your password and retry"
+   exit 1
+   fi
+fi
+
+# Create a temp dir to work in
+dir=$(mktemp -d)
+
+# Copy in some basic files
+cp -v tools/${tool}/pyproject.toml ${dir}
+cp -v Licenses/gpl-2.0.txt ${dir}/LICENSE
+readme="tools/${tool}/README.*"
+
+# Copy in the README, dropping some Sphinx constructs that PyPi doesn't like
+cat ${readme} | sed -E 's/:(doc|ref):`.*`//; /sectionauthor/d; /toctree::/d' \
+   > ${dir}/$(basename ${readme})
+
+# Copy the top-level Python and doc files
+dest=${dir}/src/${tool}
+mkdir -p ${dest}
+cp -v tools/$tool/{*.py,*.rst} ${dest}
+
+# Copy over the subdirectories, including any sub files. Drop any cache files
+# and other such things
+pushd tools/${tool}
+for subdir in $(find . -maxdepth 1 -type d | \
+   grep -vE "(__pycache__|home|usr|scratch|\.$|pyproject)"); do
+   pathname="${dest}/${subdir}"
+   echo "Copy ${pathname}"
+   cp -a ${subdir} ${pathname}
+done
+popd
+
+# Remove cache files that accidentally made it through
+find ${dest} -name __pycache__ -type f -exec rm {} \;
+find ${dest} -depth -name __pycache__ -exec rmdir 112 \;
+
+# Remove test files
+rm -rf ${dest}/*test*
+
+mkdir ${dir}/tests
+cd ${dir}
+
+# Make sure the tools are up to date
+python3 -m pip install --upgrade build
+python3 -m pip install --upgrade twine
+
+# Build the PyPi package
+python3 -m build
+
+echo "Completed build of ${tool}"
+
+# Use --skip-existing to work even if the version is already present
+if [ -n "${upload}" ]; then
+   echo "Uploading from ${dir}"
+   python3 -m twine upload ${repo} -u __token__ dist/*
+   echo "Completed upload of ${tool}"
+fi
+
+rm -rf "${dir}"
+
+echo -e "done\n\n"
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v2 03/24] Remove concurrencytest

2023-02-23 Thread Simon Glass
While our version is better, it is tricky to use it when we are trying
to package things with pip. Drop it.

Somewhat reduced functionality is provided by the upstream version[1],
along with a rather annoying message each time it is used[2] [3].

[1] pip install concurrencytest
[2] https://github.com/cgoldberg/concurrencytest/issues/12
[3] https://github.com/cgoldberg/concurrencytest/pull/14

Signed-off-by: Simon Glass 
---

(no changes since v1)

 tools/concurrencytest/.gitignore |   1 -
 tools/concurrencytest/README.md  |  74 
 tools/concurrencytest/__init__.py|   0
 tools/concurrencytest/concurrencytest.py | 144 ---
 tools/patman/test_util.py|   4 +-
 5 files changed, 2 insertions(+), 221 deletions(-)
 delete mode 100644 tools/concurrencytest/.gitignore
 delete mode 100644 tools/concurrencytest/README.md
 delete mode 100644 tools/concurrencytest/__init__.py
 delete mode 100644 tools/concurrencytest/concurrencytest.py

diff --git a/tools/concurrencytest/.gitignore b/tools/concurrencytest/.gitignore
deleted file mode 100644
index 0d20b6487c6..000
--- a/tools/concurrencytest/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.pyc
diff --git a/tools/concurrencytest/README.md b/tools/concurrencytest/README.md
deleted file mode 100644
index 2d7fe75df53..000
--- a/tools/concurrencytest/README.md
+++ /dev/null
@@ -1,74 +0,0 @@
-concurrencytest
-===
-
-![testing 
goats](https://raw.github.com/cgoldberg/concurrencytest/master/testing-goats.png
 "testing goats")
-
-Python testtools extension for running unittest suites concurrently.
-
-
-
-Install from PyPI:
-```
-pip install concurrencytest
-```
-
-
-
-Requires:
-
-* [testtools](https://pypi.python.org/pypi/testtools) : `pip install testtools`
-* [python-subunit](https://pypi.python.org/pypi/python-subunit) : `pip install 
python-subunit`
-
-
-
-Example:
-
-```python
-import time
-import unittest
-
-from concurrencytest import ConcurrentTestSuite, fork_for_tests
-
-
-class SampleTestCase(unittest.TestCase):
-"""Dummy tests that sleep for demo."""
-
-def test_me_1(self):
-time.sleep(0.5)
-
-def test_me_2(self):
-time.sleep(0.5)
-
-def test_me_3(self):
-time.sleep(0.5)
-
-def test_me_4(self):
-time.sleep(0.5)
-
-
-# Load tests from SampleTestCase defined above
-suite = unittest.TestLoader().loadTestsFromTestCase(SampleTestCase)
-runner = unittest.TextTestRunner()
-
-# Run tests sequentially
-runner.run(suite)
-
-# Run same tests across 4 processes
-suite = unittest.TestLoader().loadTestsFromTestCase(SampleTestCase)
-concurrent_suite = ConcurrentTestSuite(suite, fork_for_tests(4))
-runner.run(concurrent_suite)
-```
-Output:
-
-```
-
---
-Ran 4 tests in 2.003s
-
-OK
-
---
-Ran 4 tests in 0.504s
-
-OK
-```
diff --git a/tools/concurrencytest/__init__.py 
b/tools/concurrencytest/__init__.py
deleted file mode 100644
index e69de29bb2d..000
diff --git a/tools/concurrencytest/concurrencytest.py 
b/tools/concurrencytest/concurrencytest.py
deleted file mode 100644
index 5e88b94f415..000
--- a/tools/concurrencytest/concurrencytest.py
+++ /dev/null
@@ -1,144 +0,0 @@
-#!/usr/bin/env python
-# SPDX-License-Identifier: GPL-2.0+
-#
-# Modified by: Corey Goldberg, 2013
-#
-# Original code from:
-#   Bazaar (bzrlib.tests.__init__.py, v2.6, copied Jun 01 2013)
-#   Copyright (C) 2005-2011 Canonical Ltd
-
-"""Python testtools extension for running unittest suites concurrently.
-
-The `testtools` project provides a ConcurrentTestSuite class, but does
-not provide a `make_tests` implementation needed to use it.
-
-This allows you to parallelize a test run across a configurable number
-of worker processes. While this can speed up CPU-bound test runs, it is
-mainly useful for IO-bound tests that spend most of their time waiting for
-data to arrive from someplace else and can benefit from cocncurrency.
-
-Unix only.
-"""
-
-import os
-import sys
-import traceback
-import unittest
-from itertools import cycle
-from multiprocessing import cpu_count
-
-from subunit import ProtocolTestCase, TestProtocolClient
-from subunit.test_results import AutoTimingTestResultDecorator
-
-from testtools import ConcurrentTestSuite, iterate_tests
-
-
-_all__ = [
-'ConcurrentTestSuite',
-'fork_for_tests',
-'partition_tests',
-]
-
-
-CPU_COUNT = cpu_count()
-
-
-def fork_for_tests(concurrency_num=CPU_COUNT):
-"""Implementation of `make_tests` used to construct `ConcurrentTestSuite`.
-
-:param concurrency_num: number of processes to use.
-"""
-def do_fork(suite):
-"""Take suite and start up multiple runners by forking (Unix only).
-
-:param suite: TestSuite object.
-
-:return: An iterable of TestCase-like objects which can each have
-run(result) 

[PATCH v2 02/24] Revert "patman: test_util: Print test stdout/stderr within test summaries"

2023-02-23 Thread Simon Glass
Unfortunately this adds a new feature to concurrencytest and it has not
made it upstream to the project[1].

Drop it for now so we can use the upstream module. Once it is applied we
can bring this functionality back.

[1] https://github.com/cgoldberg/concurrencytest

This reverts commit ebcaafcded40da8ae6cb4234c2ba9901c7bee644.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 tools/concurrencytest/concurrencytest.py | 83 +---
 tools/patman/test_util.py| 33 +-
 2 files changed, 4 insertions(+), 112 deletions(-)

diff --git a/tools/concurrencytest/concurrencytest.py 
b/tools/concurrencytest/concurrencytest.py
index 1c4f03f37e5..5e88b94f415 100644
--- a/tools/concurrencytest/concurrencytest.py
+++ b/tools/concurrencytest/concurrencytest.py
@@ -31,7 +31,6 @@ from subunit import ProtocolTestCase, TestProtocolClient
 from subunit.test_results import AutoTimingTestResultDecorator
 
 from testtools import ConcurrentTestSuite, iterate_tests
-from testtools.content import TracebackContent, text_content
 
 
 _all__ = [
@@ -44,81 +43,11 @@ _all__ = [
 CPU_COUNT = cpu_count()
 
 
-class BufferingTestProtocolClient(TestProtocolClient):
-"""A TestProtocolClient which can buffer the test outputs
-
-This class captures the stdout and stderr output streams of the
-tests as it runs them, and includes the output texts in the subunit
-stream as additional details.
-
-Args:
-stream: A file-like object to write a subunit stream to
-buffer (bool): True to capture test stdout/stderr outputs and
-include them in the test details
-"""
-def __init__(self, stream, buffer=True):
-super().__init__(stream)
-self.buffer = buffer
-
-def _addOutcome(self, outcome, test, error=None, details=None,
-error_permitted=True):
-"""Report a test outcome to the subunit stream
-
-The parent class uses this function as a common implementation
-for various methods that report successes, errors, failures, etc.
-
-This version automatically upgrades the error tracebacks to the
-new 'details' format by wrapping them in a Content object, so
-that we can include the captured test output in the test result
-details.
-
-Args:
-outcome: A string describing the outcome - used as the
-event name in the subunit stream.
-test: The test case whose outcome is to be reported
-error: Standard unittest positional argument form - an
-exc_info tuple.
-details: New Testing-in-python drafted API; a dict from
-string to subunit.Content objects.
-error_permitted: If True then one and only one of error or
-details must be supplied. If False then error must not
-be supplied and details is still optional.
-"""
-if details is None:
-details = {}
-
-# Parent will raise an exception if error_permitted is False but
-# error is not None. We want that exception in that case, so
-# don't touch error when error_permitted is explicitly False.
-if error_permitted and error is not None:
-# Parent class prefers error over details
-details['traceback'] = TracebackContent(error, test)
-error_permitted = False
-error = None
-
-if self.buffer:
-stdout = sys.stdout.getvalue()
-if stdout:
-details['stdout'] = text_content(stdout)
-
-stderr = sys.stderr.getvalue()
-if stderr:
-details['stderr'] = text_content(stderr)
-
-return super()._addOutcome(outcome, test, error=error,
-details=details, error_permitted=error_permitted)
-
-
-def fork_for_tests(concurrency_num=CPU_COUNT, buffer=False):
+def fork_for_tests(concurrency_num=CPU_COUNT):
 """Implementation of `make_tests` used to construct `ConcurrentTestSuite`.
 
 :param concurrency_num: number of processes to use.
 """
-if buffer:
-test_protocol_client_class = BufferingTestProtocolClient
-else:
-test_protocol_client_class = TestProtocolClient
-
 def do_fork(suite):
 """Take suite and start up multiple runners by forking (Unix only).
 
@@ -147,7 +76,7 @@ def fork_for_tests(concurrency_num=CPU_COUNT, buffer=False):
 # child actually gets keystrokes for pdb etc).
 sys.stdin.close()
 subunit_result = AutoTimingTestResultDecorator(
-test_protocol_client_class(stream)
+TestProtocolClient(stream)
 )
 process_suite.run(subunit_result)
 except:
@@ -164,13 +93,7 @@ def fork_for_tests(concurrency_num=CPU_COUNT, buffer=False):
 else:
 os.close(c2pwrite)

[PATCH v2 01/24] binman: Avoid unwanted output in testFitFirmwareLoadables()

2023-02-23 Thread Simon Glass
This prints a message about the missing tee-os generated by the test. This
is confusing, so suppress it.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 tools/binman/ftest.py | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 062f54adb0e..d469928b256 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -6353,10 +6353,11 @@ fdt fdtmapExtract the 
devicetree blob from the fdtmap
 'tee-os-path': 'missing.bin',
 }
 test_subdir = os.path.join(self._indir, TEST_FDT_SUBDIR)
-data = self._DoReadFileDtb(
-'276_fit_firmware_loadables.dts',
-entry_args=entry_args,
-extra_indirs=[test_subdir])[0]
+with test_util.capture_sys_output() as (stdout, stderr):
+data = self._DoReadFileDtb(
+'276_fit_firmware_loadables.dts',
+entry_args=entry_args,
+extra_indirs=[test_subdir])[0]
 
 dtb = fdt.Fdt.FromData(data)
 dtb.Scan()
-- 
2.39.2.637.g21b0678d19-goog



[PATCH v2 00/24] tools: Support uploading tools to PyPi for use with pip

2023-02-23 Thread Simon Glass
Some of the tools in U-Boot are useful beyond just U-Boot. For example,
patman can be used to work with Linux and other projects which use
mailing lists (and patchwork) for patch submissions. Binman can be used
to package firmware for any project, even though it is heavily slanted
towards U-Boot so far.

While patman has a setup script which is easy to use, binman is a little
more complicated, since it has dependencies, in particular pylibfdt

It would be better if we could put all the tools on PyPi.

This series adds a script for uploading tools. It makes it easier to
update PyPi from time to time, when new features appear.

U-Boot uses tools/patman as a common library of Python functions. For
this to work with PyPi it is easier to split these into a separate
library, used by patman as well. This series creates a new
'u_boot_pylib' package for this purpose.

Unfortunately, the U-Boot version of concurrencytest has some local
patches. To avoid dependency issues it seems better to revert these and
rely on the upstream package[1], although note that it is not actually
installed.

[1] Which unfortunately may be dead but perhaps we could request a new
maintainer?

Changes in v2:
- Add a patch to hide the test options unless test code is available
- Add new patch to avoid importing test_checkpatch before it is needed
- Add new patch to use importlib to find the help
- Add patch to fix use of a type as a variable
- Add patch to split out the main code into a function
- Drop test files
- Fix removable of the /tmp dir
- Quite a few updates to make things work with the new names
- Rename the package to patch-manager
- Update the cover letter

Simon Glass (24):
  binman: Avoid unwanted output in testFitFirmwareLoadables()
  Revert "patman: test_util: Print test stdout/stderr within test
summaries"
  Remove concurrencytest
  patman: Move library functions into a library directory
  script: Add a script to build a PyPi package
  patman: Add support for building a u_boot_tools PyPi package
  patman: Avoid importing test_checkpatch before it is needed
  patman: Add support for building a patman PyPi package
  buildman: Move the main code into a function
  buildman: Hide the test options unless test code is available
  buildman: Fix use of a type as a variable
  buildman: Use importlib to find the help
  buildman: Add support for building a buildman PyPi package
  dtoc: Hide the test options unless test code is available
  dtoc: Move the main code into a function
  dtoc: Use pathlib to find the test directory
  dtoc: Add support for building a dtoc PyPi package
  binman: Move the main code into a function
  binman: Hide the 'test' command unless test code is available
  binman: Use importlib to find the help
  binman: Add support for building a binmanu PyPi package
  test: Add concurrencytest to the requirements
  doc: Add notes on how to install patman and binman
  CI: Add a check for building tools for PyPi

 .azure-pipelines.yml  |  10 +
 .gitlab-ci.yml|   6 +
 Makefile  |  22 +-
 scripts/event_dump.py |   2 +-
 scripts/make_pip.sh   | 117 ++
 test/py/requirements.txt  |   1 +
 test/run  |   1 +
 tools/binman/binman.rst   |  13 +
 tools/binman/bintool.py   |   8 +-
 tools/binman/bintool_test.py  |   8 +-
 tools/binman/btool/lz4.py |   2 +-
 tools/binman/btool/lzma_alone.py  |   2 +-
 tools/binman/cbfs_util.py |   4 +-
 tools/binman/cbfs_util_test.py|   4 +-
 tools/binman/cmdline.py   |  34 +-
 tools/binman/control.py   |  12 +-
 tools/binman/elf.py   |   6 +-
 tools/binman/elf_test.py  |   8 +-
 tools/binman/entry.py |   6 +-
 tools/binman/entry_test.py|   2 +-
 tools/binman/etype/_testing.py|   2 +-
 tools/binman/etype/atf_fip.py |   2 +-
 tools/binman/etype/blob.py|   4 +-
 tools/binman/etype/blob_ext.py|   4 +-
 tools/binman/etype/blob_ext_list.py   |   4 +-
 tools/binman/etype/fdtmap.py  |   4 +-
 tools/binman/etype/files.py   |   2 +-
 tools/binman/etype/fill.py|   2 +-
 tools/binman/etype/fit.py |   2 +-
 tools/binman/etype/fmap.py|   6 +-
 tools/binman/etype/gbb.py |   4 +-
 tools/binman/etype/intel_ifwi.py  |   2 +-
 tools/binman/etype/mkimage.py |   2 +-
 tools/binman/etype/null.py|   2 +-
 tools/binman/etype/pre_load.py|   2 +-
 tools/binman/etype/section.py |   6 +-
 tools/binman/etype/text.py

[PATCH 3/3] mmc: fsl_esdhc_imx: add ColdFire support

2023-02-23 Thread Angelo Dureghello
From: Angelo Durgehello 

ColdFire mcf5441x includes the same imx esdhc controller module,
so adding minimal code to support it.

Signed-off-by: Angelo Durgehello 
---
 drivers/mmc/fsl_esdhc_imx.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c
index 66caf683f7..4e15738782 100644
--- a/drivers/mmc/fsl_esdhc_imx.c
+++ b/drivers/mmc/fsl_esdhc_imx.c
@@ -1381,7 +1381,9 @@ void fdt_fixup_esdhc(void *blob, struct bd_info *bd)
 #endif
 
 #if CONFIG_IS_ENABLED(DM_MMC)
+#if !CONFIG_IS_ENABLED(MCF5441x)
 #include 
+#endif
 __weak void init_clk_usdhc(u32 index)
 {
 }
@@ -1536,7 +1538,12 @@ static int fsl_esdhc_probe(struct udevice *dev)
 #else
init_clk_usdhc(dev_seq(dev));
 
+#if IS_ENABLED(CONFIG_MCF5441x)
+   priv->sdhc_clk = gd->arch.sdhc_clk;
+#else
priv->sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK + dev_seq(dev));
+#endif
+
if (priv->sdhc_clk <= 0) {
dev_err(dev, "Unable to get clk for %s\n", dev->name);
return -EINVAL;
-- 
2.39.1



[PATCH 2/3] board: stmark2: add mmc support

2023-02-23 Thread Angelo Dureghello
From: Angelo Durgehello 

Enable mmc boot.

Signed-off-by: Angelo Durgehello 
---
 arch/m68k/dts/stmark2.dts |  4 
 configs/stmark2_defconfig | 12 ++--
 include/configs/stmark2.h |  6 --
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/arch/m68k/dts/stmark2.dts b/arch/m68k/dts/stmark2.dts
index 3688651e59..9532a01b2f 100644
--- a/arch/m68k/dts/stmark2.dts
+++ b/arch/m68k/dts/stmark2.dts
@@ -41,3 +41,7 @@
status = "okay";
mii-base = <0>;
 };
+
+&esdhc1 {
+   status = "okay";
+};
diff --git a/configs/stmark2_defconfig b/configs/stmark2_defconfig
index ae7a9cf6da..ab95baa148 100644
--- a/configs/stmark2_defconfig
+++ b/configs/stmark2_defconfig
@@ -14,9 +14,9 @@ CONFIG_SYS_MONITOR_LEN=262144
 CONFIG_TIMESTAMP=y
 CONFIG_SYS_MONITOR_BASE=0x47E00400
 CONFIG_USE_BOOTARGS=y
-CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/ram0 rw rootfstype=ramfs 
rdinit=/bin/init devtmpfs.mount=1"
+CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/ram0 rw rootfstype=ramfs 
rdinit=/sbin/init devtmpfs.mount=1"
 CONFIG_USE_BOOTCOMMAND=y
-CONFIG_BOOTCOMMAND="sf probe 0:1 5000; sf read ${loadaddr} 0x10 
${kern_size}; bootm ${loadaddr}"
+CONFIG_BOOTCOMMAND="run boot_sd; bootm ${loadaddr} ${loadaddr_ramfs}"
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_SYS_MALLOC_BOOTPARAMS=y
 CONFIG_HUSH_PARSER=y
@@ -32,6 +32,12 @@ CONFIG_CMD_SPI=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_MTDPARTS=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_EXT2=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+CONFIG_DOS_PARTITION=y
 CONFIG_MTDIDS_DEFAULT="nor0=spi-flash.0"
 CONFIG_MTDPARTS_DEFAULT="mtdparts=spi-flash.0:1m(u-boot),7m(kernel),-(rootfs)"
 CONFIG_ENV_IS_IN_SPI_FLASH=y
@@ -41,6 +47,8 @@ CONFIG_USE_HOSTNAME=y
 CONFIG_HOSTNAME="stmark2"
 # CONFIG_NET is not set
 CONFIG_MTD=y
+CONFIG_MMC=y
+CONFIG_FSL_ESDHC_IMX=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SF_DEFAULT_SPEED=5000
 CONFIG_SPI_FLASH_ISSI=y
diff --git a/include/configs/stmark2.h b/include/configs/stmark2.h
index 19589be270..ddb85cc7d1 100644
--- a/include/configs/stmark2.h
+++ b/include/configs/stmark2.h
@@ -13,10 +13,12 @@
 #define LDS_BOARD_TEXT \
board/sysam/stmark2/sbf_dram_init.o (.text*)
 
-#define CFG_EXTRA_ENV_SETTINGS \
+#define CFG_EXTRA_ENV_SETTINGS \
+   "boot_sd=load mmc 0:1 ${loadaddr} uImage; " \
+   "load mmc 0:1 ${loadaddr_ramfs} uRamfs\0"   \
"kern_size=0x70\0"  \
"loadaddr=0x40001000\0" \
-   "-(rootfs)\0"   \
+   "loadaddr_ramfs=0x41001000\0"   \
"update_uboot=loady ${loadaddr}; "  \
"sf probe 0:1 5000; "   \
"sf erase 0 0x8; "  \
-- 
2.39.1



[PATCH 1/3] m68k: add mmc device for mcf5441x

2023-02-23 Thread Angelo Dureghello
From: Angelo Durgehello 

Add mmc support for the mcf5441x family.

Signed-off-by: Angelo Durgehello 
---
 arch/m68k/dts/mcf5441x.dtsi | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/m68k/dts/mcf5441x.dtsi b/arch/m68k/dts/mcf5441x.dtsi
index 6769bdc270..6383b50f11 100644
--- a/arch/m68k/dts/mcf5441x.dtsi
+++ b/arch/m68k/dts/mcf5441x.dtsi
@@ -103,5 +103,13 @@
timeout-loop = <5>;
status = "disabled";
};
+
+   esdhc1: mmc@0xfc0cc000 {
+   compatible = "fsl,esdhc";
+   reg = <0xfc0cc000 0x8000>;
+   non-removable;
+   bus-width = <4>;
+   status = "disabled";
+   };
};
 };
-- 
2.39.1



[PATCH] m68k: use longword-based jumps

2023-02-23 Thread Angelo Dureghello
From: Angelo Durgehello 

Increasing of binary size requires longword-based jumps.

Signed-off-by: Angelo Durgehello 
---
 arch/m68k/cpu/mcf530x/start.S | 18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/arch/m68k/cpu/mcf530x/start.S b/arch/m68k/cpu/mcf530x/start.S
index dbe2b54e41..cef8d79aad 100644
--- a/arch/m68k/cpu/mcf530x/start.S
+++ b/arch/m68k/cpu/mcf530x/start.S
@@ -132,7 +132,8 @@ _start:
 * then (and always) gd struct space will be reserved
 */
move.l  %sp, -(%sp)
-   bsr board_init_f_alloc_reserve
+   move.l  #board_init_f_alloc_reserve, %a1
+   jsr (%a1)
 
/* update stack and frame-pointers */
move.l  %d0, %sp
@@ -140,14 +141,17 @@ _start:
 
/* initialize reserved area */
move.l  %d0, -(%sp)
-   bsr board_init_f_init_reserve
+   move.l  #board_init_f_init_reserve, %a1
+   jsr (%a1)
 
/* run low-level CPU init code (from flash) */
-   bsr cpu_init_f
+   move.l  #cpu_init_f, %a1
+   jsr (%a1)
 
/* run low-level board init code (from flash) */
clr.l   %sp@-
-   bsr board_init_f
+   move.l  #board_init_f, %a1
+   jsr (%a1)
 
/* board_init_f() does not return */
 
@@ -239,7 +243,8 @@ _fault:
 _exc_handler:
SAVE_ALL
movel   %sp,%sp@-
-   bsr exc_handler
+   move.l  #exc_handler, %a1
+   jsr (%a1)
addql   #4,%sp
RESTORE_ALL
 
@@ -247,7 +252,8 @@ _exc_handler:
 _int_handler:
SAVE_ALL
movel   %sp,%sp@-
-   bsr int_handler
+   move.l  #int_handler, %a1
+   jsr (%a1)
addql   #4,%sp
RESTORE_ALL
 
-- 
2.39.1



[PATCH] board: amcore: fix u-boot mtd partition

2023-02-23 Thread Angelo Dureghello
From: Angelo Durgehello 

Signed-off-by: Angelo Dureghello 
---
 include/configs/amcore.h | 20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/include/configs/amcore.h b/include/configs/amcore.h
index 648d30a5b2..37c45e7172 100644
--- a/include/configs/amcore.h
+++ b/include/configs/amcore.h
@@ -10,14 +10,20 @@
 
 #define CFG_SYS_UART_PORT  0
 
-#define CFG_EXTRA_ENV_SETTINGS \
+#define CONFIG_MCFTMR
+#define CONFIG_MCFUART
+#define CONFIG_SYS_UART_PORT   0
+#define CONFIG_SYS_BAUDRATE_TABLE  { 9600, 19200, 38400, 57600, 115200 }
+
+#define CONFIG_BOOTCOMMAND "bootm ffc3"
+#define CONFIG_EXTRA_ENV_SETTINGS  \
"upgrade_uboot=loady; " \
-   "protect off 0xffc0 0xffc1; "   \
-   "erase 0xffc0 0xffc1; " \
+   "protect off 0xffc0 0xffc2; "   \
+   "erase 0xffc0 0xffc2; " \
"cp.b 0x2 0xffc0 ${filesize}\0" \
"upgrade_kernel=loady; "\
-   "erase 0xffc2 0xffef; " \
-   "cp.b 0x2 0xffc2 ${filesize}\0" \
+   "erase 0xffc3 0xffef; " \
+   "cp.b 0x2 0xffc3 ${filesize}\0" \
"upgrade_jffs2=loady; " \
"erase 0xfff0 0x; " \
"cp.b 0x2 0xfff0 ${filesize}\0"
@@ -38,6 +44,10 @@
 /* amcore design has flash data bytes wired swapped */
 #define CFG_SYS_WRITE_SWAPPED_DATA
 /* reserve 128-4KB */
+#define CONFIG_SYS_MONITOR_BASE(CONFIG_SYS_FLASH_BASE + 0x400)
+#define CONFIG_SYS_MONITOR_LEN  ((192 - 4) * 1024)
+#define CONFIG_SYS_MALLOC_LEN  (1 * 1024 * 1024)
+#define CONFIG_SYS_BOOTPARAMS_LEN  (64 * 1024)
 
 #define LDS_BOARD_TEXT \
. = DEFINED(env_offset) ? env_offset : .; \
-- 
2.39.1



Re: [PATCH RFC 0/3] FMP versioning support

2023-02-23 Thread Masahisa Kojima
Hi Heinrich,

On Thu, 23 Feb 2023 at 14:53, Heinrich Schuchardt  wrote:
>
>
>
> Am 22. Februar 2023 11:40:33 MEZ schrieb Masahisa Kojima 
> :
> >This series aims to add the versioning support
> >in FMP protocol implementation.
> >
> >EDK2 reference implementation utilizes the FMP Payload Header
> >inserted right before the capsule payload. With this series,
> >U-Boot also follows the EDK2 implementation.
> >
> >Note that this series is RFC and only tested with RAW image
> >with single image index.
>
> Hello Masahisa,
>
> Could you please describe if this change will be compatible with boards that 
> are already using the existing U-Boot FMP implementation.

Yes, this change is compatible with boards using the existing U-Boot
FMP implementation.
This change utilizes the FMP Payload Header inserted right before the
capsule payload by EDK2
capsule generation script.
This change does not mandate the FMP Payload Header.
If no FMP Payload Header is found in the capsule file, fw_version,
lowest supported
version, last attempt version and last attempt status is 0 and this is
the same behavior as existing FMP
implementation.

>
> Further please describe the benefit of the change.

Currently, there is no way to know the current running firmware
version through the EFI interface.
So a user can not know that expected firmware is running after the
capsule update.
Here is the current result of FMP->GetImageInfo(). "Version" number is always 0.

# CapsuleApp.efi -P


# FMP DATA #

FMP (0) ImageInfo:
  DescriptorVersion  - 0x4
  DescriptorCount- 0x1
  DescriptorSize - 0x78
  PackageVersion - 0x
  PackageVersionName - ""
  ImageDescriptor (0)
ImageIndex  - 0x1
ImageTypeId - -66E9-8808-BA84-9347A90833E0
ImageId - 0x1
ImageIdName - "DEVELOPERBOX-FIP"
Version - 0x0
VersionName - ""
Size- 0x0
<--snip-->

After this series is applied, "Version" will have the number specified
in the capsule file generation.

I will add these explanations in the relevant commit message and cover letter.

Regards,
Masahisa Kojima



>
> Best regards
>
> Heinrich
>
>
> >
> >[TODO]
> >- test with FIT image, authenticated capsule, multiple image index.
> >- enhance U-Boot mkeficapsule tool to insert FMP Payload Header
> >
> >Masahisa Kojima (3):
> >  efi_loader: store firmware version into FmpState variable
> >  efi_loader: versioning support in GetImageInfo
> >  efi_loader: check lowest supported version in capsule update
> >
> > lib/efi_loader/efi_firmware.c | 269 ++
> > 1 file changed, 242 insertions(+), 27 deletions(-)
> >


Re: [PATCH v5 30/44] lib: Add an SPL config for LIB_UUID

2023-02-23 Thread Simon Glass
Hi Heinrich,

On Wed, 22 Feb 2023 at 23:19, Heinrich Schuchardt  wrote:
>
>
>
> Am 22. Februar 2023 17:34:11 MEZ schrieb Simon Glass :
> >This is selected by PARTITION_UUIDS which has a separate option for SPL.
> >Add an SPL option for LIB_UUID also, so that we can keep them consistent.
> >
> >Also add one for PARTITION_TYPE_GUID to avoid a build error in part_efi.c
> >which wants to call a uuid function in SPL.
> >
> >Signed-off-by: Simon Glass 
> >---
> >
> >(no changes since v1)
> >
> > disk/Kconfig | 8 
> > lib/Kconfig  | 4 
> > 2 files changed, 12 insertions(+)
> >
> >diff --git a/disk/Kconfig b/disk/Kconfig
> >index c9b9dbaf1a6..817b7c8c76d 100644
> >--- a/disk/Kconfig
> >+++ b/disk/Kconfig
> >@@ -149,6 +149,7 @@ config SPL_PARTITION_UUIDS
> >   bool "Enable support of UUID for partition in SPL"
> >   depends on SPL_PARTITIONS
> >   default y if SPL_EFI_PARTITION
> >+  select SPL_LIB_UUID
> >
> > config PARTITION_TYPE_GUID
> >   bool "Enable support of GUID for partition type"
> >@@ -157,4 +158,11 @@ config PARTITION_TYPE_GUID
> > Activate the configuration of GUID type
> > for EFI partition
> >
> >+config SPL_PARTITION_TYPE_GUID
>
> Hello Simon,
>
> you have seen my series for using the partition type guid to load main 
> U-Boot. I would like to put that change into v2023.04.
>
> If my series goes in first, we will have to add a patch to this series to 
> adjust dependencies.

OK

>
> Can we use the mmc driver in sandbox_spl for testing loading main U-Boot from 
> mmc based on different criteria like partition number, partion_type_guid, 
> file name?
>

Yes you can.

But I suggest using sandbox_vpl, since in that build we are using
OF_REAL in SPL, i.e. it has an actual device tree. That means you
won't have to adjust the sandbox mmc driver to use of-platdata (not
that it would be particularly tricky).

You'll need to update 'TEST_PY_TEST_SPEC: "test_vpl_help or test_spl"'
in CI though, so it runs.

Regards,
Simon


Re: [PATCH v1 19/24] arm: mach-imx: use CONFIG_$(SPL_)SATA instead of CONFIG_SATA

2023-02-23 Thread Simon Glass
Hi Troy,

On Thu, 23 Feb 2023 at 12:24, Troy Kisky  wrote:
>
> On Wed, Feb 22, 2023 at 7:05 AM Tom Rini  wrote:
>>
>> On Tue, Feb 21, 2023 at 05:38:16PM -0800, Troy Kisky wrote:
>>
>> > This avoid an error with enable_sata_clock when
>> > defined(CONFIG_SATA) is changed to CONFIG_IS_ENABLED(SATA).
>> >
>> > Signed-off-by: Troy Kisky 
>> > ---
>> >
>> >  arch/arm/mach-imx/Makefile | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
>> > index 4dfc60eedc4..50f26975eac 100644
>> > --- a/arch/arm/mach-imx/Makefile
>> > +++ b/arch/arm/mach-imx/Makefile
>> > @@ -54,7 +54,7 @@ obj-$(CONFIG_IMX_RDC) += rdc-sema.o
>> >  ifneq ($(CONFIG_SPL_BUILD),y)
>> >  obj-$(CONFIG_IMX_BOOTAUX) += imx_bootaux.o
>> >  endif
>> > -obj-$(CONFIG_SATA) += sata.o
>> > +obj-$(CONFIG_$(SPL_)SATA) += sata.o
>> >  obj-$(CONFIG_IMX_HAB)+= hab.o
>> >  obj-$(CONFIG_SYSCOUNTER_TIMER) += syscounter.o
>> >  endif
>>
>> In that Simon thinks the $(SPL_) syntax here is ugly, lets just move
>> this line in to the existing guard for non-SPL builds, with
>> imx_bootaux.o.
>>
>> --
>> Tom
>
>
> Hi Tom
>
> I don't think that does the same thing for mach-mvebu.
>
> arch/arm/mach-mvebu/Kconfig-config MVEBU_SPL_BOOT_DEVICE_SATA
> arch/arm/mach-mvebu/Kconfig-bool "SATA"
> arch/arm/mach-mvebu/Kconfig:imply SPL_SATA
>
> Shouldn't it be linked in SPL builds as well for that one?

Yes I think $(SPL_) is ugly but it's fine to add one...if we move to
split config it will just be another to remove.

Regards,
Simon


Re: [PATCH v1 0/3] fdt: Fix mtparts fixup

2023-02-23 Thread Tom Rini
On Thu, Feb 23, 2023 at 11:23:41AM +0100, Patrick DELAUNAY wrote:
> Hi,
> 
> On 1/23/23 21:01, Tom Rini wrote:
> > On Mon, Jan 23, 2023 at 11:06:06AM +0100, Miquel Raynal wrote:
> > > Hi Tom,
> > > 
> > > tr...@konsulko.com wrote on Fri, 13 Jan 2023 14:34:11 -0500:
> > > 
> > > > On Fri, Jan 13, 2023 at 07:45:44PM +0100, Francesco Dolcini wrote:
> > > > 
> > > > > From: Francesco Dolcini 
> > > > > 
> > > > > Recently we had a boot regression on colibri-imx7 because of a 
> > > > > cleanup change
> > > > > on Linux imx7.dtsi setting nand controller node #size-cells from 1 to 
> > > > > 0.
> > > > > 
> > > > > Because of that Linux partition parser was no longer able to properly
> > > > > parse the OF partitions leading to a boot failure, the above change 
> > > > > was
> > > > > reverted in the meantime as an immediate workaround, but some 
> > > > > improvement
> > > > > is required on both Linux and U-Boot.
> > > > > 
> > > > > This change improve the U-Boot part of it, #size-cell is set to 1 when
> > > > > it has an invalid value. This has the limitation to work only with 
> > > > > devices
> > > > > smaller than 4GiB. In general the suggestion from the Linux MTD 
> > > > > maintainer would
> > > > > be to just deprecate using this U-Boot function and pass the MTD 
> > > > > partitions
> > > > > from the command line, unless they are statically defined in the DTS 
> > > > > file
> > > > > in the first place.
> > > > > 
> > > > > This series therefore convert colibri-imx6ull and colibri-imx7 to 
> > > > > pass the
> > > > > partition list from the command line instead of fixing up the DT.
> > > > > 
> > > > > Link: 
> > > > > https://lore.kernel.org/all/20221202071900.1143950-1-france...@dolcini.it/
> > > > > Link: 
> > > > > https://lore.kernel.org/all/y4dgbtgnwpm6s...@francesco-nb.int.toradex.com/
> > > > My higher level question / concern here is, is using one of the dts
> > > > partition schemes still valid / preferred, or should everyone now have
> > > > reverted to passing via the kernel command line?  If device tree still,
> > > > is mtd/partitions/fixed-partitions.yaml the one to follow or something
> > > > else?
> > > I don't think we can "prefer" one mode over the other between cmdline
> > > and DTS. Both should work pretty well. Of course on the cmdline you can
> > > only define fixed partitions and many devices require more advanced
> > > parsers, which are only available through DTS, but for simple
> > > partitions, it works totally okay.
> > When both are present, which one is used?
> > 
> > > The only thing that I would like to avoid is the need to write code in
> > > the bootloaders to tweak the FDT in order to add partitions. That is
> > > clearly not needed, error prone, and do not follow evolution of the
> > > "standard", as we just discovered.
> > I'm not sure about this. Looking around in U-Boot today, I see two types
> > of cases. One of which, the colibri case, can clearly be not done and
> > either passed on the command line, or put in to the device tree as
> > there's nothing run-time related being tweaked here. That's a fine path
> > to take on those platforms and Francesco's patches should be updated to
> > remove the unused C code too from the board code.
> > 
> > But the other cases are doing something dynamic and run-time related.
> > There's the omap3 igep00x0 family (which yes, legacy) that is doing NAND
> > or oneNAND and adjusting things at run time.  I don't know how much
> > anyone has interest in those platforms at this point, nor exactly who to
> > contact (for Linux or U-Boot). There's also the stm32mp1 family doing
> > something that's very not obvious at first glance, so I've cc'd the
> > maintainers there.
> > 
> 
> For information, today for stm32mp1 family we are using the build
> 
>  of MTDPARTS and fdt fixup, only for backward compatibility issue
> 
> (the MTD partitions change for boot with or without OP-TEE,
> 
> with or wihtout FIP, with SPL).
> 
> 
> Today we are already plan to remove this dynamic management
> 
> and to switch to static MTD partition defined in device tree,
> 
> as already proposed by Tom in the serie
> 
>  "mtd: spi: nor: force mtd name to "nor%d""
> 
> http://patchwork.ozlabs.org/project/uboot/patch/20210916155040.v3.2.Ia461e670c7438478aa8f8939209d45c818ccd284@changeid/
> 
> 
> This patchset is already ready, we are currently testing it internally
> 
> and it should be pushed when it will be validated in our donwstream.

Great, thanks.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] lmb: Bump CONFIG_LMB_MAX_REGIONS

2023-02-23 Thread Tom Rini
On Thu, Feb 23, 2023 at 10:24:44AM +0100, Patrick DELAUNAY wrote:
> Hi,
> 
> On 2/17/23 10:28, Michal Suchánek wrote:
> > Hello,
> > 
> > On Sun, Feb 12, 2023 at 06:45:36PM -0500, Tom Rini wrote:
> > > On Wed, Feb 08, 2023 at 02:50:16PM -0500, Tom Rini wrote:
> > > > On Wed, Feb 08, 2023 at 08:11:34PM +0100, Michal Suchánek wrote:
> > > > > Hello,
> > > > > 
> > > > > On Wed, Feb 08, 2023 at 01:25:50PM -0500, Tom Rini wrote:
> > > > > > On Wed, Feb 08, 2023 at 07:24:25PM +0100, Francesco Dolcini wrote:
> > > > > > > Hello,
> > > > > > > 
> > > > > > > On Fri, Jan 27, 2023 at 08:54:55AM -0500, Tom Rini wrote:
> > > > > > > > On Fri, Jan 27, 2023 at 02:00:12PM +0100, Michal Suchanek wrote:
> > > > > > > > > It is reported that in some configurations it is not possible 
> > > > > > > > > to boot
> > > > > > > > > because u-boot runs out of lmbs.
> > > > > > > > > 
> > > > > > > > > commit 06d514d77c ("lmb: consider EFI memory map") increases 
> > > > > > > > > lmb usage,
> > > > > > > > > hence is likely the cause of the lmb overflow.
> > > > > > > > > 
> > > > > > > > > Fixes: 06d514d77c ("lmb: consider EFI memory map")
> > > > > > > > > Link: https://bugzilla.opensuse.org/show_bug.cgi?id=1207562
> > > > > > > > > Signed-off-by: Michal Suchanek 
> > > > > > > Reviewed-by: Francesco Dolcini 
> > > > > > > 
> > > > > > > > I plan to pick up
> > > > > > > > https://patchwork.ozlabs.org/project/uboot/patch/20230125230823.1567778-1-tr...@konsulko.com/
> > > > > > > > as the alternative fix for this issue and would suggest that 
> > > > > > > > any distro
> > > > > > > > hitting the problem on v2023.01 apply the above instead of 
> > > > > > > > increasing
> > > > > > > > the limit.
> > > > > > > Tom, my understanding is that you plan to merge this or an 
> > > > > > > equivalent
> > > > > > > change, correct? Otherwise I would need to send some more patches 
> > > > > > > to
> > > > > > > update a few board defconfig that are affected by this specific 
> > > > > > > issue.
> > > > > > Yes, I was hoping to push the equivalent of this patch a few hours 
> > > > > > ago,
> > > > > > along with the revert. Then I noticed the test in test/lib/lmb.c 
> > > > > > doesn't
> > > > > > scale past 8, and I just now figured out what that should look like
> > > > > > instead, I believe.
> > > > > reportedly neither fixes the problem in all cases, and raising
> > > > > CONFIG_LMB_RESERVED_REGIONS is required.
> > > > > 
> > > > > Looks like the mechanism to add regions above the default number does
> > > > > not work as intended.
> > > > > 
> > > > > The test is to boot rPi 4 from USB directly with recent firmware.
> > > > Well, given 0089affee275 ("configs: stm32mp15: increase the number of
> > > > reserved memory region in lmb") I guess this has been run in to before,
> > > > but not resolved more generically.
> > > I wonder if
> > > https://patchwork.ozlabs.org/project/uboot/patch/20230212150706.2967007-2-sjo...@collabora.com/
> > > is what will finish dealing with these issues, even the ones that had
> > > perhaps shown up before and been addressed in the commit I mentioned
> > > above?
> > Looks like this together with raising the maximum number of regions
> > works, that is v2023.04-rc2 should be fixed.
> > 
> > Thanks
> > 
> > Michal
> 
> 
> For STM32MP15x platform with have the same issue when the number of reserved
> regions increased in Linux device tree.
> 
> 
> I try to increase the region by default with CONFIG_LMB_MAX_REGIONS,
> 
> but my patch increase the used RAM size for some platform (with compilation
> issue).
> 
> 
> For Tom ask me to propose a backward compatible configuration
> 
> https://lore.kernel.org/all/18550712-c32d-e08b-c38e-6c63bad09...@foss.st.com/
> 
> => CONFIG_USE_LMB_MAX_REGIONS
> 
> 
> Moreover, if you increased CONFIG_LMB_MAX_REGIONS
> 
> the same number of region (N) is used for reserved regions (N) and for 
> memory region (N)
> 
> => the total size used = 2 * N * size of each memory region descriptor.
> 
> 
> But for most of case only the number reserved regions need to be increased
> to parse the device tree.
> 
> 
> With my patch the number of regions are statically managed by  2 array
> independently
> 
> - reserved regions = CONFIG_LMB_RESERVED_REGIONS
> 
> - memory region = CONFIG_LMB_MEMORY_REGIONS
> 
> And the total number of region (size of struct in memory) =
> 
> CONFIG_LMB_RESERVED_REGIONS + CONFIG_LMB_MEMORY_REGIONS
> 
> 
> I think a good solution to have by default, if you want managed more
> reserved memory by default in U-Boot for all platform:
> 
> 
> => LMB_USE_MAX_REGIONS=n  instead of 'y' today
> 
> => LMB_MEMORY_REGIONS=8
> 
> => LMB_RESERVED_REGIONS=16 or 32 instead of 8 today by default
> 
> 
> And change the defconfig for the size constraint platforms
> 
> to use the previous behavior with LMB_USE_MAX_REGIONS=y.
> 
> 
> NB: I define the default value with 8 to keep the previous limit and
> 
>    I just increase the number of region for the STM32MP platform:
> 

Re: [PATCH v1] configs: j7200: Merge HS and non-HS defconfigs

2023-02-23 Thread Tom Rini
On Wed, Feb 22, 2023 at 09:02:12AM -0600, Andrew Davis wrote:
> On 2/22/23 1:56 AM, Manorit Chawdhry wrote:
> > K3 devices have runtime type board detection. Make the default defconfig
> > include the secure configuration. Then remove the HS specific config.
> > 
> > Non-HS devices will continue to boot due to runtime device type detection.
> > If TI_SECURE_DEV_PKG is not set the build will emit warnings, for non-HS
> > devices these can be ignored.
> > 
> > Signed-off-by: Manorit Chawdhry 
> > ---
> 
> This will help with keeping the HS and non-HS configs in sync :)
> 
> Acked-by: Andrew Davis 

Please re-spin both of these to update the MAINTAINERS file as well.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v1 19/24] arm: mach-imx: use CONFIG_$(SPL_)SATA instead of CONFIG_SATA

2023-02-23 Thread Tom Rini
On Thu, Feb 23, 2023 at 11:23:47AM -0800, Troy Kisky wrote:
> On Wed, Feb 22, 2023 at 7:05 AM Tom Rini  wrote:
> 
> > On Tue, Feb 21, 2023 at 05:38:16PM -0800, Troy Kisky wrote:
> >
> > > This avoid an error with enable_sata_clock when
> > > defined(CONFIG_SATA) is changed to CONFIG_IS_ENABLED(SATA).
> > >
> > > Signed-off-by: Troy Kisky 
> > > ---
> > >
> > >  arch/arm/mach-imx/Makefile | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
> > > index 4dfc60eedc4..50f26975eac 100644
> > > --- a/arch/arm/mach-imx/Makefile
> > > +++ b/arch/arm/mach-imx/Makefile
> > > @@ -54,7 +54,7 @@ obj-$(CONFIG_IMX_RDC) += rdc-sema.o
> > >  ifneq ($(CONFIG_SPL_BUILD),y)
> > >  obj-$(CONFIG_IMX_BOOTAUX) += imx_bootaux.o
> > >  endif
> > > -obj-$(CONFIG_SATA) += sata.o
> > > +obj-$(CONFIG_$(SPL_)SATA) += sata.o
> > >  obj-$(CONFIG_IMX_HAB)+= hab.o
> > >  obj-$(CONFIG_SYSCOUNTER_TIMER) += syscounter.o
> > >  endif
> >
> > In that Simon thinks the $(SPL_) syntax here is ugly, lets just move
> > this line in to the existing guard for non-SPL builds, with
> > imx_bootaux.o.
> >
> > --
> > Tom
> >
> 
> Hi Tom
> 
> I don't think that does the same thing for mach-mvebu.
> 
> arch/arm/mach-mvebu/Kconfig-config MVEBU_SPL_BOOT_DEVICE_SATA
> arch/arm/mach-mvebu/Kconfig-bool "SATA"
> arch/arm/mach-mvebu/Kconfig:imply SPL_SATA
> 
> Shouldn't it be linked in SPL builds as well for that one?

Well, OK. I see there's not yet SPL_SATA functional on imx, but, when
the time comes, that file is likely to be used, so this change make
sense, thanks for explaining.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH V2 7/9] gpio/rockchip: rk_gpio support v2 gpio controller

2023-02-23 Thread Vasily Khoruzhick
On Mon, Feb 13, 2023 at 2:30 PM Chris Morgan  wrote:
>
> From: Chris Morgan 
>
> Add support for the newer GPIO controller used by the rk356x series,
> as well as the pinctrl device for the rk356x series. The GPIOv2
> controller has a write enable bit for some registers which differs
> from the older versions of the GPIO controller.
>
> Signed-off-by: Peter Geis 
> Signed-off-by: Chris Morgan 

With pinctrl part from
https://patchwork.ozlabs.org/project/uboot/patch/20230217115845.75303-11-ja...@amarulasolutions.com/

Tested-by: Vasily Khoruzhick 

> ---
>  arch/arm/include/asm/arch-rockchip/gpio.h |  38 ++
>  drivers/gpio/rk_gpio.c|  49 +-
>  drivers/pinctrl/rockchip/Makefile |   1 +
>  drivers/pinctrl/rockchip/pinctrl-rk3568.c | 453 ++
>  .../pinctrl/rockchip/pinctrl-rockchip-core.c  |  12 +-
>  5 files changed, 540 insertions(+), 13 deletions(-)
>  create mode 100644 drivers/pinctrl/rockchip/pinctrl-rk3568.c
>
> diff --git a/arch/arm/include/asm/arch-rockchip/gpio.h 
> b/arch/arm/include/asm/arch-rockchip/gpio.h
> index 1aaec5faec..15f5de321b 100644
> --- a/arch/arm/include/asm/arch-rockchip/gpio.h
> +++ b/arch/arm/include/asm/arch-rockchip/gpio.h
> @@ -6,6 +6,7 @@
>  #ifndef _ASM_ARCH_GPIO_H
>  #define _ASM_ARCH_GPIO_H
>
> +#if !defined(CONFIG_ROCKCHIP_RK3568)
>  struct rockchip_gpio_regs {
> u32 swport_dr;
> u32 swport_ddr;
> @@ -22,7 +23,44 @@ struct rockchip_gpio_regs {
> u32 reserved1[(0x60 - 0x54) / 4];
> u32 ls_sync;
>  };
> +
>  check_member(rockchip_gpio_regs, ls_sync, 0x60);
> +#else
> +struct rockchip_gpio_regs {
> +   u32 swport_dr_l;/* ADDRESS OFFSET: 0x */
> +   u32 swport_dr_h;/* ADDRESS OFFSET: 0x0004 */
> +   u32 swport_ddr_l;   /* ADDRESS OFFSET: 0x0008 */
> +   u32 swport_ddr_h;   /* ADDRESS OFFSET: 0x000c */
> +   u32 int_en_l;   /* ADDRESS OFFSET: 0x0010 */
> +   u32 int_en_h;   /* ADDRESS OFFSET: 0x0014 */
> +   u32 int_mask_l; /* ADDRESS OFFSET: 0x0018 */
> +   u32 int_mask_h; /* ADDRESS OFFSET: 0x001c */
> +   u32 int_type_l; /* ADDRESS OFFSET: 0x0020 */
> +   u32 int_type_h; /* ADDRESS OFFSET: 0x0024 */
> +   u32 int_polarity_l; /* ADDRESS OFFSET: 0x0028 */
> +   u32 int_polarity_h; /* ADDRESS OFFSET: 0x002c */
> +   u32 int_bothedge_l; /* ADDRESS OFFSET: 0x0030 */
> +   u32 int_bothedge_h; /* ADDRESS OFFSET: 0x0034 */
> +   u32 debounce_l; /* ADDRESS OFFSET: 0x0038 */
> +   u32 debounce_h; /* ADDRESS OFFSET: 0x003c */
> +   u32 dbclk_div_en_l; /* ADDRESS OFFSET: 0x0040 */
> +   u32 dbclk_div_en_h; /* ADDRESS OFFSET: 0x0044 */
> +   u32 dbclk_div_con;  /* ADDRESS OFFSET: 0x0048 */
> +   u32 reserved004c;   /* ADDRESS OFFSET: 0x004c */
> +   u32 int_status; /* ADDRESS OFFSET: 0x0050 */
> +   u32 reserved0054;   /* ADDRESS OFFSET: 0x0054 */
> +   u32 int_rawstatus;  /* ADDRESS OFFSET: 0x0058 */
> +   u32 reserved005c;   /* ADDRESS OFFSET: 0x005c */
> +   u32 port_eoi_l; /* ADDRESS OFFSET: 0x0060 */
> +   u32 port_eoi_h; /* ADDRESS OFFSET: 0x0064 */
> +   u32 reserved0068[2];/* ADDRESS OFFSET: 0x0068 */
> +   u32 ext_port;   /* ADDRESS OFFSET: 0x0070 */
> +   u32 reserved0074;   /* ADDRESS OFFSET: 0x0074 */
> +   u32 ver_id; /* ADDRESS OFFSET: 0x0078 */
> +};
> +
> +check_member(rockchip_gpio_regs, ver_id, 0x0078);
> +#endif
>
>  enum gpio_pu_pd {
> GPIO_PULL_NORMAL = 0,
> diff --git a/drivers/gpio/rk_gpio.c b/drivers/gpio/rk_gpio.c
> index 98a79b5f4d..e2653be058 100644
> --- a/drivers/gpio/rk_gpio.c
> +++ b/drivers/gpio/rk_gpio.c
> @@ -2,12 +2,15 @@
>  /*
>   * (C) Copyright 2015 Google, Inc
>   *
> - * (C) Copyright 2008-2014 Rockchip Electronics
> + * (C) Copyright 2008-2023 Rockchip Electronics
>   * Peter, Software Engineering, .
> + * Jianqun Xu, Software Engineering, .
>   */
>
>  #include 
>  #include 
> +#include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -23,6 +26,35 @@ enum {
>
>  #define OFFSET_TO_BIT(bit) (1UL << (bit))
>
> +/*
> + * Newer Rockchip devices have additional registers that must be
> + * accounted for.
> + */
> +#if defined(CONFIG_ROCKCHIP_RK3568)
> +#define GPIO_VER   2
> +#define REG_L(R)   (R##_l)
> +#define REG_H(R)   (R##_h)
> +#define

Re: [PATCH] lib: bzip2: remove inlining

2023-02-23 Thread Tom Rini
On Thu, Feb 23, 2023 at 10:53:44PM +0100, Heinrich Schuchardt wrote:
> 
> 
> On 2/23/23 17:40, Tom Rini wrote:
> > On Thu, Feb 23, 2023 at 05:39:08PM +0100, Heinrich Schuchardt wrote:
> > > On 2/23/23 17:30, Tom Rini wrote:
> > > > On Thu, Feb 23, 2023 at 08:15:25AM +0100, Heinrich Schuchardt wrote:
> > > > > Compiling sandbox_defconfig with CONFIG_CC_OPTIMIZE_FOR_DEBUG=y and
> > > > > gcc 12.2.0-14ubuntu1 leads to a build error:
> > > > > 
> > > > >   lib/bzip2/bzlib.c: In function 'BZ2_decompress':
> > > > >   lib/bzip2/bzlib.c:726:18: error: inlining failed in call to
> > > > >   'always_inline' 'BZ2_indexIntoF': function not considered for 
> > > > > inlining
> > > > > 726 | __inline__ Int32 BZ2_indexIntoF ( Int32 indx, Int32 
> > > > > *cftab )
> > > > > |  ^
> > > > > 
> > > > > Leave it to the compiler if it inlines or not.
> > > > > 
> > > > > Signed-off-by: Heinrich Schuchardt 
> > > > 
> > > > What did previous compilers do here? If we're telling the compiler to
> > > > always inline, presumably for good reason, we shouldn't just stop.
> > > > 
> > > 
> > > Inlining may make the code a bit faster. But without inlining it would be
> > > smaller. Grep for BZ_GET_SMALL to find where the inlined function is used.
> > > 
> > > In test/compression.c we check the result. 'ut compression' does not find 
> > > a
> > > problem.
> > 
> > OK, and I'm wondering if the compiler regressed.
> > 
> 
> CONFIG_CC_OPTIMIZE_FOR_DEBUG is not used in any of our defconfigs and has
> been introduced long after bzip2.
> 
> Typically CONFIG_CC_OPTIMIZE_FOR_DEBUG is used in conjunction with
> CONFIG_LTO=n. In this case the error does not occur.
> 
> It seems that gcc with -Og -flto has an issue.

OK, so this combination is fine with:
gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

So I'd really like to get some compiler people to confirm that there's
not a regression on their end here.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] lib: bzip2: remove inlining

2023-02-23 Thread Heinrich Schuchardt




On 2/23/23 17:40, Tom Rini wrote:

On Thu, Feb 23, 2023 at 05:39:08PM +0100, Heinrich Schuchardt wrote:

On 2/23/23 17:30, Tom Rini wrote:

On Thu, Feb 23, 2023 at 08:15:25AM +0100, Heinrich Schuchardt wrote:

Compiling sandbox_defconfig with CONFIG_CC_OPTIMIZE_FOR_DEBUG=y and
gcc 12.2.0-14ubuntu1 leads to a build error:

  lib/bzip2/bzlib.c: In function 'BZ2_decompress':
  lib/bzip2/bzlib.c:726:18: error: inlining failed in call to
  'always_inline' 'BZ2_indexIntoF': function not considered for inlining
726 | __inline__ Int32 BZ2_indexIntoF ( Int32 indx, Int32 *cftab )
|  ^

Leave it to the compiler if it inlines or not.

Signed-off-by: Heinrich Schuchardt 


What did previous compilers do here? If we're telling the compiler to
always inline, presumably for good reason, we shouldn't just stop.



Inlining may make the code a bit faster. But without inlining it would be
smaller. Grep for BZ_GET_SMALL to find where the inlined function is used.

In test/compression.c we check the result. 'ut compression' does not find a
problem.


OK, and I'm wondering if the compiler regressed.



CONFIG_CC_OPTIMIZE_FOR_DEBUG is not used in any of our defconfigs and 
has been introduced long after bzip2.


Typically CONFIG_CC_OPTIMIZE_FOR_DEBUG is used in conjunction with 
CONFIG_LTO=n. In this case the error does not occur.


It seems that gcc with -Og -flto has an issue.

Best regards

Heinrich


Pull request, u-boot-tegra/master

2023-02-23 Thread Tom Warren
Tom,

Please pull u-boot-tegra/master into U-Boot/master. Thanks.
It has passed 'buildman tegra' w/o error, and Thierry has tested it on his
Tegra boards.

The following changes since commit 8c3acb726ef083d3d5de12f20318ee0e5070:

  Merge branch 'master' of
https://source.denx.de/u-boot/custodians/u-boot-usb (2023-02-22 13:36:29
-0500)

are available in the git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-tegra.git master

for you to fetch changes up to 5a8fe1ee818e0f8a74fa088f6a3d705a01b6afbe:

  ARM: tegra20: implement BCT patching (2023-02-23 12:55:37 -0700)


Maxim Schwalm (1):
  ARM: tegra: provide default USB gadget setup

Ramin Khonsari (1):
  ARM: tegra30: implement BCT patching

Svyatoslav Ryhel (14):
  tegra30: clock: add EXTPERIPH
  ARM: t20/t30: swap host1x and disp1 clock parents
  ARM: tegra: clock: add clk_id_to_pll_id helper
  ARM: tegra: clock: add clock_decode_pair helper
  ARM: tegra30: add PLLD to pll setup
  ARM: tegra: Fix Tegra PWM parent clock
  spi: tegra20_slink: accept any word length
  ARM: tegra: add late init support
  ARM: tegra: create common pre-dm i2c write
  board: tegra124: switch to updated pre-dm i2c write
  board: tegra30: switch to updated pre-dm i2c write
  ARM: tegra: expose crypto module for all Tegra SoCs
  ARM: tegra: crypto: extend crypto functional
  ARM: tegra20: implement BCT patching

 arch/arm/dts/tegra114.dtsi   |  2 +-
 arch/arm/dts/tegra124.dtsi   |  2 +-
 arch/arm/include/asm/arch-tegra/clock.h  | 21 ++
 arch/arm/include/asm/arch-tegra/crypto.h | 47 +
 arch/arm/include/asm/arch-tegra/sys_proto.h  |  6 ++
 arch/arm/include/asm/arch-tegra/tegra_i2c.h  | 17 +
 arch/arm/include/asm/arch-tegra30/clock-tables.h |  6 +-
 arch/arm/mach-tegra/Kconfig  | 14 
 arch/arm/mach-tegra/Makefile |  1 +
 arch/arm/mach-tegra/board2.c |  2 +
 arch/arm/mach-tegra/clock.c  | 23 ++
 arch/arm/mach-tegra/cpu.h|  1 -
 arch/arm/mach-tegra/{tegra20 => }/crypto.c   | 63 -
 arch/arm/mach-tegra/tegra114/clock.c | 39 +-
 arch/arm/mach-tegra/tegra124/clock.c | 40 ++-
 arch/arm/mach-tegra/tegra124/cpu.c   |  4 ++
 arch/arm/mach-tegra/tegra20/Kconfig  |  1 +
 arch/arm/mach-tegra/tegra20/Makefile |  7 +-
 arch/arm/mach-tegra/tegra20/bct.c| 79 +
 arch/arm/mach-tegra/tegra20/bct.h| 42 +++
 arch/arm/mach-tegra/tegra20/clock.c  | 43 ++-
 arch/arm/mach-tegra/tegra20/crypto.h | 19 -
 arch/arm/mach-tegra/tegra210/clock.c | 39 +-
 arch/arm/mach-tegra/tegra30/Kconfig  |  8 ---
 arch/arm/mach-tegra/tegra30/Makefile |  1 +
 arch/arm/mach-tegra/tegra30/bct.c| 79 +
 arch/arm/mach-tegra/tegra30/bct.h| 42 +++
 arch/arm/mach-tegra/tegra30/clock.c  | 90
++--
 arch/arm/mach-tegra/tegra30/cpu.c| 55 +--
 board/avionic-design/tec-ng/Makefile |  4 +-
 board/avionic-design/tec-ng/tec-ng-spl.c | 34 +
 board/nvidia/beaver/Makefile |  2 +
 board/nvidia/beaver/beaver-spl.c | 43 +++
 board/nvidia/cardhu/Makefile |  4 +-
 board/nvidia/cardhu/cardhu-spl.c | 43 +++
 board/nvidia/venice2/as3722_init.c   | 65 ++---
 board/nvidia/venice2/as3722_init.h   | 43 ---
 board/toradex/apalis-tk1/as3722_init.c   | 85
--
 board/toradex/apalis-tk1/as3722_init.h   | 40 ---
 board/toradex/apalis_t30/Makefile|  2 +
 board/toradex/apalis_t30/apalis_t30-spl.c| 34 +
 board/toradex/colibri_t30/Makefile   |  2 +
 board/toradex/colibri_t30/colibri_t30-spl.c  | 34 +
 configs/beaver_defconfig |  3 -
 configs/cei-tk1-som_defconfig|  3 -
 configs/dalmore_defconfig|  3 -
 configs/jetson-tk1_defconfig |  3 -
 configs/nyan-big_defconfig   |  3 -
 configs/p2371-_defconfig |  3 -
 configs/p2371-2180_defconfig |  3 -
 configs/p2571_defconfig  |  3 -
 configs/p3450-_defconfig |  3 -
 configs/venice2_defconfig|  3 -
 doc/usage/cmd/ebtupdate.rst  | 69 ++
 drivers/pwm/tegra_pwm.c  | 10 +--
 drivers/spi/tegra20_slink.c  

Re: [PATCH v6 3/6] tpm: Support boot measurements

2023-02-23 Thread Ilias Apalodimas
Hi Eddie,
One last thing...
Since you'll send a v7, mind adding the Linaro copyright on tpm-v2.c
since it's mostly my code moving around wrt to the TCG stuff?

Cheers
/Ilias


On Thu, 23 Feb 2023 at 20:07, Ilias Apalodimas
 wrote:
>
> Hi Eddie,
>
> [...]
>
> > > But at least the kernel can find the EFI config tables properly.
> > > > Also, note that the ret is efi_status_t and the new function you added
> > > > returns an int.  Just switch the ret here accordingly.
> > > >
> > > >
> > > >   * platforms can use different ways to do so.
> > > >   */
> > > >  ret = tcg2_init_log(dev, &elog);
> > > > -   if (ret != EFI_SUCCESS)
> > > > -   goto free_pool;
> > > > -
> > > > -   memcpy(event_log.buffer, elog.log, elog.log_position);
> > > > -   event_log.pos = elog.log_position;
> > > > +   if (ret == EFI_SUCCESS) {
> > > > +   memcpy(event_log.buffer, elog.log, elog.log_position);
> > > > +   event_log.pos = elog.log_position;
> > > > +   }
> > > >
> > > >
> > > > I'll try digging into the EFI issues more once I get some time
> > > Ok Ignore the previous mail. I just noticed that the specid event is
> > > generated by tcg2_log_init() and that's where the errors come from.
> >
> >
> > OK, I think I understand the problem. One problem with your solution below
> > is that it's only useful for EFI; writing the event log to a temporary
> > buffer in the non-EFI case is a waste of time, since it can't go anywhere.
>
> It's not even a 'solution', it's just an ugly hack to help you understand
> where things go sideways.
>
> >
> > I have a solution where the user can pass in their buffer in the
> > tcg2_event_log structure in the event that no memory region is discovered.
> > EFI can use that path.
>
> Yep that sounds sane,  that way EFI can pass the efi allocated memory and
> you can call call that with NULL for non-efi code.
> Please keep in mind that the EventLog, if it comes from TF-A, needs to be
> replayed into hardware as well, since TF-A doesn't extend PCRs.
>
> >
> >
> > Thanks for the debugging effort!
>
> yw
>
> Cheers
> /Ilias
> >
> > Eddie
> >
> >
> > >
> > > So something like the *really ugly hack* fixes EFI.  Can you please
> > > turn it into human-readable code
> > >
> > >   #include 
> > >   #include 
> > >   #include 
> > > +#include 
> > >
> > >   #include "tpm-utils.h"
> > >
> > > @@ -634,7 +635,7 @@ __weak int tcg2_platform_get_log(struct udevice
> > > *dev, void **addr, u32 *size)
> > >
> > >  if (dev_read_phandle_with_args(dev, "memory-region", 
> > > NULL, 0,
> > > 0, &args))
> > > -   return -ENODEV;
> > > +   goto alloc;
> > >
> > >  a = ofnode_get_addr_size(args.node, "reg", &s);
> > >  if (a == FDT_ADDR_T_NONE)
> > > @@ -643,6 +644,9 @@ __weak int tcg2_platform_get_log(struct udevice
> > > *dev, void **addr, u32 *size)
> > >  *addr = map_physmem(a, s, MAP_NOCACHE);
> > >  *size = (u32)s;
> > >  }
> > > +alloc:
> > > +   *addr = calloc(1, 4096);
> > > +   *size = 4096;
> > >
> > >  return 0;
> > >   }
> > >
> > > Cheers
> > > /Ilias
> > >
> > > > Cheers
> > > > /Ilias
> > > > > Thanks!
> > > > > /Ilias


Re: [PATCH V2 8/9] arm64: dts: rockchip: add gpio-ranges property to gpio nodes

2023-02-23 Thread Vasily Khoruzhick
On Mon, Feb 13, 2023 at 2:30 PM Chris Morgan  wrote:
>
> From: Chris Morgan 
>
> Add gpio-ranges property to GPIO nodes so that the bank ID can
> be correctly derived for each GPIO bank.

Should not it be merged into linux first? Otherwise it will be
overwritten during the next dts sync with linux.

> Signed-off-by: Chris Morgan 
> ---
>  arch/arm/dts/rk356x.dtsi | 5 +
>  1 file changed, 5 insertions(+)
>
> diff --git a/arch/arm/dts/rk356x.dtsi b/arch/arm/dts/rk356x.dtsi
> index 5706c3e24f..6492ace0de 100644
> --- a/arch/arm/dts/rk356x.dtsi
> +++ b/arch/arm/dts/rk356x.dtsi
> @@ -1806,6 +1806,7 @@
> interrupts = ;
> clocks = <&pmucru PCLK_GPIO0>, <&pmucru DBCLK_GPIO0>;
> gpio-controller;
> +   gpio-ranges = <&pinctrl 0 0 32>;
> #gpio-cells = <2>;
> interrupt-controller;
> #interrupt-cells = <2>;
> @@ -1817,6 +1818,7 @@
> interrupts = ;
> clocks = <&cru PCLK_GPIO1>, <&cru DBCLK_GPIO1>;
> gpio-controller;
> +   gpio-ranges = <&pinctrl 0 32 32>;
> #gpio-cells = <2>;
> interrupt-controller;
> #interrupt-cells = <2>;
> @@ -1828,6 +1830,7 @@
> interrupts = ;
> clocks = <&cru PCLK_GPIO2>, <&cru DBCLK_GPIO2>;
> gpio-controller;
> +   gpio-ranges = <&pinctrl 0 64 32>;
> #gpio-cells = <2>;
> interrupt-controller;
> #interrupt-cells = <2>;
> @@ -1839,6 +1842,7 @@
> interrupts = ;
> clocks = <&cru PCLK_GPIO3>, <&cru DBCLK_GPIO3>;
> gpio-controller;
> +   gpio-ranges = <&pinctrl 0 96 32>;
> #gpio-cells = <2>;
> interrupt-controller;
> #interrupt-cells = <2>;
> @@ -1850,6 +1854,7 @@
> interrupts = ;
> clocks = <&cru PCLK_GPIO4>, <&cru DBCLK_GPIO4>;
> gpio-controller;
> +   gpio-ranges = <&pinctrl 0 128 32>;
> #gpio-cells = <2>;
> interrupt-controller;
> #interrupt-cells = <2>;
> --
> 2.34.1
>


[PATCH] clk: rockchip: rk3568: add more supported clk rates for sdmmc and emmc

2023-02-23 Thread Vasily Khoruzhick
SDHCI driver may attempt to set 26MHz clock, but clk_rk3568
will return error in this case. Apparently, SDHCI silently ignores the
error and as a result eMMC initialization fails.

Add 25 MHz and 26 MHz clk rates for sdmmc and emmc on rk3568 to fix that.

Signed-off-by: Vasily Khoruzhick 
---
 drivers/clk/rockchip/clk_rk3568.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/clk/rockchip/clk_rk3568.c 
b/drivers/clk/rockchip/clk_rk3568.c
index c83ae22dc3..253b69504f 100644
--- a/drivers/clk/rockchip/clk_rk3568.c
+++ b/drivers/clk/rockchip/clk_rk3568.c
@@ -1443,6 +1443,7 @@ static ulong rk3568_sdmmc_set_clk(struct rk3568_clk_priv 
*priv,
switch (rate) {
case OSC_HZ:
case 26 * MHz:
+   case 25 * MHz:
src_clk = CLK_SDMMC_SEL_24M;
break;
case 400 * MHz:
@@ -1632,6 +1633,8 @@ static ulong rk3568_emmc_set_clk(struct rk3568_clk_priv 
*priv, ulong rate)
 
switch (rate) {
case OSC_HZ:
+   case 26 * MHz:
+   case 25 * MHz:
src_clk = CCLK_EMMC_SEL_24M;
break;
case 52 * MHz:
-- 
2.39.2



Re: [PATCH v2 1/1] cmd: bootefi: allocate device-tree copy from high memory

2023-02-23 Thread Ilias Apalodimas
Hi Heinrich,

On Thu, Feb 23, 2023 at 08:27:39PM +0100, Heinrich Schuchardt wrote:
> The bootefi command creates a copy of the device-tree within the first
> 127 MiB of memory. This may lead to overwriting previously loaded binaries
> (e.g. kernel, initrd).
>
> Linux EFI stub itself copies U-Boot's copy of the device-tree. This means
> there is not restriction for U-Boot to place the device-tree copy to any
> address. (Restrictions existed for 32bit ARM before Linux commit
> 7a1be318f579 ("ARM: 9012/1: move device tree mapping out of linear region")
> for legacy booting.
>
> Reported-by: Alexandre Ghiti 
> Signed-off-by: Heinrich Schuchardt 
> Tested-by: Alexandre Ghiti 
> ---
> v2:
>   remove superfluous comment
> ---
>  cmd/bootefi.c | 19 +++
>  1 file changed, 3 insertions(+), 16 deletions(-)
>
> diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> index 6618335ddf..8aa15a64c8 100644
> --- a/cmd/bootefi.c
> +++ b/cmd/bootefi.c
> @@ -204,25 +204,12 @@ static efi_status_t copy_fdt(void **fdtp)
>   fdt_pages = efi_size_in_pages(fdt_totalsize(fdt) + 0x3000);
>   fdt_size = fdt_pages << EFI_PAGE_SHIFT;
>
> - /*
> -  * Safe fdt location is at 127 MiB.
> -  * On the sandbox convert from the sandbox address space.
> -  */
> - new_fdt_addr = (uintptr_t)map_sysmem(fdt_ram_start + 0x7f0 +
> -  fdt_size, 0);
> - ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
> + ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
>EFI_ACPI_RECLAIM_MEMORY, fdt_pages,

>&new_fdt_addr);
>   if (ret != EFI_SUCCESS) {
> - /* If we can't put it there, put it somewhere */
> - new_fdt_addr = (ulong)memalign(EFI_PAGE_SIZE, fdt_size);
> - ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
> -  EFI_ACPI_RECLAIM_MEMORY, fdt_pages,
> -  &new_fdt_addr);
> - if (ret != EFI_SUCCESS) {
> - log_err("ERROR: Failed to reserve space for FDT\n");
> - goto done;
> - }
> + log_err("ERROR: Failed to reserve space for FDT\n");
> + goto done;
>   }
>   new_fdt = (void *)(uintptr_t)new_fdt_addr;
>   memcpy(new_fdt, fdt, fdt_totalsize(fdt));
> --
> 2.38.1
>

Reviewed-by: Ilias Apalodimas 



Re: [RFC PATCH v3 5/9] ram: cadence: add driver for Cadence EDAC

2023-02-23 Thread Bryan Brattlof
Hi Ralph!

On February 22, 2023 thus sayeth Ralph Siemsen:
> Driver for Cadence EDAC DDR controller, as found in the Renesas RZ/N1.
> 
> Signed-off-by: Ralph Siemsen 
> ---
> 
> Changes in v3:
> - assorted small cleanups
> - support version 1.0 silicon (previously #if 0...)
> 
>  drivers/ram/Kconfig |   1 +
>  drivers/ram/Makefile|   2 +
>  drivers/ram/cadence/Kconfig |  12 +
>  drivers/ram/cadence/Makefile|   1 +
>  drivers/ram/cadence/ddr_async.c | 311 
>  drivers/ram/cadence/ddr_ctrl.c  | 414 
>  drivers/ram/cadence/ddr_ctrl.h  | 175 ++
>  7 files changed, 916 insertions(+)
>  create mode 100644 drivers/ram/cadence/Kconfig
>  create mode 100644 drivers/ram/cadence/Makefile
>  create mode 100644 drivers/ram/cadence/ddr_async.c
>  create mode 100644 drivers/ram/cadence/ddr_ctrl.c
>  create mode 100644 drivers/ram/cadence/ddr_ctrl.h
> 

Love seeing more boards here, though I know of a few chips that use some 
type of cadence controller. I'm just curious if it would it make sense 
to name this with some type of Renesas specific branding? 

~Bryan


Re: [PATCH v4 1/1] arm64: dts: rockchip: rk3568: Add Radxa ROCK 3 Model A board support

2023-02-23 Thread Vasily Khoruzhick
On Thu, Feb 23, 2023 at 7:40 AM Akash  wrote:
>
> HI Vasily,

Hi Akash,

> I just tried now adding emmc module and able to access it.

Thanks for testing! It looks like sdhci driver decides to clock your
eMMC at 52MHz which works, while for my eMMC it choses 26MHz.
Unfortunately, clk_rk3568 driver supports only certain clock rates,
and fails with e.g. 25MHz, 26MHz. SDHCI driver doesn't check for
errors and fails silently, I'll send a fix later today.

> Also Added CMD_REGULATOR support and tried command as you suggested.
>
> Pasting logs at https://paste.ubuntu.com/p/Cx6x3CNj9w/

Yeah, you can see that regulator status is incorrect. Currently,
rk_i2c driver is non-functional on rk3568 in u-boot master. It's
caused by missing pinctrl driver (it's already merged into rockchip
custodian tree)

Regards,
Vasily

> Let me know if I am missing anything here.
>
>
> Thanks,
> Akash
>
> On 23-02-2023 06:01, Vasily Khoruzhick wrote:
> > On Tue, Feb 14, 2023 at 12:11 PM Akash Gajjar  
> > wrote:
> >
> > Hi Akash,
> >
> >> Add Radxa ROCK 3 Model A support. sync rk3568-rock-3a.dts from Linux 
> >> 6.2.0-rc7
> >>
> >> Board Specifications
> >> - Rockchip RK3568
> >> - 2/4/8GB LPDDR4 3200MT/s
> >> - eMMC socket, SD card slot
> > Have you actually tested eMMC support? It seems to be broken when the
> > system boots off SD card, "mmc info" returns "unable to select a mode
> > : -70". I have a strong suspicion that it's due to rk_i2c being broken
> > for rk3568, with debug enabled it complains "I2C Send Start Bit
> > Timeout" on every i2c transaction.
> >
> > Could you please share "mmc info" and "regulator status -a" output
> > from your build?
> >
> > Regards,
> > Vasily
> >
> >> - GbE LAN,
> >> - PCIe 3.0/2.0
> >> - M.2 Connector
> >> - 3.5mm Audio jack with mic
> >> - HDMI 2.0, MIPI DSI/CSI
> >> - USB 3.0 Host/OTG, USB 2.0 Host
> >> - 40-pin GPIO expansion ports
> >> - USB Type C PD 2.0, 9V/2A, 12V/2A, 15V/2A, 20V/2A
> >>
> >> Refer Linux commit <22a442e6586c>
> >> ("arm64: dts: rockchip: add basic dts for the radxa rock3 model a")
> >>
> >> Signed-off-by: Akash Gajjar 
> >> ---
> >> Changes in v2:
> >> - Ammend the commit message, Replace Rock Pi 3a with ROCK3A Model A. 
> >> Update the
> >>specs from https://wiki.radxa.com/Rock3/3a
> >> - Sync missing node in dts, still some of the nodes like vop, vop mmu, 
> >> i2s2_2ch
> >>gpu, hdmi removed as there is no driver support present in u-boot.
> >> - Duplicated sdmmc node removed from dts.
> >> Changes in v3:
> >> - Replace rock-pi-3a-rk3568_defconfig with rock-3a-rk3568_defconfig
> >> Changes in v4:
> >> - Add maintainer for the board
> >> ---
> >>   arch/arm/dts/Makefile   |   3 +-
> >>   arch/arm/dts/rk3568-rock-3a-u-boot.dtsi |  24 +
> >>   arch/arm/dts/rk3568-rock-3a.dts | 609 
> >>   board/rockchip/evb_rk3568/MAINTAINERS   |   7 +
> >>   configs/rock-3a-rk3568_defconfig|  74 +++
> >>   5 files changed, 716 insertions(+), 1 deletion(-)
> >>   create mode 100644 arch/arm/dts/rk3568-rock-3a-u-boot.dtsi
> >>   create mode 100644 arch/arm/dts/rk3568-rock-3a.dts
> >>   create mode 100644 configs/rock-3a-rk3568_defconfig
> >>
> >> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> >> index 9d647b9639..945843bebc 100644
> >> --- a/arch/arm/dts/Makefile
> >> +++ b/arch/arm/dts/Makefile
> >> @@ -165,7 +165,8 @@ dtb-$(CONFIG_ROCKCHIP_RK3399) += \
> >>  rk3399pro-rock-pi-n10.dtb
> >>
> >>   dtb-$(CONFIG_ROCKCHIP_RK3568) += \
> >> -   rk3568-evb.dtb
> >> +   rk3568-evb.dtb \
> >> +   rk3568-rock-3a.dtb
> >>
> >>   dtb-$(CONFIG_ROCKCHIP_RV1108) += \
> >>  rv1108-elgin-r1.dtb \
> >> diff --git a/arch/arm/dts/rk3568-rock-3a-u-boot.dtsi 
> >> b/arch/arm/dts/rk3568-rock-3a-u-boot.dtsi
> >> new file mode 100644
> >> index 00..ae23ae8587
> >> --- /dev/null
> >> +++ b/arch/arm/dts/rk3568-rock-3a-u-boot.dtsi
> >> @@ -0,0 +1,24 @@
> >> +// SPDX-License-Identifier: GPL-2.0+
> >> +/*
> >> + * (C) Copyright 2021 Rockchip Electronics Co., Ltd
> >> + * (C) Copyright 2023 Akash Gajjar 
> >> + */
> >> +
> >> +#include "rk356x-u-boot.dtsi"
> >> +
> >> +/ {
> >> +   chosen {
> >> +   stdout-path = &uart2;
> >> +   u-boot,spl-boot-order = "same-as-spl", &sdmmc0;
> >> +   };
> >> +};
> >> +
> >> +&sdmmc0 {
> >> +   status = "okay";
> >> +};
> >> +
> >> +&uart2 {
> >> +   clock-frequency = <2400>;
> >> +   u-boot,dm-spl;
> >> +   status = "okay";
> >> +};
> >> diff --git a/arch/arm/dts/rk3568-rock-3a.dts 
> >> b/arch/arm/dts/rk3568-rock-3a.dts
> >> new file mode 100644
> >> index 00..a2f2baa4ea
> >> --- /dev/null
> >> +++ b/arch/arm/dts/rk3568-rock-3a.dts
> >> @@ -0,0 +1,609 @@
> >> +// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
> >> +/*
> >> + * Copyright (c) 2021 Rockchip Electronics Co., Ltd.
> >> + * Copyright (c) 2023 Akash Gajjar 
> >> + */
> >> +
> >> +/dts-v1/;
> >> +#include 
> >> +#include 
> >> +#include "rk3568.dtsi"
> >>

[PATCH] rockchip: rk3288: Use ft_system_setup instead of ft_board_setup

2023-02-23 Thread John Keeping
ft_board_setup() should be availble for use in board files but using it
in the rk3288 machine file blocks this functionality.

ft_system_setup() is the more appropriate function to use in a machine
definition.

Signed-off-by: John Keeping 
---
 arch/arm/mach-rockchip/Kconfig | 2 +-
 arch/arm/mach-rockchip/rk3288/rk3288.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index b678ec41318..3fbfd1b1564 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -119,7 +119,7 @@ config ROCKCHIP_RK322X
 config ROCKCHIP_RK3288
bool "Support Rockchip RK3288"
select CPU_V7A
-   select OF_BOARD_SETUP
+   select OF_SYSTEM_SETUP
select SKIP_LOWLEVEL_INIT_ONLY
select SUPPORT_SPL
select SPL
diff --git a/arch/arm/mach-rockchip/rk3288/rk3288.c 
b/arch/arm/mach-rockchip/rk3288/rk3288.c
index 3ad2887575d..26c7e41cd89 100644
--- a/arch/arm/mach-rockchip/rk3288/rk3288.c
+++ b/arch/arm/mach-rockchip/rk3288/rk3288.c
@@ -138,7 +138,7 @@ static int ft_rk3288w_setup(void *blob)
return ret;
 }
 
-int ft_board_setup(void *blob, struct bd_info *bd)
+int ft_system_setup(void *blob, struct bd_info *bd)
 {
if (soc_is_rk3288w())
return ft_rk3288w_setup(blob);
-- 
2.39.2



[PATCH v2 1/1] cmd: bootefi: allocate device-tree copy from high memory

2023-02-23 Thread Heinrich Schuchardt
The bootefi command creates a copy of the device-tree within the first
127 MiB of memory. This may lead to overwriting previously loaded binaries
(e.g. kernel, initrd).

Linux EFI stub itself copies U-Boot's copy of the device-tree. This means
there is not restriction for U-Boot to place the device-tree copy to any
address. (Restrictions existed for 32bit ARM before Linux commit
7a1be318f579 ("ARM: 9012/1: move device tree mapping out of linear region")
for legacy booting.

Reported-by: Alexandre Ghiti 
Signed-off-by: Heinrich Schuchardt 
Tested-by: Alexandre Ghiti 
---
v2:
remove superfluous comment
---
 cmd/bootefi.c | 19 +++
 1 file changed, 3 insertions(+), 16 deletions(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 6618335ddf..8aa15a64c8 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -204,25 +204,12 @@ static efi_status_t copy_fdt(void **fdtp)
fdt_pages = efi_size_in_pages(fdt_totalsize(fdt) + 0x3000);
fdt_size = fdt_pages << EFI_PAGE_SHIFT;
 
-   /*
-* Safe fdt location is at 127 MiB.
-* On the sandbox convert from the sandbox address space.
-*/
-   new_fdt_addr = (uintptr_t)map_sysmem(fdt_ram_start + 0x7f0 +
-fdt_size, 0);
-   ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
+   ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
 EFI_ACPI_RECLAIM_MEMORY, fdt_pages,
 &new_fdt_addr);
if (ret != EFI_SUCCESS) {
-   /* If we can't put it there, put it somewhere */
-   new_fdt_addr = (ulong)memalign(EFI_PAGE_SIZE, fdt_size);
-   ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
-EFI_ACPI_RECLAIM_MEMORY, fdt_pages,
-&new_fdt_addr);
-   if (ret != EFI_SUCCESS) {
-   log_err("ERROR: Failed to reserve space for FDT\n");
-   goto done;
-   }
+   log_err("ERROR: Failed to reserve space for FDT\n");
+   goto done;
}
new_fdt = (void *)(uintptr_t)new_fdt_addr;
memcpy(new_fdt, fdt, fdt_totalsize(fdt));
-- 
2.38.1



[PATCH v2 1/1] cmd: bootefi: allocate device-tree copy from high memory

2023-02-23 Thread Heinrich Schuchardt
The bootefi command creates a copy of the device-tree within the first
127 MiB of memory. This may lead to overwriting previously loaded binaries
(e.g. kernel, initrd).

Linux EFI stub itself copies U-Boot's copy of the device-tree. This means
there is not restriction for U-Boot to place the device-tree copy to any
address. (Restrictions existed for 32bit ARM before Linux commit
7a1be318f579 ("ARM: 9012/1: move device tree mapping out of linear region")
for legacy booting.

Reported-by: Alexandre Ghiti 
Signed-off-by: Heinrich Schuchardt 
Tested-by: Alexandre Ghiti 
---
v2:
remove superfluous comment
---
 cmd/bootefi.c | 19 +++
 1 file changed, 3 insertions(+), 16 deletions(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 6618335ddf..8aa15a64c8 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -204,25 +204,12 @@ static efi_status_t copy_fdt(void **fdtp)
fdt_pages = efi_size_in_pages(fdt_totalsize(fdt) + 0x3000);
fdt_size = fdt_pages << EFI_PAGE_SHIFT;
 
-   /*
-* Safe fdt location is at 127 MiB.
-* On the sandbox convert from the sandbox address space.
-*/
-   new_fdt_addr = (uintptr_t)map_sysmem(fdt_ram_start + 0x7f0 +
-fdt_size, 0);
-   ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
+   ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
 EFI_ACPI_RECLAIM_MEMORY, fdt_pages,
 &new_fdt_addr);
if (ret != EFI_SUCCESS) {
-   /* If we can't put it there, put it somewhere */
-   new_fdt_addr = (ulong)memalign(EFI_PAGE_SIZE, fdt_size);
-   ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
-EFI_ACPI_RECLAIM_MEMORY, fdt_pages,
-&new_fdt_addr);
-   if (ret != EFI_SUCCESS) {
-   log_err("ERROR: Failed to reserve space for FDT\n");
-   goto done;
-   }
+   log_err("ERROR: Failed to reserve space for FDT\n");
+   goto done;
}
new_fdt = (void *)(uintptr_t)new_fdt_addr;
memcpy(new_fdt, fdt, fdt_totalsize(fdt));
-- 
2.38.1



Re: [PATCH v1 19/24] arm: mach-imx: use CONFIG_$(SPL_)SATA instead of CONFIG_SATA

2023-02-23 Thread Troy Kisky
On Wed, Feb 22, 2023 at 7:05 AM Tom Rini  wrote:

> On Tue, Feb 21, 2023 at 05:38:16PM -0800, Troy Kisky wrote:
>
> > This avoid an error with enable_sata_clock when
> > defined(CONFIG_SATA) is changed to CONFIG_IS_ENABLED(SATA).
> >
> > Signed-off-by: Troy Kisky 
> > ---
> >
> >  arch/arm/mach-imx/Makefile | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
> > index 4dfc60eedc4..50f26975eac 100644
> > --- a/arch/arm/mach-imx/Makefile
> > +++ b/arch/arm/mach-imx/Makefile
> > @@ -54,7 +54,7 @@ obj-$(CONFIG_IMX_RDC) += rdc-sema.o
> >  ifneq ($(CONFIG_SPL_BUILD),y)
> >  obj-$(CONFIG_IMX_BOOTAUX) += imx_bootaux.o
> >  endif
> > -obj-$(CONFIG_SATA) += sata.o
> > +obj-$(CONFIG_$(SPL_)SATA) += sata.o
> >  obj-$(CONFIG_IMX_HAB)+= hab.o
> >  obj-$(CONFIG_SYSCOUNTER_TIMER) += syscounter.o
> >  endif
>
> In that Simon thinks the $(SPL_) syntax here is ugly, lets just move
> this line in to the existing guard for non-SPL builds, with
> imx_bootaux.o.
>
> --
> Tom
>

Hi Tom

I don't think that does the same thing for mach-mvebu.

arch/arm/mach-mvebu/Kconfig-config MVEBU_SPL_BOOT_DEVICE_SATA
arch/arm/mach-mvebu/Kconfig-bool "SATA"
arch/arm/mach-mvebu/Kconfig:imply SPL_SATA

Shouldn't it be linked in SPL builds as well for that one?

BR
Troy


Re: [PATCH 1/1] cmd: bootefi: allocate device-tree copy from high memory

2023-02-23 Thread Alexandre Ghiti
On Thu, Feb 23, 2023 at 7:00 PM Heinrich Schuchardt
 wrote:
>
> The bootefi command creates a copy of the device-tree within the first
> 127 MiB of memory. This may lead to overwriting previously loaded binaries
> (e.g. kernel, initrd).
>
> Linux EFI stub itself copies U-Boot's copy of the device-tree. This means
> there is not restriction for U-Boot to place the device-tree copy to any
> address. (Restrictions existed for 32bit ARM before Linux commit
> 7a1be318f579 ("ARM: 9012/1: move device tree mapping out of linear region")
> for legacy booting.
>
> Reported-by: Alexandre Ghiti 
> Signed-off-by: Heinrich Schuchardt 
> ---
>  cmd/bootefi.c | 15 +++
>  1 file changed, 3 insertions(+), 12 deletions(-)
>
> diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> index 6618335ddf..aca4e99930 100644
> --- a/cmd/bootefi.c
> +++ b/cmd/bootefi.c
> @@ -208,21 +208,12 @@ static efi_status_t copy_fdt(void **fdtp)
>  * Safe fdt location is at 127 MiB.
>  * On the sandbox convert from the sandbox address space.
>  */

The comment should be removed too.

> -   new_fdt_addr = (uintptr_t)map_sysmem(fdt_ram_start + 0x7f0 +
> -fdt_size, 0);
> -   ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
> +   ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
>  EFI_ACPI_RECLAIM_MEMORY, fdt_pages,
>  &new_fdt_addr);
> if (ret != EFI_SUCCESS) {
> -   /* If we can't put it there, put it somewhere */
> -   new_fdt_addr = (ulong)memalign(EFI_PAGE_SIZE, fdt_size);
> -   ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
> -EFI_ACPI_RECLAIM_MEMORY, fdt_pages,
> -&new_fdt_addr);
> -   if (ret != EFI_SUCCESS) {
> -   log_err("ERROR: Failed to reserve space for FDT\n");
> -   goto done;
> -   }
> +   log_err("ERROR: Failed to reserve space for FDT\n");
> +   goto done;
> }
> new_fdt = (void *)(uintptr_t)new_fdt_addr;
> memcpy(new_fdt, fdt, fdt_totalsize(fdt));
> --
> 2.38.1
>

Otherwise, you can add:

Tested-by: Alexandre Ghiti 

Thanks Heinrich!

Alex


Re: [PATCH v2 1/2] env: mmc: Clean up macro usage

2023-02-23 Thread Marek Vasut

On 2/23/23 17:32, Tom Rini wrote:

On Thu, Feb 23, 2023 at 02:22:51PM +0100, Marek Vasut wrote:

On 2/23/23 11:41, Patrick DELAUNAY wrote:

Hi Marek,


Hi,


On 2/9/23 13:30, Marek Vasut wrote:

Consistently use 'if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID))' instead of
mix of ifdef.

Signed-off-by: Marek Vasut 
---
Cc: Patrice Chotard 
Cc: Patrick Delaunay 
Cc: Tom Rini 
---
V2: Replace CONFIG_IS_ENABLED(PARTITION_TYPE_GUID) with
IS_ENABLED(CONFIG_PARTITION_TYPE_GUID)
---
   env/mmc.c | 4 +---
   1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/env/mmc.c b/env/mmc.c
index 5b01f657a7a..d51a5579128 100644
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -73,8 +73,7 @@ static inline int mmc_offset_try_partition(const
char *str, int copy, s64 *val)
   if (str && !strncmp((const char *)info.name, str,
sizeof(info.name)))
   break;
-#ifdef CONFIG_PARTITION_TYPE_GUID
-    if (!str) {
+    if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID) && !str) {
   const efi_guid_t env_guid = PARTITION_U_BOOT_ENVIRONMENT;
   efi_guid_t type_guid;
@@ -82,7 +81,6 @@ static inline int mmc_offset_try_partition(const
char *str, int copy, s64 *val)
   if (!memcmp(&env_guid, &type_guid, sizeof(efi_guid_t)))
   break;
   }
-#endif
   }
   /* round up to info.blksz */



If I remenber, I try this test with IS_ENABLED when I propose my patch

and I have compilation issue on next line


+            uuid_str_to_bin(info.type_guid, type_guid.b,
UUID_STR_FORMAT_GUID);


because "info.type_guid" don't exist in struct disk_partition

see ./include/part.h:59


struct disk_partition {
      lbaint_t    start;    /* # of first block in partition    */
...
#ifdef CONFIG_PARTITION_TYPE_GUID
      char    type_guid[UUID_STR_LEN + 1];    /* type GUID as string, if
exists    */
#endif
...
};


Uh, which defconfig triggers this ?

Also, is there a way to deal with this failure without reinstating the ifdef
? Tom ?


It's likely on one of the platforms that disables EFI_LOADER, where this
ends up being a fail to build.  I don't recall which, but I've seen it
before. So we probably don't end up converting this to a macro check.


Can you pick the 2/2 for starters ? It is a bugfix and applies cleanly, 
so let's not block that one. I'll keep 1/2 in my queue and revisit it, I 
see the failure in CI now.


[PATCH v6 5/9] video console: move vidconsole_get_font_size() to test.h

2023-02-23 Thread Dzmitry Sankouski
vidconsole_get_font_size is only used in tests and in font
command. It's role in 'font size' command was to only fetch
current font name, to be used in select font function.
This is redundant, because it's easy to check for empty
string, and reuse current name right in select function.

Test functions in public API use memory and clutter interface.

Move vidconsole_get_font_size to new cmd/test.h file.
Wrap it's implementation with #ifdef only when tests enabled.

Signed-off-by: Dzmitry Sankouski 
---
Changes for v2: N/A
Changes for v3: N/A
Charges for v4: N/A
Charges for v5: N/A
Charges for v6: N/A

 cmd/font.c   |  5 ++---
 drivers/video/console_truetype.c |  8 +++-
 include/cmd/test.h   | 19 +++
 include/video_console.h  |  9 -
 test/cmd/font.c  |  1 +
 5 files changed, 29 insertions(+), 13 deletions(-)
 create mode 100644 include/cmd/test.h

diff --git a/cmd/font.c b/cmd/font.c
index 7b4347f32b..af542b01ee 100644
--- a/cmd/font.c
+++ b/cmd/font.c
@@ -51,7 +51,7 @@ static int do_font_select(struct cmd_tbl *cmdtp, int flag, 
int argc,
 static int do_font_size(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
 {
-   const char *font_name;
+   const char *empty_name = {'\0'};
struct udevice *dev;
uint size;
int ret;
@@ -61,11 +61,10 @@ static int do_font_size(struct cmd_tbl *cmdtp, int flag, 
int argc,
 
if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev))
return CMD_RET_FAILURE;
-   font_name = vidconsole_get_font_size(dev, &size);
 
size = dectoul(argv[1], NULL);
 
-   ret = vidconsole_select_font(dev, font_name, size);
+   ret = vidconsole_select_font(dev, empty_name, size);
if (ret) {
printf("Failed (error %d)\n", ret);
return CMD_RET_FAILURE;
diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c
index 9cac9a6de4..f57d8b6dae 100644
--- a/drivers/video/console_truetype.c
+++ b/drivers/video/console_truetype.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (c) 2016 Google, Inc
+ * (C) Copyright 2023 Dzmitry Sankouski 
  */
 
 #include 
@@ -9,6 +10,9 @@
 #include 
 #include 
 #include 
+#if IS_ENABLED(CONFIG_UT_DM)
+#include 
+#endif
 
 /* Functions needed by stb_truetype.h */
 static int tt_floor(double val)
@@ -691,7 +695,7 @@ static int truetype_select_font(struct udevice *dev, const 
char *name,
if (!size)
size = CONFIG_CONSOLE_TRUETYPE_SIZE;
if (!name)
-   name = font_table->name;
+   name = priv->cur_met->font_name;
 
met = find_metrics(dev, name, size);
if (!met) {
@@ -724,6 +728,7 @@ static int truetype_select_font(struct udevice *dev, const 
char *name,
return 0;
 }
 
+#if IS_ENABLED(CONFIG_UT_DM)
 const char *vidconsole_get_font_size(struct udevice *dev, uint *sizep)
 {
struct console_tt_priv *priv = dev_get_priv(dev);
@@ -733,6 +738,7 @@ const char *vidconsole_get_font_size(struct udevice *dev, 
uint *sizep)
 
return met->font_name;
 }
+#endif
 
 static int console_truetype_probe(struct udevice *dev)
 {
diff --git a/include/cmd/test.h b/include/cmd/test.h
new file mode 100644
index 00..39afb99b73
--- /dev/null
+++ b/include/cmd/test.h
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2015 Google, Inc
+ * (C) Copyright 2023 Dzmitry Sankouski 
+ */
+
+#ifndef __cmd_test_h
+#define __cmd_test_h
+
+/**
+ * vidconsole_get_font_size() - get the current font name and size
+ *
+ * @dev: vidconsole device
+ * @sizep: Place to put the font size (nominal height in pixels)
+ * Returns: Current font name
+ */
+const char *vidconsole_get_font_size(struct udevice *dev, uint *sizep);
+
+#endif
diff --git a/include/video_console.h b/include/video_console.h
index 9d2c0f210e..9c3d0ad305 100644
--- a/include/video_console.h
+++ b/include/video_console.h
@@ -298,15 +298,6 @@ void vidconsole_set_cursor_pos(struct udevice *dev, int x, 
int y);
  */
 void vidconsole_list_fonts(struct udevice *dev);
 
-/**
- * vidconsole_get_font_size() - get the current font name and size
- *
- * @dev: vidconsole device
- * @sizep: Place to put the font size (nominal height in pixels)
- * Returns: Current font name
- */
-const char *vidconsole_get_font_size(struct udevice *dev, uint *sizep);
-
 #ifdef CONFIG_VIDEO_COPY
 /**
  * vidconsole_sync_copy() - Sync back to the copy framebuffer
diff --git a/test/cmd/font.c b/test/cmd/font.c
index adb353965a..524004bed8 100644
--- a/test/cmd/font.c
+++ b/test/cmd/font.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* Declare a new fdt test */
 #define FONT_TEST(_name, _flags)   UNIT_TEST(_name, _flags, font_test)
-- 
2.30.2



Re: [PATCH v4 1/1] arm64: dts: rockchip: rk3568: Add Radxa ROCK 3 Model A board support

2023-02-23 Thread Akash

HI Vasily,


I just tried now adding emmc module and able to access it.

Also Added CMD_REGULATOR support and tried command as you suggested.

Pasting logs at https://paste.ubuntu.com/p/Cx6x3CNj9w/

Let me know if I am missing anything here.


Thanks,
Akash

On 23-02-2023 06:01, Vasily Khoruzhick wrote:

On Tue, Feb 14, 2023 at 12:11 PM Akash Gajjar  wrote:

Hi Akash,


Add Radxa ROCK 3 Model A support. sync rk3568-rock-3a.dts from Linux 6.2.0-rc7

Board Specifications
- Rockchip RK3568
- 2/4/8GB LPDDR4 3200MT/s
- eMMC socket, SD card slot

Have you actually tested eMMC support? It seems to be broken when the
system boots off SD card, "mmc info" returns "unable to select a mode
: -70". I have a strong suspicion that it's due to rk_i2c being broken
for rk3568, with debug enabled it complains "I2C Send Start Bit
Timeout" on every i2c transaction.

Could you please share "mmc info" and "regulator status -a" output
from your build?

Regards,
Vasily


- GbE LAN,
- PCIe 3.0/2.0
- M.2 Connector
- 3.5mm Audio jack with mic
- HDMI 2.0, MIPI DSI/CSI
- USB 3.0 Host/OTG, USB 2.0 Host
- 40-pin GPIO expansion ports
- USB Type C PD 2.0, 9V/2A, 12V/2A, 15V/2A, 20V/2A

Refer Linux commit <22a442e6586c>
("arm64: dts: rockchip: add basic dts for the radxa rock3 model a")

Signed-off-by: Akash Gajjar 
---
Changes in v2:
- Ammend the commit message, Replace Rock Pi 3a with ROCK3A Model A. Update the
   specs from https://wiki.radxa.com/Rock3/3a
- Sync missing node in dts, still some of the nodes like vop, vop mmu, i2s2_2ch
   gpu, hdmi removed as there is no driver support present in u-boot.
- Duplicated sdmmc node removed from dts.
Changes in v3:
- Replace rock-pi-3a-rk3568_defconfig with rock-3a-rk3568_defconfig
Changes in v4:
- Add maintainer for the board
---
  arch/arm/dts/Makefile   |   3 +-
  arch/arm/dts/rk3568-rock-3a-u-boot.dtsi |  24 +
  arch/arm/dts/rk3568-rock-3a.dts | 609 
  board/rockchip/evb_rk3568/MAINTAINERS   |   7 +
  configs/rock-3a-rk3568_defconfig|  74 +++
  5 files changed, 716 insertions(+), 1 deletion(-)
  create mode 100644 arch/arm/dts/rk3568-rock-3a-u-boot.dtsi
  create mode 100644 arch/arm/dts/rk3568-rock-3a.dts
  create mode 100644 configs/rock-3a-rk3568_defconfig

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 9d647b9639..945843bebc 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -165,7 +165,8 @@ dtb-$(CONFIG_ROCKCHIP_RK3399) += \
 rk3399pro-rock-pi-n10.dtb

  dtb-$(CONFIG_ROCKCHIP_RK3568) += \
-   rk3568-evb.dtb
+   rk3568-evb.dtb \
+   rk3568-rock-3a.dtb

  dtb-$(CONFIG_ROCKCHIP_RV1108) += \
 rv1108-elgin-r1.dtb \
diff --git a/arch/arm/dts/rk3568-rock-3a-u-boot.dtsi 
b/arch/arm/dts/rk3568-rock-3a-u-boot.dtsi
new file mode 100644
index 00..ae23ae8587
--- /dev/null
+++ b/arch/arm/dts/rk3568-rock-3a-u-boot.dtsi
@@ -0,0 +1,24 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2021 Rockchip Electronics Co., Ltd
+ * (C) Copyright 2023 Akash Gajjar 
+ */
+
+#include "rk356x-u-boot.dtsi"
+
+/ {
+   chosen {
+   stdout-path = &uart2;
+   u-boot,spl-boot-order = "same-as-spl", &sdmmc0;
+   };
+};
+
+&sdmmc0 {
+   status = "okay";
+};
+
+&uart2 {
+   clock-frequency = <2400>;
+   u-boot,dm-spl;
+   status = "okay";
+};
diff --git a/arch/arm/dts/rk3568-rock-3a.dts b/arch/arm/dts/rk3568-rock-3a.dts
new file mode 100644
index 00..a2f2baa4ea
--- /dev/null
+++ b/arch/arm/dts/rk3568-rock-3a.dts
@@ -0,0 +1,609 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2021 Rockchip Electronics Co., Ltd.
+ * Copyright (c) 2023 Akash Gajjar 
+ */
+
+/dts-v1/;
+#include 
+#include 
+#include "rk3568.dtsi"
+
+/ {
+   model = "Radxa ROCK3 Model A";
+   compatible = "radxa,rock3a", "rockchip,rk3568";
+
+   chosen: chosen {
+   stdout-path = "serial2:150n8";
+   };
+
+   gmac1_clkin: external-gmac1-clock {
+   compatible = "fixed-clock";
+   clock-frequency = <12500>;
+   clock-output-names = "gmac1_clkin";
+   #clock-cells = <0>;
+   };
+
+   vcc12v_dcin: vcc12v-dcin-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc12v_dcin";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <1200>;
+   regulator-max-microvolt = <1200>;
+   };
+
+   vcc3v3_sys: vcc3v3-sys-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc3v3_sys";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   vin-supply = <&vcc12v_dcin>;
+   };
+
+   vcc5v0_sys: vcc5v0-sys-regulator {
+   compatible = "regulator-fi

[PATCH v6 8/9] video console: add 16x32 Terminus font from linux

2023-02-23 Thread Dzmitry Sankouski
Modern mobile phones typically have high pixel density.
Bootmenu is hardly readable on those with 8x16 font.

Signed-off-by: Dzmitry Sankouski 
Reviewed-by: Simon Glass 
---
Changes for v2:
- edit for runtime configuration
Changes for v3: none
Charges for v4: N/A
Charges for v5: N/A
Charges for v6: rebase only

 drivers/video/Kconfig |7 +
 include/video_font.h  |6 +
 include/video_font_ter16x32.h | 2062 +
 3 files changed, 2075 insertions(+)
 create mode 100644 include/video_font_ter16x32.h

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index a928ae498a..60f4a4bf9c 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -38,6 +38,13 @@ config VIDEO_FONT_SUN12X22
  Provides character bitmap data in header file.
  When selecting multiple fonts, you may want to enable CMD_SELECT_FONT 
too.
 
+config VIDEO_FONT_16X32
+   bool "16 x 32 font size"
+   help
+ Font for video console driver, 16 x 32 pixels
+ Provides character bitmap data in header file.
+ When selecting multiple fonts, you may want to enable CMD_SELECT_FONT 
too.
+
 config VIDEO_LOGO
bool "Show the U-Boot logo on the display"
default y if !SPLASH_SCREEN
diff --git a/include/video_font.h b/include/video_font.h
index 03622adc7a..d4dd2b5eed 100644
--- a/include/video_font.h
+++ b/include/video_font.h
@@ -18,6 +18,9 @@
 #if defined(CONFIG_VIDEO_FONT_SUN12X22)
 #include 
 #endif
+#if defined(CONFIG_VIDEO_FONT_16X32)
+#include 
+#endif
 
 static struct video_fontdata __maybe_unused fonts[] = {
 #if defined(CONFIG_VIDEO_FONT_4X6)
@@ -28,6 +31,9 @@ static struct video_fontdata __maybe_unused fonts[] = {
 #endif
 #if defined(CONFIG_VIDEO_FONT_SUN12X22)
FONT_ENTRY(12, 22, 12x22),
+#endif
+#if defined(CONFIG_VIDEO_FONT_16X32)
+   FONT_ENTRY(16, 32, 16x32),
 #endif
{/* list terminator */}
 };
diff --git a/include/video_font_ter16x32.h b/include/video_font_ter16x32.h
new file mode 100644
index 00..bcf3d4b123
--- /dev/null
+++ b/include/video_font_ter16x32.h
@@ -0,0 +1,2062 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copied from linux.
+ */
+
+#ifndef _VIDEO_FONT_TER_16X32_
+#define _VIDEO_FONT_TER_16X32_
+
+#include 
+
+static unsigned char video_fontdata_16x32[VIDEO_FONT_SIZE(256, 16, 32)] = {
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x7f, 0xfc, 0x7f, 0xfc,
+   0x70, 0x1c, 0x70, 0x1c, 0x70, 0x1c, 0x70, 0x1c,
+   0x70, 0x1c, 0x70, 0x1c, 0x70, 0x1c, 0x70, 0x1c,
+   0x70, 0x1c, 0x70, 0x1c, 0x70, 0x1c, 0x70, 0x1c,
+   0x70, 0x1c, 0x70, 0x1c, 0x70, 0x1c, 0x70, 0x1c,
+   0x7f, 0xfc, 0x7f, 0xfc, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x3f, 0xf8, 0x7f, 0xfc,
+   0xf0, 0x1e, 0xe0, 0x0e, 0xe0, 0x0e, 0xe0, 0x0e,
+   0xee, 0xee, 0xee, 0xee, 0xe0, 0x0e, 0xe0, 0x0e,
+   0xe0, 0x0e, 0xe0, 0x0e, 0xef, 0xee, 0xe7, 0xce,
+   0xe0, 0x0e, 0xe0, 0x0e, 0xe0, 0x0e, 0xf0, 0x1e,
+   0x7f, 0xfc, 0x3f, 0xf8, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1 */
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x3f, 0xf8, 0x7f, 0xfc,
+   0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe,
+   0xe3, 0x8e, 0xe3, 0x8e, 0xff, 0xfe, 0xff, 0xfe,
+   0xff, 0xfe, 0xff, 0xfe, 0xe0, 0x0e, 0xf0, 0x1e,
+   0xf8, 0x3e, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe,
+   0x7f, 0xfc, 0x3f, 0xf8, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 2 */
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x78, 0x3c, 0xfc, 0x7e, 0xfe, 0xfe, 0xff, 0xfe,
+   0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe,
+   0x7f, 0xfc, 0x7f, 0xfc, 0x3f, 0xf8, 0x1f, 0xf0,
+   0x0f, 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 3 */
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x03, 0x80, 0x07, 0xc0, 0x0f, 0xe0,
+   0x1f, 0xf0, 0x3f, 0xf8, 0x7f, 0xfc, 0xff, 0xfe,
+   0xff, 0xfe, 0x7f, 0xfc, 0x3f, 0xf8, 0x1f, 0xf0,
+   0x0f, 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 4 */
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x07, 0xc0, 0x0f, 0xe0,
+   0x0f, 0xe0, 0x0f, 0xe0, 0x0f, 0xe0, 0x0f, 0xe0,
+   0x07, 0xc0, 0x03, 0x80, 0x3b, 0xb8, 0x7f, 0xfc,
+   0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfe,
+   0x7f, 0xfc, 0x3b, 0xb8, 0x03, 0x80, 0x03, 0x80,
+   0x0f, 0xe0, 0x0f, 

Re: [PATCH v3 9/9] video console: add 12x22 console simple font test

2023-02-23 Thread Dzmitry Sankouski
Hi Simon,

I investigated the usage of vidconsole_get_font_size, and it turned out,
it's only used for tests, and in the `font size` command to provide font name.

So I moved vidconsole_get_font_size from the public API to cmd/test.h.
I think it'll be
better than cluttering public API and driver ops functions with test stuff.
Please see patches for details.

сб, 18 февр. 2023 г. в 02:49, Simon Glass :
>
> Hi Dzmitry,
>
> On Fri, 17 Feb 2023 at 07:13, Dzmitry Sankouski  wrote:
> >
> > How does CONSOLE_TRUETYPE interfere with CONFIG_VIDEO_FONT_SUN12X22?
> >
>
> I don't mean that.
>
> I tried resyncing the sandbox defconfig, and found that the defconfig
> additions in this patch went away, meaning they are not used.
>
> I think I know what is needed:
>
> vidconsole_get_font_size()
>  - implement this in vidconsole-uclass.c by calling the method for the
> driver. See how this is done with vidconsole_putc_xy(), for example.
> You can see this problem if you enable CMD_SELECT_FONT but don't
> enable CONSOLE_TRUETYPE
>
> config CMD_SELECT_FONT
> - the 'bool' needs to be indented with a tab. I think it is is being
> ignored with Kconfig which is why it doesn't work
>
> resync configs with 'make savedefconfig'
> - patches should have the CONFIG options (in defconfigs) in the
> correct order, and this is how you check it.
>
> >
> > I've got all video tests passed:
> >
> > make sandbox_defconfig && make -j4 && ./u-boot -T -c 'ut dm'
> > (...)
> > Test: dm_test_video_ansi: video.c
> > Test: dm_test_video_base: video.c
> > Test: dm_test_video_base: video.c (flat tree)
> > Test: dm_test_video_bmp: video.c
> > Test: dm_test_video_bmp16: video.c
> > Test: dm_test_video_bmp24: video.c
> > Test: dm_test_video_bmp24_32: video.c
> > Test: dm_test_video_bmp32: video.c
> > Test: dm_test_video_bmp8: video.c
> > Test: dm_test_video_bmp_comp: video.c
> > Test: dm_test_video_chars: video.c
> > Test: dm_test_video_comp_bmp32: video.c
> > Test: dm_test_video_comp_bmp8: video.c
> > Test: dm_test_video_context: video.c
> > Test: dm_test_video_rotation1: video.c
> > Test: dm_test_video_rotation2: video.c
> > Test: dm_test_video_rotation3: video.c
> > Test: dm_test_video_text: video.c
> > Test: dm_test_video_text_12x22: video.c
> > Test: dm_test_video_truetype: video.c
> > Test: dm_test_video_truetype_bs: video.c
> > Test: dm_test_video_truetype_scroll: video.c
> > Test: dm_test_virtio_all_ops: virtio_device.c
> > Test: dm_test_virtio_all_ops: virtio_device.c (flat tree)
> > Test: dm_test_virtio_base: virtio_device.c
> > (...)
> >
>
> Yes, as you say, the tests pass and look good. I think my problem was
> the above issues.
>
> Regards,
> Simon
>
>
>
>
> > чт, 16 февр. 2023 г. в 02:50, Simon Glass :
> > >
> > > Hi Dzmitry,
> > >
> > > On Wed, 15 Feb 2023 at 04:43, Dzmitry Sankouski  
> > > wrote:
> > > >
> > > > Tests fonts wider than a byte.
> > > >
> > > > Signed-off-by: Dzmitry Sankouski 
> > > > Reviewed-by: Simon Glass 
> > >
> > > I found a problem with this
> > >
> > > > ---
> > > > Changes for v2: N/A
> > > > Changes for v2: none
> > > >
> > > >  configs/sandbox_defconfig |  3 +++
> > > >  test/dm/video.c   | 41 +++
> > > >  2 files changed, 44 insertions(+)
> > > >
> > > > diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
> > > > index 34c342b6f5..625ca35f5c 100644
> > > > --- a/configs/sandbox_defconfig
> > > > +++ b/configs/sandbox_defconfig
> > > > @@ -337,3 +337,6 @@ CONFIG_TEST_FDTDEC=y
> > > >  CONFIG_UNIT_TEST=y
> > > >  CONFIG_UT_TIME=y
> > > >  CONFIG_UT_DM=y
> > > > +CONFIG_CMD_SELECT_FONT=y
> > > > +CONFIG_VIDEO_FONT_8X16=y
> > > > +CONFIG_VIDEO_FONT_SUN12X22=y
> > >
> > > I don't think you can enable this, since sandbox uses
> > > CONSOLE_TRUETYPE. Can we perhaps use sandbox_flattree to run this
> > > test?
> > >
> > > Also, for me the tests crash with signal 8 (I think).
> > >
> > > > diff --git a/test/dm/video.c b/test/dm/video.c
> > > > index 17a33cc7af..30778157d9 100644
> > > > --- a/test/dm/video.c
> > > > +++ b/test/dm/video.c
> > > > @@ -151,6 +151,8 @@ static int dm_test_video_text(struct 
> > > > unit_test_state *uts)
> > > >
> > > > ut_assertok(select_vidconsole(uts, "vidconsole0"));
> > > > ut_assertok(video_get_nologo(uts, &dev));
> > > > +   ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
> > > > +   ut_assertok(vidconsole_select_font(con, "8x16", 0));
> > > > ut_asserteq(46, compress_frame_buffer(uts, dev));
> > > >
> > > > ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
> > > > @@ -175,6 +177,42 @@ static int dm_test_video_text(struct 
> > > > unit_test_state *uts)
> > > >  }
> > > >  DM_TEST(dm_test_video_text, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
> > > >
> > > > +static int dm_test_video_text_12x22(struct unit_test_state *uts)
> > > > +{
> > > > +   struct udevice *dev, *con;
> > > > +   int i;
> > > > +
> > > > +#define WHITE  0x
> > > > +#define

[PATCH v6 1/2] video console: sandbox_defconfig: add 12x22 font

2023-02-23 Thread Dzmitry Sankouski
Add 12x22 font in order to write a test for it.
Run savedefconfig.
---
Changes for v2: N/A
Changes for v3: N/A
Charges for v4: N/A
Charges for v5: N/A
Charges for v6: N/A

 configs/sandbox_defconfig | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 34c342b6f5..a0fbdad20a 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -2,6 +2,7 @@ CONFIG_TEXT_BASE=0
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_ENV_SIZE=0x2000
 CONFIG_DEFAULT_DEVICE_TREE="sandbox"
+CONFIG_DM_RESET=y
 CONFIG_PRE_CON_BUF_ADDR=0xf
 CONFIG_BOOTSTAGE_STASH_ADDR=0x0
 CONFIG_SYS_LOAD_ADDR=0x0
@@ -100,7 +101,6 @@ CONFIG_CMD_ETHSW=y
 CONFIG_CMD_BMP=y
 CONFIG_CMD_BOOTCOUNT=y
 CONFIG_CMD_EFIDEBUG=y
-CONFIG_CMD_EFICONFIG=y
 CONFIG_CMD_RTC=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_PAUSE=y
@@ -263,7 +263,6 @@ CONFIG_DM_REBOOT_MODE=y
 CONFIG_DM_REBOOT_MODE_GPIO=y
 CONFIG_DM_REBOOT_MODE_RTC=y
 CONFIG_REMOTEPROC_SANDBOX=y
-CONFIG_DM_RESET=y
 CONFIG_SANDBOX_RESET=y
 CONFIG_RESET_SYSCON=y
 CONFIG_RESET_SCMI=y
@@ -299,10 +298,10 @@ CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_USB_ETHER=y
 CONFIG_USB_ETH_CDC=y
 CONFIG_VIDEO=y
+CONFIG_VIDEO_FONT_SUN12X22=y
 CONFIG_VIDEO_COPY=y
 CONFIG_CONSOLE_ROTATION=y
 CONFIG_CONSOLE_TRUETYPE=y
-CONFIG_CONSOLE_TRUETYPE_MAX_METRICS=10
 CONFIG_CONSOLE_TRUETYPE_CANTORAONE=y
 CONFIG_I2C_EDID=y
 CONFIG_VIDEO_SANDBOX_SDL=y
-- 
2.30.2



[PATCH v6 2/2] video console: add 12x22 console simple font test

2023-02-23 Thread Dzmitry Sankouski
Tests fonts wider than a byte.

Signed-off-by: Dzmitry Sankouski 
Reviewed-by: Simon Glass 
---
Changes for v2: N/A
Changes for v2: none
Charges for v4: N/A
Charges for v5: N/A
Charges for v6:
- rebase
- move sandbox defconfig change to separate patch
- run savedefconfig

 test/dm/video.c | 41 +
 1 file changed, 41 insertions(+)

diff --git a/test/dm/video.c b/test/dm/video.c
index 17a33cc7af..30778157d9 100644
--- a/test/dm/video.c
+++ b/test/dm/video.c
@@ -151,6 +151,8 @@ static int dm_test_video_text(struct unit_test_state *uts)
 
ut_assertok(select_vidconsole(uts, "vidconsole0"));
ut_assertok(video_get_nologo(uts, &dev));
+   ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
+   ut_assertok(vidconsole_select_font(con, "8x16", 0));
ut_asserteq(46, compress_frame_buffer(uts, dev));
 
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
@@ -175,6 +177,42 @@ static int dm_test_video_text(struct unit_test_state *uts)
 }
 DM_TEST(dm_test_video_text, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
 
+static int dm_test_video_text_12x22(struct unit_test_state *uts)
+{
+   struct udevice *dev, *con;
+   int i;
+
+#define WHITE  0x
+#define SCROLL_LINES   100
+
+   ut_assertok(select_vidconsole(uts, "vidconsole0"));
+   ut_assertok(video_get_nologo(uts, &dev));
+   ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
+   ut_assertok(vidconsole_select_font(con, "12x22", 0));
+   ut_asserteq(46, compress_frame_buffer(uts, dev));
+
+   ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
+   vidconsole_putc_xy(con, 0, 0, 'a');
+   ut_asserteq(89, compress_frame_buffer(uts, dev));
+
+   vidconsole_putc_xy(con, 0, 0, ' ');
+   ut_asserteq(46, compress_frame_buffer(uts, dev));
+
+   for (i = 0; i < 20; i++)
+   vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i);
+   ut_asserteq(363, compress_frame_buffer(uts, dev));
+
+   vidconsole_set_row(con, 0, WHITE);
+   ut_asserteq(46, compress_frame_buffer(uts, dev));
+
+   for (i = 0; i < 20; i++)
+   vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i);
+   ut_asserteq(363, compress_frame_buffer(uts, dev));
+
+   return 0;
+}
+DM_TEST(dm_test_video_text_12x22, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
+
 /* Test handling of special characters in the console */
 static int dm_test_video_chars(struct unit_test_state *uts)
 {
@@ -184,6 +222,7 @@ static int dm_test_video_chars(struct unit_test_state *uts)
ut_assertok(select_vidconsole(uts, "vidconsole0"));
ut_assertok(video_get_nologo(uts, &dev));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
+   ut_assertok(vidconsole_select_font(con, "8x16", 0));
vidconsole_put_string(con, test_string);
ut_asserteq(466, compress_frame_buffer(uts, dev));
 
@@ -201,6 +240,7 @@ static int dm_test_video_ansi(struct unit_test_state *uts)
ut_assertok(select_vidconsole(uts, "vidconsole0"));
ut_assertok(video_get_nologo(uts, &dev));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
+   ut_assertok(vidconsole_select_font(con, "8x16", 0));
 
/* reference clear: */
video_clear(con->parent);
@@ -249,6 +289,7 @@ static int check_vidconsole_output(struct unit_test_state 
*uts, int rot,
 
ut_assertok(video_get_nologo(uts, &dev));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con));
+   ut_assertok(vidconsole_select_font(con, "8x16", 0));
ut_asserteq(46, compress_frame_buffer(uts, dev));
 
/* Check display wrap */
-- 
2.30.2



[PATCH v6 4/9] video console: implement multiple fonts configuration

2023-02-23 Thread Dzmitry Sankouski
This needed for unit testing different fonts.

Configured fonts are placed in an array of fonts.
First font is selected by default upon console probe.

Signed-off-by: Dzmitry Sankouski 
Reviewed-by: Simon Glass 
---
Changes for v2: N/A
Changes for v3: N/A
Charges for v4: N/A
Charges for v5: N/A
Charges for v6: rebase only

 common/splash.c | 17 +++---
 drivers/video/Kconfig   | 15 ++
 drivers/video/console_core.c| 81 +
 drivers/video/console_normal.c  | 32 +++-
 drivers/video/console_rotate.c  | 72 -
 drivers/video/vidconsole_internal.h | 20 ---
 include/video_font.h| 17 +-
 include/video_font_4x6.h| 11 ++--
 include/video_font_8x16.h   |  8 +--
 include/video_font_data.h   | 31 +++
 10 files changed, 207 insertions(+), 97 deletions(-)
 create mode 100644 include/video_font_data.h

diff --git a/common/splash.c b/common/splash.c
index 245ff680eb..1cd9afae2d 100644
--- a/common/splash.c
+++ b/common/splash.c
@@ -127,6 +127,7 @@ void splash_get_pos(int *x, int *y)
 #include 
 #include 
 #include 
+#include 
 
 void splash_display_banner(void)
 {
@@ -138,13 +139,15 @@ void splash_display_banner(void)
if (ret)
return;
 
-#ifdef CONFIG_VIDEO_LOGO
-   col = BMP_LOGO_WIDTH / VIDEO_FONT_WIDTH + 1;
-   row = BMP_LOGO_HEIGHT / VIDEO_FONT_HEIGHT + 1;
-#else
-   col = 0;
-   row = 0;
-#endif
+   if (IS_ENABLED(CONFIG_VIDEO_LOGO)) {
+   struct video_fontdata *fontdata = &fonts[0];
+
+   col = BMP_LOGO_WIDTH / fontdata->width + 1;
+   row = BMP_LOGO_HEIGHT / fontdata->height + 1;
+   } else {
+   col = 0;
+   row = 0;
+   }
 
display_options_get_banner(false, buf, sizeof(buf));
vidconsole_position_cursor(dev, col, 1);
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 2a76d19cc8..ce97eb4727 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -16,6 +16,21 @@ config VIDEO
 
 if VIDEO
 
+config VIDEO_FONT_4X6
+   bool "4 x 6 font size"
+   help
+ Font for video console driver, 4 x 6 pixels.
+ Provides character bitmap data in header file.
+ When selecting multiple fonts, you may want to enable CMD_SELECT_FONT 
too.
+
+config VIDEO_FONT_8X16
+   bool "8 x 16 font size"
+   default y
+   help
+ Font for video console driver, 8 x 16 pixels
+ Provides character bitmap data in header file.
+ When selecting multiple fonts, you may want to enable CMD_SELECT_FONT 
too.
+
 config VIDEO_LOGO
bool "Show the U-Boot logo on the display"
default y if !SPLASH_SCREEN
diff --git a/drivers/video/console_core.c b/drivers/video/console_core.c
index de004f585c..b82ca6d43c 100644
--- a/drivers/video/console_core.c
+++ b/drivers/video/console_core.c
@@ -9,8 +9,41 @@
 #include 
 #include 
 #include 
+#include 
 #include "vidconsole_internal.h"
 
+/**
+ * console_set_font() - prepare vidconsole for chosen font.
+ *
+ * @devvidconsole device
+ * @fontdata   pointer to font data struct
+ */
+static int console_set_font(struct udevice *dev, struct video_fontdata 
*fontdata)
+{
+   struct console_simple_priv *priv = dev_get_priv(dev);
+   struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev);
+   struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
+
+   debug("console_simple: setting %s font\n", fontdata->name);
+   debug("width: %d\n", fontdata->width);
+   debug("byte width: %d\n", fontdata->byte_width);
+   debug("height: %d\n", fontdata->height);
+
+   priv->fontdata = fontdata;
+   vc_priv->x_charsize = fontdata->width;
+   vc_priv->y_charsize = fontdata->height;
+   if (vid_priv->rot % 2) {
+   vc_priv->cols = vid_priv->ysize / fontdata->width;
+   vc_priv->rows = vid_priv->xsize / fontdata->height;
+   vc_priv->xsize_frac = VID_TO_POS(vid_priv->ysize);
+   } else {
+   vc_priv->cols = vid_priv->xsize / fontdata->width;
+   vc_priv->rows = vid_priv->ysize / fontdata->height;
+   }
+
+   return 0;
+}
+
 int check_bpix_support(int bpix)
 {
if (bpix == VIDEO_BPP8 && IS_ENABLED(CONFIG_VIDEO_BPP8))
@@ -43,7 +76,7 @@ inline void fill_pixel_and_goto_next(void **dstp, u32 value, 
int pbytes, int ste
 }
 
 int fill_char_vertically(uchar *pfont, void **line, struct video_priv 
*vid_priv,
-bool direction)
+struct video_fontdata *fontdata, bool direction)
 {
int step, line_step, pbytes, bitcount, width_remainder, ret;
void *dst;
@@ -61,17 +94,17 @@ int fill_char_vertically(uchar *pfont, void **line, struct 
video_priv *vid_priv,
line_step = vid_priv->line_length;
}
 
-   width_remainder = VIDEO_FONT_WIDTH % 8;

[PATCH v6 1/9] video console: refactoring and optimization

2023-02-23 Thread Dzmitry Sankouski
- move common code to vidconsole_internal.h and console_core.c
- unite probe functions
- get rid of code duplications in switch across bpp values
- extract common pixel fill logic in two functions one per
horizontal and vertical filling
- rearrange statements in put_xy* methods in unified way
- replace types - uint*_t to u*

Signed-off-by: Dzmitry Sankouski 
Reviewed-by: Simon Glass 
---
Changes for v2: none
Changes for v3: none
Changes for v4:
- move common code to vidconsole_internal.h
- unite probe functions
Changes for v5:
- move common functions to console-core.c file
- remove static keyword from shared functions
Changes for v6: none

 drivers/video/Makefile  |   6 +
 drivers/video/console_core.c| 141 +
 drivers/video/console_normal.c  | 150 --
 drivers/video/console_rotate.c  | 308 
 drivers/video/vidconsole_internal.h |  95 +
 5 files changed, 324 insertions(+), 376 deletions(-)
 create mode 100644 drivers/video/console_core.c
 create mode 100644 drivers/video/vidconsole_internal.h

diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index cdb7d9a54d..cb3f373645 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -9,6 +9,12 @@ obj-$(CONFIG_BACKLIGHT_GPIO) += backlight_gpio.o
 obj-$(CONFIG_BACKLIGHT_PWM) += pwm_backlight.o
 obj-$(CONFIG_CONSOLE_NORMAL) += console_normal.o
 obj-$(CONFIG_CONSOLE_ROTATION) += console_rotate.o
+ifdef CONFIG_CONSOLE_NORMAL
+obj-y += console_core.o
+else ifdef CONFIG_CONSOLE_ROTATION
+obj-y += console_core.o
+endif
+obj-$(CONFIG_CONSOLE_ROTATION) += console_core.o
 obj-$(CONFIG_CONSOLE_TRUETYPE) += console_truetype.o fonts/
 obj-$(CONFIG_DISPLAY) += display-uclass.o
 obj-$(CONFIG_VIDEO_MIPI_DSI) += dsi-host-uclass.o
diff --git a/drivers/video/console_core.c b/drivers/video/console_core.c
new file mode 100644
index 00..9c2e4cb4ea
--- /dev/null
+++ b/drivers/video/console_core.c
@@ -0,0 +1,141 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2015 Google, Inc
+ * (C) Copyright 2015
+ * Bernecker & Rainer Industrieelektronik GmbH - http://www.br-automation.com
+ * (C) Copyright 2023 Dzmitry Sankouski 
+ */
+
+#include 
+#include 
+#include 
+#include "vidconsole_internal.h"
+
+int check_bpix_support(int bpix)
+{
+   if (bpix == VIDEO_BPP8 && IS_ENABLED(CONFIG_VIDEO_BPP8))
+   return 0;
+   else if (bpix == VIDEO_BPP16 && IS_ENABLED(CONFIG_VIDEO_BPP16))
+   return 0;
+   else if (bpix == VIDEO_BPP32 && IS_ENABLED(CONFIG_VIDEO_BPP32))
+   return 0;
+   else
+   return -ENOSYS;
+}
+
+inline void fill_pixel_and_goto_next(void **dstp, u32 value, int pbytes, int 
step)
+{
+   u8 *dst_byte = *dstp;
+
+   if (pbytes == 4) {
+   u32 *dst = *dstp;
+   *dst = value;
+   }
+   if (pbytes == 2) {
+   u16 *dst = *dstp;
+   *dst = value;
+   }
+   if (pbytes == 1) {
+   u8 *dst = *dstp;
+   *dst = value;
+   }
+   *dstp = dst_byte + step;
+}
+
+int fill_char_vertically(uchar *pfont, void **line, struct video_priv 
*vid_priv,
+bool direction)
+{
+   int step, line_step, pbytes, ret;
+   void *dst;
+
+   ret = check_bpix_support(vid_priv->bpix);
+   if (ret)
+   return ret;
+
+   pbytes = VNBYTES(vid_priv->bpix);
+   if (direction) {
+   step = -pbytes;
+   line_step = -vid_priv->line_length;
+   } else {
+   step = pbytes;
+   line_step = vid_priv->line_length;
+   }
+
+   for (int row = 0; row < VIDEO_FONT_HEIGHT; row++) {
+   dst = *line;
+   uchar bits = pfont[row];
+
+   for (int i = 0; i < VIDEO_FONT_WIDTH; i++) {
+   u32 value = (bits & 0x80) ?
+   vid_priv->colour_fg :
+   vid_priv->colour_bg;
+
+   fill_pixel_and_goto_next(&dst,
+value,
+pbytes,
+step
+   );
+   bits <<= 1;
+   }
+   *line += line_step;
+   }
+   return ret;
+}
+
+int fill_char_horizontally(uchar *pfont, void **line, struct video_priv 
*vid_priv,
+  bool direction)
+{
+   int step, line_step, pbytes, ret;
+   void *dst;
+   u8 mask = 0x80;
+
+   ret = check_bpix_support(vid_priv->bpix);
+   if (ret)
+   return ret;
+
+   pbytes = VNBYTES(vid_priv->bpix);
+   if (direction) {
+   step = -pbytes;
+   line_step = vid_priv->line_length;
+   } else {
+   step = pbytes;
+   line_step = -vid_priv->line_length;
+   }
+   for (int col = 0; col < VID

[PATCH v6 6/9] video console: allow font size configuration at runtime

2023-02-23 Thread Dzmitry Sankouski
Allow font size configuration at runtime for console_simple.c
driver. This needed for unit testing different fonts.

Configuring is done by `font` command, also used for font
selection in true type console.

Signed-off-by: Dzmitry Sankouski 
Reviewed-by: Simon Glass 
---
Changes for v2: N/A
Changes for v3:
- move 8x16 font patch extracted
- implement multiple fonts patch extracted
- add static modifiers, where needed
- remove list fonts operation
- put fontdata in local var
Charges for v4: N/A
Charges for v5: N/A
Charges for v6: rebase only

 cmd/Kconfig |  8 
 cmd/Makefile|  2 +-
 drivers/video/Kconfig   |  1 +
 drivers/video/console_core.c| 21 +
 drivers/video/console_normal.c  |  2 ++
 drivers/video/console_rotate.c  |  6 ++
 drivers/video/vidconsole_internal.h | 12 
 7 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 2caa4af71c..a3512836c1 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -2226,6 +2226,14 @@ config CMD_VIDCONSOLE
  The name 'lcdputs' is a bit of a misnomer, but so named because the
  video device is often an LCD.
 
+config CMD_SELECT_FONT
+   bool "select font size"
+   depends on VIDEO
+   default n
+   help
+ Enabling this will provide 'font' command.
+ Allows font selection at runtime.
+
 endmenu
 
 source "cmd/ti/Kconfig"
diff --git a/cmd/Makefile b/cmd/Makefile
index 36d2daf22a..2d8bb4fc05 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -78,7 +78,7 @@ obj-$(CONFIG_CMD_EXT2) += ext2.o
 obj-$(CONFIG_CMD_FAT) += fat.o
 obj-$(CONFIG_CMD_FDT) += fdt.o
 obj-$(CONFIG_CMD_SQUASHFS) += sqfs.o
-obj-$(CONFIG_CONSOLE_TRUETYPE) += font.o
+obj-$(CONFIG_CMD_SELECT_FONT) += font.o
 obj-$(CONFIG_CMD_FLASH) += flash.o
 obj-$(CONFIG_CMD_FPGA) += fpga.o
 obj-$(CONFIG_CMD_FPGAD) += fpgad.o
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index ce97eb4727..e1bcc89b30 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -165,6 +165,7 @@ config CONSOLE_ROTATION
 
 config CONSOLE_TRUETYPE
bool "Support a console that uses TrueType fonts"
+   select CMD_SELECT_FONT
help
  TrueTrype fonts can provide outline-drawing capability rather than
  needing to provide a bitmap for each font and size that is needed.
diff --git a/drivers/video/console_core.c b/drivers/video/console_core.c
index b82ca6d43c..ee340b1528 100644
--- a/drivers/video/console_core.c
+++ b/drivers/video/console_core.c
@@ -180,3 +180,24 @@ int console_probe(struct udevice *dev)
 {
return console_set_font(dev, &fonts[0]);
 }
+
+int console_simple_get_font(struct udevice *dev, int seq, struct vidfont_info 
*info)
+{
+   info->name = (&fonts[seq])->name;
+
+   return 0;
+}
+
+int console_simple_select_font(struct udevice *dev, const char *name, uint 
size)
+{
+   struct video_fontdata *font;
+
+   for (font = fonts; font->name; font++) {
+   if (!strcmp(name, font->name)) {
+   console_set_font(dev, font);
+   return 0;
+   }
+   };
+   printf("no such font: %s, make sure it's name has x 
format\n", name);
+   return -ENOENT;
+}
diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c
index 03e859898c..79eaa53b2d 100644
--- a/drivers/video/console_normal.c
+++ b/drivers/video/console_normal.c
@@ -101,6 +101,8 @@ struct vidconsole_ops console_ops = {
.putc_xy= console_putc_xy,
.move_rows  = console_move_rows,
.set_row= console_set_row,
+   .get_font   = console_simple_get_font,
+   .select_font= console_simple_select_font,
 };
 
 U_BOOT_DRIVER(vidconsole_normal) = {
diff --git a/drivers/video/console_rotate.c b/drivers/video/console_rotate.c
index b924bc3459..f9f96835ee 100644
--- a/drivers/video/console_rotate.c
+++ b/drivers/video/console_rotate.c
@@ -262,18 +262,24 @@ struct vidconsole_ops console_ops_1 = {
.putc_xy= console_putc_xy_1,
.move_rows  = console_move_rows_1,
.set_row= console_set_row_1,
+   .get_font   = console_simple_get_font,
+   .select_font= console_simple_select_font,
 };
 
 struct vidconsole_ops console_ops_2 = {
.putc_xy= console_putc_xy_2,
.move_rows  = console_move_rows_2,
.set_row= console_set_row_2,
+   .get_font   = console_simple_get_font,
+   .select_font= console_simple_select_font,
 };
 
 struct vidconsole_ops console_ops_3 = {
.putc_xy= console_putc_xy_3,
.move_rows  = console_move_rows_3,
.set_row= console_set_row_3,
+   .get_font   = console_simple_get_font,
+   .select_font= console_simple_select_font,
 };
 
 U_BOOT_DRIVER(vidconsole_1) = {
diff --git a/drivers/video/vidconsole_internal.h 
b/driver

[PATCH v6 3/9] video console: move 8x16 font data in named header

2023-02-23 Thread Dzmitry Sankouski
Consistent font data header names needed to add new
fonts.

Signed-off-by: Dzmitry Sankouski 
Reviewed-by: Simon Glass 
---
Changes for v2: N/A
Changes for v3: N/A
Charges for v4: N/A
Charges for v5: N/A
Charges for v6: rebase only

 include/video_font.h | 2 +-
 include/{video_font_data.h => video_font_8x16.h} | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)
 rename include/{video_font_data.h => video_font_8x16.h} (99%)

diff --git a/include/video_font.h b/include/video_font.h
index 5e23f70f85..b07c07662c 100644
--- a/include/video_font.h
+++ b/include/video_font.h
@@ -10,7 +10,7 @@
 #ifdef CONFIG_VIDEO_FONT_4X6
 #include 
 #else
-#include 
+#include 
 #endif
 
 #endif /* _VIDEO_FONT_ */
diff --git a/include/video_font_data.h b/include/video_font_8x16.h
similarity index 99%
rename from include/video_font_data.h
rename to include/video_font_8x16.h
index 6e64198d1a..d3d4295032 100644
--- a/include/video_font_data.h
+++ b/include/video_font_8x16.h
@@ -6,8 +6,8 @@
  * This file contains an 8x16 bitmap font for code page 437.
  */
 
-#ifndef _VIDEO_FONT_DATA_
-#define _VIDEO_FONT_DATA_
+#ifndef _VIDEO_FONT_8X16
+#define _VIDEO_FONT_8X16
 
 #define VIDEO_FONT_CHARS   256
 #define VIDEO_FONT_WIDTH   8
@@ -4623,7 +4623,6 @@ static unsigned char __maybe_unused 
video_fontdata[VIDEO_FONT_SIZE] = {
0x00, /*  */
0x00, /*  */
0x00, /*  */
-
 };
 
 #endif
-- 
2.30.2



[PATCH v6 2/9] video console: add support for fonts wider than 1 byte

2023-02-23 Thread Dzmitry Sankouski
Devices with high ppi may benefit from wider fonts.

Current width implementation is limited by 1 byte, i.e. 8 bits.
New version iterates VIDEO_FONT_BYTE_WIDTH times, to process all
width bytes, thus allowing fonts wider than 1 byte.

Signed-off-by: Dzmitry Sankouski 
Reviewed-by: Simon Glass 
---
Charges for v2:
- replace TAIL_BIT_COUNT macro with c code
- rename refactoring
Charges for v3: none
Charges for v4: N/A
Charges for v5: N/A
Charges for v6: rebase only

 drivers/video/console_core.c| 84 ++---
 drivers/video/console_normal.c  |  2 +-
 drivers/video/console_rotate.c  |  6 +--
 drivers/video/vidconsole_internal.h |  1 +
 4 files changed, 59 insertions(+), 34 deletions(-)

diff --git a/drivers/video/console_core.c b/drivers/video/console_core.c
index 9c2e4cb4ea..de004f585c 100644
--- a/drivers/video/console_core.c
+++ b/drivers/video/console_core.c
@@ -45,7 +45,7 @@ inline void fill_pixel_and_goto_next(void **dstp, u32 value, 
int pbytes, int ste
 int fill_char_vertically(uchar *pfont, void **line, struct video_priv 
*vid_priv,
 bool direction)
 {
-   int step, line_step, pbytes, ret;
+   int step, line_step, pbytes, bitcount, width_remainder, ret;
void *dst;
 
ret = check_bpix_support(vid_priv->bpix);
@@ -61,23 +61,36 @@ int fill_char_vertically(uchar *pfont, void **line, struct 
video_priv *vid_priv,
line_step = vid_priv->line_length;
}
 
+   width_remainder = VIDEO_FONT_WIDTH % 8;
for (int row = 0; row < VIDEO_FONT_HEIGHT; row++) {
+   uchar bits;
+
+   bitcount = 8;
dst = *line;
-   uchar bits = pfont[row];
-
-   for (int i = 0; i < VIDEO_FONT_WIDTH; i++) {
-   u32 value = (bits & 0x80) ?
-   vid_priv->colour_fg :
-   vid_priv->colour_bg;
-
-   fill_pixel_and_goto_next(&dst,
-value,
-pbytes,
-step
-   );
-   bits <<= 1;
+   for (int col = 0; col < VIDEO_FONT_BYTE_WIDTH; col++) {
+   if (width_remainder) {
+   bool is_last_iteration = (VIDEO_FONT_BYTE_WIDTH 
- col == 1);
+
+   if (is_last_iteration)
+   bitcount = width_remainder;
+   }
+   bits = pfont[col];
+
+   for (int bit = 0; bit < bitcount; bit++) {
+   u32 value = (bits & 0x80) ?
+   vid_priv->colour_fg :
+   vid_priv->colour_bg;
+
+   fill_pixel_and_goto_next(&dst,
+value,
+pbytes,
+step
+   );
+   bits <<= 1;
+   }
}
*line += line_step;
+   pfont += VIDEO_FONT_BYTE_WIDTH;
}
return ret;
 }
@@ -85,9 +98,9 @@ int fill_char_vertically(uchar *pfont, void **line, struct 
video_priv *vid_priv,
 int fill_char_horizontally(uchar *pfont, void **line, struct video_priv 
*vid_priv,
   bool direction)
 {
-   int step, line_step, pbytes, ret;
+   int step, line_step, pbytes, bitcount = 8, width_remainder, ret;
void *dst;
-   u8 mask = 0x80;
+   u8 mask;
 
ret = check_bpix_support(vid_priv->bpix);
if (ret)
@@ -101,21 +114,32 @@ int fill_char_horizontally(uchar *pfont, void **line, 
struct video_priv *vid_pri
step = pbytes;
line_step = -vid_priv->line_length;
}
-   for (int col = 0; col < VIDEO_FONT_WIDTH; col++) {
-   dst = *line;
-   for (int row = 0; row < VIDEO_FONT_HEIGHT; row++) {
-   u32 value = (pfont[row * VIDEO_FONT_BYTE_WIDTH] & mask) 
?
-   vid_priv->colour_fg :
-   vid_priv->colour_bg;
-
-   fill_pixel_and_goto_next(&dst,
-value,
-pbytes,
-step
-   );
+
+   width_remainder = VIDEO_FONT_WIDTH % 8;
+   for (int col = 0; col < VIDEO_FONT_BYTE_WIDTH; col++) {
+   mask = 0x80;
+   if (width_remainder) {
+   bool is_last_iteration = (VIDEO_FONT_BYTE_WIDTH - col 
== 1);
+
+   if (is_last_iteratio

[PATCH v6 00/10] vidconsole: refactoring and support for wider fonts

2023-02-23 Thread Dzmitry Sankouski
Version 6 contains entire rebased patch series.
New patch 'move vidconsole_get_font_size() to test.h' added.

Version 5 contain minor changes:
- move common functions to console-core.c file
- remove static keyword from shared functions

In version 4, only first patch sent, because review fixes to this would add
large rebase & patch formatting overhead. When it'll receive reviewed tag,
I'll resent entire rebased series.

Modern mobile phones typically have high pixel density.
Bootmenu is hardly readable on those with 8x16 font.

This patch series aims to add wider fonts for devices with high ppi.

Add 16x32, 12x22 fonts from linux, and allow font size configuration.

There was significant changes in version 2:
- fix video tests failures
- add runtime font size configuration
- add test for 12x22 font

In version 3,
'video console: add select font logic to vidconsole uclass driver'
patch was removed in favor of already merged patch
'video: Add font functions to the vidconsole API'

Dzmitry Sankouski (10):
  video console: refactoring and optimization
  video console: add support for fonts wider than 1 byte
  video console: move 8x16 font data in named header
  video console: implement multiple fonts configuration
  video console: move vidconsole_get_font_size() to test.h
  video console: allow font size configuration at runtime
  video console: add 12x22 Sun font from linux
  video console: add 16x32 Terminus font from linux
  video console: sandbox_defconfig: add 12x22 font
  video console: add 12x22 console simple font test

 cmd/Kconfig |8 +
 cmd/Makefile|2 +-
 cmd/font.c  |5 +-
 common/splash.c |   17 +-
 configs/sandbox_defconfig   |5 +-
 drivers/video/Kconfig   |   30 +
 drivers/video/Makefile  |6 +
 drivers/video/console_core.c|  203 +
 drivers/video/console_normal.c  |  176 +-
 drivers/video/console_rotate.c  |  368 +-
 drivers/video/console_truetype.c|8 +-
 drivers/video/vidconsole_internal.h |  114 +
 include/cmd/test.h  |   19 +
 include/video_console.h |9 -
 include/video_font.h|   31 +-
 include/video_font_4x6.h|   11 +-
 include/video_font_8x16.h   | 4624 
 include/video_font_data.h   | 4644 +---
 include/video_font_sun12x22.h   | 6158 +++
 include/video_font_ter16x32.h   | 2062 +
 test/cmd/font.c |1 +
 test/dm/video.c |   41 +
 22 files changed, 13488 insertions(+), 5054 deletions(-)
 create mode 100644 drivers/video/console_core.c
 create mode 100644 drivers/video/vidconsole_internal.h
 create mode 100644 include/cmd/test.h
 create mode 100644 include/video_font_8x16.h
 create mode 100644 include/video_font_sun12x22.h
 create mode 100644 include/video_font_ter16x32.h

-- 
2.30.2


Re: [PATCH v6 3/6] tpm: Support boot measurements

2023-02-23 Thread Ilias Apalodimas
Hi Eddie,

[...]

> > But at least the kernel can find the EFI config tables properly.
> > > Also, note that the ret is efi_status_t and the new function you added
> > > returns an int.  Just switch the ret here accordingly.
> > >
> > >
> > >   * platforms can use different ways to do so.
> > >   */
> > >  ret = tcg2_init_log(dev, &elog);
> > > -   if (ret != EFI_SUCCESS)
> > > -   goto free_pool;
> > > -
> > > -   memcpy(event_log.buffer, elog.log, elog.log_position);
> > > -   event_log.pos = elog.log_position;
> > > +   if (ret == EFI_SUCCESS) {
> > > +   memcpy(event_log.buffer, elog.log, elog.log_position);
> > > +   event_log.pos = elog.log_position;
> > > +   }
> > >
> > >
> > > I'll try digging into the EFI issues more once I get some time
> > Ok Ignore the previous mail. I just noticed that the specid event is
> > generated by tcg2_log_init() and that's where the errors come from.
>
>
> OK, I think I understand the problem. One problem with your solution below
> is that it's only useful for EFI; writing the event log to a temporary
> buffer in the non-EFI case is a waste of time, since it can't go anywhere.

It's not even a 'solution', it's just an ugly hack to help you understand
where things go sideways.

>
> I have a solution where the user can pass in their buffer in the
> tcg2_event_log structure in the event that no memory region is discovered.
> EFI can use that path.

Yep that sounds sane,  that way EFI can pass the efi allocated memory and
you can call call that with NULL for non-efi code.
Please keep in mind that the EventLog, if it comes from TF-A, needs to be
replayed into hardware as well, since TF-A doesn't extend PCRs.

>
>
> Thanks for the debugging effort!

yw

Cheers
/Ilias
>
> Eddie
>
>
> >
> > So something like the *really ugly hack* fixes EFI.  Can you please
> > turn it into human-readable code
> >
> >   #include 
> >   #include 
> >   #include 
> > +#include 
> >
> >   #include "tpm-utils.h"
> >
> > @@ -634,7 +635,7 @@ __weak int tcg2_platform_get_log(struct udevice
> > *dev, void **addr, u32 *size)
> >
> >  if (dev_read_phandle_with_args(dev, "memory-region", NULL, 
> > 0,
> > 0, &args))
> > -   return -ENODEV;
> > +   goto alloc;
> >
> >  a = ofnode_get_addr_size(args.node, "reg", &s);
> >  if (a == FDT_ADDR_T_NONE)
> > @@ -643,6 +644,9 @@ __weak int tcg2_platform_get_log(struct udevice
> > *dev, void **addr, u32 *size)
> >  *addr = map_physmem(a, s, MAP_NOCACHE);
> >  *size = (u32)s;
> >  }
> > +alloc:
> > +   *addr = calloc(1, 4096);
> > +   *size = 4096;
> >
> >  return 0;
> >   }
> >
> > Cheers
> > /Ilias
> >
> > > Cheers
> > > /Ilias
> > > > Thanks!
> > > > /Ilias


Re: [PATCH RFC u-boot-mvebu 00/59] arm: mvebu: Various fixes

2023-02-23 Thread Pali Rohár
On Thursday 23 February 2023 12:11:46 Martin Rowe wrote:
> > > > Have you tried booting from eMMC boot partition or eMMC user data
> > > > partition? Because all 3 options should work, but I'm not fully sure if
> > > > BootROM choose partition from eMMC register or if tries all 3 in some
> > > > order. This is something which needs to be checked and verified.
> > >
> > > I only tested from boot0, but will test the others as well. I've only
> > > ever seen it fallback, but I'll check the new changes and see if they
> > > can select the boot device.
> >
> > Ok. When testing, ensure that you erase uboots from other partitions or
> > check that it boots the correct version from the correction partition.
> 
> BootROM always tries boot0, boot1, then user, regardless of partconf
> setting. SPL does use the partconf setting, though. So when I
> configure:
> boot0 - zeroed
> boot1 - u-boot (with local version 'boot1')
> user - u-boot (with local version 'user')
> mmc partconf 0 0 7 0
> I see the output below. Note that BootROM tries boot0 first with two
> addresses, switches to boot1 (see 'boot1' following 2023.04-rc2),
> loads SPL, which then loads u-boot from user (see 'user' following
> 2023.04-rc2)

Ok, I was not sure how that bootrom is choosing initial partition as I
have not fully understood bootrom mmc code. So from this it looks like
that bootrom ignores MMC EXT_CSD[179] register, try booting from BOOT0
and then it really switch to the next partition. (My understanding of
that bootrom binary was that "Switching BootPartitions." does nothing.)

Can you check if boot_ack argument has some effect on the initial
choice? Or if completely disabling boot partitions (boot_enable to 0)
have some effect?

If really EXT_CSD[179] register is completely ignored we may change SPL
to always boot from BOOT0 (when eMMC with boot partitions is used) and
if it fails then fallback to BootROM booting.

> =
> BootROM - 1.73
> 
> Booting from MMC
> BootROM: Bad header at offset 
> BootROM: Bad header at offset 0020
> Switching BootPartitions.
> 
> U-Boot SPL 2023.04-rc2boot1-00098-g93408c61cd-dirty (Feb 23 2023 -
> 19:43:59 +1000)
> High speed PHY - Version: 2.0
> EEPROM TLV detection failed: Using static config for Clearfog Pro.
> Detected Device ID 6828
> board SerDes lanes topology details:
>  | Lane # | Speed |  Type   |
>  
>  |   0|   3   | SATA0|
>  |   1|   0   | SGMII1|
>  |   2|   5   | PCIe1|
>  |   3|   5   | USB3 HOST1|
>  |   4|   5   | PCIe2|
>  |   5|   0   | SGMII2|
>  
> High speed PHY - Ended Successfully
> mv_ddr: 14.0.0
> DDR3 Training Sequence - Switching XBAR Window to FastPath Window
> mv_ddr: completed successfully
> Trying to boot from MMC1
> 
> 
> U-Boot 2023.04-rc2user-00098-g93408c61cd-dirty (Feb 23 2023 - 19:44:54 +1000)
> 
> SoC:   MV88F6828-A0 at 1600 MHz
> DRAM:  1 GiB (800 MHz, 32-bit, ECC not enabled)
> Core:  38 devices, 22 uclasses, devicetree: separate
> MMC:   mv_sdh: 0
> Loading Environment from MMC... *** Warning - bad CRC, using default 
> environment
> 
> Model: SolidRun Clearfog A1
> Board: SolidRun Clearfog Pro
> Net:
> Warning: ethernet@7 (eth1) using random MAC address - ae:50:98:34:2e:3e
> eth1: ethernet@7
> Warning: ethernet@3 (eth2) using random MAC address - 0a:66:2b:f7:45:09
> , eth2: ethernet@3
> Warning: ethernet@34000 (eth3) using random MAC address - d2:8e:11:7e:64:c0
> , eth3: ethernet@34000
> Hit any key to stop autoboot:  0
> =>
> =
> 
> > > > Could you try to use SolidRun eMMC patch which SolidRun has for years in
> > > > its repository?
> > > >
> > > > https://github.com/SolidRun/u-boot/commit/19a96f7c40a8fc1d0a6546ac2418d966e5840a99
> > > >
> > > > Probably same functionality is needed to implement also into
> > > > board_fix_fdt() function enabled by CONFIG_OF_BOARD_FIXUP. Look for
> > > > other boards how they use CONFIG_OF_BOARD_FIXUP.
> > > >
> > > > And if ... you can try to put this logic in board_late_init() function.
> > > > For inspiration look into Espressobin board which deactivates eMMC at
> > > > runtime by checking existence of eMMC:
> > > > https://source.denx.de/u-boot/u-boot/-/blob/master/board/Marvell/mvebu_armada-37xx/board.c
> 
> I've not been able to get this to work. I enable CONFIG_OF_BOARD_FIXUP
> in my config and add the following to
> board/solidrun/clearfog/clearfog.c:
> +int board_fix_fdt(void *blob)
> +   {
> +   int offset;
> +   offset = fdt_path_offset(blob, "/soc/internal-regs/sdhci@d8000");
> +   if (offset >= 0) {
> +   printf("offset");
> +   fdt_delprop(blob, offset, "cd-gpios");
> +   fdt_setprop_empty(blob, offset, "non-removable");
> +   }
> +   return 0;
> +}
> Then I boot from MMC and get the following:
> ===

[PATCH 1/1] cmd: bootefi: allocate device-tree copy from high memory

2023-02-23 Thread Heinrich Schuchardt
The bootefi command creates a copy of the device-tree within the first
127 MiB of memory. This may lead to overwriting previously loaded binaries
(e.g. kernel, initrd).

Linux EFI stub itself copies U-Boot's copy of the device-tree. This means
there is not restriction for U-Boot to place the device-tree copy to any
address. (Restrictions existed for 32bit ARM before Linux commit
7a1be318f579 ("ARM: 9012/1: move device tree mapping out of linear region")
for legacy booting.

Reported-by: Alexandre Ghiti 
Signed-off-by: Heinrich Schuchardt 
---
 cmd/bootefi.c | 15 +++
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 6618335ddf..aca4e99930 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -208,21 +208,12 @@ static efi_status_t copy_fdt(void **fdtp)
 * Safe fdt location is at 127 MiB.
 * On the sandbox convert from the sandbox address space.
 */
-   new_fdt_addr = (uintptr_t)map_sysmem(fdt_ram_start + 0x7f0 +
-fdt_size, 0);
-   ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
+   ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
 EFI_ACPI_RECLAIM_MEMORY, fdt_pages,
 &new_fdt_addr);
if (ret != EFI_SUCCESS) {
-   /* If we can't put it there, put it somewhere */
-   new_fdt_addr = (ulong)memalign(EFI_PAGE_SIZE, fdt_size);
-   ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
-EFI_ACPI_RECLAIM_MEMORY, fdt_pages,
-&new_fdt_addr);
-   if (ret != EFI_SUCCESS) {
-   log_err("ERROR: Failed to reserve space for FDT\n");
-   goto done;
-   }
+   log_err("ERROR: Failed to reserve space for FDT\n");
+   goto done;
}
new_fdt = (void *)(uintptr_t)new_fdt_addr;
memcpy(new_fdt, fdt, fdt_totalsize(fdt));
-- 
2.38.1



Re: [PATCH v6 3/6] tpm: Support boot measurements

2023-02-23 Thread Eddie James



On 2/23/23 03:47, Ilias Apalodimas wrote:

On Thu, 23 Feb 2023 at 11:30, Ilias Apalodimas
 wrote:

On Thu, 23 Feb 2023 at 11:02, Ilias Apalodimas
 wrote:

Hi Eddie,

 final_event->number_of_events++;

@@ -350,66 +142,6 @@ static efi_status_t tcg2_agile_log_append(u32 pcr_index, 
u32 event_type,
   return ret;
  }

-/**
- * platform_get_tpm_device() - retrieve TPM device
- *
- * This function retrieves the udevice implementing a TPM
- *
- * This function may be overridden if special initialization is needed.
- *
- * @dev: udevice
- * Return:   status code
- */
-__weak efi_status_t platform_get_tpm2_device(struct udevice **dev)
-{
- for_each_tpm_device(*dev) {
- /* Only support TPMv2 devices */
- if (tpm_get_version(*dev) == TPM_V2)
- return EFI_SUCCESS;
- }
-
- return EFI_NOT_FOUND;
-}
-
-/**
- * platform_get_eventlog() - retrieve the eventlog address and size
- *
- * This function retrieves the eventlog address and size if the underlying
- * firmware has done some measurements and passed them.
- *
- * This function may be overridden based on platform specific method of
- * passing the eventlog address and size.
- *
- * @dev: udevice
- * @addr:eventlog address
- * @sz:  eventlog size
- * Return:   status code
- */
-__weak efi_status_t platform_get_eventlog(struct udevice *dev, u64 *addr,
-   u32 *sz)
-{
- const u64 *basep;
- const u32 *sizep;
-
- basep = dev_read_prop(dev, "tpm_event_log_addr", NULL);
- if (!basep)
- return EFI_NOT_FOUND;
-
- *addr = be64_to_cpup((__force __be64 *)basep);
-
- sizep = dev_read_prop(dev, "tpm_event_log_size", NULL);
- if (!sizep)
- return EFI_NOT_FOUND;
-
- *sz = be32_to_cpup((__force __be32 *)sizep);
- if (*sz == 0) {
- log_debug("event log empty\n");
- return EFI_NOT_FOUND;
- }
-
- return EFI_SUCCESS;
-}
-
  /**
   * tpm2_get_max_command_size() - get the supported max command size
   *
@@ -485,239 +217,6 @@ static int tpm2_get_manufacturer_id(struct udevice *dev, 
u32 *manufacturer_id)
   return 0;
  }

-/**
- * tpm2_get_num_pcr() - get the number of PCRs
- *
- * @dev: TPM device
- * @manufacturer_id: output buffer for the number
- *
- * Return: 0 on success, -1 on error
- */
-static int tpm2_get_num_pcr(struct udevice *dev, u32 *num_pcr)
-{
- u8 response[TPM2_RESPONSE_BUFFER_SIZE];
- u32 ret;
-
- memset(response, 0, sizeof(response));
- ret = tpm2_get_capability(dev, TPM2_CAP_TPM_PROPERTIES,
-   TPM2_PT_PCR_COUNT, response, 1);
- if (ret)
- return -1;
-
- *num_pcr = get_unaligned_be32(response + properties_offset);
- if (*num_pcr > TPM2_MAX_PCRS)
- return -1;
-
- return 0;
-}
-
-/**
- * is_active_pcr() - Check if a supported algorithm is active
- *
- * @dev: TPM device
- * @selection:   struct of PCR information
- *
- * Return: true if PCR is active
- */
-static bool is_active_pcr(struct tpms_pcr_selection *selection)
-{
- int i;
- /*
-  * check the pcr_select. If at least one of the PCRs supports the
-  * algorithm add it on the active ones
-  */
- for (i = 0; i < selection->size_of_select; i++) {
- if (selection->pcr_select[i])
- return true;
- }
-
- return false;
-}
-
-/**
- * tpm2_get_pcr_info() - get the supported, active PCRs and number of banks
- *
- * @dev: TPM device
- * @supported_pcr:   bitmask with the algorithms supported
- * @active_pcr:  bitmask with the active algorithms
- * @pcr_banks:   number of PCR banks
- *
- * Return: 0 on success, -1 on error
- */
-static int tpm2_get_pcr_info(struct udevice *dev, u32 *supported_pcr,
-  u32 *active_pcr, u32 *pcr_banks)
-{
- u8 response[TPM2_RESPONSE_BUFFER_SIZE];
- struct tpml_pcr_selection pcrs;
- u32 ret, num_pcr;
- size_t i;
- int tpm_ret;
-
- *supported_pcr = 0;
- *active_pcr = 0;
- *pcr_banks = 0;
- memset(response, 0, sizeof(response));
- ret = tpm2_get_capability(dev, TPM2_CAP_PCRS, 0, response, 1);
- if (ret)
- goto out;
-
- pcrs.count = get_unaligned_be32(response);
- /*
-  * We only support 5 algorithms for now so check against that
-  * instead of TPM2_NUM_PCR_BANKS
-  */
- if (pcrs.count > MAX_HASH_COUNT || pcrs.count < 1)
- goto out;
-
- tpm_ret = tpm2_get_num_pcr(dev, &num_pcr);
- if (tpm_ret)
- goto out;
-
- for (i = 0; i < pcrs.count; i++) {
- /*
-  * Definition of TPMS_PCR_SELECTION Structure
-  * hash: u16
-  * size_of_select: u8
-  * pcr_select: u8 array
-  *
-  * The offsets depend on the number of the device PCRs
-  * so we ha

Re: [PATCH v2 1/2] env: mmc: Clean up macro usage

2023-02-23 Thread Simon Glass
Hi,

On Thu, 23 Feb 2023 at 06:23, Marek Vasut  wrote:
>
> On 2/23/23 11:41, Patrick DELAUNAY wrote:
> > Hi Marek,
>
> Hi,
>
> > On 2/9/23 13:30, Marek Vasut wrote:
> >> Consistently use 'if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID))' instead of
> >> mix of ifdef.
> >>
> >> Signed-off-by: Marek Vasut 
> >> ---
> >> Cc: Patrice Chotard 
> >> Cc: Patrick Delaunay 
> >> Cc: Tom Rini 
> >> ---
> >> V2: Replace CONFIG_IS_ENABLED(PARTITION_TYPE_GUID) with
> >> IS_ENABLED(CONFIG_PARTITION_TYPE_GUID)
> >> ---
> >>   env/mmc.c | 4 +---
> >>   1 file changed, 1 insertion(+), 3 deletions(-)
> >>
> >> diff --git a/env/mmc.c b/env/mmc.c
> >> index 5b01f657a7a..d51a5579128 100644
> >> --- a/env/mmc.c
> >> +++ b/env/mmc.c
> >> @@ -73,8 +73,7 @@ static inline int mmc_offset_try_partition(const
> >> char *str, int copy, s64 *val)
> >>   if (str && !strncmp((const char *)info.name, str,
> >> sizeof(info.name)))
> >>   break;
> >> -#ifdef CONFIG_PARTITION_TYPE_GUID
> >> -if (!str) {
> >> +if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID) && !str) {
> >>   const efi_guid_t env_guid = PARTITION_U_BOOT_ENVIRONMENT;
> >>   efi_guid_t type_guid;
> >> @@ -82,7 +81,6 @@ static inline int mmc_offset_try_partition(const
> >> char *str, int copy, s64 *val)
> >>   if (!memcmp(&env_guid, &type_guid, sizeof(efi_guid_t)))
> >>   break;
> >>   }
> >> -#endif
> >>   }
> >>   /* round up to info.blksz */
> >
> >
> > If I remenber, I try this test with IS_ENABLED when I propose my patch
> >
> > and I have compilation issue on next line
> >
> >
> > +uuid_str_to_bin(info.type_guid, type_guid.b,
> > UUID_STR_FORMAT_GUID);
> >
> >
> > because "info.type_guid" don't exist in struct disk_partition
> >
> > see ./include/part.h:59
> >
> >
> > struct disk_partition {
> >  lbaint_tstart;/* # of first block in partition*/
> > ...
> > #ifdef CONFIG_PARTITION_TYPE_GUID
> >  chartype_guid[UUID_STR_LEN + 1];/* type GUID as string, if
> > exists*/
> > #endif
> > ...
> > };
>
> Uh, which defconfig triggers this ?
>
> Also, is there a way to deal with this failure without reinstating the
> ifdef ? Tom ?

We can create static inline accessors as we have done with some things
in global_data.h

Regards,
Simon


Re: bootefi issue

2023-02-23 Thread Heinrich Schuchardt

On 2/23/23 17:24, Alexandre Ghiti wrote:

On Thu, Feb 23, 2023 at 4:57 PM Heinrich Schuchardt
 wrote:


On 2/23/23 14:38, Alexandre Ghiti wrote:

Hi Heinrich,

I fell into an issue in u-boot, and I struggle to find the correct
fix: I'm loading a kernel of 66MB at kernel_addr_r (=0x8400_, this
is the default value) and then I'm booting it using bootefi. But the
loaded kernel is overwritten by the fdt because u-boot loads the dtb
at 0x87f0_ 
(https://elixir.bootlin.com/u-boot/v2023.01/source/cmd/bootefi.c#L211:
I guess efi_allocate_pages does not fail because the efi allocator is
not aware of the kernel that was loaded there). So I have multiple
fixes and don't know which one is right:

1. bootefi could load the kernel first and then the fdt (so that the
efi allocator fails at 0x87f0_)
2. check before efi_allocate_pages that the "normal" allocator is free
there (I tried malloc_usable_size but it fails).
3. decrease kernel_addr_r...But I would disagree :)

Any idea?

Thanks,

Alex


Hello Alexandre,

this address for copying the device-tree dates back to 2016-04-11 when
AllocatePages() didn't work properly.

For riscv64 I see no reason why we should not use a high address.

@Ilias
Does ARM have any problem with the device-tree being in high memory?
Otherwise we should make a change as in the diff below.

Best regards

Heinrich


diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 6618335ddf..08a0cfa764 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -210,19 +210,12 @@ static efi_status_t copy_fdt(void **fdtp)
   */
  new_fdt_addr = (uintptr_t)map_sysmem(fdt_ram_start + 0x7f0 +
   fdt_size, 0);


I guess we can entirely remove this ^ right?


-   ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
+   ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
   EFI_ACPI_RECLAIM_MEMORY, fdt_pages,
   &new_fdt_addr);
  if (ret != EFI_SUCCESS) {
-   /* If we can't put it there, put it somewhere */
-   new_fdt_addr = (ulong)memalign(EFI_PAGE_SIZE, fdt_size);
-   ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
-EFI_ACPI_RECLAIM_MEMORY, fdt_pages,
-&new_fdt_addr);
-   if (ret != EFI_SUCCESS) {
-   log_err("ERROR: Failed to reserve space for FDT\n");
-   goto done;
-   }
+   log_err("ERROR: Failed to reserve space for FDT\n");
+   goto done;
  }
  new_fdt = (void *)(uintptr_t)new_fdt_addr;
  memcpy(new_fdt, fdt, fdt_totalsize(fdt));



What would prevent the efi allocator to return an address that
overwrites the loaded kernel?


Our AllocatePages() assigns high memory when called with 
EFI_ALLOCATE_ANY_PAGES.


Currently we have a gap in U-Boot. Memory is not allocated by the 'load' 
command. We need to merge the EFI memory allocator and lib/lmb.c.


A quick fix has been commit 06d514d77c37 ("lmb: consider EFI memory 
map") but that does not cover everything.


Best regards

Heinrich


Re: bootefi issue

2023-02-23 Thread Alexandre Ghiti
On Thu, Feb 23, 2023 at 4:57 PM Heinrich Schuchardt
 wrote:
>
> On 2/23/23 14:38, Alexandre Ghiti wrote:
> > Hi Heinrich,
> >
> > I fell into an issue in u-boot, and I struggle to find the correct
> > fix: I'm loading a kernel of 66MB at kernel_addr_r (=0x8400_, this
> > is the default value) and then I'm booting it using bootefi. But the
> > loaded kernel is overwritten by the fdt because u-boot loads the dtb
> > at 0x87f0_ 
> > (https://elixir.bootlin.com/u-boot/v2023.01/source/cmd/bootefi.c#L211:
> > I guess efi_allocate_pages does not fail because the efi allocator is
> > not aware of the kernel that was loaded there). So I have multiple
> > fixes and don't know which one is right:
> >
> > 1. bootefi could load the kernel first and then the fdt (so that the
> > efi allocator fails at 0x87f0_)
> > 2. check before efi_allocate_pages that the "normal" allocator is free
> > there (I tried malloc_usable_size but it fails).
> > 3. decrease kernel_addr_r...But I would disagree :)
> >
> > Any idea?
> >
> > Thanks,
> >
> > Alex
>
> Hello Alexandre,
>
> this address for copying the device-tree dates back to 2016-04-11 when
> AllocatePages() didn't work properly.
>
> For riscv64 I see no reason why we should not use a high address.
>
> @Ilias
> Does ARM have any problem with the device-tree being in high memory?
> Otherwise we should make a change as in the diff below.
>
> Best regards
>
> Heinrich
>
>
> diff --git a/cmd/bootefi.c b/cmd/bootefi.c
> index 6618335ddf..08a0cfa764 100644
> --- a/cmd/bootefi.c
> +++ b/cmd/bootefi.c
> @@ -210,19 +210,12 @@ static efi_status_t copy_fdt(void **fdtp)
>   */
>  new_fdt_addr = (uintptr_t)map_sysmem(fdt_ram_start + 0x7f0 +
>   fdt_size, 0);

I guess we can entirely remove this ^ right?

> -   ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
> +   ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
>   EFI_ACPI_RECLAIM_MEMORY, fdt_pages,
>   &new_fdt_addr);
>  if (ret != EFI_SUCCESS) {
> -   /* If we can't put it there, put it somewhere */
> -   new_fdt_addr = (ulong)memalign(EFI_PAGE_SIZE, fdt_size);
> -   ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
> -EFI_ACPI_RECLAIM_MEMORY, fdt_pages,
> -&new_fdt_addr);
> -   if (ret != EFI_SUCCESS) {
> -   log_err("ERROR: Failed to reserve space for FDT\n");
> -   goto done;
> -   }
> +   log_err("ERROR: Failed to reserve space for FDT\n");
> +   goto done;
>  }
>  new_fdt = (void *)(uintptr_t)new_fdt_addr;
>  memcpy(new_fdt, fdt, fdt_totalsize(fdt));
>

What would prevent the efi allocator to return an address that
overwrites the loaded kernel?


[PATCH 3/3] rk3566: radxa-cm3: Enable USB OTG

2023-02-23 Thread Manoj Sai
Enable USB OTG support and update the fastboot buffer address
for Radxa Compute Module 3 IO Board.

This would help to use fastboot by default.

Signed-off-by: Manoj Sai 
---
 configs/radxa-cm3-io-rk3566_defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/configs/radxa-cm3-io-rk3566_defconfig 
b/configs/radxa-cm3-io-rk3566_defconfig
index 2100cf2cb2..4d2acef6cd 100644
--- a/configs/radxa-cm3-io-rk3566_defconfig
+++ b/configs/radxa-cm3-io-rk3566_defconfig
@@ -21,6 +21,7 @@ CONFIG_DEBUG_UART_BASE=0xFE66
 CONFIG_DEBUG_UART_CLOCK=2400
 CONFIG_SYS_LOAD_ADDR=0xc00800
 CONFIG_DEBUG_UART=y
+# CONFIG_ANDROID_BOOT_IMAGE is not set
 CONFIG_FIT=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_SPL_LOAD_FIT=y
@@ -47,6 +48,7 @@ CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SPL_REGMAP=y
 CONFIG_SPL_SYSCON=y
 CONFIG_SPL_CLK=y
+CONFIG_FASTBOOT_BUF_ADDR=0xc00800
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_SYS_I2C_ROCKCHIP=y
 CONFIG_MISC=y
@@ -74,4 +76,5 @@ CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_GENERIC=y
 CONFIG_USB_DWC3=y
 CONFIG_USB_DWC3_GENERIC=y
+CONFIG_USB_GADGET=y
 CONFIG_ERRNO_STR=y
-- 
2.25.1



[PATCH 2/3] rockchip: rk356x: update the dwc3_device register offset

2023-02-23 Thread Manoj Sai
update the dwc3_device register offset in board_usb_init()
for rk3568 platforms.

Signed-off-by: Manoj Sai 
---
 arch/arm/mach-rockchip/board.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c
index f1f70c81d0..c7729c966a 100644
--- a/arch/arm/mach-rockchip/board.c
+++ b/arch/arm/mach-rockchip/board.c
@@ -300,6 +300,9 @@ int usb_gadget_handle_interrupts(int index)
 
 int board_usb_init(int index, enum usb_init_type init)
 {
+   if (IS_ENABLED(CONFIG_ROCKCHIP_RK3568))
+   dwc3_device_data.base = 0xfcc0;
+
return dwc3_uboot_init(&dwc3_device_data);
 }
 #endif /* CONFIG_USB_DWC3_GADGET */
-- 
2.25.1



[PATCH 1/3] arm: dts: rockchip: rk3566: Enable USB OTG for Radxa CM3

2023-02-23 Thread Manoj Sai
Enable USB OTG support for Radxa Compute Module 3 IO Board

Signed-off-by: Manoj Sai 
---

Note: Above changeset has sent to kernel mailing list, which is currently under 
review.
https://lore.kernel.org/linux-arm-kernel/20230223135929.630787-1-abbaraju.manoj...@amarulasolutions.com/T/#u
---
 arch/arm/dts/rk3566-radxa-cm3-io.dts | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/dts/rk3566-radxa-cm3-io.dts 
b/arch/arm/dts/rk3566-radxa-cm3-io.dts
index d89d5263cb..5e4236af4f 100644
--- a/arch/arm/dts/rk3566-radxa-cm3-io.dts
+++ b/arch/arm/dts/rk3566-radxa-cm3-io.dts
@@ -254,6 +254,14 @@
status = "okay";
 };
 
+&usb2phy0_otg {
+   status = "okay";
+};
+
+&usb_host0_xhci {
+   status = "okay";
+};
+
 &vop {
assigned-clocks = <&cru DCLK_VOP0>, <&cru DCLK_VOP1>;
assigned-clock-parents = <&pmucru PLL_HPLL>, <&cru PLL_VPLL>;
-- 
2.25.1



[PATCH 0/3] USB OTG support for radxa cm3 IO board

2023-02-23 Thread Manoj Sai
Patch 1/3 Enable usb otg nodes in device tree.
Patch 2/3 Update dwc3_device register offset of rk3568.
Patch 3/3 Enable Usb gadget  and update the fastboot address in config.

Manoj Sai (3):
  arm: dts: rockchip: rk3566: Enable USB OTG for Radxa CM3
  rockchip: rk356x: update the dwc3_device register offset
  rk3566: radxa-cm3: Enable USB OTG

 arch/arm/dts/rk3566-radxa-cm3-io.dts  | 8 
 arch/arm/mach-rockchip/board.c| 3 +++
 configs/radxa-cm3-io-rk3566_defconfig | 3 +++
 3 files changed, 14 insertions(+)

-- 
2.25.1



Re: [PATCH] lib: bzip2: remove inlining

2023-02-23 Thread Tom Rini
On Thu, Feb 23, 2023 at 05:39:08PM +0100, Heinrich Schuchardt wrote:
> On 2/23/23 17:30, Tom Rini wrote:
> > On Thu, Feb 23, 2023 at 08:15:25AM +0100, Heinrich Schuchardt wrote:
> > > Compiling sandbox_defconfig with CONFIG_CC_OPTIMIZE_FOR_DEBUG=y and
> > > gcc 12.2.0-14ubuntu1 leads to a build error:
> > > 
> > >  lib/bzip2/bzlib.c: In function 'BZ2_decompress':
> > >  lib/bzip2/bzlib.c:726:18: error: inlining failed in call to
> > >  'always_inline' 'BZ2_indexIntoF': function not considered for 
> > > inlining
> > >726 | __inline__ Int32 BZ2_indexIntoF ( Int32 indx, Int32 *cftab )
> > >|  ^
> > > 
> > > Leave it to the compiler if it inlines or not.
> > > 
> > > Signed-off-by: Heinrich Schuchardt 
> > 
> > What did previous compilers do here? If we're telling the compiler to
> > always inline, presumably for good reason, we shouldn't just stop.
> > 
> 
> Inlining may make the code a bit faster. But without inlining it would be
> smaller. Grep for BZ_GET_SMALL to find where the inlined function is used.
> 
> In test/compression.c we check the result. 'ut compression' does not find a
> problem.

OK, and I'm wondering if the compiler regressed.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] lib: bzip2: remove inlining

2023-02-23 Thread Heinrich Schuchardt

On 2/23/23 17:30, Tom Rini wrote:

On Thu, Feb 23, 2023 at 08:15:25AM +0100, Heinrich Schuchardt wrote:

Compiling sandbox_defconfig with CONFIG_CC_OPTIMIZE_FOR_DEBUG=y and
gcc 12.2.0-14ubuntu1 leads to a build error:

 lib/bzip2/bzlib.c: In function 'BZ2_decompress':
 lib/bzip2/bzlib.c:726:18: error: inlining failed in call to
 'always_inline' 'BZ2_indexIntoF': function not considered for inlining
   726 | __inline__ Int32 BZ2_indexIntoF ( Int32 indx, Int32 *cftab )
   |  ^

Leave it to the compiler if it inlines or not.

Signed-off-by: Heinrich Schuchardt 


What did previous compilers do here? If we're telling the compiler to
always inline, presumably for good reason, we shouldn't just stop.



Inlining may make the code a bit faster. But without inlining it would 
be smaller. Grep for BZ_GET_SMALL to find where the inlined function is 
used.


In test/compression.c we check the result. 'ut compression' does not 
find a problem.


Best regards

Heinrich


Re: [PULL] u-boot-usb/next

2023-02-23 Thread Tom Rini
On Wed, Feb 22, 2023 at 11:09:00PM +0100, Marek Vasut wrote:
> On 2/22/23 19:37, Tom Rini wrote:
> > On Wed, Feb 22, 2023 at 04:36:08PM +0100, Marek Vasut wrote:
> > 
> > > The following changes since commit 
> > > 4eb7c5030d3f3c707c02a64dc8ea90de3da89928:
> > > 
> > >Merge tag 'efi-2023-04-rc3' of
> > > https://source.denx.de/u-boot/custodians/u-boot-efi (2023-02-19 17:03:30
> > > -0500)
> > > 
> > > are available in the Git repository at:
> > > 
> > >git://source.denx.de/u-boot-usb.git next
> > 
> > This seems to be based on current master and not current next, can you
> > please rebase?
> 
> Try below, build just passed
> 
> The following changes since commit 2bfd217a16978794b43f0a30111b7472fba232b6:
> 
>   Merge tag 'dm-next-valentine' of
> https://source.denx.de/u-boot/custodians/u-boot-dm into next (2023-02-14
> 15:11:37 -0500)
> 
> are available in the Git repository at:
> 
>   git://source.denx.de/u-boot-usb.git next
> 
> for you to fetch changes up to aeb8b59f2f4aeb02ac87ec39f834177a0e260f85:
> 
>   uniphier_defconfig: Disable USB_XHCI_DWC3 (2023-02-22 19:40:11 +0100)
> 
> 
> Kunihiko Hayashi (9):
>   usb: dwc3-generic: Allow different controller DT node pattern
>   usb: dwc3-generic: Add clock initialization in child DT node
>   usb: dwc3-generic: Export glue structures and functions
>   usb: dwc3-generic: Add the size of regs property to glue structure
>   reset: uniphier: Add USB glue reset support
>   clk: uniphier: Add missing USB SS-PHY clocks
>   phy: socionext: Add UniPhier USB3 PHY driver
>   usb: dwc3-uniphier: Use dwc3-generic instead of xhci-dwc3
>   uniphier_defconfig: Disable USB_XHCI_DWC3
> 
> Marek Vasut (1):
>   usb: dwc3: Look up reference clock DT phandle in both controller DT
> nodes
> 
>  configs/uniphier_v7_defconfig |   1 -
>  configs/uniphier_v8_defconfig |   1 -
>  drivers/clk/uniphier/clk-uniphier-sys.c   |   5 +++
>  drivers/phy/socionext/Kconfig |   8 +
>  drivers/phy/socionext/Makefile|   1 +
>  drivers/phy/socionext/phy-uniphier-usb3.c | 168 
> +++
>  drivers/reset/reset-uniphier.c|  78
> +-
>  drivers/usb/dwc3/Kconfig  |   4 ++-
>  drivers/usb/dwc3/dwc3-generic.c   | 132
> ---
>  drivers/usb/dwc3/dwc3-generic.h   |  33 ++
>  drivers/usb/dwc3/dwc3-uniphier.c  | 116
> +--
>  11 files changed, 453 insertions(+), 94 deletions(-)
>  create mode 100644 drivers/phy/socionext/phy-uniphier-usb3.c
>  create mode 100644 drivers/usb/dwc3/dwc3-generic.h

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2] usb: dwc3-uniphier: Select PHY

2023-02-23 Thread Tom Rini
On Thu, Feb 23, 2023 at 05:29:24PM +0100, Marek Vasut wrote:

> Make sure the PHY subsystem is activated for the uniphier DWC3 glue
> logic, as it depends on PHY implementation there.
> 
> Signed-off-by: Marek Vasut 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH] usb: dwc3-meson-g12a: Select PHY instead of imply PHY

2023-02-23 Thread Marek Vasut
Imply means you can turn off the option and expect things to work
- "it's a good idea to have X enabled" is when to use imply
- "you must have X for Y to work" is when to use select

Use "select" here.

Signed-off-by: Marek Vasut 
---
Cc: Mattijs Korpershoek 
Cc: Neil Armstrong 
Cc: Tom Rini 
---
 drivers/usb/dwc3/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index f010291d022..e8373b30bb7 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -40,7 +40,7 @@ config SPL_USB_DWC3_GENERIC
 config USB_DWC3_MESON_G12A
bool "Amlogic Meson G12A USB wrapper"
depends on DM_USB && USB_DWC3 && ARCH_MESON
-   imply PHY
+   select PHY
help
  Select this for Amlogic Meson G12A Platforms.
  This wrapper supports Host and Peripheral operation modes.
@@ -48,7 +48,7 @@ config USB_DWC3_MESON_G12A
 config USB_DWC3_MESON_GXL
bool "Amlogic Meson GXL USB wrapper"
depends on DM_USB && USB_DWC3 && ARCH_MESON
-   imply PHY
+   select PHY
help
  Select this for Amlogic Meson GXL and GXM Platforms.
  This wrapper supports Host and Peripheral operation modes.
-- 
2.39.1



  1   2   >