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

2023-02-13 Thread Soma, Ashok Reddy
Hi Sjoerd Simons,

Thanks for you patches.

However even after your patches, I still see below error.

ERROR: reserving fdt memory region failed (addr=8 size=18000 
flags=4)
ERROR: reserving fdt memory region failed (addr=500 size=2 
flags=4)

My DT has extra reserved memory nodes which are reserved as below.
Any idea what may be wrong ?

Reserved memory nodes in DT:

memory@0 {
device_type = "memory";
reg = <0x00 0x00 0x00 0x8000 0x08 0x00 0x01 0x8000>;
};

memory@500 {
device_type = "memory";
reg = <0x500 0x00 0x02 0x00>;
};

reserved-memory {
#address-cells = <0x02>;
#size-cells = <0x02>;
ranges;

buffer@0 {
no-map;
reg = <0x08 0x00 0x01 0x8000>;
};

buffer@1 {
no-map;
reg = <0x500 0x00 0x02 0x00>;
};
};

Boot log:

## Loading init Ramdisk from Legacy Image at 0400 ...
   Image Name:   petalinux-image-minimal-xlnx-zyn
   Created:  2011-04-05  23:00:00 UTC
   Image Type:   AArch64 Linux RAMDisk Image (uncompressed)
   Data Size:59194022 Bytes = 56.5 MiB
   Load Address: 
   Entry Point:  
   Verifying Checksum ... OK
## Flattened Device Tree blob at 0010
   Booting using the fdt blob at 0x10
Working FDT set to 10
Host not halted after 16000 microseconds.
   Loading Ramdisk to 74575000, end 77de8aa6 ... OK
ERROR: reserving fdt memory region failed (addr=8 size=18000 
flags=4)
ERROR: reserving fdt memory region failed (addr=500 size=2 
flags=4)
   Loading Device Tree to 74564000, end 74574603 ... OK
Working FDT set to 74564000

Starting kernel ...


Thanks,
Ashok


> -Original Message-
> From: Sjoerd Simons 
> Sent: Sunday, February 12, 2023 8:37 PM
> To: Tom Rini 
> Cc: Ashok Reddy Soma ; Heinrich
> Schuchardt ; Simek, Michal
> ; Patrice Chotard ;
> u-boot@lists.denx.de
> Subject: [PATCH v2 1/1] lmb: Treat a region which is a subset as equal
> 
> CAUTION: This message has originated from an External Source. Please use
> proper judgment and caution when opening attachments, clicking links, or
> responding to this email.
> 
> 
> In various cases logical memory blocks are coalesced; As a result doing a
> strict check whether memory blocks are the same doesn't necessarily work as
> a previous addition of a given block might have been merged into a bigger
> block.
> 
> Fix this by considering a block is already registered if it's a pure subset 
> of one
> of the existing blocks.
> 
> Signed-off-by: Sjoerd Simons 
> 
> ---
> 
> Changes in v2:
> - Adjust calculation to prevent integer overview (fixes lmb tests)
> 
>  lib/lmb.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/lmb.c b/lib/lmb.c
> index f447c639a60..2444b2a6212 100644
> --- a/lib/lmb.c
> +++ b/lib/lmb.c
> @@ -247,8 +247,10 @@ static long lmb_add_region_flags(struct lmb_region
> *rgn, phys_addr_t base,
> phys_addr_t rgnbase = rgn->region[i].base;
> phys_size_t rgnsize = rgn->region[i].size;
> phys_size_t rgnflags = rgn->region[i].flags;
> +   phys_addr_t end = base + size - 1;
> +   phys_addr_t rgnend = rgnbase + rgnsize - 1;
> 
> -   if (rgnbase == base && rgnsize == size) {
> +   if (rgnbase <= base && end <= rgnend) {
> if (flags == rgnflags)
> /* Already have this region, so we're done */
> return 0;
> --
> 2.39.1



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

2023-02-13 Thread Sumit Garg
On Mon, 13 Feb 2023 at 21:58, Tom Rini  wrote:
>
> On Mon, Feb 13, 2023 at 10:19:09AM +0530, Sumit Garg wrote:
>
> > Co-developed-by: Mike Worsfold 
> > Signed-off-by: Mike Worsfold 
> > Signed-off-by: Sumit Garg 
>
> I don't see this originally in patchwork, and I didn't check
> lore.kernel.org, I'm not sure what happened.

Ah I see, it looks like earlier post for this patch never made it to
the u-boot mailing list.

> With that, applied to
> u-boot/master, thanks!

Thanks.

-Sumit

>
> --
> Tom


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

2023-02-13 Thread 云春峰
On Mon, 2023-02-13 at 22:00 +0100, Marek Vasut wrote:
> On 2/13/23 02:46, Chunfeng Yun (云春峰) wrote:
> > On Fri, 2023-02-10 at 11:32 +0100, Marek Vasut wrote:
> > > On 2/10/23 09:33, Chunfeng Yun wrote:
> > > [...]
> > > > @@ -50,6 +50,27 @@
> > > >#define IPPC_U3_CTRL(p)  (IPPC_U3_CTRL_0P + ((p) *
> > > > 0x08))
> > > >#define IPPC_U2_CTRL(p)  (IPPC_U2_CTRL_0P + ((p) *
> > > > 0x08))
> > > >
> > > > +/* xHCI CSR */
> > > > +#define LS_EOF_CFG 0x930
> > > > +#define LSEOF_OFFSET   0x89
> > > > +
> > > > +#define FS_EOF_CFG 0x934
> > > > +#define FSEOF_OFFSET   0x2e
> > > > +
> > > > +#define SS_GEN1_EOF_CFG0x93c
> > > > +#define SSG1EOF_OFFSET 0x78
> > > > +
> > > > +#define HFCNTR_CFG 0x944
> > > > +#define ITP_DELTA_CLK  (0xa << 1)
> > > > +#define ITP_DELTA_CLK_MASK GENMASK(5, 1)
> > > > +#define FRMCNT_LEV1_RANG   (0x12b << 8)
> > > 
> > > Look at FIELD_PREP() macro, that should let you avoid the (0x12b
> > > <<
> > > 8) .
Sorry, misunderstood you

> > 
> > Seems not use FIELD_PREP() macro here.
> > It's not a mask, it's the value set in below mask
> > FRMCNT_LEV1_RANG_MASK.
> 
> So that would be
> 
> FIELD_PREP(FRMCNT_LEV1_RANG_MASK, 0x12b)
> 
> I think ?
Sure, I'll use it instead

Thanks a lot

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


Re: [PATCH 2/3] rockchip: Require an external TPL binary when TPL is missing

2023-02-13 Thread Kever Yang

Hi Jonas,

On 2023/2/6 20:51, Jonas Karlman wrote:

Hi Quentin,
On 2023-02-06 12:26, Quentin Schulz wrote:

Hi Jonas,

On 2/5/23 21:21, Jonas Karlman wrote:

Rockchip SoCs typically use U-Boot TPL to initialize DRAM, then jumps
back to boot-rom to load the next stage of the boot flow, U-Boot SPL.

For RK356x there is currently no support to initialize DRAM using U-Boot
TPL and instead an external TPL binary must be used to generate a
working u-boot-rockchip.bin image.

Use the new external-tpl entry unless CONFIG_TPL=y to indicate that an
external TPL binary must be provided to generate a working firmware.

Signed-off-by: Jonas Karlman 
---
   Makefile  |  1 +
   arch/arm/dts/rockchip-u-boot.dtsi | 16 
   tools/binman/missing-blob-help|  5 +
   3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 7eaf45496c1c..7e9272be937f 100644
--- a/Makefile
+++ b/Makefile
@@ -1332,6 +1332,7 @@ cmd_binman = $(srctree)/tools/binman/binman $(if 
$(BINMAN_DEBUG),-D) \
-a opensbi-path=${OPENSBI} \
-a default-dt=$(default_dt) \
-a scp-path=$(SCP) \
+   -a external-tpl-path=$(EXTERNAL_TPL) \
-a spl-bss-pad=$(if $(CONFIG_SPL_SEPARATE_BSS),,1) \
-a tpl-bss-pad=$(if $(CONFIG_TPL_SEPARATE_BSS),,1) \
-a spl-dtb=$(CONFIG_SPL_OF_REAL) \
diff --git a/arch/arm/dts/rockchip-u-boot.dtsi 
b/arch/arm/dts/rockchip-u-boot.dtsi
index 6c662a72d4f9..bc3bc9bc3e37 100644
--- a/arch/arm/dts/rockchip-u-boot.dtsi
+++ b/arch/arm/dts/rockchip-u-boot.dtsi
@@ -20,12 +20,16 @@
mkimage {
filename = "idbloader.img";
args = "-n", CONFIG_SYS_SOC, "-T", "rksd";
-#ifdef CONFIG_TPL
multiple-data-files;
   
+#ifdef CONFIG_TPL

u-boot-tpl {
-   };
+#else
+   external-tpl {
+   filename = "ddr.bin";
+   missing-msg = "external-tpl-rockchip";
   #endif
+   };

NACK. This forces the use of a TPL (either built by U-Boot or external)
which is not always the case. There are still boards without a TPL which
work perfectly fine (at least I would hope so :) ).

Basically there are three possible cases:
SPL
TPL+SPL
TPL(external blob)+SPL

Here you remove the ability to have SPL only.

Hence why I suggested we add a new Kconfig option for EXTERNAL_TPL, not
for the path but to explicit this third possibility.

Thanks for the feedback, I will add a Kconfig option to make this explicit.
We could also add the optional prop in the external-tpl node to only include
the external TPL when it is provided. This will require also fixing the
missing/optional handling for the mkimage entry.


Could you help to send the new patchset with this update?


Thanks,

- Kever



Re: [PATCH 2/3] rockchip: Require an external TPL binary when TPL is missing

2023-02-13 Thread Kever Yang



On 2023/2/9 00:06, Quentin Schulz wrote:

Hi Kever,

On 2/8/23 16:41, Kever Yang wrote:

Hi Quentin,

On 2023/2/6 19:26, Quentin Schulz wrote:

Hi Jonas,

On 2/5/23 21:21, Jonas Karlman wrote:

Rockchip SoCs typically use U-Boot TPL to initialize DRAM, then jumps
back to boot-rom to load the next stage of the boot flow, U-Boot SPL.

For RK356x there is currently no support to initialize DRAM using 
U-Boot

TPL and instead an external TPL binary must be used to generate a
working u-boot-rockchip.bin image.

Use the new external-tpl entry unless CONFIG_TPL=y to indicate that an
external TPL binary must be provided to generate a working firmware.

Signed-off-by: Jonas Karlman 
---
  Makefile  |  1 +
  arch/arm/dts/rockchip-u-boot.dtsi | 16 
  tools/binman/missing-blob-help    |  5 +
  3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 7eaf45496c1c..7e9272be937f 100644
--- a/Makefile
+++ b/Makefile
@@ -1332,6 +1332,7 @@ cmd_binman = $(srctree)/tools/binman/binman 
$(if $(BINMAN_DEBUG),-D) \

  -a opensbi-path=${OPENSBI} \
  -a default-dt=$(default_dt) \
  -a scp-path=$(SCP) \
+    -a external-tpl-path=$(EXTERNAL_TPL) \
  -a spl-bss-pad=$(if $(CONFIG_SPL_SEPARATE_BSS),,1) \
  -a tpl-bss-pad=$(if $(CONFIG_TPL_SEPARATE_BSS),,1) \
  -a spl-dtb=$(CONFIG_SPL_OF_REAL) \
diff --git a/arch/arm/dts/rockchip-u-boot.dtsi 
b/arch/arm/dts/rockchip-u-boot.dtsi

index 6c662a72d4f9..bc3bc9bc3e37 100644
--- a/arch/arm/dts/rockchip-u-boot.dtsi
+++ b/arch/arm/dts/rockchip-u-boot.dtsi
@@ -20,12 +20,16 @@
  mkimage {
  filename = "idbloader.img";
  args = "-n", CONFIG_SYS_SOC, "-T", "rksd";
-#ifdef CONFIG_TPL
  multiple-data-files;
  +#ifdef CONFIG_TPL
  u-boot-tpl {
-    };
+#else
+    external-tpl {
+    filename = "ddr.bin";
+    missing-msg = "external-tpl-rockchip";
  #endif
+    };


NACK. This forces the use of a TPL (either built by U-Boot or 
external) which is not always the case. There are still boards 
without a TPL which work perfectly fine (at least I would hope so :) ).


Basically there are three possible cases:
SPL
TPL+SPL
TPL(external blob)+SPL


I'm afraid all the boards support by mainline U-Boot is using 
"TPL(U-Boot or external)+SPL+U-Boot" mode, and this mode also always 
used by rockchip vendor branch.




That seems to be incorrect.

for conf in $(git grep -l ARCH_ROCKCHIP configs); do
    make $(basename $conf) > /dev/null 2>&1
    if ! grep -q CONFIG_TPL=y .config; then
    echo $conf does not enable TPL;
    fi
done

returns:
configs/chromebit_mickey_defconfig does not enable TPL
configs/chromebook_bob_defconfig does not enable TPL
configs/chromebook_jerry_defconfig does not enable TPL
configs/chromebook_kevin_defconfig does not enable TPL
configs/chromebook_minnie_defconfig does not enable TPL
configs/chromebook_speedy_defconfig does not enable TPL
configs/elgin-rv1108_defconfig does not enable TPL
configs/evb-rk3036_defconfig does not enable TPL
configs/evb-rk3128_defconfig does not enable TPL
configs/evb-rk3308_defconfig does not enable TPL
configs/evb-rk3568_defconfig does not enable TPL
configs/evb-rv1108_defconfig does not enable TPL
configs/ficus-rk3399_defconfig does not enable TPL
configs/geekbox_defconfig does not enable TPL
configs/kylin-rk3036_defconfig does not enable TPL
configs/miqi-rk3288_defconfig does not enable TPL
configs/phycore-rk3288_defconfig does not enable TPL
configs/popmetal-rk3288_defconfig does not enable TPL
configs/roc-cc-rk3308_defconfig does not enable TPL
configs/rock2_defconfig does not enable TPL
configs/rock_defconfig does not enable TPL
configs/sheep-rk3368_defconfig does not enable TPL

is there something I'm missing?


Most of them use simple SPL+U-Boot(for 32bit processer) or have external 
TPL.


We can keep an option to support SPL only case for now.



For "SPL+U-Boot" use case, it only happen many years ago in some of 
rk3288 board and rk3399 board,


the SPL will need to support both sdram driver and storage(SPI, 
SDCard, eMMC) driver and without back to BootRom,


and other function may add to SPL, but the sram size limit is always 
there, so all the rk3288 and rk3399 board have migrate to use 
"TPL+SPL+U-Boot.itb" mode.




It seems not all have migrated.

The "TPL+SPL+U-Boot.itb" is much clear and easy to maintine for all 
the boards and will be the only accept mode for new board support in 
the future on rockchip platform:


- TPL for dram init;

- SPL for storage init and load next stage firmware, decode FIT image 
with ATF/OPTEE support, secure boot support and etc;


- U-Boot.itb including ATF and U-Boot proper, maybe also OPTEE.

This model can very easy to do the debug with replace the binary from 
rockchip  vendor tree during board bringup.




That's fine by me, but we currently have Rockchip boards in 

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

2023-02-13 Thread Yu-Chien Peter Lin
Hi Heinrich,

On Mon, Feb 13, 2023 at 08:36:30AM +0100, Heinrich Schuchardt wrote:
> On 2/12/23 08:00, Yu Chien Peter Lin wrote:
> > This patch adds a brief introduction to the RISC-V architecture and
> > the typical boot process used on a variety of RISC-V platforms.
> > 
> > Signed-off-by: Yu Chien Peter Lin 
> > ---
> > Hi RISC-V community,
> > 
> > Please leave a comment if there is anything I've missed that should
> > be mentioned in the document. Thanks.
> > ---
> >   doc/arch/index.rst |  1 +
> >   doc/arch/riscv.rst | 43 +++
> >   2 files changed, 44 insertions(+)
> >   create mode 100644 doc/arch/riscv.rst
> > 
> > diff --git a/doc/arch/index.rst b/doc/arch/index.rst
> > index b3e85f9bf3..b8da4b8c8e 100644
> > --- a/doc/arch/index.rst
> > +++ b/doc/arch/index.rst
> > @@ -11,6 +11,7 @@ Architecture-specific doc
> >  m68k
> >  mips
> >  nios2
> > +   riscv
> >  sandbox/index
> >  sh
> >  x86
> > diff --git a/doc/arch/riscv.rst b/doc/arch/riscv.rst
> > new file mode 100644
> > index 00..243e7e7e2e
> > --- /dev/null
> > +++ b/doc/arch/riscv.rst
> > @@ -0,0 +1,43 @@
> > +.. SPDX-License-Identifier: GPL-2.0+
> > +.. Copyright (C) 2023, Yu Chien Peter Lin 
> > +
> > +RISC-V
> > +==
> > +
> > +Overview
> > +
> > +
> > +This document outlines the U-Boot boot process for the RISC-V architecture.
> > +RISC-V is an open-source instruction set architecture (ISA) based on the
> > +principles of reduced instruction set computing (RISC). It has been 
> > designed
> > +to be flexible and customizable, allowing it to be adapted to different use
> > +cases, from embedded systems to high performance servers.
> > +
> > +Typical Boot Process
> > +
> > +
> > +RISC-V production boot images typically include a U-Boot SPL for 
> > platform-specific
> 
> %s/typically include/may include/
> 
> Many boards don't use SPL:
> 
> ae350_rv32_defconfig
> ae350_rv64_defconfig
> sipeed_maix_bitm_defconfig
> sipeed_maix_smode_defconfig
> openpiton_riscv64_defconfig
> qemu-riscv64_defconfig
> 
> Please provide a description of those boot processes too.

Sure, I will add a description for these defconfigs.

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

OK, will fix.

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

OK.

> > +U-Boot (or U-Boot proper) running in S-mode. Finally, the S-mode Operating 
> > System
> > +is loaded.
> > +
> > +In between the boot stages, the hartid is passed through the a0 register, 
> > and the
> > +start address of the devicetree is passed through the a1 register.
> > +
> > +The following diagram illustrates the boot process::
> > +
> > +   <--( M-mode )><---( S-mode )-->
> > +   ++   +-+++   ++
> > +   | U-Boot SPL |-->|   SBI   |--->| U-Boot |-->|   OS   |
> > +   ++   +-+++   ++
> 
> SBI (Supervisory Binary Interface) is an interface not a software. So it
> does not fit into this diagram.

Sure, I will rename the block to SBI firmware.

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


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

2023-02-13 Thread Kever Yang

Hi Akash,

    Please add MAINTAINER for the board.

    Other parts looks good to me.


Thanks,

- Kever

On 2023/2/13 22:39, Akash Gajjar wrote:

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
- 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

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

  arch/arm/dts/Makefile   |   3 +-
  arch/arm/dts/rk3568-rock-3a-u-boot.dtsi |  24 +
  arch/arm/dts/rk3568-rock-3a.dts | 609 
  configs/rock-3a-rk3568_defconfig|  74 +++
  4 files changed, 709 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 d9b719f85d..7c28418c82 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 = 
+   u-boot,spl-boot-order = "same-as-spl", 
+   };
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   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 = <_dcin>;
+   };
+
+   vcc5v0_sys: vcc5v0-sys-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc5v0_sys";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   vin-supply = <_dcin>;
+   };
+
+   vcc5v0_usb: vcc5v0-usb-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc5v0_usb";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   vin-supply = <_dcin>;
+   };
+
+   vcc5v0_usb_host: vcc5v0-usb-host-regulator {
+   compatible = "regulator-fixed";
+   enable-active-high;
+   gpio = < RK_PA6 GPIO_ACTIVE_HIGH>;
+   pinctrl-names = 

Re: [PATCH 1/1] arm64: dts: rockchip: rk3308: Add Radxa ROCK Pi S support

2023-02-13 Thread Kever Yang

Hi Akash,

    You will need to add MAINTAINER for this board.

    other parts looks good to me.


Thanks,

- Kever

On 2023/2/14 00:11, Akash Gajjar wrote:

Add Radxa ROCK 3 Model A support. sync rk3308-rock-pi-s.dts from
Linux 6.2.0-rc7.

ROCK Pi S is RK3308 based SBC from radxa.com. ROCK Pi S has a,
- 256MB/512MB DDR3 RAM
- SD, NAND flash (optional on board 1/2/4/8Gb)
- 100MB ethernet, PoE (optional)
- Onboard 802.11 b/g/n wifi + Bluetooth 4.0 Module
- USB2.0 Type-A HOST x1
- USB3.0 Type-C OTG x1
- 26-pin expansion header
- USB Type-C DC 5V Power Supply

Linux commit commit for the same,
<2e04c25b1320> ("arm64: dts: rockchip: add ROCK Pi S DTS support")

Signed-off-by: Akash Gajjar 
---
  arch/arm/dts/rk3308-rock-pi-s-u-boot.dtsi |  17 ++
  arch/arm/dts/rk3308-rock-pi-s.dts | 228 ++
  configs/rock-pi-s-rk3308_defconfig|  89 +
  3 files changed, 334 insertions(+)
  create mode 100644 arch/arm/dts/rk3308-rock-pi-s-u-boot.dtsi
  create mode 100644 arch/arm/dts/rk3308-rock-pi-s.dts
  create mode 100644 configs/rock-pi-s-rk3308_defconfig

diff --git a/arch/arm/dts/rk3308-rock-pi-s-u-boot.dtsi 
b/arch/arm/dts/rk3308-rock-pi-s-u-boot.dtsi
new file mode 100644
index 00..27735c49dd
--- /dev/null
+++ b/arch/arm/dts/rk3308-rock-pi-s-u-boot.dtsi
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2018-2019 Rockchip Electronics Co., Ltd
+ */
+#include "rk3308-u-boot.dtsi"
+
+/ {
+   chosen {
+   u-boot,spl-boot-order = "same-as-spl", 
+   };
+};
+
+ {
+   u-boot,dm-pre-reloc;
+   clock-frequency = <2400>;
+   status = "okay";
+};
diff --git a/arch/arm/dts/rk3308-rock-pi-s.dts 
b/arch/arm/dts/rk3308-rock-pi-s.dts
new file mode 100644
index 00..b5a8691b3f
--- /dev/null
+++ b/arch/arm/dts/rk3308-rock-pi-s.dts
@@ -0,0 +1,228 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2019 Fuzhou Rockchip Electronics Co., Ltd
+ * Copyright (C) 2023 Akash Gajjar 
+ * Copyright (c) 2023 Jagan Teki 
+ */
+
+/dts-v1/;
+#include 
+#include "rk3308.dtsi"
+
+/ {
+   model = "Radxa ROCK Pi S";
+   compatible = "radxa,rockpis", "rockchip,rk3308";
+
+   aliases {
+   ethernet0 = 
+   mmc0 = 
+   mmc1 = 
+   };
+
+   chosen {
+   stdout-path = "serial0:150n8";
+   };
+
+   leds {
+   compatible = "gpio-leds";
+   pinctrl-names = "default";
+   pinctrl-0 = <_led_gio>, <_led_gpio>;
+
+   green-led {
+   default-state = "on";
+   gpios = < RK_PA6 GPIO_ACTIVE_HIGH>;
+   label = "rockpis:green:power";
+   linux,default-trigger = "default-on";
+   };
+
+   blue-led {
+   default-state = "on";
+   gpios = < RK_PA5 GPIO_ACTIVE_HIGH>;
+   label = "rockpis:blue:user";
+   linux,default-trigger = "heartbeat";
+   };
+   };
+
+   sdio_pwrseq: sdio-pwrseq {
+   compatible = "mmc-pwrseq-simple";
+   pinctrl-0 = <_enable_h>;
+   pinctrl-names = "default";
+   reset-gpios = < RK_PA2 GPIO_ACTIVE_LOW>;
+   };
+
+   vcc_1v8: vcc-1v8 {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc_1v8";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   vin-supply = <_io>;
+   };
+
+   vcc_io: vcc-io {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc_io";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   vin-supply = <_sys>;
+   };
+
+   vcc_ddr: vcc-ddr {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc_ddr";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <150>;
+   regulator-max-microvolt = <150>;
+   vin-supply = <_sys>;
+   };
+
+   vcc5v0_otg: vcc5v0-otg {
+   compatible = "regulator-fixed";
+   enable-active-high;
+   gpio = < RK_PC5 GPIO_ACTIVE_HIGH>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_vbus_drv>;
+   regulator-name = "vcc5v0_otg";
+   regulator-always-on;
+   vin-supply = <_sys>;
+   };
+
+   vcc5v0_sys: vcc5v0-sys {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc5v0_sys";
+   regulator-always-on;
+   regulator-boot-on;
+   

Re: [PATCH v2 13/14] rockchip: Enable bootstage on rockpro64

2023-02-13 Thread Simon Glass
Hi Andrew,

On Sat, 11 Feb 2023 at 16:29, Andrew Abbott  wrote:
>
> On Sun, Jan 8, 2023, at 08:57, Simon Glass wrote:
> > This board is useful for benchmarking overall U-Boot performance. Enable
> > the bootstage feature so we get a report.
> >
> > Since this returns to the boot rom before finishing executing
> > board_init_r() in SPL, add a few bootstage calls so that we can collect
> > timing from TPL.
> >
> > For the stash region, use a portion of SRAM, 64KB below the stack top.
> > This allows the TPL image to be up to nearly 120KB (it is typically about
> > 64KB). SPL normally runs from SDRAM at 0, so can use the same stash
> > region.
> >
> > Signed-off-by: Simon Glass 
>
> > diff --git a/configs/rockpro64-rk3399_defconfig 
> > b/configs/rockpro64-rk3399_defconfig
> > index 5b8d678f6bb..2f1ae156bd4 100644
> > --- a/configs/rockpro64-rk3399_defconfig
> > +++ b/configs/rockpro64-rk3399_defconfig
> > @@ -9,6 +9,7 @@ CONFIG_ENV_OFFSET=0x3F8000
> > CONFIG_DEFAULT_DEVICE_TREE="rk3399-rockpro64"
> > CONFIG_ROCKCHIP_RK3399=y
> > CONFIG_TARGET_ROCKPRO64_RK3399=y
> > +CONFIG_BOOTSTAGE_STASH_ADDR=0xff8e
> > CONFIG_DEBUG_UART_BASE=0xFF1A
> > CONFIG_DEBUG_UART_CLOCK=2400
> > CONFIG_SPL_SPI_FLASH_SUPPORT=y
> > @@ -17,6 +18,12 @@ CONFIG_SYS_LOAD_ADDR=0x800800
> > CONFIG_DEBUG_UART=y
> > CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
> > CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x30
> > +CONFIG_BOOTSTAGE=y
>
> Building from master commit a1e6b529e57c622e862e93fa6da03d9504565089 and 
> copying u-boot-rockchip.bin to an SD card and booting from that on a 
> RockPRO64 v2.1, I don't get past this:
> (dirty because building on NixOS applies some patches)
>
> >U-Boot TPL 2023.04-rc1-00483-ga1e6b529e5-dirty (Jan 01 1980 - 00:00:00)
> >Channel 0: LPDDR4, 50MHz
> >BW=32 Col=10 Bk=8 CS0 Row=16/15 CS=1 Die BW=16 Size=2048MB
> >Channel 1: LPDDR4, 50MHz
> >BW=32 Col=10 Bk=8 CS0 Row=16/15 CS=1 Die BW=16 Size=2048MB
> >256B stride
> >lpddr4_set_rate: change freq to 800MHz 1, 0
> >Trying to boot from BOOTROM
> >Returning to boot ROM...
> >
> >U-Boot SPL 2023.04-rc1-00483-ga1e6b529e5-dirty (Jan 01 1980 - 00:00:00 +)
> >Trying to boot from MMC2
>
> I bisected down to this patch. If I disable CONFIG_BOOTSTATE, I can boot. Is 
> there something I need to do to successfully boot with bootstate enabled?

I'm not sure what happened here, but there may have been some timer
changes that went in at the same time. I will take a look.

Regards,
Sim on


[ANN] U-Boot v2023.04-rc2 released

2023-02-13 Thread Tom Rini
Hey all,

It's the scheduled day for -rc2, and I've waited until the end of my
day, to give the most time for more PRs to come in. Between -rc1 and now
I've gone over my queue, looked over a few other things and tried to
make sure everything I could take in, was taken in. I'm now going to try
and follow through on what I've said and ask that PRs from here to
release contain fixes. I can see "remove unmaintained code" as a fix,
but not "add missing platform" as a fix. With that, I'll be updating the
next branch shortly and we'll take things from there.

In terms of a changelog, 
git log --merges v2023.04-rc1..v2023.04-rc2
contains what I've pulled but as always, better PR messages and tags
will provide better results here.

Continuing on schedule now and that means the rest of the rcs every
other Monday, and with final release on April 3rd, 2023.  Thanks all!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH v2 7/8] video console: add 16x32 Terminus font from linux

2023-02-13 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 
---
Changes for v2:
- edit for runtime configuration

 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 2023572aa2..4d42c3fc56 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, 0xe0, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 5 */
+   0x00, 0x00, 

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

2023-02-13 Thread Chris Morgan
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 
---
 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 READ_REG(REG)  ((readl(REG_L(REG)) & 0x) | \
+   ((readl(REG_H(REG)) & 0x) << 16))
+#define WRITE_REG(REG, VAL)\
+{\
+   writel(((VAL) & 0x) | 0x, REG_L(REG)); \
+   writelVAL) & 0x) >> 16) | 0x, REG_H(REG));\
+}
+#define CLRBITS_LE32(REG, MASK)WRITE_REG(REG, READ_REG(REG) & ~(MASK))
+#define SETBITS_LE32(REG, MASK)

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

2023-02-13 Thread Chris Morgan
From: Chris Morgan 

Add gpio-ranges property to GPIO nodes so that the bank ID can
be correctly derived for each GPIO bank.

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 = < PCLK_GPIO0>, < DBCLK_GPIO0>;
gpio-controller;
+   gpio-ranges = < 0 0 32>;
#gpio-cells = <2>;
interrupt-controller;
#interrupt-cells = <2>;
@@ -1817,6 +1818,7 @@
interrupts = ;
clocks = < PCLK_GPIO1>, < DBCLK_GPIO1>;
gpio-controller;
+   gpio-ranges = < 0 32 32>;
#gpio-cells = <2>;
interrupt-controller;
#interrupt-cells = <2>;
@@ -1828,6 +1830,7 @@
interrupts = ;
clocks = < PCLK_GPIO2>, < DBCLK_GPIO2>;
gpio-controller;
+   gpio-ranges = < 0 64 32>;
#gpio-cells = <2>;
interrupt-controller;
#interrupt-cells = <2>;
@@ -1839,6 +1842,7 @@
interrupts = ;
clocks = < PCLK_GPIO3>, < DBCLK_GPIO3>;
gpio-controller;
+   gpio-ranges = < 0 96 32>;
#gpio-cells = <2>;
interrupt-controller;
#interrupt-cells = <2>;
@@ -1850,6 +1854,7 @@
interrupts = ;
clocks = < PCLK_GPIO4>, < DBCLK_GPIO4>;
gpio-controller;
+   gpio-ranges = < 0 128 32>;
#gpio-cells = <2>;
interrupt-controller;
#interrupt-cells = <2>;
-- 
2.34.1



[PATCH V2 9/9] evb1-v10-rk3568: Update MAINTAINERS and documentation

2023-02-13 Thread Chris Morgan
From: Chris Morgan 

Update the MAINTAINERS file to include the devicetree for the
rk3568-evb1-v10 board.

Also update Rockchip board docs to include information on building
RK3568 based devices.

Signed-off-by: Chris Morgan 
---
 board/rockchip/evb_rk3568/MAINTAINERS | 12 +++-
 doc/board/rockchip/rockchip.rst   | 10 ++
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/board/rockchip/evb_rk3568/MAINTAINERS 
b/board/rockchip/evb_rk3568/MAINTAINERS
index b6ea498d2b..f959e8862b 100644
--- a/board/rockchip/evb_rk3568/MAINTAINERS
+++ b/board/rockchip/evb_rk3568/MAINTAINERS
@@ -1,6 +1,8 @@
 EVB-RK3568
-M:  Joseph Chen 
-S:  Maintained
-F:  board/rockchip/evb_rk3568
-F:  include/configs/evb_rk3568.h
-F:  configs/evb-rk3568_defconfig
+M: Joseph Chen 
+S: Maintained
+F: arch/arm/dts/rk3568-evb1-v10-u-boot.dtsi
+F: arch/arm/dts/rk3568-evb1-v10.dts
+F: board/rockchip/evb_rk3568
+F: configs/evb1-v10-rk3568_defconfig
+F: include/configs/evb_rk3568.h
diff --git a/doc/board/rockchip/rockchip.rst b/doc/board/rockchip/rockchip.rst
index 28c837a382..02e6e82927 100644
--- a/doc/board/rockchip/rockchip.rst
+++ b/doc/board/rockchip/rockchip.rst
@@ -86,6 +86,8 @@ List of mainline supported Rockchip boards:
  - Radxa ROCK Pi 4 (rock-pi-4-rk3399)
  - Rockchip Evb-RK3399 (evb_rk3399)
  - Theobroma Systems RK3399-Q7 SoM - Puma (puma_rk3399)
+* rk3568
+ - Rockchip EVB-RK3568 (evb1-v10-rk3568)
 * rv1108
  - Rockchip Evb-rv1108 (evb-rv1108)
  - Elgin-R1 (elgin-rv1108)
@@ -167,6 +169,14 @@ To build rk3399 boards:
 make evb-rk3399_defconfig
 make CROSS_COMPILE=aarch64-linux-gnu-
 
+To build rk3568 boards:
+
+.. code-block:: bash
+
+   export BL31=../arm-trusted-firmware/build/rk3568/release/bl31/bl31.elf
+   make evb1-v10-rk3568_defconfig
+   make CROSS_COMPILE=aarch64-linux-gnu-
+
 Flashing
 
 
-- 
2.34.1



[PATCH V2 4/9] arm64: dts: rockchip: Sync rk356x from Linux main

2023-02-13 Thread Chris Morgan
From: Chris Morgan 

Sync rk3566 and rk3568 from the mainline Linux kernel (6.2-rc2 as of
this writing).

Note that this will rename the rk3568-evb to rk3568-evb1-v10.

Signed-off-by: Chris Morgan 
---
 arch/arm/dts/Makefile |   2 +-
 arch/arm/dts/rk3568-evb.dts   |  79 --
 ...-boot.dtsi => rk3568-evb1-v10-u-boot.dtsi} |   0
 arch/arm/dts/rk3568-evb1-v10.dts  | 692 ++
 arch/arm/dts/rk3568.dtsi  | 122 +++
 arch/arm/dts/rk356x.dtsi  | 182 -
 ...68_defconfig => evb1-v10-rk3568_defconfig} |   4 +-
 7 files changed, 985 insertions(+), 96 deletions(-)
 delete mode 100644 arch/arm/dts/rk3568-evb.dts
 rename arch/arm/dts/{rk3568-evb-u-boot.dtsi => rk3568-evb1-v10-u-boot.dtsi} 
(100%)
 create mode 100644 arch/arm/dts/rk3568-evb1-v10.dts
 rename configs/{evb-rk3568_defconfig => evb1-v10-rk3568_defconfig} (94%)

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 9d647b9639..56e0543bd2 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -165,7 +165,7 @@ dtb-$(CONFIG_ROCKCHIP_RK3399) += \
rk3399pro-rock-pi-n10.dtb
 
 dtb-$(CONFIG_ROCKCHIP_RK3568) += \
-   rk3568-evb.dtb
+   rk3568-evb1-v10.dtb
 
 dtb-$(CONFIG_ROCKCHIP_RV1108) += \
rv1108-elgin-r1.dtb \
diff --git a/arch/arm/dts/rk3568-evb.dts b/arch/arm/dts/rk3568-evb.dts
deleted file mode 100644
index 6978655709..00
--- a/arch/arm/dts/rk3568-evb.dts
+++ /dev/null
@@ -1,79 +0,0 @@
-// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
-/*
- * Copyright (c) 2021 Rockchip Electronics Co., Ltd.
- *
- */
-
-/dts-v1/;
-#include 
-#include 
-#include "rk3568.dtsi"
-
-/ {
-   model = "Rockchip RK3568 EVB1 DDR4 V10 Board";
-   compatible = "rockchip,rk3568-evb1-v10", "rockchip,rk3568";
-
-   chosen: chosen {
-   stdout-path = "serial2:150n8";
-   };
-
-   dc_12v: dc-12v {
-   compatible = "regulator-fixed";
-   regulator-name = "dc_12v";
-   regulator-always-on;
-   regulator-boot-on;
-   regulator-min-microvolt = <1200>;
-   regulator-max-microvolt = <1200>;
-   };
-
-   vcc3v3_sys: vcc3v3-sys {
-   compatible = "regulator-fixed";
-   regulator-name = "vcc3v3_sys";
-   regulator-always-on;
-   regulator-boot-on;
-   regulator-min-microvolt = <330>;
-   regulator-max-microvolt = <330>;
-   vin-supply = <_12v>;
-   };
-
-   vcc5v0_sys: vcc5v0-sys {
-   compatible = "regulator-fixed";
-   regulator-name = "vcc5v0_sys";
-   regulator-always-on;
-   regulator-boot-on;
-   regulator-min-microvolt = <500>;
-   regulator-max-microvolt = <500>;
-   vin-supply = <_12v>;
-   };
-
-   vcc3v3_lcd0_n: vcc3v3-lcd0-n {
-   compatible = "regulator-fixed";
-   regulator-name = "vcc3v3_lcd0_n";
-   regulator-boot-on;
-
-   regulator-state-mem {
-   regulator-off-in-suspend;
-   };
-   };
-
-   vcc3v3_lcd1_n: vcc3v3-lcd1-n {
-   compatible = "regulator-fixed";
-   regulator-name = "vcc3v3_lcd1_n";
-   regulator-boot-on;
-
-   regulator-state-mem {
-   regulator-off-in-suspend;
-   };
-   };
-};
-
- {
-   bus-width = <8>;
-   max-frequency = <2>;
-   non-removable;
-   status = "okay";
-};
-
- {
-   status = "okay";
-};
diff --git a/arch/arm/dts/rk3568-evb-u-boot.dtsi 
b/arch/arm/dts/rk3568-evb1-v10-u-boot.dtsi
similarity index 100%
rename from arch/arm/dts/rk3568-evb-u-boot.dtsi
rename to arch/arm/dts/rk3568-evb1-v10-u-boot.dtsi
diff --git a/arch/arm/dts/rk3568-evb1-v10.dts b/arch/arm/dts/rk3568-evb1-v10.dts
new file mode 100644
index 00..674792567f
--- /dev/null
+++ b/arch/arm/dts/rk3568-evb1-v10.dts
@@ -0,0 +1,692 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2021 Rockchip Electronics Co., Ltd.
+ *
+ */
+
+/dts-v1/;
+#include 
+#include 
+#include 
+#include 
+#include "rk3568.dtsi"
+
+/ {
+   model = "Rockchip RK3568 EVB1 DDR4 V10 Board";
+   compatible = "rockchip,rk3568-evb1-v10", "rockchip,rk3568";
+
+   aliases {
+   ethernet0 = 
+   ethernet1 = 
+   mmc0 = 
+   mmc1 = 
+   };
+
+   chosen: chosen {
+   stdout-path = "serial2:150n8";
+   };
+
+   dc_12v: dc-12v {
+   compatible = "regulator-fixed";
+   regulator-name = "dc_12v";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <1200>;
+   regulator-max-microvolt = <1200>;
+   };
+
+   hdmi-con {
+   compatible = 

[PATCH V2 6/9] rockchip: rk3568: enable automatic power savings

2023-02-13 Thread Chris Morgan
From: Chris Morgan 

It enables automatic clock gating on idle, disables the eDP phy by
default, and sets the core pvtpll ring length. It is reported this
lowers the temperature on at least one SoC by 7C.

Signed-off-by: Peter Geis 
Signed-off-by: Chris Morgan 
---
 arch/arm/mach-rockchip/rk3568/rk3568.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/arch/arm/mach-rockchip/rk3568/rk3568.c 
b/arch/arm/mach-rockchip/rk3568/rk3568.c
index a2d59abc26..4a08820a09 100644
--- a/arch/arm/mach-rockchip/rk3568/rk3568.c
+++ b/arch/arm/mach-rockchip/rk3568/rk3568.c
@@ -24,6 +24,16 @@
 #define SGRF_SOC_CON4  0x10
 #define EMMC_HPROT_SECURE_CTRL 0x03
 #define SDMMC0_HPROT_SECURE_CTRL   0x01
+
+#define PMU_BASE_ADDR  0xfdd9
+#define PMU_NOC_AUTO_CON0  (0x70)
+#define PMU_NOC_AUTO_CON1  (0x74)
+#define EDP_PHY_GRF_BASE   0xfdcb
+#define EDP_PHY_GRF_CON0   (EDP_PHY_GRF_BASE + 0x00)
+#define EDP_PHY_GRF_CON10  (EDP_PHY_GRF_BASE + 0x28)
+#define CPU_GRF_BASE   0xfdc3
+#define GRF_CORE_PVTPLL_CON0   (0x10)
+
 /* PMU_GRF_GPIO0D_IOMUX_L */
 enum {
GPIO0D1_SHIFT   = 4,
@@ -98,6 +108,20 @@ void board_debug_uart_init(void)
 int arch_cpu_init(void)
 {
 #ifdef CONFIG_SPL_BUILD
+   /*
+* When perform idle operation, corresponding clock can
+* be opened or gated automatically.
+*/
+   writel(0x, PMU_BASE_ADDR + PMU_NOC_AUTO_CON0);
+   writel(0x000f000f, PMU_BASE_ADDR + PMU_NOC_AUTO_CON1);
+
+   /* Disable eDP phy by default */
+   writel(0x00070007, EDP_PHY_GRF_CON10);
+   writel(0x0ff10ff1, EDP_PHY_GRF_CON0);
+
+   /* Set core pvtpll ring length */
+   writel(0x00ff002b, CPU_GRF_BASE + GRF_CORE_PVTPLL_CON0);
+
/* Set the emmc sdmmc0 to secure */
rk_clrreg(SGRF_BASE + SGRF_SOC_CON4, (EMMC_HPROT_SECURE_CTRL << 11
| SDMMC0_HPROT_SECURE_CTRL << 4));
-- 
2.34.1



[PATCH V2 5/9] rockchip: rk3568: add boot device detection

2023-02-13 Thread Chris Morgan
From: Chris Morgan 

Enable spl to detect which device it was booted from.

Signed-off-by: Peter Geis 
Signed-off-by: Chris Morgan 
---
 arch/arm/mach-rockchip/rk3568/rk3568.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/mach-rockchip/rk3568/rk3568.c 
b/arch/arm/mach-rockchip/rk3568/rk3568.c
index 22eeb77d41..a2d59abc26 100644
--- a/arch/arm/mach-rockchip/rk3568/rk3568.c
+++ b/arch/arm/mach-rockchip/rk3568/rk3568.c
@@ -7,6 +7,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -70,6 +71,12 @@ static struct mm_region rk3568_mem_map[] = {
}
 };
 
+const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
+   [BROM_BOOTSOURCE_EMMC] = "/sdhci@fe31",
+   [BROM_BOOTSOURCE_SPINOR] = "/spi@fe30/flash@0",
+   [BROM_BOOTSOURCE_SD] = "/mmc@fe2b",
+};
+
 struct mm_region *mem_map = rk3568_mem_map;
 
 void board_debug_uart_init(void)
-- 
2.34.1



[PATCH V2 3/9] rockchip: vop2: Add vop2 dt-binding from Linux

2023-02-13 Thread Chris Morgan
From: Chris Morgan 

In order to support Rockchip devices with the VOP2, import the VOP2
dt-bindings from Linux.

Signed-off-by: Chris Morgan 
Reviewed-by: Kever Yang 
---
 include/dt-bindings/soc/rockchip,vop2.h | 14 ++
 1 file changed, 14 insertions(+)
 create mode 100644 include/dt-bindings/soc/rockchip,vop2.h

diff --git a/include/dt-bindings/soc/rockchip,vop2.h 
b/include/dt-bindings/soc/rockchip,vop2.h
new file mode 100644
index 00..6e66a802b9
--- /dev/null
+++ b/include/dt-bindings/soc/rockchip,vop2.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */
+
+#ifndef __DT_BINDINGS_ROCKCHIP_VOP2_H
+#define __DT_BINDINGS_ROCKCHIP_VOP2_H
+
+#define ROCKCHIP_VOP2_EP_RGB0  1
+#define ROCKCHIP_VOP2_EP_HDMI0 2
+#define ROCKCHIP_VOP2_EP_EDP0  3
+#define ROCKCHIP_VOP2_EP_MIPI0 4
+#define ROCKCHIP_VOP2_EP_LVDS0 5
+#define ROCKCHIP_VOP2_EP_MIPI1 6
+#define ROCKCHIP_VOP2_EP_LVDS1 7
+
+#endif /* __DT_BINDINGS_ROCKCHIP_VOP2_H */
-- 
2.34.1



[PATCH V2 2/9] dts: rockchip: px30: add gpio-ranges property to gpio nodes

2023-02-13 Thread Chris Morgan
From: Chris Morgan 

Add the gpio-ranges property to each GPIO node for use in deriving
the correct bank ID. Note that invoking "gpio status -a" no longer
causes the board to hit a "Synchronous Abort".

Fixes: 537b1a277479 ("rockchip: add px30 devicetrees")

Signed-off-by: Chris Morgan 
---
 arch/arm/dts/px30.dtsi | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/dts/px30.dtsi b/arch/arm/dts/px30.dtsi
index bfa3580429..3152bf107d 100644
--- a/arch/arm/dts/px30.dtsi
+++ b/arch/arm/dts/px30.dtsi
@@ -1366,6 +1366,7 @@
interrupts = ;
clocks = < PCLK_GPIO0_PMU>;
gpio-controller;
+   gpio-ranges = < 0 0 32>;
#gpio-cells = <2>;
 
interrupt-controller;
@@ -1378,6 +1379,7 @@
interrupts = ;
clocks = < PCLK_GPIO1>;
gpio-controller;
+   gpio-ranges = < 0 32 32>;
#gpio-cells = <2>;
 
interrupt-controller;
@@ -1390,6 +1392,7 @@
interrupts = ;
clocks = < PCLK_GPIO2>;
gpio-controller;
+   gpio-ranges = < 0 64 32>;
#gpio-cells = <2>;
 
interrupt-controller;
@@ -1402,6 +1405,7 @@
interrupts = ;
clocks = < PCLK_GPIO3>;
gpio-controller;
+   gpio-ranges = < 0 96 32>;
#gpio-cells = <2>;
 
interrupt-controller;
-- 
2.34.1



[PATCH V2 1/9] gpio: gpio-rockchip: parse gpio-ranges for bank id

2023-02-13 Thread Chris Morgan
From: Chris Morgan 

Use the new devicetree property of gpio-ranges to determine the GPIO
bank ID. Preserve the "old" way of doing things too, so that boards
can be migrated and tested gradually (I only have a 3566 and 3326 to
test).

Signed-off-by: Chris Morgan 
---
 drivers/gpio/rk_gpio.c | 20 +---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/rk_gpio.c b/drivers/gpio/rk_gpio.c
index 68f30157a9..98a79b5f4d 100644
--- a/drivers/gpio/rk_gpio.c
+++ b/drivers/gpio/rk_gpio.c
@@ -142,6 +142,7 @@ static int rockchip_gpio_probe(struct udevice *dev)
 {
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
struct rockchip_gpio_priv *priv = dev_get_priv(dev);
+   struct ofnode_phandle_args args;
char *end;
int ret;
 
@@ -150,9 +151,22 @@ static int rockchip_gpio_probe(struct udevice *dev)
if (ret)
return ret;
 
-   uc_priv->gpio_count = ROCKCHIP_GPIOS_PER_BANK;
-   end = strrchr(dev->name, '@');
-   priv->bank = trailing_strtoln(dev->name, end);
+   /*
+* If "gpio-ranges" is present in the devicetree use it to parse
+* the GPIO bank ID, otherwise use the legacy method.
+*/
+   ret = ofnode_parse_phandle_with_args(dev_ofnode(dev),
+"gpio-ranges", NULL, 3,
+0, );
+   if (!ret || ret != -ENOENT) {
+   uc_priv->gpio_count = args.args[2];
+   priv->bank = args.args[1] / args.args[2];
+   } else {
+   uc_priv->gpio_count = ROCKCHIP_GPIOS_PER_BANK;
+   end = strrchr(dev->name, '@');
+   priv->bank = trailing_strtoln(dev->name, end);
+   }
+
priv->name[0] = 'A' + priv->bank;
uc_priv->bank_name = priv->name;
 
-- 
2.34.1



[PATCH V2 0/9] Rockchip: Improve Support for RK3566 Devices

2023-02-13 Thread Chris Morgan
From: Chris Morgan 

This series is to lay the groundwork to improve support for the RK3566
based devices. This syncs the devicetrees with upstream Linux and adds
support for the pin controller of the rk356x series.

Future patches will be submitted that builds on top of this to support
devices such as the Anbernic RG353 and RG503 which are based on the
RK3566.

Changes Since V1:
 - Updated GPIO to parse bank ID from new property of "gpio-ranges"
   which should be included in upstream Linux soon.
 - Updated name of u-boot.dtsi file for the rk3568-evb1-v10.
 - Updated MAINTAINERS file for evb-rk3568 board.
 - Updated rockchip documentation for build instructions for
   rk3568 boards.
 - Removed links to patches co-authored by Peter Geis and instead
   included him in the tags.

Chris Morgan (9):
  gpio: gpio-rockchip: parse gpio-ranges for bank id
  dts: rockchip: px30: add gpio-ranges property to gpio nodes
  rockchip: vop2: Add vop2 dt-binding from Linux
  arm64: dts: rockchip: Sync rk356x from Linux main
  rockchip: rk3568: add boot device detection
  rockchip: rk3568: enable automatic power savings
  gpio/rockchip: rk_gpio support v2 gpio controller
  arm64: dts: rockchip: add gpio-ranges property to gpio nodes
  evb1-v10-rk3568: Update MAINTAINERS and documentation

 arch/arm/dts/Makefile |   2 +-
 arch/arm/dts/px30.dtsi|   4 +
 arch/arm/dts/rk3568-evb.dts   |  79 --
 ...-boot.dtsi => rk3568-evb1-v10-u-boot.dtsi} |   0
 arch/arm/dts/rk3568-evb1-v10.dts  | 692 ++
 arch/arm/dts/rk3568.dtsi  | 122 +++
 arch/arm/dts/rk356x.dtsi  | 187 -
 arch/arm/include/asm/arch-rockchip/gpio.h |  38 +
 arch/arm/mach-rockchip/rk3568/rk3568.c|  31 +
 board/rockchip/evb_rk3568/MAINTAINERS |  12 +-
 ...68_defconfig => evb1-v10-rk3568_defconfig} |   4 +-
 doc/board/rockchip/rockchip.rst   |  10 +
 drivers/gpio/rk_gpio.c|  69 +-
 drivers/pinctrl/rockchip/Makefile |   1 +
 drivers/pinctrl/rockchip/pinctrl-rk3568.c | 453 
 .../pinctrl/rockchip/pinctrl-rockchip-core.c  |  12 +-
 include/dt-bindings/soc/rockchip,vop2.h   |  14 +
 17 files changed, 1613 insertions(+), 117 deletions(-)
 delete mode 100644 arch/arm/dts/rk3568-evb.dts
 rename arch/arm/dts/{rk3568-evb-u-boot.dtsi => rk3568-evb1-v10-u-boot.dtsi} 
(100%)
 create mode 100644 arch/arm/dts/rk3568-evb1-v10.dts
 rename configs/{evb-rk3568_defconfig => evb1-v10-rk3568_defconfig} (94%)
 create mode 100644 drivers/pinctrl/rockchip/pinctrl-rk3568.c
 create mode 100644 include/dt-bindings/soc/rockchip,vop2.h

-- 
2.34.1



Re: imx8mp EQOS regression in dwc_eth_qos,c

2023-02-13 Thread Marek Vasut

On 2/13/23 22:04, Fabio Estevam wrote:

Adding Marek, who has sent some EQOS patches recently.

On Mon, Feb 13, 2023 at 6:02 PM Elmar Psilog  wrote:


Hello,
Think I found a regression in EQOS driver with fixed-phy. Maybe someone
with a imx8mp board might check that use case to confirm? That would be
great.
While ethernet was working in v2022.04 a "ping" in v2023.01 returns

ERROR: no/invalid  property!
invalid speed 0 eqos_adjust_link() failed: -22 FAILED

although devicetree/hardware kept unchanged.
This happens because in file fixed.c in in function fixedphy_config()
the call

  val = ofnode_read_u32_default(node, "speed", 0);

returns 0 instead of 1000 and also the duplex is not set. Found that  in
file/function dwc_eth_qos.c / eqos_start() the line

eqos->phy->node = eqos->phy_of_node;

is responsible for losing the information. Don't know what magic happens
here - so I can't fix it - I just followed the data. So all works well
and even the parsing of old and new fixed-link devicetree works til that
line. After that I don't get speed anymore. Maybe you can have a look at
this?


Try this patch (needs CONFIG_FIXED_PHY=y) :

diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c
index d488bd0c288..592af53b352 100644
--- a/drivers/net/dwc_eth_qos.c
+++ b/drivers/net/dwc_eth_qos.c
@@ -791,9 +791,21 @@ static int eqos_start(struct udevice *dev)
 */
if (!eqos->phy) {
int addr = -1;
-   addr = eqos_get_phy_addr(eqos, dev);
-   eqos->phy = phy_connect(eqos->mii, addr, dev,
-   eqos->config->interface(dev));
+   ofnode fixed_node;
+
+   if (IS_ENABLED(CONFIG_PHY_FIXED)) {
+   fixed_node = ofnode_find_subnode(dev_ofnode(dev),
+"fixed-link");
+   if (ofnode_valid(fixed_node)) {
+   eqos->phy = 
fixed_phy_create(dev_ofnode(dev));

+   }
+
+   if (!eqos->phy) {
+   addr = eqos_get_phy_addr(eqos, dev);
+   eqos->phy = phy_connect(eqos->mii, addr, dev,
+ 
eqos->config->interface(dev));

+   }
+
if (!eqos->phy) {
pr_err("phy_connect() failed");
goto err_stop_resets;


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

2023-02-13 Thread Marek Vasut

On 2/13/23 04:08, Kunihiko Hayashi wrote:

Hi Marek,


Hello Hayashi-san,


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

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

[...]


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


This should be just 'return ret;'


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


This should be goto out_rst, however ...


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


... the out_rst: should only do:

out_rst:
    clk_disable_bulk();
    return ret

out_clk part can be removed.


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


Thank you


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


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


reset_assert_bulk()
clk_disable_bulk()


I think so, however, when I added .exit() and executed "usb stop;usb 
start",

unfortunately the command got stuck.

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


Do you know where exactly the system hangs ?

Do you expect to add the CCF support ?

If so, then add at least a FIXME code comment that the exit callback 
must be implemented, so that this is not forgotten once CCF is in place. 
I don't want this series to grow much further into some "rework 
everything at once" thing.


Re: imx8mp EQOS regression in dwc_eth_qos,c

2023-02-13 Thread Fabio Estevam
Adding Marek, who has sent some EQOS patches recently.

On Mon, Feb 13, 2023 at 6:02 PM Elmar Psilog  wrote:
>
> Hello,
> Think I found a regression in EQOS driver with fixed-phy. Maybe someone
> with a imx8mp board might check that use case to confirm? That would be
> great.
> While ethernet was working in v2022.04 a "ping" in v2023.01 returns
>
> ERROR: no/invalid  property!
> invalid speed 0 eqos_adjust_link() failed: -22 FAILED
>
> although devicetree/hardware kept unchanged.
> This happens because in file fixed.c in in function fixedphy_config()
> the call
>
>  val = ofnode_read_u32_default(node, "speed", 0);
>
> returns 0 instead of 1000 and also the duplex is not set. Found that  in
> file/function dwc_eth_qos.c / eqos_start() the line
>
> eqos->phy->node = eqos->phy_of_node;
>
> is responsible for losing the information. Don't know what magic happens
> here - so I can't fix it - I just followed the data. So all works well
> and even the parsing of old and new fixed-link devicetree works til that
> line. After that I don't get speed anymore. Maybe you can have a look at
> this?
>
> Thank you and best regards,
> Elmar
>
>
> DTS should be correct
>  {
>pinctrl-names = "default";
>pinctrl-0 = <_eqos>;
>phy-mode = "rgmii-id";
>status = "okay";
>
>// fixed-link = <0 1 1000 0 0>; // old - just for test
>fixed-link {
>  speed = <1000>;
>  full-duplex;
>};
> };


imx8mp EQOS regression in dwc_eth_qos,c

2023-02-13 Thread Elmar Psilog

Hello,
Think I found a regression in EQOS driver with fixed-phy. Maybe someone
with a imx8mp board might check that use case to confirm? That would be
great.
While ethernet was working in v2022.04 a "ping" in v2023.01 returns

ERROR: no/invalid  property!
invalid speed 0 eqos_adjust_link() failed: -22 FAILED

although devicetree/hardware kept unchanged.
This happens because in file fixed.c in in function fixedphy_config()
the call

val = ofnode_read_u32_default(node, "speed", 0);

returns 0 instead of 1000 and also the duplex is not set. Found that  in
file/function dwc_eth_qos.c / eqos_start() the line

eqos->phy->node = eqos->phy_of_node;

is responsible for losing the information. Don't know what magic happens
here - so I can't fix it - I just followed the data. So all works well
and even the parsing of old and new fixed-link devicetree works til that
line. After that I don't get speed anymore. Maybe you can have a look at
this?

Thank you and best regards,
Elmar


DTS should be correct
 {
  pinctrl-names = "default";
  pinctrl-0 = <_eqos>;
  phy-mode = "rgmii-id";
  status = "okay";

  // fixed-link = <0 1 1000 0 0>; // old - just for test
  fixed-link {
speed = <1000>;
full-duplex;
  };
};


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

2023-02-13 Thread Andreas Schwab
On Feb 13 2023, Qu Wenruo wrote:

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

I can confirm that this fixes the issue.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."


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

2023-02-13 Thread Marek Vasut

On 2/13/23 02:46, Chunfeng Yun (云春峰) wrote:

On Fri, 2023-02-10 at 11:32 +0100, Marek Vasut wrote:

On 2/10/23 09:33, Chunfeng Yun wrote:
[...]

@@ -50,6 +50,27 @@
   #define IPPC_U3_CTRL(p)  (IPPC_U3_CTRL_0P + ((p) * 0x08))
   #define IPPC_U2_CTRL(p)  (IPPC_U2_CTRL_0P + ((p) * 0x08))
   
+/* xHCI CSR */

+#define LS_EOF_CFG 0x930
+#define LSEOF_OFFSET   0x89
+
+#define FS_EOF_CFG 0x934
+#define FSEOF_OFFSET   0x2e
+
+#define SS_GEN1_EOF_CFG0x93c
+#define SSG1EOF_OFFSET 0x78
+
+#define HFCNTR_CFG 0x944
+#define ITP_DELTA_CLK  (0xa << 1)
+#define ITP_DELTA_CLK_MASK GENMASK(5, 1)
+#define FRMCNT_LEV1_RANG   (0x12b << 8)


Look at FIELD_PREP() macro, that should let you avoid the (0x12b <<
8) .

Seems not use FIELD_PREP() macro here.
It's not a mask, it's the value set in below mask
FRMCNT_LEV1_RANG_MASK.


So that would be

FIELD_PREP(FRMCNT_LEV1_RANG_MASK, 0x12b)

I think ?


+#define FRMCNT_LEV1_RANG_MASK  GENMASK(19, 8)
+
+#define SS_GEN2_EOF_CFG0x990
+#define SSG2EOF_OFFSET 0x3c
+
+#define XSEOF_OFFSET_MASK  GENMASK(11, 0)


[...]


@@ -308,6 +354,7 @@ static int xhci_mtk_remove(struct udevice *dev)
   
   static const struct udevice_id xhci_mtk_ids[] = {

{ .compatible = "mediatek,mtk-xhci" },
+   { .compatible = "mediatek,mt8195-xhci" },


Is the extra compatible string really needed, can't the driver match
on
the generic one ?

These settings are a workaround only for mt8195 to fix HW issue, can't
use generic compatible.


Ah, I see, OK


Re: imx8mp spi fail

2023-02-13 Thread Fabio Estevam
Hi Elmar,

On Mon, Feb 13, 2023 at 4:46 PM Elmar Psilog  wrote:
>
> Thank you so much, you made my day! Sorry, I didn't see the alias was
> used different.

Glad to know it is working.

> Although my credibility gambled away I think I found a real bug in EQOS
> driver with fixed-phy:
>
> In file fixed.c in in function fixedphy_config() the call
>
>  val = ofnode_read_u32_default(node, "speed", 0);
>
> returns 0 instead of 1000 and also the duplex is not set. I found that
> in file/function dwc_eth_qos.c / eqos_start() the line
>
> eqos->phy->node = eqos->phy_of_node;
>
> is reponsible for losing the info. Don't know what magic happens here -
> so I can't fix it - just followed the data. So all works well and even
> the parsing of old and new fixed-link devicetree works til that line.
> After that I don't get speed anymore. Can someone please confirm?

I don't have an imx8mp board to confirm.

Please open a new thread to discuss this new issue.


Re: imx8mp spi fail

2023-02-13 Thread Elmar Psilog

Thank you so much, you made my day! Sorry, I didn't see the alias was
used different.

Although my credibility gambled away I think I found a real bug in EQOS
driver with fixed-phy:

In file fixed.c in in function fixedphy_config() the call

    val = ofnode_read_u32_default(node, "speed", 0);

returns 0 instead of 1000 and also the duplex is not set. I found that 
in file/function dwc_eth_qos.c / eqos_start() the line

eqos->phy->node = eqos->phy_of_node;

is reponsible for losing the info. Don't know what magic happens here -
so I can't fix it - just followed the data. So all works well and even
the parsing of old and new fixed-link devicetree works til that line.
After that I don't get speed anymore. Can someone please confirm?

Best regards,

Elmar

Am 13.02.23 um 00:38 schrieb Fabio Estevam:

Hi Elmar,

On Sun, Feb 12, 2023 at 3:04 PM Elmar Psilog  wrote:

Hello, kindly ask for help about SPI at an IMX8MP. I tried latest
2023.01. If you can please have a look and check it works on your side?

sspi command returns: Invalid bus 0

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

aliases {
 spi0 = 
};

Does this help?


What am I doing wrong or is this a bug? Thanks ahead for any hint.
dt: (tested with both types of cs-gpios)
 {
  pinctrl-names = "default";
  pinctrl-0 = <_ecspi1>;
  cs-gpios = <0>, < 9 GPIO_ACTIVE_LOW>;
//  cs-gpios = < 9 GPIO_ACTIVE_LOW>;

This last format is the correct one.


[PATCH 1/1] efi_loader: avoid buffer overrun in efi_var_mem_compare

2023-02-13 Thread Heinrich Schuchardt
We should not scan beyond the end of string name.

Signed-off-by: Heinrich Schuchardt 
---
 lib/efi_loader/efi_var_mem.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/efi_loader/efi_var_mem.c b/lib/efi_loader/efi_var_mem.c
index e1058e3c6a..d6b65aed12 100644
--- a/lib/efi_loader/efi_var_mem.c
+++ b/lib/efi_loader/efi_var_mem.c
@@ -41,11 +41,13 @@ efi_var_mem_compare(struct efi_var_entry *var, const 
efi_guid_t *guid,
 i < sizeof(efi_guid_t) && match; ++i)
match = (guid1[i] == guid2[i]);
 
-   for (data = var->name, var_name = name;; ++data, ++var_name) {
+   for (data = var->name, var_name = name;; ++data) {
if (match)
match = (*data == *var_name);
if (!*data)
break;
+   if (*var_name)
+   ++var_name;
}
 
++data;
-- 
2.38.1



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

2023-02-13 Thread Andreas Schwab
On Feb 13 2023, Qu Wenruo wrote:

> On 2023/2/13 00:20, Andreas Schwab wrote:
>> When I print ce->size in __btrfs_map_block, it is almost always
>> 1073741824, which looks bogus.
>> 
> Can you provide the image of that filesystem?

How do I do that?

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."


Re: [PATCH v2 3/3] fdt: introduce fsapply command

2023-02-13 Thread Simon Glass
Hi Andre,

On Mon, 13 Feb 2023 at 10:26, Andre Przywara  wrote:
>
> On Fri, 10 Feb 2023 09:05:34 -0700
> Simon Glass  wrote:
>
> Hi Simon,
>
> > On Fri, 10 Feb 2023 at 04:32, Lothar Waßmann  
> > wrote:
> > >
> > > Hi,
> > >
> > > On Fri, 10 Feb 2023 11:02:13 + Andre Przywara wrote:
> > > > Explicitly specifying the exact filenames of devicetree overlays files
> > > > on a U-Boot command line can be quite tedious for users, especially
> > > > when it should be made persistent for every boot.
> > > >
> > > > To simplify the task of applying (custom) DT overlays, introduce a
> > > > "fdt fsapply" subcommand, that iterates a given directory in any
> > > > supported filesystem, and tries to apply every .dtbo file found it
> > > > there.
> > > >
> > > > This allows users to simply drop a DT overlay file into a magic
> > > > directory, and it will be applied on the next boot automatically,
> > > > by the virtue of just a generic U-Boot command call.
> > > >
> > > > Signed-off-by: Andre Przywara 
> > > > ---
> > > >  cmd/fdt.c | 87 +++
> > > >  1 file changed, 87 insertions(+)
> >
> > Please add some help at doc/usage/cmd
>
> Right, will do.
>
> > Also please add a test for this subcommand in test/cmd
>
> Yeah, I knew you would say that ;-)
> It's still the same problem as last time: sandboxfs doesn't implement
> .readdir, so this doesn't work easily there. So I started with filling this
> gap, and was just wondering if I should piggy back on the already existing
> sandbox_fs_ls abstraction, and somewhat re-translate this back into dirent
> structures, or whether I should properly wrap
> {open,read,close}dir in os_*dir() helpers, and build sandbox_fs_readdir()
> based on that?
>
> Any advice? Both seem equally doable.

I like option two as I think it will help in the future too!

Regards,
SImon

>
> Cheers,
> Andre
>
> > > > diff --git a/cmd/fdt.c b/cmd/fdt.c
> > > > index 1972490bdc2..00f92dbbb5d 100644
> > > > --- a/cmd/fdt.c
> > > > +++ b/cmd/fdt.c
> > > > @@ -127,6 +129,81 @@ static int fdt_get_header_value(int argc, char 
> > > > *const argv[])
> > > >   return CMD_RET_FAILURE;
> > > >  }
> > > >
> > > > +#ifdef CONFIG_OF_LIBFDT_OVERLAY
> > > > +static int apply_all_overlays(const char *ifname, const char 
> > > > *dev_part_str,
> > > > +   const char *dirname)
> > > > +{
> > > > + unsigned long addr;
> > > > + struct fdt_header *dtbo;
> > > > + const char *addr_str;
> > > > + struct fs_dir_stream *dirs;
> > > > + struct fs_dirent *dent;
> > > > + char fname[256], *name_beg;
> > > > + int ret;
> > > > +
> > > > + addr_str = env_get("fdtoverlay_addr_r");
> > > > + if (!addr_str) {
> > > > + printf("Invalid fdtoverlay_addr_r for loading 
> > > > overlays\n");
> > > > + return CMD_RET_FAILURE;
> > > > + }
> > > > + addr = hextoul(addr_str, NULL);
> > > > +
> > > > + ret = fs_set_blk_dev(ifname, dev_part_str, FS_TYPE_ANY);
> > > > + if (ret)
> > > > + return CMD_RET_FAILURE;
> > > > +
> > > > + if (!dirname)
> > > > + dirname = "/";
> > > > + dirs = fs_opendir(dirname);
> > > > + if (!dirs) {
> > > > + printf("Cannot find directory \"%s\"\n", dirname);
> > > > + return CMD_RET_FAILURE;
> > > > + }
> > > > +
> > > > + strcpy(fname, dirname);
> > > > + name_beg = strchr(fname, 0);
> > > > + if (name_beg[-1] != '/')
> > > > + *name_beg++ = '/';
> > > > +
> > > > + dtbo = map_sysmem(addr, 0);
> > > > + while ((dent = fs_readdir(dirs))) {
> > > > + loff_t size = 0;
> > > > +
> > > > + if (dent->type == FS_DT_DIR)
> > > > + continue;
> > > > +
> > > > + if (strcmp(dent->name + strlen(dent->name) - 5, ".dtbo"))
> > > > + continue;
> > > > +
> > > > + printf("%s: ", dent->name);
> > > > + strcpy(name_beg, dent->name);
> > > > + fs_set_blk_dev(ifname, dev_part_str, FS_TYPE_ANY);
> > > > + if (dent->size > SZ_2M)
> > > > + size = SZ_2M;
> > > > + else
> > > > + size = dent->size;
> > > > + ret = fs_read(fname, addr, 0, size, );
> > > > + if (ret) {
> > > > + printf("  errno: %d\n", ret);
> > > > + continue;
> > > > + }
> > > > + if (!fdt_valid()) {
> > > > + /* fdt_valid() clears the pointer upon failure */
> > > > + dtbo = map_sysmem(addr, 0);
> > > > + continue;
> > > > + }
> > > > +
> > > > + if (fdt_overlay_apply_verbose(working_fdt, dtbo) == 0)
> > > > + printf("applied\n");
> > > > + }
> > > > + unmap_sysmem(dtbo);
> > > > +
> > > > + fs_closedir(dirs);
> > > > +
> > > > + return 0;
> > 

Re: [PATCH] arm: kirkwood: Enable uart0 dm-pre-reloc for Pogoplug V4 board

2023-02-13 Thread Tony Dinh
On Mon, Feb 13, 2023 at 1:12 AM Stefan Roese  wrote:
>
> Hi Michael,
>
> On 2/13/23 09:48, Michael Walle wrote:
> > Am 2023-02-13 09:43, schrieb Stefan Roese:
> >> On 2/10/23 22:08, Tony Dinh wrote:
> >>> When DM_SERIAL is enabled, the device-tree tag u-boot,dm-pre-reloc is
> >>> required for this board to boot over UART with kwboot. Enable this in
> >>> kirkwood-pogoplug-series-4-u-boot.dtsi.
> >>>
> >>> Signed-off-by: Tony Dinh 
> >>
> >> Reviewed-by: Stefan Roese 
> >
> > If I understood it correctly, this is a workaround, right? Maybe we
> > can include a link to the original discussion here for the case when
> > someone stumbles over this commit:
> >
> > Link: https://lore.kernel.org/r/20230201080210.ypz4nrj4y2igwxz3@pali/
>
> Correct, it's not fully understood, why this property is really needed.
> Some bug still might be hidden in the early DT console code. Still we
> want to move forward with this board, so this dm-pre-reloc property
> helps here.
>
> I'll add the link to the discussion to the commit text. Good idea.

Thanks Stefan!

All the best,
Tony

>
> Thanks,
> Stefan
>


[PATCH] board: gateworks: venice: move README to RST

2023-02-13 Thread Tim Harvey
Move board/gateworks/venice/README to RST documentation.

Signed-off-by: Tim Harvey 
---
 board/gateworks/venice/MAINTAINERS|  1 +
 board/gateworks/venice/README | 35 ---
 doc/board/gateworks/imx8mm_venice.rst | 50 +++
 doc/board/gateworks/imx8mn_venice.rst | 50 +++
 doc/board/gateworks/imx8mp_venice.rst | 50 +++
 doc/board/gateworks/index.rst | 11 ++
 doc/board/index.rst   |  1 +
 7 files changed, 163 insertions(+), 35 deletions(-)
 delete mode 100644 board/gateworks/venice/README
 create mode 100644 doc/board/gateworks/imx8mm_venice.rst
 create mode 100644 doc/board/gateworks/imx8mn_venice.rst
 create mode 100644 doc/board/gateworks/imx8mp_venice.rst
 create mode 100644 doc/board/gateworks/index.rst

diff --git a/board/gateworks/venice/MAINTAINERS 
b/board/gateworks/venice/MAINTAINERS
index cfdea0cb8adc..01a47a15d6fc 100644
--- a/board/gateworks/venice/MAINTAINERS
+++ b/board/gateworks/venice/MAINTAINERS
@@ -3,5 +3,6 @@ M:  Tim Harvey 
 S: Maintained
 F: arch/arm/dts/imx8m*-venice*
 F: board/gateworks/venice/
+F: doc/board/gateworks/*venice*
 F: include/configs/imx8m*_venice.h
 F: configs/imx8m*_venice_defconfig
diff --git a/board/gateworks/venice/README b/board/gateworks/venice/README
deleted file mode 100644
index ea9b8348a7df..
--- a/board/gateworks/venice/README
+++ /dev/null
@@ -1,35 +0,0 @@
-U-Boot for the Gateworks i.MX8M Mini Venice Development Kit boards
-
-Quick Start
-===
-- Build the ARM Trusted firmware binary
-- Get ddr firmware
-- Build U-Boot
-- Flash to eMMC
-- Boot
-
-Get and Build the ARM Trusted firmware
-==
-$ git clone https://github.com/nxp-imx/imx-atf
-$ git checkout imx_5.4.47_2.2.0
-$ make PLAT=imx8mm CROSS_COMPILE=aarch64-linux-gnu- bl31
-$ cp build/imx8mm/release/bl31.bin .
-
-Get the DDR Firmware
-
-$ wget https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-8.9.bin
-$ chmod +x firmware-imx-8.9.bin
-$ ./firmware-imx-8.9.bin
-$ cp firmware-imx-8.9/firmware/ddr/synopsys/lpddr4*.bin .
-
-Build U-Boot
-
-$ make imx8mm_venice_defconfig
-$ make CROSS_COMPILE=aarch64-linux-gnu-
-
-Update eMMC
-===
-=> tftpboot $loadaddr flash.bin
-=> setexpr blkcnt $filesize + 0x1ff && setexpr blkcnt $blkcnt / 0x200
-=> mmc dev 2 && mmc write $loadaddr 0x42 $blkcnt # for IMX8MM
-=> mmc dev 2 && mmc write $loadaddr 0x40 $blkcnt # for IMX8MN
diff --git a/doc/board/gateworks/imx8mm_venice.rst 
b/doc/board/gateworks/imx8mm_venice.rst
new file mode 100644
index ..f1e7e4994458
--- /dev/null
+++ b/doc/board/gateworks/imx8mm_venice.rst
@@ -0,0 +1,50 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+imx8mm_venice
+=
+
+U-Boot for the Gateworks i.MX8M Mini Venice Development Kit boards
+
+Quick Start
+---
+- Build the ARM Trusted firmware binary
+- Get DDR firmware
+- Build U-Boot
+- Flash to eMMC
+- Boot
+
+Get and Build the ARM Trusted firmware
+--
+
+.. code-block:: bash
+
+   $ git clone https://github.com/nxp-imx/imx-atf.git -b lf_v2.4
+   $ make PLAT=imx8mm bl31 CROSS_COMPILE=aarch64-linux-gnu-
+   $ cp build/imx8mm/release/bl31.bin .
+
+Get the DDR Firmware
+
+
+.. code-block:: bash
+
+   $ wget https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-8.9.bin
+   $ chmod +x firmware-imx-8.9.bin
+   $ ./firmware-imx-8.9.bin
+   $ cp firmware-imx-8.9/firmware/ddr/synopsys/lpddr4*.bin .
+
+Build U-Boot
+
+
+.. code-block:: bash
+
+   $ make imx8mm_venice_defconfig
+   $ make CROSS_COMPILE=aarch64-linux-gnu-
+
+Update eMMC
+---
+
+.. code-block:: bash
+
+   => tftpboot $loadaddr flash.bin
+   => setexpr blkcnt $filesize + 0x1ff && setexpr blkcnt $blkcnt / 0x200
+   => mmc dev 2 && mmc write $loadaddr 0x42 $blkcnt
diff --git a/doc/board/gateworks/imx8mn_venice.rst 
b/doc/board/gateworks/imx8mn_venice.rst
new file mode 100644
index ..7ba953a4a85c
--- /dev/null
+++ b/doc/board/gateworks/imx8mn_venice.rst
@@ -0,0 +1,50 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+imx8mn_venice
+=
+
+U-Boot for the Gateworks i.MX8M Nano Venice Development Kit boards
+
+Quick Start
+---
+- Build the ARM Trusted firmware binary
+- Get DDR firmware
+- Build U-Boot
+- Flash to eMMC
+- Boot
+
+Get and Build the ARM Trusted firmware
+--
+
+.. code-block:: bash
+
+   $ git clone https://github.com/nxp-imx/imx-atf.git -b lf_v2.4
+   $ make PLAT=imx8mn bl31 CROSS_COMPILE=aarch64-linux-gnu-
+   $ cp build/imx8mn/release/bl31.bin .
+
+Get the DDR Firmware
+
+
+.. code-block:: bash
+
+   $ wget https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-8.9.bin
+   $ chmod +x firmware-imx-8.9.bin
+   $ ./firmware-imx-8.9.bin
+   $ cp firmware-imx-8.9/firmware/ddr/synopsys/lpddr4*.bin .
+
+Build U-Boot

[PATCH] timer: fttmr010: return a previously deleted driver now ported to DM

2023-02-13 Thread Sergei Antonov
The fttmr010 timer driver was deleted by
commit 29fc6f24926e ("ARM: remove a320evb board support")
The original source file was: arch/arm/cpu/arm920t/a320/timer.c

Return the driver to the codebase in a DM compatible form.
A platform using fttmr010 will be submitted later.

This hardware is described in the datasheet [1], starting from page 348.
According to the datasheet, there is a Revision Register at offset 0x3C,
which is not present in 'struct fttmr010'. Add it and debug() print
revision in probe function.

[1]
https://bitbucket.org/Kasreyn/mkrom-uc7112lx/src/master/documents/FIC8120_DS_v1.2.pdf

Signed-off-by: Sergei Antonov 
---
 drivers/timer/Kconfig  |  7 +++
 drivers/timer/Makefile |  1 +
 drivers/timer/fttmr010_timer.c | 92 ++
 include/faraday/fttmr010.h |  1 +
 4 files changed, 101 insertions(+)
 create mode 100644 drivers/timer/fttmr010_timer.c

diff --git a/drivers/timer/Kconfig b/drivers/timer/Kconfig
index f32bd16227e3..915b2af160c1 100644
--- a/drivers/timer/Kconfig
+++ b/drivers/timer/Kconfig
@@ -145,6 +145,13 @@ config DESIGNWARE_APB_TIMER
  Enables support for the Designware APB Timer driver. This timer is
  present on Altera SoCFPGA SoCs.
 
+config FTTMR010_TIMER
+   bool "Faraday Technology timer support"
+   depends on TIMER
+   help
+ Select this to enable support for the timer found on
+ devices using Faraday Technology's IP.
+
 config GXP_TIMER
bool "HPE GXP Timer"
depends on TIMER
diff --git a/drivers/timer/Makefile b/drivers/timer/Makefile
index 3c92113fc6fd..cdc20f5e946e 100644
--- a/drivers/timer/Makefile
+++ b/drivers/timer/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_$(SPL_)ATMEL_PIT_TIMER) += atmel_pit_timer.o
 obj-$(CONFIG_$(SPL_)ATMEL_TCB_TIMER) += atmel_tcb_timer.o
 obj-$(CONFIG_CADENCE_TTC_TIMER)+= cadence-ttc.o
 obj-$(CONFIG_DESIGNWARE_APB_TIMER) += dw-apb-timer.o
+obj-$(CONFIG_FTTMR010_TIMER)   += fttmr010_timer.o
 obj-$(CONFIG_GXP_TIMER)+= gxp-timer.o
 obj-$(CONFIG_MPC83XX_TIMER) += mpc83xx_timer.o
 obj-$(CONFIG_NOMADIK_MTU_TIMER)+= nomadik-mtu-timer.o
diff --git a/drivers/timer/fttmr010_timer.c b/drivers/timer/fttmr010_timer.c
new file mode 100644
index ..b6289e646109
--- /dev/null
+++ b/drivers/timer/fttmr010_timer.c
@@ -0,0 +1,92 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2009 Faraday Technology
+ * Po-Yu Chuang 
+ *
+ * 23/08/2022 Port to DM
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define TIMER_LOAD_VAL 0x
+
+struct fttmr010_timer_priv {
+   struct fttmr010 __iomem *regs;
+};
+
+static u64 fttmr010_timer_get_count(struct udevice *dev)
+{
+   struct fttmr010_timer_priv *priv = dev_get_priv(dev);
+   struct fttmr010 *tmr = priv->regs;
+   u32 now = TIMER_LOAD_VAL - readl(>timer3_counter);
+
+   /* increment tbu if tbl has rolled over */
+   if (now < gd->arch.tbl)
+   gd->arch.tbu++;
+   gd->arch.tbl = now;
+
+   return ((u64)gd->arch.tbu << 32) | gd->arch.tbl;
+}
+
+static int fttmr010_timer_probe(struct udevice *dev)
+{
+   struct fttmr010_timer_priv *priv = dev_get_priv(dev);
+   struct fttmr010 *tmr;
+   unsigned int cr;
+
+   priv->regs = dev_read_addr_ptr(dev);
+   if (!priv->regs)
+   return -EINVAL;
+   tmr = priv->regs;
+
+   debug("Faraday FTTMR010 timer revision 0x%08X\n", 
readl(>revision));
+
+   /* disable timers */
+   writel(0, >cr);
+
+   /* setup timer */
+   writel(TIMER_LOAD_VAL, >timer3_load);
+   writel(TIMER_LOAD_VAL, >timer3_counter);
+   writel(0, >timer3_match1);
+   writel(0, >timer3_match2);
+
+   /* we don't want timer to issue interrupts */
+   writel(FTTMR010_TM3_MATCH1 |
+  FTTMR010_TM3_MATCH2 |
+  FTTMR010_TM3_OVERFLOW,
+  >interrupt_mask);
+
+   cr = readl(>cr);
+   cr |= FTTMR010_TM3_CLOCK;   /* use external clock */
+   cr |= FTTMR010_TM3_ENABLE;
+   writel(cr, >cr);
+
+   gd->arch.tbl = 0;
+   gd->arch.tbu = 0;
+
+   return 0;
+}
+
+static const struct timer_ops fttmr010_timer_ops = {
+   .get_count = fttmr010_timer_get_count,
+};
+
+static const struct udevice_id fttmr010_timer_ids[] = {
+   { .compatible = "faraday,fttmr010-timer" },
+   {}
+};
+
+U_BOOT_DRIVER(fttmr010_timer) = {
+   .name = "fttmr010_timer",
+   .id = UCLASS_TIMER,
+   .of_match = fttmr010_timer_ids,
+   .priv_auto = sizeof(struct fttmr010_timer_priv),
+   .probe = fttmr010_timer_probe,
+   .ops = _timer_ops,
+};
diff --git a/include/faraday/fttmr010.h b/include/faraday/fttmr010.h
index ec1c9895f57c..5b1bef38c77d 100644
--- a/include/faraday/fttmr010.h
+++ b/include/faraday/fttmr010.h
@@ -26,6 +26,7 @@ struct fttmr010 {
unsigned intcr; /* 0x30 */
unsigned int

[PATCH] mtd: spinand: Fix display of unknown raw ID

2023-02-13 Thread Patrice Chotard
In case ID is not found in manufacturer table, the raw ID is
printed using %*phN format which is not supported by lib/vsprintf.c.
The information displayed doesn't reflect the raw ID return by the
unknown spi-nand.

Use %02x format instead, as done in spi-nor-core.c.

For example, before this patch:
  ERROR: spi-nand: spi_nand flash@0: unknown raw ID f74ec040
after
  ERROR: spi-nand: spi_nand flash@0: unknown raw ID 00 c2 26 03

Fixes: 0a6d6bae0386 ("mtd: nand: Add core infrastructure to support SPI NANDs")

Signed-off-by: Patrice Chotard 
---

 drivers/mtd/nand/spi/core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index 134bf22c805..70d8ae531ee 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -979,8 +979,9 @@ static int spinand_detect(struct spinand_device *spinand)
 
ret = spinand_manufacturer_detect(spinand);
if (ret) {
-   dev_err(spinand->slave->dev, "unknown raw ID %*phN\n",
-   SPINAND_MAX_ID_LEN, spinand->id.data);
+   dev_err(spinand->slave->dev, "unknown raw ID %02x %02x %02x 
%02x\n",
+   spinand->id.data[0], spinand->id.data[1],
+   spinand->id.data[2], spinand->id.data[3]);
return ret;
}
 
-- 
2.25.1



Re: [PATCH v2 3/3] fdt: introduce fsapply command

2023-02-13 Thread Andre Przywara
On Fri, 10 Feb 2023 09:05:34 -0700
Simon Glass  wrote:

Hi Simon,

> On Fri, 10 Feb 2023 at 04:32, Lothar Waßmann  wrote:
> >
> > Hi,
> >
> > On Fri, 10 Feb 2023 11:02:13 + Andre Przywara wrote:  
> > > Explicitly specifying the exact filenames of devicetree overlays files
> > > on a U-Boot command line can be quite tedious for users, especially
> > > when it should be made persistent for every boot.
> > >
> > > To simplify the task of applying (custom) DT overlays, introduce a
> > > "fdt fsapply" subcommand, that iterates a given directory in any
> > > supported filesystem, and tries to apply every .dtbo file found it
> > > there.
> > >
> > > This allows users to simply drop a DT overlay file into a magic
> > > directory, and it will be applied on the next boot automatically,
> > > by the virtue of just a generic U-Boot command call.
> > >
> > > Signed-off-by: Andre Przywara 
> > > ---
> > >  cmd/fdt.c | 87 +++
> > >  1 file changed, 87 insertions(+)  
> 
> Please add some help at doc/usage/cmd

Right, will do.

> Also please add a test for this subcommand in test/cmd

Yeah, I knew you would say that ;-)
It's still the same problem as last time: sandboxfs doesn't implement
.readdir, so this doesn't work easily there. So I started with filling this
gap, and was just wondering if I should piggy back on the already existing
sandbox_fs_ls abstraction, and somewhat re-translate this back into dirent
structures, or whether I should properly wrap
{open,read,close}dir in os_*dir() helpers, and build sandbox_fs_readdir()
based on that?

Any advice? Both seem equally doable.

Cheers,
Andre

> > > diff --git a/cmd/fdt.c b/cmd/fdt.c
> > > index 1972490bdc2..00f92dbbb5d 100644
> > > --- a/cmd/fdt.c
> > > +++ b/cmd/fdt.c
> > > @@ -127,6 +129,81 @@ static int fdt_get_header_value(int argc, char 
> > > *const argv[])
> > >   return CMD_RET_FAILURE;
> > >  }
> > >
> > > +#ifdef CONFIG_OF_LIBFDT_OVERLAY
> > > +static int apply_all_overlays(const char *ifname, const char 
> > > *dev_part_str,
> > > +   const char *dirname)
> > > +{
> > > + unsigned long addr;
> > > + struct fdt_header *dtbo;
> > > + const char *addr_str;
> > > + struct fs_dir_stream *dirs;
> > > + struct fs_dirent *dent;
> > > + char fname[256], *name_beg;
> > > + int ret;
> > > +
> > > + addr_str = env_get("fdtoverlay_addr_r");
> > > + if (!addr_str) {
> > > + printf("Invalid fdtoverlay_addr_r for loading overlays\n");
> > > + return CMD_RET_FAILURE;
> > > + }
> > > + addr = hextoul(addr_str, NULL);
> > > +
> > > + ret = fs_set_blk_dev(ifname, dev_part_str, FS_TYPE_ANY);
> > > + if (ret)
> > > + return CMD_RET_FAILURE;
> > > +
> > > + if (!dirname)
> > > + dirname = "/";
> > > + dirs = fs_opendir(dirname);
> > > + if (!dirs) {
> > > + printf("Cannot find directory \"%s\"\n", dirname);
> > > + return CMD_RET_FAILURE;
> > > + }
> > > +
> > > + strcpy(fname, dirname);
> > > + name_beg = strchr(fname, 0);
> > > + if (name_beg[-1] != '/')
> > > + *name_beg++ = '/';
> > > +
> > > + dtbo = map_sysmem(addr, 0);
> > > + while ((dent = fs_readdir(dirs))) {
> > > + loff_t size = 0;
> > > +
> > > + if (dent->type == FS_DT_DIR)
> > > + continue;
> > > +
> > > + if (strcmp(dent->name + strlen(dent->name) - 5, ".dtbo"))
> > > + continue;
> > > +
> > > + printf("%s: ", dent->name);
> > > + strcpy(name_beg, dent->name);
> > > + fs_set_blk_dev(ifname, dev_part_str, FS_TYPE_ANY);
> > > + if (dent->size > SZ_2M)
> > > + size = SZ_2M;
> > > + else
> > > + size = dent->size;
> > > + ret = fs_read(fname, addr, 0, size, );
> > > + if (ret) {
> > > + printf("  errno: %d\n", ret);
> > > + continue;
> > > + }
> > > + if (!fdt_valid()) {
> > > + /* fdt_valid() clears the pointer upon failure */
> > > + dtbo = map_sysmem(addr, 0);
> > > + continue;
> > > + }
> > > +
> > > + if (fdt_overlay_apply_verbose(working_fdt, dtbo) == 0)
> > > + printf("applied\n");
> > > + }
> > > + unmap_sysmem(dtbo);
> > > +
> > > + fs_closedir(dirs);
> > > +
> > > + return 0;  
> > return CMD_RET_SUCCESS;  
> 
> There is no need for that...0 means success in U-Boot. It is shorter
> and clearer IMO.
> 
> Regards,
> SImon



[PATCH v5 07/11] dm: doc: Move to new driver model schema

2023-02-13 Thread Simon Glass
Now that Linux has accepted these tags, update the dtoc tool to use them.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 tools/dtoc/dtb_platdata.py | 10 +-
 tools/dtoc/test/dtoc_test_add_prop.dts |  4 ++--
 tools/dtoc/test/dtoc_test_addr32.dts   |  4 ++--
 tools/dtoc/test/dtoc_test_addr32_64.dts|  6 +++---
 tools/dtoc/test/dtoc_test_addr64.dts   |  6 +++---
 tools/dtoc/test/dtoc_test_addr64_32.dts|  6 +++---
 tools/dtoc/test/dtoc_test_alias_bad.dts|  6 +++---
 tools/dtoc/test/dtoc_test_alias_bad_path.dts   |  6 +++---
 tools/dtoc/test/dtoc_test_alias_bad_uc.dts |  6 +++---
 tools/dtoc/test/dtoc_test_aliases.dts  |  4 ++--
 tools/dtoc/test/dtoc_test_driver_alias.dts |  2 +-
 tools/dtoc/test/dtoc_test_inst.dts |  6 +++---
 tools/dtoc/test/dtoc_test_invalid_driver.dts   |  2 +-
 tools/dtoc/test/dtoc_test_noparent.dts |  6 +++---
 tools/dtoc/test/dtoc_test_noprops.dts  |  2 +-
 tools/dtoc/test/dtoc_test_phandle.dts  | 10 +-
 tools/dtoc/test/dtoc_test_phandle_bad.dts  |  2 +-
 tools/dtoc/test/dtoc_test_phandle_bad2.dts |  4 ++--
 tools/dtoc/test/dtoc_test_phandle_cd_gpios.dts | 10 +-
 tools/dtoc/test/dtoc_test_phandle_reorder.dts  |  4 ++--
 tools/dtoc/test/dtoc_test_phandle_single.dts   |  4 ++--
 tools/dtoc/test/dtoc_test_simple.dts   | 10 +-
 tools/dtoc/test/dtoc_test_single_reg.dts   |  4 ++--
 23 files changed, 62 insertions(+), 62 deletions(-)

diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index a69a7889ce1..39f416cfd80 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -35,9 +35,9 @@ PROP_IGNORE_LIST = [
 'linux,phandle',
 "status",
 'phandle',
-'u-boot,dm-pre-reloc',
-'u-boot,dm-tpl',
-'u-boot,dm-spl',
+'bootph-all',
+'bootph-pre-sram',
+'bootph-pre-ram',
 ]
 
 # C type declarations for the types we support
@@ -442,7 +442,7 @@ class DtbPlatdata():
 """
 parent = node.parent
 if parent and not parent.props:
-raise ValueError("Parent node '%s' has no properties - do you need 
u-boot,dm-spl or similar?" %
+raise ValueError("Parent node '%s' has no properties - do you need 
bootph-pre-ram or similar?" %
  parent.path)
 num_addr, num_size = 2, 2
 if parent:
@@ -754,7 +754,7 @@ class DtbPlatdata():
 # This might indicate that the parent node is not in the
 # SPL/TPL devicetree but the child is. For example if we are
 # dealing with of-platdata in TPL, the parent has a
-# u-boot,dm-tpl tag but the child has u-boot,dm-pre-reloc. In
+# bootph-pre-sram tag but the child has bootph-all. In
 # this case the child node exists in TPL but the parent does
 # not.
 raise ValueError("Node '%s' requires parent node '%s' but it 
is not in the valid list" %
diff --git a/tools/dtoc/test/dtoc_test_add_prop.dts 
b/tools/dtoc/test/dtoc_test_add_prop.dts
index fa296e55527..8225de36d27 100644
--- a/tools/dtoc/test/dtoc_test_add_prop.dts
+++ b/tools/dtoc/test/dtoc_test_add_prop.dts
@@ -11,13 +11,13 @@
#address-cells = <1>;
#size-cells = <1>;
spl-test {
-   u-boot,dm-pre-reloc;
+   bootph-all;
compatible = "sandbox,spl-test";
intval = <1>;
};
 
spl-test2 {
-   u-boot,dm-pre-reloc;
+   bootph-all;
compatible = "sandbox,spl-test";
intarray = <5>;
};
diff --git a/tools/dtoc/test/dtoc_test_addr32.dts 
b/tools/dtoc/test/dtoc_test_addr32.dts
index 239045497c6..3e7dc567292 100644
--- a/tools/dtoc/test/dtoc_test_addr32.dts
+++ b/tools/dtoc/test/dtoc_test_addr32.dts
@@ -12,13 +12,13 @@
#size-cells = <1>;
 
test1 {
-   u-boot,dm-pre-reloc;
+   bootph-all;
compatible = "test1";
reg = <0x1234 0x5678>;
};
 
test2 {
-   u-boot,dm-pre-reloc;
+   bootph-all;
compatible = "test2";
reg = <0x12345678 0x98765432 2 3>;
};
diff --git a/tools/dtoc/test/dtoc_test_addr32_64.dts 
b/tools/dtoc/test/dtoc_test_addr32_64.dts
index 7599d5b0a59..7ce16feef1a 100644
--- a/tools/dtoc/test/dtoc_test_addr32_64.dts
+++ b/tools/dtoc/test/dtoc_test_addr32_64.dts
@@ -12,19 +12,19 @@
#size-cells = <2>;
 
test1 {
-   u-boot,dm-pre-reloc;
+   bootph-all;
compatible = "test1";
reg = <0x1234 0x5678 0x0>;
};
 
test2 {
-   u-boot,dm-pre-reloc;
+   bootph-all;
compatible = "test2";
reg = <0x12345678 0x98765432 0x10987654>;
};
 
test3 {
-  

Re: [PATCH 2/5] video console: refactoring and optimization

2023-02-13 Thread Dzmitry Sankouski
For version 3 patches:

Summary of 8 commits for 1232 boards (4 threads, 1 job per thread)
01: video console: unite normal and rotated files
02: video console: refactoring and optimization
   sandbox: (for 1/7 boards) all -64.0 text -64.0
03: video console: add support for fonts wider than 1 byte
04: video console: add select font logic to vidconsole uclass driver
   sandbox: (for 1/7 boards) all +288.0 data +32.0 text +256.0
05: video console: allow font size configuration at runtime
   sandbox: (for 1/7 boards) all +1208.0 data +64.0 rodata +96.0 text +1048.0
06: video console: add 12x22 Sun font from linux
07: video console: add 16x32 Terminus font from linux
08: video console: add 12x22 console simple font test
   sandbox: (for 1/7 boards) all +13152.0 data +11336.0 rodata +256.0
text +1560.0
(no errors to report)

ср, 4 янв. 2023 г. в 23:02, Simon Glass :

>
> Hi Dzmitry,
>
> On Wed, 4 Jan 2023 at 04:17, Dzmitry Sankouski  wrote:
> >
> > Regarding code-size there's a gain with CONFIG_CONSOLE_ROTATION
> > enabled, and penalty with disabled:
> >
> > New:
> > CONFIG_VIDEO_CONSOLE=y
> > CONFIG_CONSOLE_ROTATION=y
> > dzmitry@debian:~/side/u-boot$ du --bytes drivers/video/console_simple.o
> > 108208  drivers/video/console_simple.o
> >
> > CONFIG_VIDEO_CONSOLE=y
> > # CONFIG_CONSOLE_ROTATION is not set
> > dzmitry@debian:~/side/u-boot$ du --bytes drivers/video/console_simple.o
> > 53848   drivers/video/console_simple.o
> >
> > Old:
> > dzmitry@debian:~/side/u-boot$ du --bytes drivers/video/console_normal.o
> > 44728   drivers/video/console_normal.o
> > dzmitry@debian:~/side/u-boot$ du --bytes drivers/video/console_rotate.o
> > 85424   drivers/video/console_rotate.o
> >
> > In theory, there should be a small performance penalty for the `if
> > (direction)` statement -
> > for every row, and for each pixel. For an 8x16 font, it'll be 144 if 
> > statements.
> >
> > I'll comment on functions in the next patch versions.
>
> To check this, use:
>
> buildman -b  
>
> to build each commit, then
>
> buildman -b   -sS
>
> You can add -B for function bloat and --step 0 to diff just the first
> and last commits.
>
>
> - Simon
>
> >
> > пт, 30 дек. 2022 г. в 01:41, Simon Glass :
> > >
> > > Hi Dzmitry,
> > >
> > > On Mon, 26 Dec 2022 at 13:50, Dzmitry Sankouski  
> > > wrote:
> > > >
> > > > - 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 
> > > > ---
> > > >  drivers/video/console_simple.c | 508 -
> > > >  1 file changed, 184 insertions(+), 324 deletions(-)
> > >
> > > This looks like a nice tidy up.
> > >
> > > Is there a code-size or performance penalty with this? E.g. with
> > > CONFIG_CONSOLE_ROTATION disabled
> > >
> > > Please can you comment the functions property so we know what they do?
> > >
> > > Regards,
> > > Simon


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

2023-02-13 Thread Michal Simek




On 2/13/23 16:56, Simon Glass wrote:

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

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

Signed-off-by: Simon Glass 
Version 4:


This line above shouldn't be there.

M


[PATCH v2 8/8] video console: add 12x22 console simple font test

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

Signed-off-by: Dzmitry Sankouski 
---
Changes for v2: N/A

 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 de799b5cea..0d501c8f15 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -335,3 +335,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
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, ));
+   ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, ));
+   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, ));
@@ -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, ));
+   ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, ));
+   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, ));
+   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, ));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, ));
+   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, ));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, ));
+   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, ));
ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, ));
+   ut_assertok(vidconsole_select_font(con, "8x16", 0));
ut_asserteq(46, compress_frame_buffer(uts, dev));
 
/* Check display wrap */
-- 
2.30.2



[PATCH v2 2/8] video console: refactoring and optimization

2023-02-13 Thread Dzmitry Sankouski
- 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 
---
Changes for v2:
- move width and pixel data size macros to console_simple.c
- performance: move if statement out of pixel fill loops
- document new functions
- remove console_probe_2 function
- make fill_pixel_and_goto_next void
- fix video unit tests failures

 drivers/video/console_simple.c | 598 ++---
 1 file changed, 258 insertions(+), 340 deletions(-)

diff --git a/drivers/video/console_simple.c b/drivers/video/console_simple.c
index a4b3cfe3d8..1eb47be449 100644
--- a/drivers/video/console_simple.c
+++ b/drivers/video/console_simple.c
@@ -3,6 +3,7 @@
  * Copyright (c) 2015 Google, Inc
  * (C) Copyright 2015
  * Bernecker & Rainer Industrieelektronik GmbH - http://www.br-automation.com
+ * (C) Copyright 2023 Dzmitry Sankouski 
  */
 
 #include 
@@ -11,46 +12,209 @@
 #include 
 #include /* Get font data, width and height */
 
-static int console_normal_set_row(struct udevice *dev, uint row, int clr)
-{
-   struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
-   void *line, *end;
-   int pixels = VIDEO_FONT_HEIGHT * vid_priv->xsize;
-   int ret;
-   int i;
+#define VIDEO_FONT_BYTE_WIDTH  ((VIDEO_FONT_WIDTH / 8) + (VIDEO_FONT_WIDTH % 8 
> 0))
 
-   line = vid_priv->fb + row * VIDEO_FONT_HEIGHT * vid_priv->line_length;
-   switch (vid_priv->bpix) {
-   case VIDEO_BPP8:
-   if (IS_ENABLED(CONFIG_VIDEO_BPP8)) {
-   uint8_t *dst = line;
+#define FLIPPED_DIRECTION 1
+#define NORMAL_DIRECTION 0
 
-   for (i = 0; i < pixels; i++)
-   *dst++ = clr;
-   end = dst;
-   break;
-   }
+/**
+ * Checks if bits per pixel supported.
+ *
+ * @param bpix framebuffer bits per pixel.
+ *
+ * @returns 0, if supported, or else -ENOSYS.
+ */
+static int check_bpix_support(int bpix)
+{
+   switch (bpix) {
+   case VIDEO_BPP8:
+   if (IS_ENABLED(CONFIG_VIDEO_BPP8))
+   return 0;
case VIDEO_BPP16:
-   if (IS_ENABLED(CONFIG_VIDEO_BPP16)) {
-   uint16_t *dst = line;
+   if (IS_ENABLED(CONFIG_VIDEO_BPP16))
+   return 0;
+   case VIDEO_BPP32:
+   if (IS_ENABLED(CONFIG_VIDEO_BPP32))
+   return 0;
+   default:
+   return -ENOSYS;
+   }
+}
+
+/**
+ * Fill 1 pixel in framebuffer, and go to next one.
+ *
+ * @param dstp a pointer to pointer to framebuffer.
+ * @param valuevalue to write to framebuffer.
+ * @param pbytes   framebuffer bytes per pixel.
+ * @param step framebuffer pointer increment. Usually is equal to 
pbytes,
+ * and may be negative to control filling direction.
+ */
+static 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;
+}
+
+#if (CONFIG_IS_ENABLED(CONSOLE_ROTATION))
+/**
+ * Fills 1 character in framebuffer horizontally.
+ * Horizontally means we're filling char font data columns across the lines.
+ *
+ * @param pfonta pointer to character font data.
+ * @param line a pointer to pointer to framebuffer. It's a point for 
upper left char corner
+ * @param vid_priv driver private data.
+ * @param directioncontrols character orientation. Can be normal or 
flipped.
+ * When normal:   When flipped:
+ *|---|
+ *|   *|   line stepping  |
+ *|^  * * * * *|   |  |
+ *||* *|   v   * *|
+ *||   |   * * * * *  |
+ *|  line stepping |   *  |
+ *||  |
+ *|  stepping ->   |<- stepping   |
+ *|---!!we're starting from upper left char corner|
+ *|---|
+ *
+ * @returns 0, if success, or else error code.
+ */
+static 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)
+ 

[PATCH v2 4/8] video console: add select font logic to vidconsole uclass driver

2023-02-13 Thread Dzmitry Sankouski
Select font logic at runtime needed to unit test different fonts.
This commit is a preparation to enable runtime font selection in
console_simple driver.

- move console true type select font logic to driver ops
- add select font logic to vidconsole-uclass.c

Signed-off-by: Dzmitry Sankouski 
---
Changes for v2: N/A

 cmd/font.c|  7 ++-
 drivers/video/console_truetype.c  |  6 --
 drivers/video/vidconsole-uclass.c | 22 ++
 include/video.h   |  1 +
 include/video_console.h   | 18 +-
 5 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/cmd/font.c b/cmd/font.c
index 3e522f3aaa..769796c5ec 100644
--- a/cmd/font.c
+++ b/cmd/font.c
@@ -15,7 +15,12 @@
 static int do_font_list(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
 {
-   vidconsole_list_fonts();
+   struct udevice *dev;
+
+   if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, ))
+   return CMD_RET_FAILURE;
+
+   vidconsole_list_fonts(dev);
 
return 0;
 }
diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c
index 6859c9fa11..389fa483fc 100644
--- a/drivers/video/console_truetype.c
+++ b/drivers/video/console_truetype.c
@@ -584,7 +584,7 @@ static struct font_info *console_truetype_find_font(void)
return NULL;
 }
 
-void vidconsole_list_fonts(void)
+void console_truetype_list_fonts(struct udevice __maybe_unused *dev)
 {
struct font_info *tab;
 
@@ -674,7 +674,7 @@ static void select_metrics(struct udevice *dev, struct 
console_tt_metrics *met)
vc_priv->tab_width_frac = VID_TO_POS(met->font_size) * 8 / 2;
 }
 
-int vidconsole_select_font(struct udevice *dev, const char *name, uint size)
+int console_truetype_select_font(struct udevice *dev, const char *name, uint 
size)
 {
struct console_tt_priv *priv = dev_get_priv(dev);
struct console_tt_metrics *met;
@@ -763,6 +763,8 @@ struct vidconsole_ops console_truetype_ops = {
.set_row= console_truetype_set_row,
.backspace  = console_truetype_backspace,
.entry_start= console_truetype_entry_start,
+   .list_fonts = console_truetype_list_fonts,
+   .select_font= console_truetype_select_font,
 };
 
 U_BOOT_DRIVER(vidconsole_truetype) = {
diff --git a/drivers/video/vidconsole-uclass.c 
b/drivers/video/vidconsole-uclass.c
index 6bdfb6e37d..5a08fdd689 100644
--- a/drivers/video/vidconsole-uclass.c
+++ b/drivers/video/vidconsole-uclass.c
@@ -85,6 +85,28 @@ static int vidconsole_back(struct udevice *dev)
return video_sync(dev->parent, false);
 }
 
+void vidconsole_list_fonts(struct udevice *dev)
+{
+   struct vidconsole_ops *ops = vidconsole_get_ops(dev);
+
+   if (ops->select_font)
+   ops->list_fonts(dev);
+}
+
+int vidconsole_select_font(struct udevice *dev, const char *name, uint size)
+{
+   struct vidconsole_ops *ops = vidconsole_get_ops(dev);
+   int ret;
+
+   if (ops->select_font) {
+   ret = ops->select_font(dev, name, size);
+   if (ret != -ENOSYS)
+   return ret;
+   }
+
+   return 0;
+}
+
 /* Move to a newline, scrolling the display if necessary */
 static void vidconsole_newline(struct udevice *dev)
 {
diff --git a/include/video.h b/include/video.h
index 43f2e2c02f..91c05fa9f0 100644
--- a/include/video.h
+++ b/include/video.h
@@ -115,6 +115,7 @@ struct video_priv {
bool flush_dcache;
u8 fg_col_idx;
u8 bg_col_idx;
+   struct video_fontdata *fontdata;
 };
 
 /**
diff --git a/include/video_console.h b/include/video_console.h
index d755eb73cf..fc702cc165 100644
--- a/include/video_console.h
+++ b/include/video_console.h
@@ -133,6 +133,22 @@ struct vidconsole_ops {
 * characters.
 */
int (*backspace)(struct udevice *dev);
+
+   /**
+* list_fonts() - List the available fonts
+*
+* This shows a list on the console
+*/
+   void (*list_fonts)(struct udevice *dev);
+
+   /**
+* select_font() - Select a font to use
+*
+* @dev: vidconsole device
+* @name: Font name
+* @size: Size of the font (norminal pixel height) or 0 for default
+*/
+   int (*select_font)(struct udevice *dev, const char *name, uint size);
 };
 
 /* Get a pointer to the driver operations for a video console device */
@@ -236,7 +252,7 @@ void vidconsole_set_cursor_pos(struct udevice *dev, int x, 
int y);
  *
  * This shows a list on the console
  */
-void vidconsole_list_fonts(void);
+void vidconsole_list_fonts(struct udevice *dev);
 
 /**
  * vidconsole_select_font() - Select a font to use
-- 
2.30.2



[PATCH v2 3/8] video console: add support for fonts wider than 1 byte

2023-02-13 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 
---
Charges for v2:
- replace TAIL_BIT_COUNT macro with c code
- rename refactoring

 drivers/video/console_simple.c | 93 +-
 1 file changed, 59 insertions(+), 34 deletions(-)

diff --git a/drivers/video/console_simple.c b/drivers/video/console_simple.c
index 1eb47be449..cdc26cac30 100644
--- a/drivers/video/console_simple.c
+++ b/drivers/video/console_simple.c
@@ -13,6 +13,7 @@
 #include /* Get font data, width and height */
 
 #define VIDEO_FONT_BYTE_WIDTH  ((VIDEO_FONT_WIDTH / 8) + (VIDEO_FONT_WIDTH % 8 
> 0))
+#define VIDEO_FONT_CHAR_PIXEL_BYTES(VIDEO_FONT_HEIGHT * 
VIDEO_FONT_BYTE_WIDTH)
 
 #define FLIPPED_DIRECTION 1
 #define NORMAL_DIRECTION 0
@@ -95,9 +96,9 @@ static inline void fill_pixel_and_goto_next(void **dstp, u32 
value, int pbytes,
 static 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)
@@ -111,21 +112,32 @@ static int fill_char_horizontally(uchar *pfont, void 
**line, struct video_priv *
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(,
-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_iteration)
+   bitcount = width_remainder;
+   }
+   for (int bit = 0; bit < bitcount; bit++) {
+   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(,
+value,
+pbytes,
+step
+   );
+   }
+   *line += line_step;
+   mask >>= 1;
}
-   *line += line_step;
-   mask >>= 1;
}
return ret;
 }
@@ -158,7 +170,7 @@ static int fill_char_horizontally(uchar *pfont, void 
**line, struct video_priv *
 static 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);
@@ -174,23 +186,36 @@ static int fill_char_vertically(uchar *pfont, void 
**line, struct video_priv *vi
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(,
-value,
-pbytes,
-step
-   );
-   bits <<= 1;
+   for (int col = 0; col < 

[PATCH v2 1/8] video console: unite normal and rotated files

2023-02-13 Thread Dzmitry Sankouski
Unite console_normal.c and console_rotate.c files.
Those files have similar logic, and common logic
may be extracted after putting code in single file.

Signed-off-by: Dzmitry Sankouski 
---
Changes for v2:
- none

 drivers/video/Kconfig |   8 +-
 drivers/video/Makefile|   3 +-
 drivers/video/console_normal.c| 178 --
 .../{console_rotate.c => console_simple.c}| 166 
 4 files changed, 171 insertions(+), 184 deletions(-)
 delete mode 100644 drivers/video/console_normal.c
 rename drivers/video/{console_rotate.c => console_simple.c} (75%)

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index f539977d9b..1dfe11d182 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -124,17 +124,17 @@ config VIDEO_MIPI_DSI
  The MIPI Display Serial Interface (MIPI DSI) defines a high-speed
  serial interface between a host processor and a display module.
 
-config CONSOLE_NORMAL
+config VIDEO_CONSOLE
bool "Support a simple text console"
default y
help
  Support drawing text on the frame buffer console so that it can be
- used as a console. Rotation is not supported by this driver (see
- CONFIG_CONSOLE_ROTATION for that). A built-in 8x16 font is used
- for the display.
+ used as a console. See CONFIG_CONSOLE_ROTATION for rotation support.
+ A built-in 8x16 font is used for the display.
 
 config CONSOLE_ROTATION
bool "Support rotated displays"
+   depends on VIDEO_CONSOLE
help
  Sometimes, for example if the display is mounted in portrait
  mode or even if it's mounted landscape but rotated by 180degree,
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 40a871d638..75decf707d 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -7,8 +7,7 @@ ifdef CONFIG_DM
 obj-$(CONFIG_BACKLIGHT) += backlight-uclass.o
 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
+obj-$(CONFIG_VIDEO_CONSOLE) += console_simple.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_normal.c b/drivers/video/console_normal.c
deleted file mode 100644
index 04f022491e..00
--- a/drivers/video/console_normal.c
+++ /dev/null
@@ -1,178 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (c) 2015 Google, Inc
- * (C) Copyright 2001-2015
- * DENX Software Engineering -- w...@denx.de
- * Compulab Ltd - http://compulab.co.il/
- * Bernecker & Rainer Industrieelektronik GmbH - http://www.br-automation.com
- */
-
-#include 
-#include 
-#include 
-#include 
-#include /* Get font data, width and height */
-
-static int console_normal_set_row(struct udevice *dev, uint row, int clr)
-{
-   struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
-   void *line, *end;
-   int pixels = VIDEO_FONT_HEIGHT * vid_priv->xsize;
-   int ret;
-   int i;
-
-   line = vid_priv->fb + row * VIDEO_FONT_HEIGHT * vid_priv->line_length;
-   switch (vid_priv->bpix) {
-   case VIDEO_BPP8:
-   if (IS_ENABLED(CONFIG_VIDEO_BPP8)) {
-   uint8_t *dst = line;
-
-   for (i = 0; i < pixels; i++)
-   *dst++ = clr;
-   end = dst;
-   break;
-   }
-   case VIDEO_BPP16:
-   if (IS_ENABLED(CONFIG_VIDEO_BPP16)) {
-   uint16_t *dst = line;
-
-   for (i = 0; i < pixels; i++)
-   *dst++ = clr;
-   end = dst;
-   break;
-   }
-   case VIDEO_BPP32:
-   if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
-   uint32_t *dst = line;
-
-   for (i = 0; i < pixels; i++)
-   *dst++ = clr;
-   end = dst;
-   break;
-   }
-   default:
-   return -ENOSYS;
-   }
-   ret = vidconsole_sync_copy(dev, line, end);
-   if (ret)
-   return ret;
-
-   return 0;
-}
-
-static int console_normal_move_rows(struct udevice *dev, uint rowdst,
-uint rowsrc, uint count)
-{
-   struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
-   void *dst;
-   void *src;
-   int size;
-   int ret;
-
-   dst = vid_priv->fb + rowdst * VIDEO_FONT_HEIGHT * vid_priv->line_length;
-   src = vid_priv->fb + rowsrc * VIDEO_FONT_HEIGHT * vid_priv->line_length;
-   size = VIDEO_FONT_HEIGHT * vid_priv->line_length * count;
-   ret 

[PATCH v2 0/8] vidconsole: refactoring and support for wider fonts

2023-02-13 Thread Dzmitry Sankouski
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 3:
- fix video tests failures
- add runtime font size configuration
- add test for 12x22 font

Dzmitry Sankouski (8):
  video console: unite normal and rotated files
  video console: refactoring and optimization
  video console: add support for fonts wider than 1 byte
  video console: add select font logic to vidconsole uclass driver
  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: add 12x22 console simple font test

 cmd/Kconfig   |8 +
 cmd/Makefile  |2 +-
 cmd/font.c|7 +-
 common/splash.c   |7 +-
 configs/qemu-x86_defconfig|1 +
 configs/sandbox_defconfig |3 +
 drivers/video/Kconfig |   38 +-
 drivers/video/Makefile|3 +-
 drivers/video/console_normal.c|  178 -
 drivers/video/console_rotate.c|  497 ---
 drivers/video/console_simple.c|  638 +++
 drivers/video/console_truetype.c  |6 +-
 drivers/video/vidconsole-uclass.c |   22 +
 include/video.h   |1 +
 include/video_console.h   |   18 +-
 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/dm/video.c   |   41 +
 22 files changed, 13681 insertions(+), 5319 deletions(-)
 delete mode 100644 drivers/video/console_normal.c
 delete mode 100644 drivers/video/console_rotate.c
 create mode 100644 drivers/video/console_simple.c
 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: Please pull u-boot-dm

2023-02-13 Thread Tom Rini
On Sun, Feb 12, 2023 at 05:37:09PM -0700, Simon Glass wrote:

> Hi Tom,
> 
> https://source.denx.de/u-boot/custodians/u-boot-dm/-/pipelines/15164
> 
> 
> The following changes since commit a5e490f14e904fd240ccec5d364509b36a3150f9:
> 
>   socfpga: fix the serial console on DE1-SoC (2023-02-12 15:47:19 -0500)
> 
> are available in the Git repository at:
> 
>   git://git.denx.de/u-boot-dm.git tags/dm-pull-12feb23
> 
> for you to fetch changes up to 4ee85df9ce0b6385a28f538af31680eed4ee153e:
> 
>   cmd: fdt: allow standalone "fdt move" (2023-02-12 17:33:51 -0700)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


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

2023-02-13 Thread Tom Rini
On Mon, Feb 13, 2023 at 10:19:09AM +0530, Sumit Garg wrote:

> Co-developed-by: Mike Worsfold 
> Signed-off-by: Mike Worsfold 
> Signed-off-by: Sumit Garg 

I don't see this originally in patchwork, and I didn't check
lore.kernel.org, I'm not sure what happened. With that, applied to
u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: Please pull u-boot-i2c

2023-02-13 Thread Tom Rini
On Mon, Feb 13, 2023 at 03:52:55PM +0100, Heiko Schocher wrote:

> Hello Tom,
> 
> please pull from u-boot-i2c:
> 
> The following changes since commit a5e490f14e904fd240ccec5d364509b36a3150f9:
> 
>   socfpga: fix the serial console on DE1-SoC (2023-02-12 15:47:19 -0500)
> 
> are available in the Git repository at:
> 
>   https://source.denx.de/u-boot/custodians/u-boot-i2c.git 
> tags/i2c-updates-for-v2023.04
> 
> for you to fetch changes up to f536fda99fa2c1c88f68d8da54ed6233cec3532e:
> 
>   i2c: i2c-cdns.c: Update driver to read fifo-depth from device tree 
> (2023-02-13 09:58:27 +0100)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: Please pull u-boot-marvell/master

2023-02-13 Thread Tom Rini
On Mon, Feb 13, 2023 at 03:01:25PM +0100, Stefan Roese wrote:

> Hi Tom,
> 
> please pull this next batch of Marvell related patches.
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


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

2023-02-13 Thread Thomas Fitzsimmons
Convert the documentation for the Broadcom BCM7445 and BCM7260 boards
to reStructuredText format and add the new filename to
doc/board/broadcom/index.rst.
---

Changes in v2:
- Remove "About this" heading

 doc/README.bcm7xxx | 156 
 doc/board/broadcom/bcm7xxx.rst | 183 +
 doc/board/broadcom/index.rst   |   1 +
 3 files changed, 184 insertions(+), 156 deletions(-)
 delete mode 100644 doc/README.bcm7xxx
 create mode 100644 doc/board/broadcom/bcm7xxx.rst

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

[PATCH 1/1] arm64: dts: rockchip: rk3308: Add Radxa ROCK Pi S support

2023-02-13 Thread Akash Gajjar
Add Radxa ROCK 3 Model A support. sync rk3308-rock-pi-s.dts from
Linux 6.2.0-rc7.

ROCK Pi S is RK3308 based SBC from radxa.com. ROCK Pi S has a,
- 256MB/512MB DDR3 RAM
- SD, NAND flash (optional on board 1/2/4/8Gb)
- 100MB ethernet, PoE (optional)
- Onboard 802.11 b/g/n wifi + Bluetooth 4.0 Module
- USB2.0 Type-A HOST x1
- USB3.0 Type-C OTG x1
- 26-pin expansion header
- USB Type-C DC 5V Power Supply

Linux commit commit for the same,
<2e04c25b1320> ("arm64: dts: rockchip: add ROCK Pi S DTS support")

Signed-off-by: Akash Gajjar 
---
 arch/arm/dts/rk3308-rock-pi-s-u-boot.dtsi |  17 ++
 arch/arm/dts/rk3308-rock-pi-s.dts | 228 ++
 configs/rock-pi-s-rk3308_defconfig|  89 +
 3 files changed, 334 insertions(+)
 create mode 100644 arch/arm/dts/rk3308-rock-pi-s-u-boot.dtsi
 create mode 100644 arch/arm/dts/rk3308-rock-pi-s.dts
 create mode 100644 configs/rock-pi-s-rk3308_defconfig

diff --git a/arch/arm/dts/rk3308-rock-pi-s-u-boot.dtsi 
b/arch/arm/dts/rk3308-rock-pi-s-u-boot.dtsi
new file mode 100644
index 00..27735c49dd
--- /dev/null
+++ b/arch/arm/dts/rk3308-rock-pi-s-u-boot.dtsi
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2018-2019 Rockchip Electronics Co., Ltd
+ */
+#include "rk3308-u-boot.dtsi"
+
+/ {
+   chosen {
+   u-boot,spl-boot-order = "same-as-spl", 
+   };
+};
+
+ {
+   u-boot,dm-pre-reloc;
+   clock-frequency = <2400>;
+   status = "okay";
+};
diff --git a/arch/arm/dts/rk3308-rock-pi-s.dts 
b/arch/arm/dts/rk3308-rock-pi-s.dts
new file mode 100644
index 00..b5a8691b3f
--- /dev/null
+++ b/arch/arm/dts/rk3308-rock-pi-s.dts
@@ -0,0 +1,228 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2019 Fuzhou Rockchip Electronics Co., Ltd
+ * Copyright (C) 2023 Akash Gajjar 
+ * Copyright (c) 2023 Jagan Teki 
+ */
+
+/dts-v1/;
+#include 
+#include "rk3308.dtsi"
+
+/ {
+   model = "Radxa ROCK Pi S";
+   compatible = "radxa,rockpis", "rockchip,rk3308";
+
+   aliases {
+   ethernet0 = 
+   mmc0 = 
+   mmc1 = 
+   };
+
+   chosen {
+   stdout-path = "serial0:150n8";
+   };
+
+   leds {
+   compatible = "gpio-leds";
+   pinctrl-names = "default";
+   pinctrl-0 = <_led_gio>, <_led_gpio>;
+
+   green-led {
+   default-state = "on";
+   gpios = < RK_PA6 GPIO_ACTIVE_HIGH>;
+   label = "rockpis:green:power";
+   linux,default-trigger = "default-on";
+   };
+
+   blue-led {
+   default-state = "on";
+   gpios = < RK_PA5 GPIO_ACTIVE_HIGH>;
+   label = "rockpis:blue:user";
+   linux,default-trigger = "heartbeat";
+   };
+   };
+
+   sdio_pwrseq: sdio-pwrseq {
+   compatible = "mmc-pwrseq-simple";
+   pinctrl-0 = <_enable_h>;
+   pinctrl-names = "default";
+   reset-gpios = < RK_PA2 GPIO_ACTIVE_LOW>;
+   };
+
+   vcc_1v8: vcc-1v8 {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc_1v8";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <180>;
+   vin-supply = <_io>;
+   };
+
+   vcc_io: vcc-io {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc_io";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   vin-supply = <_sys>;
+   };
+
+   vcc_ddr: vcc-ddr {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc_ddr";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <150>;
+   regulator-max-microvolt = <150>;
+   vin-supply = <_sys>;
+   };
+
+   vcc5v0_otg: vcc5v0-otg {
+   compatible = "regulator-fixed";
+   enable-active-high;
+   gpio = < RK_PC5 GPIO_ACTIVE_HIGH>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_vbus_drv>;
+   regulator-name = "vcc5v0_otg";
+   regulator-always-on;
+   vin-supply = <_sys>;
+   };
+
+   vcc5v0_sys: vcc5v0-sys {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc5v0_sys";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   };
+
+   vdd_core: vdd-core {
+   compatible = "pwm-regulator";
+  

[PATCH 0/1] Add Radxa ROCK Pi S support in U-boot

2023-02-13 Thread Akash Gajjar
ROCK Pi S is rk3308 soc based board from Radxa. Add board support in u-boot.
Booting logs is accessible at https://paste.ubuntu.com/p/cJDRzBRdXq/

Akash Gajjar (1):
  arm64: dts: rockchip: rk3308: Add Radxa ROCK Pi S support

 arch/arm/dts/rk3308-rock-pi-s-u-boot.dtsi |  17 ++
 arch/arm/dts/rk3308-rock-pi-s.dts | 228 ++
 configs/rock-pi-s-rk3308_defconfig|  89 +
 3 files changed, 334 insertions(+)
 create mode 100644 arch/arm/dts/rk3308-rock-pi-s-u-boot.dtsi
 create mode 100644 arch/arm/dts/rk3308-rock-pi-s.dts
 create mode 100644 configs/rock-pi-s-rk3308_defconfig

-- 
2.25.1



[PATCH v5 00/11] dm: Move to new driver model schema for device tree tags

2023-02-13 Thread Simon Glass
Now that a new schema has been accepted upstream, press it into service in
U-Boot.

Changes in v5:
- Move this patch earlier in the series and make it additive
- Add a note to the SPL file about the migration
- Ensure that the old tags are supported in each commit of this series

Changes in v4:
- Add a way to support handling old u-boot,dm- tags
- Add new patch with a way to set the environment for a pytest
- Add new patch with a test for the various migration combinations

Changes in v3:
- Rebase to master again, with new conversions
- Add a new patch to warn about pre-schema driver model tags
- Add a new patch to check for pre-schema driver model tags in CI

Changes in v2:
- Add binding document
- Convert k3-am68-sk boards also

Simon Glass (11):
  schemas: Add schema for U-Boot driver model 'phase tags'
  dm: Add support for handling old u-boot,dm- tags
  dm: dts: Convert driver model tags to use new schema
  dm: treewide: Complete migration to new driver model schema
  dm: doc: Update device tree binding docs for new schema
  dm: doc: Update documentation for new driver model schema
  dm: doc: Move to new driver model schema
  checkpatch: Add a warning for pre-schema driver model tags
  CI: Add a check for pre-schema driver model tags
  test: Add a way to set the environment for a pytest
  dm: test: Add a test for the various migration combinations

 .azure-pipelines.yml  |  12 ++
 .gitlab-ci.yml|   9 ++
 arch/arc/dts/abilis_tb100.dts |   2 +-
 arch/arc/dts/axc001.dtsi  |   2 +-
 arch/arc/dts/axc003.dtsi  |   2 +-
 arch/arc/dts/axs10x_mb.dtsi   |   6 +-
 arch/arc/dts/emsdp.dts|   2 +-
 arch/arc/dts/hsdk-common.dtsi |   2 +-
 arch/arc/dts/iot_devkit.dts   |   2 +-
 arch/arc/dts/nsim.dts |   2 +-
 arch/arc/dts/skeleton.dtsi|   2 +-
 arch/arm/dts/am335x-brppt1-mmc-u-boot.dtsi|  48 
 arch/arm/dts/am335x-brsmarc1.dts  |  28 ++---
 arch/arm/dts/am335x-brxre1.dts|  22 ++--
 arch/arm/dts/am335x-evm-u-boot.dtsi   |  22 ++--
 arch/arm/dts/am335x-evmsk-u-boot.dtsi |   4 +-
 arch/arm/dts/am335x-guardian-u-boot.dtsi  |  28 ++---
 arch/arm/dts/am335x-pdu001-u-boot.dtsi|  30 ++---
 arch/arm/dts/am335x-pxm50-u-boot.dtsi |   4 +-
 arch/arm/dts/am335x-regor-rdk-u-boot.dtsi |   8 +-
 arch/arm/dts/am335x-rut-u-boot.dtsi   |   4 +-
 .../dts/am335x-sancloud-bbe-lite-u-boot.dtsi  |  18 +--
 arch/arm/dts/am335x-shc-u-boot.dtsi   |  20 ++--
 arch/arm/dts/am335x-wega-rdk-u-boot.dtsi  |  14 +--
 arch/arm/dts/am33xx-u-boot.dtsi   |   2 +-
 arch/arm/dts/am3517-evm-u-boot.dtsi   |  18 +--
 arch/arm/dts/am4372-generic-u-boot.dtsi   |   4 +-
 arch/arm/dts/am4372-u-boot.dtsi   |  20 ++--
 arch/arm/dts/am437x-gp-evm-u-boot.dtsi|  24 ++--
 arch/arm/dts/am437x-idk-evm-u-boot.dtsi   |   8 +-
 arch/arm/dts/am437x-sk-evm-u-boot.dtsi|   8 +-
 arch/arm/dts/armada-3720-eDPU-u-boot.dtsi |   6 +-
 arch/arm/dts/armada-3720-uDPU-u-boot.dtsi |   6 +-
 arch/arm/dts/armada-385-atl-x530-u-boot.dtsi  |   2 +-
 .../dts/armada-385-turris-omnia-u-boot.dtsi   |  12 +-
 arch/arm/dts/armada-388-clearfog-u-boot.dtsi  |  18 +--
 arch/arm/dts/armada-388-helios4-u-boot.dtsi   |  20 ++--
 .../armada-38x-controlcenterdc-u-boot.dtsi|  12 +-
 arch/arm/dts/armada-ap80x-quad.dtsi   |   8 +-
 .../arm/dts/armada-xp-theadorable-u-boot.dtsi |   2 +-
 arch/arm/dts/ast2500-evb.dts  |   8 +-
 arch/arm/dts/ast2500-u-boot.dtsi  |   8 +-
 arch/arm/dts/ast2600-evb.dts  |   6 +-
 arch/arm/dts/ast2600-u-boot.dtsi  |  10 +-
 .../dts/at91-sam9x60_curiosity-u-boot.dtsi|  34 +++---
 arch/arm/dts/at91-sama5d27_giantboard.dts |  16 +--
 arch/arm/dts/at91-sama5d27_som1_ek.dts|  24 ++--
 .../dts/at91-sama5d27_wlsom1_ek-u-boot.dtsi   |  20 ++--
 arch/arm/dts/at91-sama5d2_icp-u-boot.dtsi |  18 +--
 arch/arm/dts/at91-sama5d2_ptc_ek.dts  |  18 +--
 arch/arm/dts/at91-sama5d2_xplained.dts|  38 +++---
 arch/arm/dts/at91-sama5d3_xplained.dts|  14 +--
 arch/arm/dts/at91-sama5d4_xplained.dts|  20 ++--
 arch/arm/dts/at91-sama5d4ek.dts   |  20 ++--
 arch/arm/dts/at91-sama7g5ek-u-boot.dtsi   |  24 ++--
 arch/arm/dts/at91sam9260-smartweb.dts |   4 +-
 arch/arm/dts/at91sam9260.dtsi |  26 ++---
 arch/arm/dts/at91sam9260ek.dts|   4 +-
 arch/arm/dts/at91sam9261.dtsi |  26 ++---
 arch/arm/dts/at91sam9263.dtsi |  26 ++---
 arch/arm/dts/at91sam9263ek.dts|   4 +-
 arch/arm/dts/at91sam9g15ek.dts|   2 +-
 arch/arm/dts/at91sam9g20-taurus.dts   |   6 +-
 

[PATCH v5 11/11] dm: test: Add a test for the various migration combinations

2023-02-13 Thread Simon Glass
Test that:

- sandbox shows a warning when an unmigrated DT is used
- sandbox fails to run when migration is turned off
- sandbox_spl fails to build when migration is turned off

Signed-off-by: Simon Glass 
---

Changes in v5:
- Ensure that the old tags are supported in each commit of this series

Changes in v4:
- Add new patch with a test for the various migration combinations

 test/py/tests/test_of_migrate.py | 108 +++
 1 file changed, 108 insertions(+)
 create mode 100644 test/py/tests/test_of_migrate.py

diff --git a/test/py/tests/test_of_migrate.py b/test/py/tests/test_of_migrate.py
new file mode 100644
index 000..910f7c05510
--- /dev/null
+++ b/test/py/tests/test_of_migrate.py
@@ -0,0 +1,108 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright 2023 Google LLC
+# Written by Simon Glass 
+
+"""Test handling of unmigrated u-boot,dm- tags"""
+
+import os
+import pytest
+
+import u_boot_utils as util
+
+# This is needed for Azure, since the default '..' directory is not writeable
+TMPDIR1 = '/tmp/test_no_migrate'
+TMPDIR2 = '/tmp/test_no_migrate_spl'
+TMPDIR3 = '/tmp/test_migrate'
+
+def build_for_migrate(cons, replace_pair, board, tmpdir, disable_migrate=True):
+"""Build an updated U-Boot with a slightly modified device tree
+
+Args:
+cons (ConsoleBase): U-Boot console
+replace_pair (tuple):
+String to find
+String to replace it with
+board (str): Board to build
+tmpdir (str): Temporary directory to use
+disable_migrate (bool): True to disable CONFIG_OF_TAG_MIGRATE in build
+"""
+srcdir = cons.config.source_dir
+build_dir = cons.config.build_dir
+
+# Get the source for the existing dts
+dt_dir = os.path.join(build_dir, 'arch', 'sandbox', 'dts')
+orig_fname = os.path.join(dt_dir, 'sandbox.dtb')
+out_dts = os.path.join(dt_dir, 'sandbox_out.dts')
+util.run_and_log(cons, ['dtc', orig_fname, '-I', 'dtb', '-O', 'dts',
+'-o', out_dts])
+
+# Update it to use an old tag
+with open(out_dts) as inf:
+data = inf.read()
+data = data.replace(*replace_pair)
+
+dts_fname = os.path.join(dt_dir, 'sandbox_oldtag.dts')
+with open(dts_fname, 'w') as outf:
+print(data, file=outf)
+dtb_fname = os.path.join(dt_dir, 'sandbox_oldtag.dtb')
+util.run_and_log(cons, ['dtc', dts_fname, '-o', dtb_fname])
+
+migrate = ['-a', '~CONFIG_OF_TAG_MIGRATE'] if disable_migrate else []
+
+# Build sandbox with this new dtb, turning off OF_TAG_MIGRATE
+env = dict(os.environ)
+env['EXT_DTB'] = dtb_fname
+env['DEVICE_TREE'] = 'sandbox_new'
+env['NO_LTO'] = '1'  # Speed up build
+out = util.run_and_log(
+cons, ['./tools/buildman/buildman', '-m', '--board', board,
+   *migrate, '-w', '-o', tmpdir], ignore_errors=True, env=env)
+return out
+
+@pytest.mark.slow
+@pytest.mark.boardspec('sandbox')
+def test_of_no_migrate(u_boot_console):
+"""Test sandbox with old boot phase tags like u-boot,dm-pre-proper"""
+cons = u_boot_console
+
+build_for_migrate(cons, ['bootph-some-ram', 'u-boot,dm-pre-proper'],
+  'sandbox', TMPDIR1)
+
+# It should fail to run, since the lcd device will not be bound before
+# relocation. so won't get its frame-buffer memory
+out = util.run_and_log(
+cons, [os.path.join(TMPDIR1, 'u-boot'), '-D', '-c', 'help'],
+ignore_errors=True)
+assert "Video device 'lcd' cannot allocate frame buffer memory" in out
+
+
+@pytest.mark.slow
+@pytest.mark.boardspec('sandbox_spl')
+@pytest.mark.boardspec('spl_of_platdata_inst')
+@pytest.mark.boardspec('!sandbox_tpl')
+def test_of_no_migrate_spl(u_boot_console):
+"""Test sandbox with old boot phase tags like u-boot,dm-spl"""
+cons = u_boot_console
+
+out = build_for_migrate(cons, ['bootph-pre-ram', 'u-boot,dm-spl'],
+'sandbox_spl', TMPDIR2)
+
+# It should fail to build, since the SPL DT will not include 'spl-test'
+# node, among others
+assert "undefined type ‘struct dtd_sandbox_spl_test’" in out
+
+
+@pytest.mark.slow
+@pytest.mark.boardspec('sandbox')
+def test_of_migrate(u_boot_console):
+"""Test sandbox shows a message when tags were migrated"""
+cons = u_boot_console
+
+build_for_migrate(cons, ['bootph-some-ram', 'u-boot,dm-pre-proper'],
+  'sandbox', TMPDIR3, disable_migrate=False)
+
+# It should show a migration message
+out = util.run_and_log(
+cons, [os.path.join(TMPDIR3, 'u-boot'), '-D', '-c', 'help'],
+ignore_errors=True)
+assert "Warning: Device tree includes old 'u-boot,dm-' tags" in out
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v5 09/11] CI: Add a check for pre-schema driver model tags

2023-02-13 Thread Simon Glass
These should not be used anymore. Add a check to ensure they don't creek
back into U-Boot. Use bootph-... instead.

Signed-off-by: Simon Glass 
---

(no changes since v3)

Changes in v3:
- Add a new patch to check for pre-schema driver model tags in CI

 .azure-pipelines.yml | 12 
 .gitlab-ci.yml   |  9 +
 2 files changed, 21 insertions(+)

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 947c400f8d3..8327edf87aa 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -213,6 +213,18 @@ stages:
   export PYTHONPATH=${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt
   make pylint_err
 
+  - job: check_for_pre_schema_tags
+displayName: 'Check for pre-schema driver model tags'
+pool:
+  vmImage: $(ubuntu_vm)
+container:
+  image: $(ci_runner_image)
+  options: $(container_option)
+steps:
+  # If grep succeeds and finds a match the test fails as we should
+  # have no matches.
+  - script: git grep u-boot,dm- -- '*.dts*' && exit 1 || exit 0
+
 - stage: test_py
   jobs:
   - job: test_py
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 272d69e2206..c3ceca2974d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -235,6 +235,15 @@ Run pylint:
 - export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt"
 - make pylint_err
 
+# Check for pre-schema driver model tags
+Check for pre-schema tags:
+  stage: testsuites
+  script:
+- git config --global --add safe.directory "${CI_PROJECT_DIR}";
+# If grep succeeds and finds a match the test fails as we should
+# have no matches.
+- git grep u-boot,dm- -- '*.dts*' && exit 1 || exit 0
+
 # Test sandbox with test.py
 sandbox test.py:
   variables:
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v5 04/11] dm: treewide: Complete migration to new driver model schema

2023-02-13 Thread Simon Glass
Update various build and test components to use the new schema.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 drivers/core/ofnode.c| 10 +-
 drivers/video/video-uclass.c |  4 ++--
 dts/Kconfig  |  2 +-
 include/dm/device.h  |  2 +-
 include/dm/ofnode.h  | 10 +-
 test/dm/test-fdt.c   |  2 +-
 test/py/tests/test_ofplatdata.py |  8 
 tools/binman/binman.rst  |  3 +--
 tools/dtoc/test_fdt.py   |  8 
 9 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index 5fdac2b6638..f49ee493d3c 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -1312,22 +1312,22 @@ bool ofnode_pre_reloc(ofnode node)
 {
 #if defined(CONFIG_SPL_BUILD) || defined(CONFIG_TPL_BUILD)
/* for SPL and TPL the remaining nodes after the fdtgrep 1st pass
-* had property dm-pre-reloc or u-boot,dm-spl/tpl.
+* had property bootph-all or bootph-pre-sram/bootph-pre-ram.
 * They are removed in final dtb (fdtgrep 2nd pass)
 */
return true;
 #else
-   if (ofnode_read_bool(node, "u-boot,dm-pre-reloc"))
+   if (ofnode_read_bool(node, "bootph-all"))
return true;
-   if (ofnode_read_bool(node, "u-boot,dm-pre-proper"))
+   if (ofnode_read_bool(node, "bootph-some-ram"))
return true;
 
/*
 * In regular builds individual spl and tpl handling both
 * count as handled pre-relocation for later second init.
 */
-   if (ofnode_read_bool(node, "u-boot,dm-spl") ||
-   ofnode_read_bool(node, "u-boot,dm-tpl"))
+   if (ofnode_read_bool(node, "bootph-pre-ram") ||
+   ofnode_read_bool(node, "bootph-pre-sram"))
return true;
 
if (IS_ENABLED(CONFIG_OF_TAG_MIGRATE)) {
diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
index 6aaacff10df..ab482f11e5d 100644
--- a/drivers/video/video-uclass.c
+++ b/drivers/video/video-uclass.c
@@ -529,8 +529,8 @@ static int video_post_bind(struct udevice *dev)
addr = uc_priv->video_ptr;
size = alloc_fb(dev, );
if (addr < gd->video_bottom) {
-   /* Device tree node may need the 'u-boot,dm-pre-reloc' or
-* 'u-boot,dm-pre-proper' tag
+   /* Device tree node may need the 'bootph-all' or
+* 'bootph-some-ram' tag
 */
printf("Video device '%s' cannot allocate frame buffer memory 
-ensure the device is set up before relocation\n",
   dev->name);
diff --git a/dts/Kconfig b/dts/Kconfig
index deb865d4c28..3b7489f0f87 100644
--- a/dts/Kconfig
+++ b/dts/Kconfig
@@ -362,7 +362,7 @@ config OF_SPL_REMOVE_PROPS
help
  Since SPL normally runs in a reduced memory space, the device tree
  is cut down to only what is needed to load and start U-Boot. Only
- nodes marked with the property "u-boot,dm-pre-reloc" will be
+ nodes marked with the property "bootph-all" will be
  included. In addition, some properties are not used by U-Boot and
  can be discarded. This option defines the list of properties to
  discard.
diff --git a/include/dm/device.h b/include/dm/device.h
index e9460386ca9..b86bf90609b 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -1070,7 +1070,7 @@ static inline bool device_is_on_pci_bus(const struct 
udevice *dev)
  * sub-nodes and binds drivers for each node where a driver can be found.
  *
  * If this is called prior to relocation, only pre-relocation devices will be
- * bound (those marked with u-boot,dm-pre-reloc in the device tree, or where
+ * bound (those marked with bootph-all in the device tree, or where
  * the driver has the DM_FLAG_PRE_RELOC flag set). Otherwise, all devices will
  * be bound.
  *
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index 3f6b0843c58..c00677275ee 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -1188,12 +1188,12 @@ int ofnode_read_simple_size_cells(ofnode node);
  * determine if a node was bound in one of SPL/TPL stages.
  *
  * There are 4 settings currently in use
- * - u-boot,dm-pre-proper: U-Boot proper pre-relocation only
- * - u-boot,dm-pre-reloc: legacy and indicates any of TPL or SPL
+ * - bootph-some-ram: U-Boot proper pre-relocation only
+ * - bootph-all: all phases
  * Existing platforms only use it to indicate nodes needed in
- * SPL. Should probably be replaced by u-boot,dm-spl for new platforms.
- * - u-boot,dm-spl: SPL and U-Boot pre-relocation
- * - u-boot,dm-tpl: TPL and U-Boot pre-relocation
+ * SPL. Should probably be replaced by bootph-pre-ram for new platforms.
+ * - bootph-pre-ram: SPL and U-Boot pre-relocation
+ * - bootph-pre-sram: TPL and U-Boot pre-relocation
  *
  * @node: node to check
  * Return: true if node is needed in SPL/TL, false otherwise
diff --git 

[PATCH v5 06/11] dm: doc: Update documentation for new driver model schema

2023-02-13 Thread Simon Glass
Now that Linux has accepted these tags, move U-Boot over to use them.
Tidy up the comments and formatting, making sure that VPL is mentioned
too.

Signed-off-by: Simon Glass 
---

Changes in v5:
- Add a note to the SPL file about the migration

 doc/README.TPL|  4 +--
 doc/develop/driver-model/design.rst   | 15 +--
 .../driver-model/fs_firmware_loader.rst   |  4 +--
 doc/develop/driver-model/of-plat.rst  | 25 ++-
 doc/develop/driver-model/pci-info.rst | 10 
 doc/develop/driver-model/serial-howto.rst | 24 +-
 doc/develop/spl.rst   |  9 +--
 7 files changed, 49 insertions(+), 42 deletions(-)

diff --git a/doc/README.TPL b/doc/README.TPL
index 72027fd692e..95b466e4af9 100644
--- a/doc/README.TPL
+++ b/doc/README.TPL
@@ -35,8 +35,8 @@ is set. Source files can be compiled for TPL with options 
chosen in the
 board config file.
 
 TPL use a small device tree (u-boot-tpl.dtb), containing only the nodes with
-the pre-relocation properties: 'u-boot,dm-pre-reloc' and 'u-boot,dm-tpl'
-(see README.SPL for details).
+the pre-relocation properties: 'bootph-all' and 'bootph-pre-sram'
+(see doc/develop/spl.rst for details).
 
 For example:
 
diff --git a/doc/develop/driver-model/design.rst 
b/doc/develop/driver-model/design.rst
index 20611e85e34..8c2c81d7ac9 100644
--- a/doc/develop/driver-model/design.rst
+++ b/doc/develop/driver-model/design.rst
@@ -1114,12 +1114,12 @@ Pre-Relocation Support
 --
 
 For pre-relocation we simply call the driver model init function. Only
-drivers marked with DM_FLAG_PRE_RELOC or the device tree 'u-boot,dm-pre-reloc'
+drivers marked with DM_FLAG_PRE_RELOC or the device tree 'bootph-all'
 property are initialised prior to relocation. This helps to reduce the driver
 model overhead. This flag applies to SPL and TPL as well, if device tree is
 enabled (CONFIG_OF_CONTROL) there.
 
-Note when device tree is enabled, the device tree 'u-boot,dm-pre-reloc'
+Note when device tree is enabled, the device tree 'bootph-all'
 property can provide better control granularity on which device is bound
 before relocation. While with DM_FLAG_PRE_RELOC flag of the driver all
 devices with the same driver are bound, which requires allocation a large
@@ -1128,14 +1128,15 @@ only way for statically declared devices via 
U_BOOT_DRVINFO() to be bound
 prior to relocation.
 
 It is possible to limit this to specific relocation steps, by using
-the more specialized 'u-boot,dm-spl' and 'u-boot,dm-tpl' flags
-in the device tree node. For U-Boot proper you can use 'u-boot,dm-pre-proper'
+the more specialized 'bootph-pre-ram' and 'bootph-pre-sram' flags
+in the device tree node. For U-Boot proper you can use 'bootph-some-ram'
 which means that it will be processed (and a driver bound) in U-Boot proper
 prior to relocation, but will not be available in SPL or TPL.
 
-To reduce the size of SPL and TPL, only the nodes with pre-relocation 
properties
-('u-boot,dm-pre-reloc', 'u-boot,dm-spl' or 'u-boot,dm-tpl') are keept in their
-device trees (see README.SPL for details); the remaining nodes are always 
bound.
+To reduce the size of SPL and TPL, only the nodes with pre-relocation
+properties ('bootph-all', 'bootph-pre-ram' or 'bootph-pre-sram') are kept in
+their device trees (see README.SPL for details); the remaining nodes are
+always bound.
 
 Then post relocation we throw that away and re-init driver model again.
 For drivers which require some sort of continuity between pre- and
diff --git a/doc/develop/driver-model/fs_firmware_loader.rst 
b/doc/develop/driver-model/fs_firmware_loader.rst
index a44708cb4c5..b0823700a90 100644
--- a/doc/develop/driver-model/fs_firmware_loader.rst
+++ b/doc/develop/driver-model/fs_firmware_loader.rst
@@ -28,7 +28,7 @@ defined in fs-loader node as shown in below:
 Example for block device::
 
fs_loader0: fs-loader {
-   u-boot,dm-pre-reloc;
+   bootph-all;
compatible = "u-boot,fs-loader";
phandlepart = < 1>;
};
@@ -41,7 +41,7 @@ device, it can be described in FDT as shown in below:
 Example for ubi::
 
fs_loader1: fs-loader {
-   u-boot,dm-pre-reloc;
+   bootph-all;
compatible = "u-boot,fs-loader";
mtdpart = "UBI",
ubivol = "ubi0";
diff --git a/doc/develop/driver-model/of-plat.rst 
b/doc/develop/driver-model/of-plat.rst
index b454f7be85e..01724ba72ce 100644
--- a/doc/develop/driver-model/of-plat.rst
+++ b/doc/develop/driver-model/of-plat.rst
@@ -67,7 +67,7 @@ device. As an example, consider this MMC node:
 pinctrl-0 = <_clk>, <_cmd>, <_cd>, <_bus4>;
 vmmc-supply = <_sd>;
 status = "okay";
-u-boot,dm-pre-reloc;
+bootph-all;
 };
 
 
@@ -632,7 +632,7 @@ the devicetree. For example, if the devicetree 

[PATCH v5 05/11] dm: doc: Update device tree binding docs for new schema

2023-02-13 Thread Simon Glass
Now that Linux has accepted these tags, move U-Boot over to use them.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 doc/device-tree-bindings/chosen.txt   |  2 +-
 .../clock/rockchip,rk3368-dmc.txt |  2 +-
 .../clock/rockchip,rk3399-dmc.txt |  2 +-
 .../clock/st,stm32mp1.txt | 22 +--
 doc/device-tree-bindings/device.txt   |  6 ++---
 .../fsp/fsp2/apollolake/fsp-s.txt |  2 +-
 .../memory-controller/k3-j721e-ddrss.txt  |  2 +-
 .../memory-controllers/k3-am654-ddrss.txt |  2 +-
 doc/device-tree-bindings/misc/fs_loader.txt   |  8 +++
 doc/device-tree-bindings/net/mdio-mux-reg.txt |  2 +-
 doc/device-tree-bindings/pci/x86-pci.txt  |  4 ++--
 .../pinctrl/nexell,s5pxx18-pinctrl.txt|  2 +-
 .../ram/fsl,mpc83xx-mem-controller.txt|  2 +-
 .../video/atmel-hlcdc.txt |  2 +-
 14 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/doc/device-tree-bindings/chosen.txt 
b/doc/device-tree-bindings/chosen.txt
index e5ba6720ce1..c8312540f57 100644
--- a/doc/device-tree-bindings/chosen.txt
+++ b/doc/device-tree-bindings/chosen.txt
@@ -129,7 +129,7 @@ Example
};
 
fs_loader0: fs-loader@0 {
-   u-boot,dm-pre-reloc;
+   bootph-all;
compatible = "u-boot,fs-loader";
phandlepart = < 1>;
};
diff --git a/doc/device-tree-bindings/clock/rockchip,rk3368-dmc.txt 
b/doc/device-tree-bindings/clock/rockchip,rk3368-dmc.txt
index 8e7357d53d3..da474fbabde 100644
--- a/doc/device-tree-bindings/clock/rockchip,rk3368-dmc.txt
+++ b/doc/device-tree-bindings/clock/rockchip,rk3368-dmc.txt
@@ -54,7 +54,7 @@ Example (for DDR3-1600K and 800MHz)
#include 
 
dmc: dmc@ff61 {
-   u-boot,dm-pre-reloc;
+   bootph-all;
compatible = "rockchip,rk3368-dmc";
reg = <0 0xff61 0 0x400
   0 0xff62 0 0x400>;
diff --git a/doc/device-tree-bindings/clock/rockchip,rk3399-dmc.txt 
b/doc/device-tree-bindings/clock/rockchip,rk3399-dmc.txt
index a15dc5d1f85..4a56f78f555 100644
--- a/doc/device-tree-bindings/clock/rockchip,rk3399-dmc.txt
+++ b/doc/device-tree-bindings/clock/rockchip,rk3399-dmc.txt
@@ -16,7 +16,7 @@ Required properties:
 
 Example:
dmc: dmc {
-   u-boot,dm-pre-reloc;
+   bootph-all;
compatible = "rockchip,rk3399-dmc";
devfreq-events = <>;
interrupts = ;
diff --git a/doc/device-tree-bindings/clock/st,stm32mp1.txt 
b/doc/device-tree-bindings/clock/st,stm32mp1.txt
index 4d4136d2fce..e638bcef7bc 100644
--- a/doc/device-tree-bindings/clock/st,stm32mp1.txt
+++ b/doc/device-tree-bindings/clock/st,stm32mp1.txt
@@ -251,9 +251,9 @@ Example of clock tree initialization
 
 / {
clocks {
-   u-boot,dm-pre-reloc;
+   bootph-all;
clk_hse: clk-hse {
-   u-boot,dm-pre-reloc;
+   bootph-all;
#clock-cells = <0>;
compatible = "fixed-clock";
clock-frequency = <2400>;
@@ -261,28 +261,28 @@ Example of clock tree initialization
};
 
clk_hsi: clk-hsi {
-   u-boot,dm-pre-reloc;
+   bootph-all;
#clock-cells = <0>;
compatible = "fixed-clock";
clock-frequency = <6400>;
};
 
clk_lse: clk-lse {
-   u-boot,dm-pre-reloc;
+   bootph-all;
#clock-cells = <0>;
compatible = "fixed-clock";
clock-frequency = <32768>;
};
 
clk_lsi: clk-lsi {
-   u-boot,dm-pre-reloc;
+   bootph-all;
#clock-cells = <0>;
compatible = "fixed-clock";
clock-frequency = <32000>;
};
 
clk_csi: clk-csi {
-   u-boot,dm-pre-reloc;
+   bootph-all;
#clock-cells = <0>;
compatible = "fixed-clock";
clock-frequency = <400>;
@@ -292,7 +292,7 @@ Example of clock tree initialization
soc {
 
rcc: rcc@5000 {
-   u-boot,dm-pre-reloc;
+   bootph-all;
compatible = "st,stm32mp1-rcc", "syscon";
reg = <0x5000 0x1000>;
#address-cells = <1>;
@@ -371,7 +371,7 @@ Example of clock tree initialization
reg = <0>;
cfg = < 2 80 0 0 0 PQR(1,0,0) >;
frac = < 0x800 >;
-

[PATCH v5 08/11] checkpatch: Add a warning for pre-schema driver model tags

2023-02-13 Thread Simon Glass
Help ensure that these don't creep into development by adding a check in
checkpatch for them.

Signed-off-by: Simon Glass 
---

(no changes since v3)

Changes in v3:
- Add a new patch to warn about pre-schema driver model tags

 scripts/checkpatch.pl   | 6 ++
 tools/patman/test_checkpatch.py | 6 ++
 2 files changed, 12 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index ccfcbb3e125..62b764f6c38 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2680,6 +2680,12 @@ sub u_boot_line {
"DEVICE_PRIV_AUTO", $herecurr);
u_boot_struct_name($line, "per_device_plat_auto", "_plat",
"DEVICE_PLAT_AUTO", $herecurr);
+
+   # Avoid using the pre-schema driver model tags
+   if ($line =~ /^\+.*u-boot,dm-.*/) {
+   ERROR("PRE_SCHEMA",
+ "Driver model schema uses 'bootph-...' tags now\n" . 
$herecurr);
+   }
 }
 
 sub exclude_global_initialisers {
diff --git a/tools/patman/test_checkpatch.py b/tools/patman/test_checkpatch.py
index 4c2ab6e590e..a8bb364e42b 100644
--- a/tools/patman/test_checkpatch.py
+++ b/tools/patman/test_checkpatch.py
@@ -452,6 +452,12 @@ index 000..2234c87
 self.check_strl("cat");
 self.check_strl("cpy");
 
+def test_schema(self):
+"""Check for uses of strn(cat|cpy)"""
+pm = PatchMaker()
+pm.add_line('arch/sandbox/dts/sandbox.dtsi', '\tu-boot,dm-pre-proper;')
+self.check_single_message(pm, 'PRE_SCHEMA', 'error')
+
 if __name__ == "__main__":
 unittest.main()
 gitutil.RunTests()
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v5 10/11] test: Add a way to set the environment for a pytest

2023-02-13 Thread Simon Glass
This is useful when we need to control a particular environment variable.
Add a way to handle this.

Signed-off-by: Simon Glass 
---

(no changes since v4)

Changes in v4:
- Add new patch with a way to set the environment for a pytest

 test/py/multiplexed_log.py | 5 +++--
 test/py/u_boot_utils.py| 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/test/py/multiplexed_log.py b/test/py/multiplexed_log.py
index 5e79075f2e6..63237594bb4 100644
--- a/test/py/multiplexed_log.py
+++ b/test/py/multiplexed_log.py
@@ -111,7 +111,7 @@ class RunAndLog(object):
 """Clean up any resources managed by this object."""
 pass
 
-def run(self, cmd, cwd=None, ignore_errors=False, stdin=None):
+def run(self, cmd, cwd=None, ignore_errors=False, stdin=None, env=None):
 """Run a command as a sub-process, and log the results.
 
 The output is available at self.output which can be useful if there is
@@ -126,6 +126,7 @@ class RunAndLog(object):
 or exits with an error code, otherwise an exception will be
 raised if such problems occur.
 stdin: Input string to pass to the command as stdin (or None)
+env: Environment to use, or None to use the current one
 
 Returns:
 The output as a string.
@@ -139,7 +140,7 @@ class RunAndLog(object):
 try:
 p = subprocess.Popen(cmd, cwd=cwd,
 stdin=subprocess.PIPE if stdin else None,
-stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env)
 (stdout, stderr) = p.communicate(input=stdin)
 if stdout is not None:
 stdout = stdout.decode('utf-8')
diff --git a/test/py/u_boot_utils.py b/test/py/u_boot_utils.py
index c4fc23aeda3..9e161fbc238 100644
--- a/test/py/u_boot_utils.py
+++ b/test/py/u_boot_utils.py
@@ -157,7 +157,7 @@ def wait_until_file_open_fails(fn, ignore_errors):
 return
 raise Exception('File can still be opened')
 
-def run_and_log(u_boot_console, cmd, ignore_errors=False, stdin=None):
+def run_and_log(u_boot_console, cmd, ignore_errors=False, stdin=None, 
env=None):
 """Run a command and log its output.
 
 Args:
@@ -170,6 +170,7 @@ def run_and_log(u_boot_console, cmd, ignore_errors=False, 
stdin=None):
 an error code, otherwise an exception will be raised if such
 problems occur.
 stdin: Input string to pass to the command as stdin (or None)
+env: Environment to use, or None to use the current one
 
 Returns:
 The output as a string.
@@ -177,7 +178,7 @@ def run_and_log(u_boot_console, cmd, ignore_errors=False, 
stdin=None):
 if isinstance(cmd, str):
 cmd = cmd.split()
 runner = u_boot_console.log.get_runner(cmd[0], sys.stdout)
-output = runner.run(cmd, ignore_errors=ignore_errors, stdin=stdin)
+output = runner.run(cmd, ignore_errors=ignore_errors, stdin=stdin, env=env)
 runner.close()
 return output
 
-- 
2.39.1.581.gbfd45094c4-goog



[PATCH v5 02/11] dm: Add support for handling old u-boot,dm- tags

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

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

Signed-off-by: Simon Glass 
Version 4:
Acked-by: Michal Simek 
---

Changes in v5:
- Move this patch earlier in the series and make it additive

Changes in v4:
- Add a way to support handling old u-boot,dm- tags

 common/board_r.c  |  7 +++
 drivers/core/ofnode.c | 12 
 dts/Kconfig   | 10 ++
 include/asm-generic/global_data.h |  4 
 scripts/Makefile.lib  | 23 +--
 5 files changed, 50 insertions(+), 6 deletions(-)

diff --git a/common/board_r.c b/common/board_r.c
index e45003353f7..6b4180b3ecd 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -569,6 +569,13 @@ static int dm_announce(void)
printf("Warning: Unexpected devicetree source (not from 
a prior stage)");
printf("Warning: U-Boot may not function properly\n");
}
+   if (IS_ENABLED(CONFIG_OF_TAG_MIGRATE) &&
+   (gd->flags & GD_FLG_OF_TAG_MIGRATE))
+   /*
+* U-Boot will silently fail to work after 2023.07 if
+* there are old tags present
+*/
+   printf("Warning: Device tree includes old 'u-boot,dm-' 
tags: please fix by 2023.07!\n");
}
 
return 0;
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index d08578e9c4f..5fdac2b6638 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -1330,6 +1330,18 @@ bool ofnode_pre_reloc(ofnode node)
ofnode_read_bool(node, "u-boot,dm-tpl"))
return true;
 
+   if (IS_ENABLED(CONFIG_OF_TAG_MIGRATE)) {
+   /* detect and handle old tags */
+   if (ofnode_read_bool(node, "u-boot,dm-pre-reloc") ||
+   ofnode_read_bool(node, "u-boot,dm-pre-proper") ||
+   ofnode_read_bool(node, "u-boot,dm-spl") ||
+   ofnode_read_bool(node, "u-boot,dm-tpl") ||
+   ofnode_read_bool(node, "u-boot,dm-vpl")) {
+   gd->flags |= GD_FLG_OF_TAG_MIGRATE;
+   return true;
+   }
+   }
+
return false;
 #endif
 }
diff --git a/dts/Kconfig b/dts/Kconfig
index 44cc6bf1f6f..deb865d4c28 100644
--- a/dts/Kconfig
+++ b/dts/Kconfig
@@ -342,6 +342,16 @@ config SPL_MULTI_DTB_FIT_USER_DEF_ADDR
   at compilation time. This is the address of this area. It must be
   aligned on 2-byte boundary.
 
+config OF_TAG_MIGRATE
+   bool "Ease migration from old device trees with u-boot,dm- tags"
+   default y
+   help
+ U-Boot moved over to use new tags to mark device tree nodes which need
+ to be processed in SPL, before relocation, etc. Enable this option to
+ detect old tags and handle them.
+
+ Note: This option will be removed after the 2023.07 release.
+
 config OF_SPL_REMOVE_PROPS
string "List of device tree properties to drop for SPL"
depends on SPL_OF_CONTROL
diff --git a/include/asm-generic/global_data.h 
b/include/asm-generic/global_data.h
index da17ac8cbc8..987fb66c17a 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -650,6 +650,10 @@ enum gd_flags {
 * @GD_FLG_FDT_CHANGED: Device tree change has been detected by tests
 */
GD_FLG_FDT_CHANGED = 0x10,
+   /**
+* @GD_FLG_OF_TAG_MIGRATE: Device tree has old u-boot,dm- tags
+*/
+   GD_FLG_OF_TAG_MIGRATE = 0x20,
 };
 
 #endif /* __ASSEMBLY__ */
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index ac45a884785..7b27224b5d4 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -585,24 +585,35 @@ cmd_mkimage = $(objtree)/tools/mkimage 
$(MKIMAGEFLAGS_$(@F)) -d $< $@ \
 # ---
 # Pass the original device tree file through fdtgrep twice. The first pass
 # removes any unwanted nodes (i.e. those which don't have the
-# 'u-boot,dm-pre-reloc' property and thus are not needed by SPL. The second
+# 'bootph-all' property and thus are not needed by SPL. The second
 # pass removes various unused properties from the remaining nodes.
 # The output is typically a much smaller device tree file.
+
+ifdef CONFIG_OF_TAG_MIGRATE
+# Support the old tags for a migration period
+migrate_tpl := -b u-boot,dm-pre-reloc -b u-boot,dm-tpl
+migrate_vpl := -b u-boot,dm-pre-reloc -b u-boot,dm-vpl
+migrate_spl := -b u-boot,dm-pre-reloc -b u-boot,dm-spl
+migrate_all := -P u-boot,dm-pre-reloc \
+   -P u-boot,dm-spl -P u-boot,dm-tpl -P u-boot,dm-vpl
+endif
+
 ifeq ($(CONFIG_VPL_BUILD),y)
-fdtgrep_props := -b 

[PATCH v5 01/11] schemas: Add schema for U-Boot driver model 'phase tags'

2023-02-13 Thread Simon Glass
U-Boot has some particular challenges with device tree and devices:

- U-Boot has multiple build phases, such as a Secondary Program Loader
  (SPL) phase which typically runs in a pre-SDRAM environment where code
  and data space are limited. In particular, there may not be enough
  space for the full device tree blob. U-Boot uses various automated
  techniques to reduce the size from perhaps 40KB to 3KB. It is not
  always possible to handle these tags entirely at build time, since
  U-Boot proper must have the full device tree, even though we do not
  want it to process all nodes until after relocation.
- Some U-Boot phases needs to run before the clocks are properly set up,
  where the CPU may be running very slowly. Therefore it is important to
  bind only those devices which are actually needed in that phase
- U-Boot uses lazy initialisation for its devices, with 'bind' and
  'probe' being separate steps. Even if a device is bound, it is not
  actually probed until it is used. This is necessary to keep the boot
  time reasonable, e.g. to under a second

The phases of U-Boot in order are: TPL, VPL, SPL, U-Boot (first
pre-relocation, then post-relocation). ALl but the last two are optional.

For the above reasons, U-Boot only includes the full device tree in the
final 'U-Boot proper' build. Even then, before relocation U-Boot only
processes nodes which are marked as being needed.

For this to work, U-Boot's driver model[1] provides a way to mark device
tree nodes as applicable for a particular phase. This works by adding a
tag to the node, e.g.:

   cru: clock-controller@ff76 {
  bootph-all;
  compatible = "rockchip,rk3399-cru";
  reg = <0x0 0xff76 0x0 0x1000>;
  rockchip,grf = <>;
  #clock-cells = <1>;
  #reset-cells = <1>;
  ...
   };

Here the "bootph-all" tag indicates that the node must be present in all
phases, since the clock driver is required.

There has been discussion over the years about whether this could be done
in a property instead, e.g.

   options {
  bootph-all = <> <_a> ...;
  ...
   };

Some problems with this:

- we need to be able to merge several such tags from different .dtsi files
  since many boards have their own specific requirements
- it is hard to find and cross-reference the affected nodes
- it is more error-prone
- it requires significant tool rework in U-Boot, including fdtgrep and
  the build system
- is harder (slower, more code) to process since it involves scanning
  another node/property to find out what to do with a particular node
- we don't want to add phandle arguments to the above since we are
  referring, e.g., to the clock device as a whole, not a paricular clock
- the of-platdata feature[2], which converts device tree to C for even
  more constrained environments, would need to become aware of the
  /options node

There is also the question about whether this needs to be U-Boot-specific,
or whether the tags could be generic. From what I can tell, U-Boot is the
only bootloader which seriously attempts to use a runtime device tree in
all cases. For this version, an attempt is made to name the phases in a
generic manner.

It should also be noted that the approach provided here has stood the test
of time, used in U-Boot for 8 years so far.

So add the schema for this. This will allow a major class of schema
exceptions to be dropped from the U-Boot source tree.

This has been applied upstream[3]

[1] https://u-boot.readthedocs.io/en/latest/develop/driver-model/index.html
[2] https://u-boot.readthedocs.io/en/latest/develop/driver-model/of-plat.html
[3] https://github.com/devicetree-org/dt-schema/commit/63bd847

Signed-off-by: Simon Glass 
---

(no changes since v2)

Changes in v2:
- Add binding document

 doc/device-tree-bindings/bootph.yaml | 88 
 1 file changed, 88 insertions(+)
 create mode 100644 doc/device-tree-bindings/bootph.yaml

diff --git a/doc/device-tree-bindings/bootph.yaml 
b/doc/device-tree-bindings/bootph.yaml
new file mode 100644
index 000..a3ccf06efa7
--- /dev/null
+++ b/doc/device-tree-bindings/bootph.yaml
@@ -0,0 +1,88 @@
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright 2022 Google LLC
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/bootph.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Boot-phase-specific device nodes
+
+maintainers:
+  - Simon Glass 
+
+description: |
+  Some programs run in memory-constrained environments yet want to make use
+  of device tree.
+
+  The full device tree is often quite large relative to the available memory
+  of a boot phase, so cannot fit into every phase of the boot process. Even
+  when memory is not a problem, some phases may wish to limit which device
+  nodes are present, so as to reduce execution time.
+
+  This binding supports adding tags to device tree nodes to allow them to be
+  marked according to the phases where they should be included.
+
+  Without any tags, nodes are included 

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

2023-02-13 Thread Akash Gajjar
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
- 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

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

 arch/arm/dts/Makefile   |   3 +-
 arch/arm/dts/rk3568-rock-3a-u-boot.dtsi |  24 +
 arch/arm/dts/rk3568-rock-3a.dts | 609 
 configs/rock-3a-rk3568_defconfig|  74 +++
 4 files changed, 709 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 d9b719f85d..7c28418c82 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 = 
+   u-boot,spl-boot-order = "same-as-spl", 
+   };
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   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 = <_dcin>;
+   };
+
+   vcc5v0_sys: vcc5v0-sys-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc5v0_sys";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   vin-supply = <_dcin>;
+   };
+
+   vcc5v0_usb: vcc5v0-usb-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc5v0_usb";
+   regulator-always-on;
+   regulator-boot-on;
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   vin-supply = <_dcin>;
+   };
+
+   vcc5v0_usb_host: vcc5v0-usb-host-regulator {
+   compatible = "regulator-fixed";
+   enable-active-high;
+   gpio = < RK_PA6 GPIO_ACTIVE_HIGH>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_usb_host_en>;
+   regulator-name = "vcc5v0_usb_host";
+   regulator-min-microvolt = <500>;
+ 

[PATCH v3 0/1] Add Radxa ROCK 3 Model A support in U-boot.

2023-02-13 Thread Akash Gajjar
ROCK 3 Model A is rk3568 based soc board from Radxa, Add board support in 
u-boot. Booting logs is accessible at https://paste.ubuntu.com/p/v9BNrB7MdM/

Akash Gajjar (1):
  arm64: dts: rockchip: rk3568: Add Radxa ROCK 3 Model A board support

 arch/arm/dts/Makefile   |   3 +-
 arch/arm/dts/rk3568-rock-3a-u-boot.dtsi |  24 +
 arch/arm/dts/rk3568-rock-3a.dts | 609 
 configs/rock-3a-rk3568_defconfig|  74 +++
 4 files changed, 709 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

-- 
2.25.1



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

2023-02-13 Thread Tom Rini
On Sun, Feb 12, 2023 at 05:57:35PM -0600, Adam Ford wrote:

> Beacon Embedded has an i.MX8M Plus development kit which consists
> of a SOM + baseboard.  The SOM includes Bluetooth, WiFi, QSPI, eMMC,
> and one Ethernet PHY. The baseboard includes audio, HDMI, USB-C Dual
> Role port, USB Hub with five ports, a PCIe slot, and a second Ethernet
> PHY.  The device trees are already queued for inclusion in Linux 6.3.
> 
> Signed-off-by: Adam Ford 
[snip]
> diff --git a/board/beacon/imx8mp/imx8mp_beacon.env 
> b/board/beacon/imx8mp/imx8mp_beacon.env
> new file mode 100644
> index 00..ba9f1e462f
> --- /dev/null
> +++ b/board/beacon/imx8mp/imx8mp_beacon.env
> @@ -0,0 +1,29 @@
> +arch=arm
> +baudrate=115200
> +board=imx8mp
> +board_name=imx8mp

You don't need to specify the variables that will be set via
include/env_default.h (and if you see an example that is, whoops), just
what you normally would have put in CFG_EXTRA_ENV_SETTINGS. I see a few
more in here as well that should be pulled.

> diff --git a/doc/board/beacon/beacon-imx8mp.rst 
> b/doc/board/beacon/beacon-imx8mp.rst
> new file mode 100644
> index 00..375931c07d
> --- /dev/null
> +++ b/doc/board/beacon/beacon-imx8mp.rst
> @@ -0,0 +1,52 @@

I _think_ this is fine itself, but please run 'make htmldocs' (see
doc/build/documentation.rst for instructions) as I'm pretty sure you
didn't since this is a new directory and so index files need to be
updated too.

[snip]
> +++ b/include/configs/imx8mp_beacon.h
> @@ -0,0 +1,31 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * Copyright 2022 Logic PD, Inc dba Beacon EmbeddedWorks
> + */
> +
> +#ifndef __IMX8MP_BEACON_H
> +#define __IMX8MP_BEACON_H
> +
> +#include 
> +#include 
> +#include 

While I'm seeing it again, do we _really_ need these includes here?

> +#define CFG_SYS_UBOOT_BASE   (QSPI0_AMBA_BASE + 
> CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512)
> +
> +#if defined(CONFIG_CMD_NET)
> +#define PHY_ANEG_TIMEOUT 2
> +#endif
> +
> +/* Link Definitions */
> +
> +#define CFG_SYS_INIT_RAM_ADDR0x4000
> +#define CFG_SYS_INIT_RAM_SIZE0x8
> +
> +/* Totally 6GB DDR */
> +#define CFG_SYS_SDRAM_BASE   0x4000
> +#define PHYS_SDRAM   0x4000
> +#define PHYS_SDRAM_SIZE  0xC000  /* 3 GB */
> +#define PHYS_SDRAM_2 0x1
> +#define PHYS_SDRAM_2_SIZE0xC000  /* 3 GB */

And are all of these still, strictly, required? I can accept that they
are but it's good to confirm, as part of the CONFIG migration work I
saw a lot of seemingly not needed anymore defines in config header
files, and we're getting closer now to being able to make the file
optional.

-- 
Tom


signature.asc
Description: PGP signature


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

2023-02-13 Thread Adam Ford
On Sun, Feb 12, 2023 at 12:08 PM Tom Rini  wrote:
>
> On Sun, Feb 12, 2023 at 12:02:26PM -0600, Adam Ford wrote:
> > On Sun, Feb 12, 2023 at 11:47 AM Tom Rini  wrote:
> > >
> > > On Sun, Feb 12, 2023 at 11:36:38AM -0600, Adam Ford wrote:
> > >
> > > > Beacon Embedded has an i.MX8M Plus development kit which consists
> > > > of a SOM + baseboard.  The SOM includes Bluetooth, WiFi, QSPI, eMMC,
> > > > and one Ethernet PHY. The baseboard includes audio, HDMI, USB-C Dual
> > > > Role port, USB Hub with five ports, a PCIe slot, and a second Ethernet
> > > > PHY.  The device trees are already queued for inclusion in Linux 6.3.
> > > >
> > > > Signed-off-by: Adam Ford 
> > > [snip]
> > > > diff --git a/board/beacon/imx8mp/README b/board/beacon/imx8mp/README
> > > > new file mode 100644
> > > > index 00..47999bb038
> > > > --- /dev/null
> > > > +++ b/board/beacon/imx8mp/README
> > >
> > > Our rST docs have gotten to the point I think where we should say no to
> > > new board README files, this belongs under doc/board/
> >
> > OK.  I'll work on that.
> >
> > >
> > > [snip]
> > > > +#define CFG_EXTRA_ENV_SETTINGS   \
> > > > + "scriptaddr=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
> > > > + "kernel_addr_r=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
> > > > + "image=Image\0" \
> > > > + "console=ttymxc1,115200\0" \
> > > > + "fdt_addr_r=0x4300\0"   \
> > > > + "fdt_addr=0x4300\0" \
> > > > + "boot_fdt=try\0" \
> > > > + "boot_fit=no\0" \
> > > > + "fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \
> > > > + "bootm_size=0x1000\0" \
> > > > + "mmcdev=1\0" \
> > > > + "mmcpart=1\0" \
> > > > + "optargs=audit=0 video=LVDS-1:d video=LVDS-2:d\0" \
> > > > + "finduuid=part uuid mmc ${mmcdev}:2 uuid\0" \
> > > > + "mmcargs=setenv bootargs console=${console} " \
> > > > + " root=PARTUUID=${uuid} rootwait rw ${mtdparts} ${optargs}\0" \
> > > > + "bootscript=echo Running bootscript from mmc ...; " \
> > > > + "source\0" \
> > > > + "loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} 
> > > > ${image}\0" \
> > > > + "loadfdt=echo ${fdt_file}; fatload mmc ${mmcdev}:${mmcpart} 
> > > > ${fdt_addr_r} ${fdt_file}\0" \
> > > > + "mmcboot=echo Booting from mmc ...; " \
> > > > + "run finduuid; run mmcargs; " \
> > > > + "if test ${boot_fit} = yes || test ${boot_fit} = try; 
> > > > then " \
> > > > + "bootm ${loadaddr}; " \
> > > > + "else " \
> > > > + "if run loadfdt; then " \
> > > > + "booti ${loadaddr} - ${fdt_addr_r}; " \
> > > > + "else " \
> > > > + "echo WARN: Cannot load the DT; " \
> > > > + "fi; " \
> > > > + "fi;\0" \
> > > > + "netargs=setenv bootargs ${jh_clk} console=${console} " \
> > > > + "root=/dev/nfs " \
> > > > + "ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \
> > > > + "netboot=echo Booting from net ...; " \
> > > > + "run netargs;  " \
> > > > + "if test ${ip_dyn} = yes; then " \
> > > > + "setenv get_cmd dhcp; " \
> > > > + "else " \
> > > > + "setenv get_cmd tftp; " \
> > > > + "fi; " \
> > > > + "${get_cmd} ${loadaddr} ${image}; " \
> > > > + "if test ${boot_fit} = yes || test ${boot_fit} = try; 
> > > > then " \
> > > > + "bootm ${loadaddr}; " \
> > > > + "else " \
> > > > + "if ${get_cmd} ${fdt_addr_r} ${fdt_file}; then " \
> > > > + "booti ${loadaddr} - ${fdt_addr_r}; " \
> > > > + "else " \
> > > > + "echo WARN: Cannot load the DT; " \
> > > > + "fi; " \
> > > > + "fi;\0"
> > >
> > > And this should all be plain text environment (see board/*/*/*.env for
> >
> > I didn't even know this was a thing, but after reviewing what others
> > are doing, I like this much better.
>
> That's good to hear.
>
> > > examples), and please put it somewhere on your TODO list to migrate
> > > other platforms README and environments, thanks!
> >
> > Is there a deadline?
>
> Neither has a firm deadline at this point, thanks!

Tom,

I pushed a V2 and CC'd you.  If you're OK with both the env file and
the rst file for this board, I'll do the same thing for the other
Beacon and LogicPD boards.  I just don't want to do the work until I
know my first attempt at these new files is acceptable.

Thanks,

adam
>
> --
> Tom


Re: U-boot not loading NVMe driver on Pi CM4

2023-02-13 Thread Stefan Roese

Hi Ignatius,

On 2/10/23 17:05, Simon Glass wrote:

Hi Ignatius,

On Thu, 9 Feb 2023 at 17:29, Ignatius Rivaldi  wrote:


Added more debug logging and for some reason the nvme driver tries to bind
to pcie root bridge instead of the SSD
drivers/pinctrl/pinctrl-uclass.c:300-pinctrl_select_state_simple()
pcie_brcm pcie@7d50: set_state_simple op missing
PCIe BRCM: link up, 5.0 Gbps x1 (SSC)
drivers/core/device.c:184-  device_bind_common() Bound device pci_0:0.0 to
pcie@7d50
drivers/core/uclass.c:338-uclass_find_device_by_seq() 0
drivers/core/uclass.c:346-uclass_find_device_by_seq()- 0 'gpio@7e20'

drivers/core/uclass.c:349-uclass_find_device_by_seq()- found
drivers/pinctrl/pinctrl-uclass.c:300-pinctrl_select_state_simple()
pci_bridge_drv pci_0:0.0: set_state_simple op missing
drivers/core/device.c:184-  device_bind_common() Bound device nvme#0 to
pci_0:0.0
U-Boot> pci
DEBUG.driver-model,drivers/core/uclass.c:338-uclass_find_device_by_seq() 0
DEBUG.driver-model,drivers/core/uclass.c:346-uclass_find_device_by_seq()
- 0 'pcie@7d50'
DEBUG.driver-model,drivers/core/uclass.c:349-uclass_find_device_by_seq()
- found
BusDevFun  VendorId   DeviceId   Device Class   Sub-Class
_
00.00.00   0x14e4 0x2711 Bridge device   0x04
DEBUG.driver-model,drivers/core/uclass.c:338-uclass_find_device_by_seq() 1
DEBUG.driver-model,drivers/core/uclass.c:346-uclass_find_device_by_seq()
- 0 'pcie@7d50'
DEBUG.driver-model,drivers/core/uclass.c:346-uclass_find_device_by_seq()
- 1 'pci_0:0.0'
DEBUG.driver-model,drivers/core/uclass.c:349-uclass_find_device_by_seq()
- found
01.00.00   0x1e0f 0x0001 Mass storage controller 0x08
DEBUG.driver-model,drivers/core/uclass.c:338-uclass_find_device_by_seq() 2
DEBUG.driver-model,drivers/core/uclass.c:346-uclass_find_device_by_seq()
- 0 'pcie@7d50'
DEBUG.driver-model,drivers/core/uclass.c:346-uclass_find_device_by_seq()
- 1 'pci_0:0.0'
DEBUG.driver-model,drivers/core/uclass.c:353-uclass_find_device_by_seq()
- not found

It should be pci_1:0.0 I think

On Thu, Feb 9, 2023 at 11:22 AM Ignatius Rivaldi 
wrote:


(please try not to top post)

I don't know what is going on here. The PCI scan seems to show the
wrong device, as you say. Perhaps it is a bug in the bcm controller
driver?

+Michal Suchanek
+Stefan Roese


I've not used the NVMe driver in U-Boot yet, but at least the PCI class
and subclass ID seem to be fine AFAIT:

class code =  0x01 (Mass storage controller)
sub class code =  0x08
programming interface =   0x02

Are other PCI drivers probed correctly, if you can test this on your
board? E.g. an Intel E1000 PCIe board perhaps?

Added Bin, perhaps he has some further ideas.

Thanks,
Stefan



Regards,
SImon





Hi all,

I'm using U-boot 2022.07 from Yocto Langdale distribution, with the
following NVMe related kconfigs manually enabled through menuconfig:

CONFIG_NVME
CONFIG_NVME_PCI
CONFIG_CMD_NVME

and logging turned into max

The SSD is Kioxia SSD, and it works with Pi 4 bootloader as I can boot
Raspberry Pi OS from the NVMe drive.

U boot is installed in the fat32 partition in the NVMe SSD for this Yocto
poky build.

When I boot to U boot prompt, I can see that the SSD is detected by pci
U-Boot> pci long
0
   - 0 'pcie@7d50'
   - found

Found PCI device 00.00.00:
  vendor ID =   0x14e4
  device ID =   0x2711
  command register ID = 0x0006
  status register = 0x0010
  revision ID = 0x20
  class code =  0x06 (Bridge device)
  sub class code =  0x04
  programming interface =   0x00
  cache line =  0x08
  latency time =0x00
  header type = 0x01
  BIST =0x00
  base address 0 =  0x
  base address 1 =  0x
  primary bus number =  0x00
  secondary bus number =0x01
  subordinate bus number =  0x01
  secondary latency timer = 0x00
  IO base = 0x00
  IO limit =0x00
  secondary status =0x
  memory base = 0xc000
  memory limit =0xc000
  prefetch memory base =0xfff1
  prefetch memory limit =   0x0001
  prefetch memory base upper =  0x
  prefetch memory limit upper = 0x
  IO base upper 16 bits =   0x
  IO limit upper 16 bits =  0x
  expansion ROM base address =  0x
  interrupt line =  0x00
  interrupt pin =   0x01
  bridge control =  0x
1
   - 0 'pcie@7d50'
   - 1 'pci_0:0.0'
   - found

Found PCI device 01.00.00:
  vendor ID =   0x1e0f
  device ID =   0x0001
  command register ID = 0x0006
  status register = 0x0010
  revision ID = 0x00
  class 

Please pull u-boot-i2c

2023-02-13 Thread Heiko Schocher
Hello Tom,

please pull from u-boot-i2c:

The following changes since commit a5e490f14e904fd240ccec5d364509b36a3150f9:

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

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-i2c.git 
tags/i2c-updates-for-v2023.04

for you to fetch changes up to f536fda99fa2c1c88f68d8da54ed6233cec3532e:

  i2c: i2c-cdns.c: Update driver to read fifo-depth from device tree 
(2023-02-13 09:58:27 +0100)


i2c updates for v2023.04

- add new i2c driver ast2600 from Ryan Chen

- i2c-cdns: make read fifo-depth configurable through device tree
  from Pei Yue Ho

- mxc i2c driver: print base address in hex, not in decimal
  from Fabio


Fabio Estevam (1):
  i2c: mxc_i2c: Use hex notation for the base address

Pei Yue Ho (2):
  dt-bindings: i2c: i2c-cdns.txt: Add description for an optional 
parameter, fifo-depth
  i2c: i2c-cdns.c: Update driver to read fifo-depth from device tree

Ryan Chen (2):
  i2c:aspeed:support ast2600 i2c new register mode driver
  arm: aspeed: dtsi: add reg for i2c

 MAINTAINERS   |   6 +++
 arch/arm/dts/ast2600.dtsi |   1 +
 doc/device-tree-bindings/i2c/i2c-cdns.txt |   4 ++
 drivers/i2c/Kconfig   |  10 
 drivers/i2c/Makefile  |   1 +
 drivers/i2c/ast2600_i2c.c | 366

 drivers/i2c/ast2600_i2c.h | 120 
++
 drivers/i2c/i2c-cdns.c|  30 +++-
 drivers/i2c/mxc_i2c.c |   2 +-
 9 files changed, 527 insertions(+), 13 deletions(-)
 create mode 100644 drivers/i2c/ast2600_i2c.c
 create mode 100644 drivers/i2c/ast2600_i2c.h


Azure build is fine:

https://dev.azure.com/hs0298/hs/_build/results?buildId=101=results

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


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

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

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


Applied to u-boot-i2c.git master

bye,
Heiko

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


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

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

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

Applied to u-boot-i2c.git master

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


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

2023-02-13 Thread Heiko Schocher
Hello Ryan,

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


Applied to u-boot-i2c.git master

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


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

2023-02-13 Thread Heiko Schocher
Hello Ryan,

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


Applied to u-boot-i2c.git master

bye,
Heiko

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


Re: [PATCH] i2c: mxc_i2c: Use hex notation for the base address

2023-02-13 Thread Heiko Schocher
Hello Fabio,

On 03.01.23 20:03, Fabio Estevam wrote:
> Printing the I2C controller base address in decimal notation
> is not helpful.
> 
> Change it to hex notation, which is the standard format found
> in the Reference Manual and devicetree.
> 
> Signed-off-by: Fabio Estevam 
> Acked-by: Dhruva Gole 
> Reviewed-by: Heiko Schocher 
> ---
>  drivers/i2c/mxc_i2c.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied to u-boot-i2c.git master

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


Re: [PATCH v2 2/2] samsung: common: do not reset if cros-ec uclass is missing

2023-02-13 Thread Simon Glass
On Mon, 13 Feb 2023 at 01:08, Henrik Grimler  wrote:
>
> Otherwise non-ChromeOS samsung devices, like the odroid boards, are
> stuck in a bootloop if CONFIG_CROS_EC is not enabled:
>
> <...>
> MMC: SAMSUNG SDHCI: 2, EXYNOS DWMMC: 0
> Loading Environment from MMC... *** Warning - bad CRC, using default 
> environment
>
> cros-ec communications failure -96
>
> Please reset with Power+Refresh
>
> Cannot init cros-ec device
> resetting ...
>
> Issue started after commit e44d7e73fe0d ("dm: core: Switch
> uclass_*_device_err to use uclass_*_device_check").
>
> Signed-off-by: Henrik Grimler 
> ---
>  board/samsung/common/board.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass 


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

2023-02-13 Thread Simon Glass
Hi Michal,

On Mon, 13 Feb 2023 at 00:53, Michal Simek  wrote:
>
>
>
> On 2/12/23 18:44, Tom Rini wrote:
> > On Fri, Feb 10, 2023 at 08:28:56AM -0700, Simon Glass wrote:
> >
> >> Add a CONFIG option to deal with this automatically, printing a warning
> >> when U-Boot starts up. This can be useful if the device tree comes from
> >> another project.
> >>
> >> We will maintain this through the 2023.07 release, providing 6 months
> >> for people to notice.
> >>
> >> Signed-off-by: Simon Glass 
> >
> > Adding Michal since he got lost by accident on this iteration. Does that
> > sound like enough time to get the tooling you know of updated?
> >
>
> This patch makes sense to me and provide good migration path. Thanks!
>
> In connection to have tree working all the time for bisecting reasons I think
> the whole series should be a little bit rearranged and this shouldn't be the
> patch 10/11 but very early.
> But I will let Tom to decide if this should be rearranged or not.
>
> Acked-by: Michal Simek 

With a bit of fiddling I think that is possible. I will send a v5.

Regards,
Simon


[PATCH v1] mtd: nand: raw: rockchip_nfc: fix oobfree offset and description

2023-02-13 Thread Johan Jonker
The MTD framework reserves 1 or 2 bytes for the bad block marker
depending on the bus size. The rockchip_nfc driver currently only
supports a 8 bit bus, but reserves standard 2 bytes for the BBM.
The first free OOB byte is therefore OOB2 at offset 2.
Page address(PA) bytes are moved to the last 4 positions before
ECC. Update the description for U-boot.

Signed-off-by: Johan Jonker 
---

Note:
  Merge after serie:
[PATCH v2 00/10] Fixes for Rockchip NFC driver part 1
---
 drivers/mtd/nand/raw/rockchip_nfc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/raw/rockchip_nfc.c 
b/drivers/mtd/nand/raw/rockchip_nfc.c
index 9e3a2533..bcab219b 100644
--- a/drivers/mtd/nand/raw/rockchip_nfc.c
+++ b/drivers/mtd/nand/raw/rockchip_nfc.c
@@ -487,10 +487,10 @@ static int rk_nfc_write_page_raw(struct mtd_info *mtd,
 *
 *BBM  OOB1 OOB2 OOB3 |..|  PA0  PA1  PA2  PA3
 *
-* The rk_nfc_ooblayout_free() function already has reserved
-* these 4 bytes with:
+* The oobfree structure already has reserved these 4 bytes
+* together with 2 bytes for BBM by reducing it's length:
 *
-* oob_region->offset = NFC_SYS_DATA_SIZE + 2;
+* oobfree[0].length = rknand->metadata_size - 
NFC_SYS_DATA_SIZE - 2;
 */
if (!i)
memcpy(rk_nfc_oob_ptr(chip, i),
@@ -867,7 +867,7 @@ static int rk_nfc_ecc_init(struct rk_nfc *nfc, struct 
nand_chip *chip)
ecc->layout->eccpos[i] = rknand->metadata_size + i;

ecc->layout->oobfree[0].length = rknand->metadata_size - 
NFC_SYS_DATA_SIZE - 2;
-   ecc->layout->oobfree[0].offset = NFC_SYS_DATA_SIZE + 2;
+   ecc->layout->oobfree[0].offset = 2;

return 0;
 }
--
2.20.1



Please pull u-boot-marvell/master

2023-02-13 Thread Stefan Roese

Hi Tom,

please pull this next batch of Marvell related patches.


- mvebu: Support for 2 new Armada 385 boards (Tony)
- mvebu: Minor misc board enhancements (Tony)
- kirkwood: Serial driver fixes (Kconfig & dtsi) (Tony)
- cmd: return code when tlv_eeprom incorrectly called (Heinrich)


Here the Azure build, without any issues:

https://dev.azure.com/sr0718/u-boot/_build/results?buildId=284=results

Thanks,
Stefan

The following changes since commit a5e490f14e904fd240ccec5d364509b36a3150f9:

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

are available in the Git repository at:

  g...@source.denx.de:u-boot/custodians/u-boot-marvell.git

for you to fetch changes up to dd15284b749e41a3db94883bde9b96601491ec10:

  arm: kirkwood: Enable uart0 dm-pre-reloc for Pogoplug V4 board 
(2023-02-13 10:15:04 +0100)



Heinrich Schuchardt (1):
  cmd: return code when tlv_eeprom incorrectly called

Tony Dinh (6):
  arm: kirkwood: Use CONFIG_SYS_NS16550 with DM_SERIAL for Kirkwood 
boards

  arm: mvebu: Add support for Thecus N2350 (Armada 385) board
  arm: kirkwood: sheevaplug: reduce u-boot image size
  arm: mvebu: Power up 2nd SATA port for Thecus N2350
  arm: mvebu: Add support for Synology DS116 (Armada 385)
  arm: kirkwood: Enable uart0 dm-pre-reloc for Pogoplug V4 board

 arch/arm/dts/Makefile  |   2 +
 arch/arm/dts/armada-385-synology-ds116.dts | 291 ++
 arch/arm/dts/armada-385-thecus-n2350.dts   | 446 
+

 .../arm/dts/kirkwood-pogoplug-series-4-u-boot.dtsi |   7 +
 arch/arm/mach-kirkwood/Kconfig |   1 +
 arch/arm/mach-mvebu/Kconfig|  18 +
 board/Synology/ds116/MAINTAINERS   |   7 +
 board/Synology/ds116/Makefile  |   6 +
 board/Synology/ds116/ds116.c   | 135 +++
 board/thecus/n2350/MAINTAINERS |   7 +
 board/thecus/n2350/Makefile|   6 +
 board/thecus/n2350/n2350.c | 126 ++
 cmd/tlv_eeprom.c   |  11 +-
 configs/ds116_defconfig|  92 +
 configs/n2350_defconfig|  93 +
 configs/sheevaplug_defconfig   |   5 +
 include/configs/ds116.h|  56 +++
 include/configs/n2350.h|  56 +++
 18 files changed, 1358 insertions(+), 7 deletions(-)
 create mode 100644 arch/arm/dts/armada-385-synology-ds116.dts
 create mode 100644 arch/arm/dts/armada-385-thecus-n2350.dts
 create mode 100644 arch/arm/dts/kirkwood-pogoplug-series-4-u-boot.dtsi
 create mode 100644 board/Synology/ds116/MAINTAINERS
 create mode 100644 board/Synology/ds116/Makefile
 create mode 100644 board/Synology/ds116/ds116.c
 create mode 100644 board/thecus/n2350/MAINTAINERS
 create mode 100644 board/thecus/n2350/Makefile
 create mode 100644 board/thecus/n2350/n2350.c
 create mode 100644 configs/ds116_defconfig
 create mode 100644 configs/n2350_defconfig
 create mode 100644 include/configs/ds116.h
 create mode 100644 include/configs/n2350.h


Re: [PATCH] arm: mvebu: Add support for Synology DS116 (Armada 385)

2023-02-13 Thread Stefan Roese

On 2/9/23 23:00, Tony Dinh wrote:

Synology DS116 is a NAS based on Marvell Armada 385 SoC.

Board Specification:

- Marvel MV88F6820 Dual Core at 1.8GHz
- 1 GiB DDR3 RAM
- 8MB Macronix mx25l6405d SPI flash
- I2C
- 2x USB 3.0
- 1x GBE LAN port (PHY: Marvell 88E1510)
- 1x SATA (6 Gbps)
- 3x LED
- PIC16F1829 (connected to uart1)
- GPIO fan
- serial console

Note that this patch depends on the add-support for Thecus N2350 patch:
https://patchwork.ozlabs.org/project/uboot/patch/20230201231306.7010-1-mibo...@gmail.com/

Signed-off-by: Tony Dinh 


Applied to u-boot-marvell/master

Thanks,
Stefan


---

  arch/arm/dts/Makefile  |   1 +
  arch/arm/dts/armada-385-synology-ds116.dts | 291 +
  arch/arm/mach-mvebu/Kconfig|   7 +
  board/Synology/ds116/MAINTAINERS   |   7 +
  board/Synology/ds116/Makefile  |   6 +
  board/Synology/ds116/ds116.c   | 135 ++
  configs/ds116_defconfig|  92 +++
  include/configs/ds116.h|  56 
  8 files changed, 595 insertions(+)
  create mode 100644 arch/arm/dts/armada-385-synology-ds116.dts
  create mode 100644 board/Synology/ds116/MAINTAINERS
  create mode 100644 board/Synology/ds116/Makefile
  create mode 100644 board/Synology/ds116/ds116.c
  create mode 100644 configs/ds116_defconfig
  create mode 100644 include/configs/ds116.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index dee298228f..9d647b9639 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -247,6 +247,7 @@ dtb-$(CONFIG_ARCH_MVEBU) += \
armada-385-atl-x530.dtb \
armada-385-atl-x530DP.dtb   \
armada-385-db-88f6820-amc.dtb   \
+   armada-385-synology-ds116.dtb   \
armada-385-thecus-n2350.dtb \
armada-385-turris-omnia.dtb \
armada-388-clearfog.dtb \
diff --git a/arch/arm/dts/armada-385-synology-ds116.dts 
b/arch/arm/dts/armada-385-synology-ds116.dts
new file mode 100644
index 00..82a0373f7f
--- /dev/null
+++ b/arch/arm/dts/armada-385-synology-ds116.dts
@@ -0,0 +1,291 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Device Tree file for Synology DS116 NAS
+ *
+ * Copyright (C) 2017 Willy Tarreau 
+ */
+
+/dts-v1/;
+#include "armada-385.dtsi"
+#include 
+
+/ {
+   model = "Synology DS116";
+   compatible = "marvell,a385-gp", "marvell,armada385", 
"marvell,armada380";
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0x 0x4000>; /* 1 GB */
+   };
+
+   soc {
+   ranges = ;
+
+   internal-regs {
+   i2c@11000 {
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>;
+   status = "okay";
+   clock-frequency = <10>;
+
+   eeprom@57 {
+   compatible = "atmel,24c64";
+   reg = <0x57>;
+   };
+   };
+
+   serial@12000 {
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>;
+   status = "okay";
+   };
+
+   serial@12100 {
+   /* A PIC16F1829 is connected to uart1 at 9600 
bps,
+* and takes single-character orders :
+*   "1" : power off // already handled by the 
poweroff node
+*   "2" : short beep
+*   "3" : long beep
+*   "4" : turn the power LED ON
+*   "5" : flash the power LED
+*   "6" : turn the power LED OFF
+*   "7" : turn the status LED OFF
+*   "8" : turn the status LED ON
+*   "9" : flash the status LED
+*   "A" : flash the motherboard LED (D8)
+*   "B" : turn the motherboard LED OFF
+*   "C" : hard reset
+*/
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>;
+   status = "okay";
+   };
+
+   poweroff@12100 {
+   compatible = "synology,power-off";
+   reg = <0x12100 0x100>;
+   clocks = < 0>;
+   };
+
+

Re: [PATCH] arm: kirkwood: Enable uart0 dm-pre-reloc for Pogoplug V4 board

2023-02-13 Thread Stefan Roese

On 2/10/23 22:08, Tony Dinh wrote:

When DM_SERIAL is enabled, the device-tree tag u-boot,dm-pre-reloc is
required for this board to boot over UART with kwboot. Enable this in
kirkwood-pogoplug-series-4-u-boot.dtsi.

Signed-off-by: Tony Dinh 


Applied to u-boot-marvell/master

Thanks,
Stefan


---

  arch/arm/dts/kirkwood-pogoplug-series-4-u-boot.dtsi | 7 +++
  1 file changed, 7 insertions(+)
  create mode 100644 arch/arm/dts/kirkwood-pogoplug-series-4-u-boot.dtsi

diff --git a/arch/arm/dts/kirkwood-pogoplug-series-4-u-boot.dtsi 
b/arch/arm/dts/kirkwood-pogoplug-series-4-u-boot.dtsi
new file mode 100644
index 00..f9e127234c
--- /dev/null
+++ b/arch/arm/dts/kirkwood-pogoplug-series-4-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2023 Tony Dinh 
+ */
+ {
+   u-boot,dm-pre-reloc;
+};


Viele Grüße,
Stefan Roese

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


Re: [RESEND PATCH v2] arm: mvebu: Power up 2nd SATA port for Thecus N2350

2023-02-13 Thread Stefan Roese

On 2/7/23 02:00, Tony Dinh wrote:

Currently, only the 1st SATA port is powered up (by GPIO1 12).
Add GPIO1 13 in board initialization to power up the 2nd SATA port.

Note that this patch depends on the initial add-support patch:
https://patchwork.ozlabs.org/project/uboot/patch/20230201231306.7010-1-mibo...@gmail.com/

Signed-off-by: Tony Dinh 


Applied to u-boot-marvell/master

Thanks,
Stefan


---

Changes in v2:
- Use BIT macros to make it easier to see which GPIOs are used.
- Resent to correct missing BIT(0) in N2350_GPP_OUT_VAL_MID

  board/thecus/n2350/n2350.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/board/thecus/n2350/n2350.c b/board/thecus/n2350/n2350.c
index 4cfdfba662..fd8f95f944 100644
--- a/board/thecus/n2350/n2350.c
+++ b/board/thecus/n2350/n2350.c
@@ -24,8 +24,8 @@ DECLARE_GLOBAL_DATA_PTR;
  
  #define N2350_GPP_OUT_ENA_LOW	(~(BIT(20) | BIT(21) | BIT(24)))

  #define N2350_GPP_OUT_ENA_MID (~(BIT(12) | BIT(13) | BIT(16) | BIT(19) | 
BIT(22)))
-#define N2350_GPP_OUT_VAL_LOW  0x120
-#define N2350_GPP_OUT_VAL_MID  0x1001
+#define N2350_GPP_OUT_VAL_LOW  (BIT(21) | BIT(24))
+#define N2350_GPP_OUT_VAL_MID  (BIT(0) | BIT(12) | BIT(13))
  #define N2350_GPP_POL_LOW 0x0
  #define N2350_GPP_POL_MID 0x0
  


Viele Grüße,
Stefan Roese

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


Re: [PATCH] arm: kirkwood: sheevaplug: reduce u-boot image size

2023-02-13 Thread Stefan Roese

On 2/2/23 23:16, Tony Dinh wrote:

Sheevaplug board has 512K CONFIG_BOARD_SIZE_LIMIT. Recently, DM_SERIAL has
pushed the image size a few hundred bytes over that limit. So explicitly
deselect some configs that are unrelated to this board
(and gain back a bit over 2K).

Signed-off-by: Tony Dinh 


Applied to u-boot-marvell/master

Thanks,
Stefan


---

  configs/sheevaplug_defconfig | 5 +
  1 file changed, 5 insertions(+)

diff --git a/configs/sheevaplug_defconfig b/configs/sheevaplug_defconfig
index cb38a3fbd5..40ab16dfa0 100644
--- a/configs/sheevaplug_defconfig
+++ b/configs/sheevaplug_defconfig
@@ -26,6 +26,11 @@ CONFIG_USE_PREBOOT=y
  CONFIG_HUSH_PARSER=y
  CONFIG_SYS_MAXARGS=32
  CONFIG_CMD_BOOTZ=y
+# CONFIG_BOOTM_PLAN9 is not set
+# CONFIG_BOOTM_RTEMS is not set
+# CONFIG_BOOTM_VXWORKS is not set
+# CONFIG_CMD_IMI is not set
+# CONFIG_CMD_XIMG is not set
  # CONFIG_CMD_FLASH is not set
  CONFIG_CMD_MMC=y
  CONFIG_CMD_NAND=y


Viele Grüße,
Stefan Roese

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


Re: [PATCH v3] arm: mvebu: Add support for Thecus N2350 (Armada 385) board

2023-02-13 Thread Stefan Roese

On 2/2/23 00:13, Tony Dinh wrote:

Thecus N2350 is a NAS based on Marvell Armada 385 SoC.

Specification:

- Processor: Marvel MV88F6820 Dual Core at 1GHz
- 1 GiB DDR4 RAM
- 4MB Macronix mx25l3205d SPI flash
- 512MB Hynix H27U4G8F2DTR-BC NAND flash
- I2C
- 2x USB 3.0
- 1x GBE LAN port (PHY: Marvell 88E1510)
- 2x SATA (hot swap slots)
- 3x buttons
- 10x LEDS
- serial console

Signed-off-by: Tony Dinh 


Applied to u-boot-marvell/master

Thanks,
Stefan


---

Changes in v3:
- Add missing DTS file path in MAINTAINERS file
- Remove "common.h" in board file
- Remove CFG_I2C_MVTWSI_BASE0 in include header file
- Cleanup unecessary comments in include header file

Changes in v2:
- Use node pointers already defined from armada-38x.dtsi in this board DTS
- Remove extra compatible attributes in this board DTS
- Remove unnecessary armada-385-thecus-n2350-u-boot.dtsi
- Remove unnecessary check_board() function in board file
- Remove unnecessary "default false" for DDR4 in arch/arm/mach-mvebu/Kconfig
- Use "rootfs" as partition name for NAND partition
- Various DTS naming convention correction

  arch/arm/dts/Makefile|   1 +
  arch/arm/dts/armada-385-thecus-n2350.dts | 446 +++
  arch/arm/mach-mvebu/Kconfig  |  11 +
  board/thecus/n2350/MAINTAINERS   |   7 +
  board/thecus/n2350/Makefile  |   6 +
  board/thecus/n2350/n2350.c   | 126 +++
  configs/n2350_defconfig  |  93 +
  include/configs/n2350.h  |  56 +++
  8 files changed, 746 insertions(+)
  create mode 100644 arch/arm/dts/armada-385-thecus-n2350.dts
  create mode 100644 board/thecus/n2350/MAINTAINERS
  create mode 100644 board/thecus/n2350/Makefile
  create mode 100644 board/thecus/n2350/n2350.c
  create mode 100644 configs/n2350_defconfig
  create mode 100644 include/configs/n2350.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 3ecd6a86e9..c5d1825a3b 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -245,6 +245,7 @@ dtb-$(CONFIG_ARCH_MVEBU) += \
armada-385-atl-x530.dtb \
armada-385-atl-x530DP.dtb   \
armada-385-db-88f6820-amc.dtb   \
+   armada-385-thecus-n2350.dtb \
armada-385-turris-omnia.dtb \
armada-388-clearfog.dtb \
armada-388-gp.dtb   \
diff --git a/arch/arm/dts/armada-385-thecus-n2350.dts 
b/arch/arm/dts/armada-385-thecus-n2350.dts
new file mode 100644
index 00..fc29c4d25a
--- /dev/null
+++ b/arch/arm/dts/armada-385-thecus-n2350.dts
@@ -0,0 +1,446 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Device Tree file for Thecus N2350 board
+ *
+ * Copyright (C) 2018-2023 Tony Dinh 
+ * Copyright (C) 2018 Manuel Jung 
+ */
+
+/dts-v1/;
+#include 
+#include 
+#include "armada-385.dtsi"
+
+/ {
+   model = "Thecus N2350";
+   compatible = "thecus,n2350", "marvell,armada385";
+
+   aliases {
+   ethernet0 = 
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0x 0x4000>; /* 1GB */
+   };
+
+   soc {
+   ranges = ;
+
+   };
+
+   usb3_0_phy: usb3_0_phy {
+   compatible = "usb-nop-xceiv";
+   vcc-supply = <_0_power>;
+   };
+
+   usb3_1_phy: usb3_1_phy {
+   compatible = "usb-nop-xceiv";
+   vcc-supply = <_1_power>;
+   };
+
+   gpio-keys {
+   compatible = "gpio-keys";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   pinctrl-0 = <_power_button _copy_button 
_reset_button>;
+   pinctrl-names = "default";
+
+   button@1 {
+   label = "Power Button";
+   linux,code = ;
+   gpios = < 17 GPIO_ACTIVE_HIGH>;
+   };
+
+   button@2 {
+   label = "Copy Button";
+   linux,code = ;
+   gpios = < 20 GPIO_ACTIVE_HIGH>;
+   };
+
+   button@3 {
+   label = "Reset Button";
+   linux,code = ;
+   gpios = < 18 GPIO_ACTIVE_HIGH>;
+   };
+   };
+
+   gpio-leds {
+   compatible = "gpio-leds";
+   pinctrl-0 = <_sata1_white_led
+   _sata1_red_led
+   _sata2_white_led
+   _sata2_red_led
+   _sys_white_led
+   _sys_red_led
+   _pwr_blue_led
+   _pwr_red_led
+   _usb_white_led
+   _usb_red_led>;
+
+   

Re: [PATCH] arm: kirkwood: Use CONFIG_SYS_NS16550 with DM_SERIAL for Kirkwood boards

2023-02-13 Thread Stefan Roese

On 1/31/23 23:06, Tony Dinh wrote:

CONFIG_SYS_NS16550 is required when DM_SERIAL is enabled for
Kirkwood boards.

Signed-off-by: Tony Dinh 


Applied to u-boot-marvell/master

Thanks,
Stefan


---

  arch/arm/mach-kirkwood/Kconfig | 1 +
  1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig
index 45cc932636..b19ed2c6b3 100644
--- a/arch/arm/mach-kirkwood/Kconfig
+++ b/arch/arm/mach-kirkwood/Kconfig
@@ -15,6 +15,7 @@ config SHEEVA_88SV131
  config KIRKWOOD_COMMON
bool
select DM_SERIAL
+   select SYS_NS16550
  
  config HAS_CUSTOM_SYS_INIT_SP_ADDR

  bool "Use a custom location for the initial stack pointer address"


Viele Grüße,
Stefan Roese

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


Re: [PATCH] cmd: return code when tlv_eeprom incorrectly called

2023-02-13 Thread Stefan Roese

On 1/27/23 22:49, Heinrich Schuchardt wrote:

A command called with incorrect parameters should set $? to 1 (false).
Instead of calling cmd_usage(cmdtp) and then returning 0 just return
CMD_RET_FAILURE.

Signed-off-by: Heinrich Schuchardt 


Applied to u-boot-marvell/master

Thanks,
Stefan


---
  cmd/tlv_eeprom.c | 11 ---
  1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/cmd/tlv_eeprom.c b/cmd/tlv_eeprom.c
index bf8d453dc5..4591ff336b 100644
--- a/cmd/tlv_eeprom.c
+++ b/cmd/tlv_eeprom.c
@@ -479,17 +479,14 @@ int do_tlv_eeprom(struct cmd_tbl *cmdtp, int flag, int 
argc, char *const argv[])
show_tlv_devices();
break;
default:
-   cmd_usage(cmdtp);
-   break;
+   return CMD_RET_USAGE;
}
return 0;
}
  
  	// The set command takes one or two args.

-   if (argc > 4) {
-   cmd_usage(cmdtp);
-   return 0;
-   }
+   if (argc > 4)
+   return CMD_RET_USAGE;
  
  	// Set command. If the TLV exists in the EEPROM, delete it. Then if

// data was supplied for this TLV add the TLV with the new contents at
@@ -512,7 +509,7 @@ int do_tlv_eeprom(struct cmd_tbl *cmdtp, int flag, int 
argc, char *const argv[])
current_dev = devnum;
has_been_read = 0;
} else {
-   cmd_usage(cmdtp);
+   return CMD_RET_USAGE;
}
  
  	return 0;


Viele Grüße,
Stefan Roese

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


[PATCH] misc: imx: remove DM dependency for ocotp driver in SPL

2023-02-13 Thread Jean-Marie Lemetayer
The ocotp driver is available for regular and SPL builds using the
(SPL_)MXC_OCOTP configuration. Also, the ocotp driver does not support
the driver model (DM) configuration.

But, for SPL builds, the SPL_MXC_OCOTP configuration depends on
SPL_MISC which implies on SPL_DM.

This commit replaces the dependency on SPL_MISC with SPL_DRIVERS_MISC.
So the only requirement is to have enabled miscellaneous drivers for
the SPL.

Signed-off-by: Jean-Marie Lemetayer 
---

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

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index b07261d3db..1696ed62c0 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -352,7 +352,7 @@ config NPCM_HOST

 config SPL_MXC_OCOTP
bool "Enable MXC OCOTP driver in SPL"
-   depends on SPL_MISC && (ARCH_IMX8M || ARCH_MX6 || ARCH_MX7 || 
ARCH_MX7ULP || ARCH_VF610)
+   depends on SPL_DRIVERS_MISC && (ARCH_IMX8M || ARCH_MX6 || ARCH_MX7 || 
ARCH_MX7ULP || ARCH_VF610)
default y
help
  If you say Y here, you will get support for the One Time
--
2.34.1



[PATCH 1/2] clk: sunxi: add THS clk/reset

2023-02-13 Thread qianfanguijin
From: qianfan Zhao 

Add clock/reset definitions for THS peripherals.

Signed-off-by: qianfan Zhao 
---
 drivers/clk/sunxi/clk_h3.c  | 5 +
 drivers/clk/sunxi/clk_h6.c  | 4 
 drivers/clk/sunxi/clk_r40.c | 5 +
 3 files changed, 14 insertions(+)

diff --git a/drivers/clk/sunxi/clk_h3.c b/drivers/clk/sunxi/clk_h3.c
index 213ab510ed..774d67cbfa 100644
--- a/drivers/clk/sunxi/clk_h3.c
+++ b/drivers/clk/sunxi/clk_h3.c
@@ -38,6 +38,7 @@ static struct ccu_clk_gate h3_gates[] = {
[CLK_BUS_DE]= GATE(0x064, BIT(12)),
 
[CLK_BUS_PIO]   = GATE(0x068, BIT(5)),
+   [CLK_BUS_THS]   = GATE(0x068, BIT(8)),
 
[CLK_BUS_I2C0]  = GATE(0x06c, BIT(0)),
[CLK_BUS_I2C1]  = GATE(0x06c, BIT(1)),
@@ -49,6 +50,8 @@ static struct ccu_clk_gate h3_gates[] = {
 
[CLK_BUS_EPHY]  = GATE(0x070, BIT(0)),
 
+   [CLK_THS]   = GATE(0x074, BIT(31)),
+
[CLK_SPI0]  = GATE(0x0a0, BIT(31)),
[CLK_SPI1]  = GATE(0x0a4, BIT(31)),
 
@@ -98,6 +101,8 @@ static struct ccu_reset h3_resets[] = {
 
[RST_BUS_EPHY]  = RESET(0x2c8, BIT(2)),
 
+   [RST_BUS_THS]   = RESET(0x2d0, BIT(8)),
+
[RST_BUS_I2C0]  = RESET(0x2d8, BIT(0)),
[RST_BUS_I2C1]  = RESET(0x2d8, BIT(1)),
[RST_BUS_I2C2]  = RESET(0x2d8, BIT(2)),
diff --git a/drivers/clk/sunxi/clk_h6.c b/drivers/clk/sunxi/clk_h6.c
index 24eb9725db..5464530056 100644
--- a/drivers/clk/sunxi/clk_h6.c
+++ b/drivers/clk/sunxi/clk_h6.c
@@ -42,6 +42,8 @@ static struct ccu_clk_gate h6_gates[] = {
 
[CLK_BUS_EMAC]  = GATE(0x97c, BIT(0)),
 
+   [CLK_BUS_THS]   = GATE(0x9fc, BIT(0)),
+
[CLK_USB_PHY0]  = GATE(0xa70, BIT(29)),
[CLK_USB_OHCI0] = GATE(0xa70, BIT(31)),
 
@@ -91,6 +93,8 @@ static struct ccu_reset h6_resets[] = {
 
[RST_BUS_EMAC]  = RESET(0x97c, BIT(16)),
 
+   [RST_BUS_THS]   = RESET(0x9fc, BIT(16)),
+
[RST_USB_PHY0]  = RESET(0xa70, BIT(30)),
 
[RST_USB_PHY1]  = RESET(0xa74, BIT(30)),
diff --git a/drivers/clk/sunxi/clk_r40.c b/drivers/clk/sunxi/clk_r40.c
index 630e80d2b4..4fbfd28207 100644
--- a/drivers/clk/sunxi/clk_r40.c
+++ b/drivers/clk/sunxi/clk_r40.c
@@ -42,6 +42,7 @@ static struct ccu_clk_gate r40_gates[] = {
[CLK_BUS_TCON_TOP]  = GATE(0x064, BIT(30)),
 
[CLK_BUS_PIO]   = GATE(0x068, BIT(5)),
+   [CLK_BUS_THS]   = GATE(0x068, BIT(8)),
 
[CLK_BUS_I2C0]  = GATE(0x06c, BIT(0)),
[CLK_BUS_I2C1]  = GATE(0x06c, BIT(1)),
@@ -57,6 +58,8 @@ static struct ccu_clk_gate r40_gates[] = {
[CLK_BUS_UART6] = GATE(0x06c, BIT(22)),
[CLK_BUS_UART7] = GATE(0x06c, BIT(23)),
 
+   [CLK_THS]   = GATE(0x074, BIT(31)),
+
[CLK_SPI0]  = GATE(0x0a0, BIT(31)),
[CLK_SPI1]  = GATE(0x0a4, BIT(31)),
[CLK_SPI2]  = GATE(0x0a8, BIT(31)),
@@ -113,6 +116,8 @@ static struct ccu_reset r40_resets[] = {
[RST_BUS_TCON_TV1]  = RESET(0x2c4, BIT(29)),
[RST_BUS_TCON_TOP]  = RESET(0x2c4, BIT(30)),
 
+   [RST_BUS_THS]   = RESET(0x2d0, BIT(8)),
+
[RST_BUS_I2C0]  = RESET(0x2d8, BIT(0)),
[RST_BUS_I2C1]  = RESET(0x2d8, BIT(1)),
[RST_BUS_I2C2]  = RESET(0x2d8, BIT(2)),
-- 
2.17.1



[PATCH 2/2] drivers: thermal: Introduce sun8i_thermal

2023-02-13 Thread qianfanguijin
From: qianfan Zhao 

Portting sun8i_thermal.c from linux-5.15 drivers and drop interrupt
features. Next is an example from allwinner T3:

=> temperature get thermal-sensor@1c24c00
thermal-sensor@1c24c00: 39437 C
=>
thermal-sensor@1c24c00: 39776 C
=>
thermal-sensor@1c24c00: 39437 C

Signed-off-by: qianfan Zhao 
---
 drivers/thermal/Kconfig |   8 +
 drivers/thermal/Makefile|   1 +
 drivers/thermal/sun8i_thermal.c | 368 
 3 files changed, 377 insertions(+)
 create mode 100644 drivers/thermal/sun8i_thermal.c

diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index 97d4163e8e..be3118175f 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -41,4 +41,12 @@ config TI_DRA7_THERMAL
 Enable thermal support for for the Texas Instruments DRA752 SoC family.
 The driver supports reading CPU temperature.
 
+config SUN8I_THERMAL
+   bool "Temperature sensor driver for allwinner sunxi SOCs"
+   depends on ARCH_SUNXI
+   select REGMAP
+   help
+Enable thermal support for for the sunxi SoC family.
+The driver supports reading CPU temperature.
+
 endif # if DM_THERMAL
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 8acc7d20cb..9f419962cc 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -9,3 +9,4 @@ obj-$(CONFIG_IMX_THERMAL) += imx_thermal.o
 obj-$(CONFIG_IMX_SCU_THERMAL) += imx_scu_thermal.o
 obj-$(CONFIG_TI_DRA7_THERMAL) += ti-bandgap.o
 obj-$(CONFIG_IMX_TMU) += imx_tmu.o
+obj-$(CONFIG_SUN8I_THERMAL) += sun8i_thermal.o
diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c
new file mode 100644
index 00..51ea81ccf7
--- /dev/null
+++ b/drivers/thermal/sun8i_thermal.c
@@ -0,0 +1,368 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Thermal sensor driver for Allwinner SOC
+ * Based on the linux driver
+ *
+ * Copyright (C) 2023 qianfan Zhao
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define FT_TEMP_MASK   GENMASK(11, 0)
+#define TEMP_CALIB_MASKGENMASK(11, 0)
+#define CALIBRATE_DEFAULT  0x800
+
+#define SUN8I_THS_CTRL00x00
+#define SUN8I_THS_CTRL20x40
+#define SUN8I_THS_IC   0x44
+#define SUN8I_THS_IS   0x48
+#define SUN8I_THS_MFC  0x70
+#define SUN8I_THS_TEMP_CALIB   0x74
+#define SUN8I_THS_TEMP_DATA0x80
+
+#define SUN50I_THS_CTRL0   0x00
+#define SUN50I_H6_THS_ENABLE   0x04
+#define SUN50I_H6_THS_PC   0x08
+#define SUN50I_H6_THS_DIC  0x10
+#define SUN50I_H6_THS_DIS  0x20
+#define SUN50I_H6_THS_MFC  0x30
+#define SUN50I_H6_THS_TEMP_CALIB   0xa0
+#define SUN50I_H6_THS_TEMP_DATA0xc0
+
+#define SUN8I_THS_CTRL0_T_ACQ0(x)  (GENMASK(15, 0) & (x))
+#define SUN8I_THS_CTRL2_T_ACQ1(x)  ((GENMASK(15, 0) & (x)) << 16)
+#define SUN8I_THS_DATA_IRQ_STS(x)  BIT(x + 8)
+
+#define SUN50I_THS_CTRL0_T_ACQ(x)  ((GENMASK(15, 0) & (x)) << 16)
+#define SUN50I_THS_FILTER_EN   BIT(2)
+#define SUN50I_THS_FILTER_TYPE(x)  (GENMASK(1, 0) & (x))
+#define SUN50I_H6_THS_PC_TEMP_PERIOD(x)((GENMASK(19, 0) & (x)) 
<< 12)
+#define SUN50I_H6_THS_DATA_IRQ_STS(x)  BIT(x)
+
+struct ths_device;
+
+struct ths_thermal_chip {
+   boolhas_mod_clk;
+   boolhas_bus_clk_reset;
+   int sensor_num;
+   int offset;
+   int scale;
+   int ft_deviation;
+   int temp_data_base;
+   int (*init)(struct ths_device *tmdev);
+   int (*calc_temp)(struct ths_device *tmdev,
+int id, int reg);
+};
+
+struct ths_device {
+   const struct ths_thermal_chip   *chip;
+   struct udevice  *dev;
+   struct regmap   *regmap;
+   struct reset_ctl*reset;
+   struct clk  *bus_clk;
+   struct clk  *mod_clk;
+};
+
+/* Temp Unit: millidegree Celsius */
+static int sun8i_ths_calc_temp(struct ths_device *tmdev,
+  int id, int reg)
+{
+   return tmdev->chip->offset - (reg * tmdev->chip->scale / 10);
+}
+
+static int sun50i_h5_calc_temp(struct ths_device *tmdev,
+  int id, int reg)
+{
+   if (reg >= 0x500)
+   return -1191 * reg / 10 + 223000;
+   else if 

[PATCH] watchdog: ftwdt010: return a previously deleted driver now ported to DM

2023-02-13 Thread Sergei Antonov
The ftwdt010 watchdog driver was deleted by
commit 11232139e399 ("nds32: Remove the architecture")

Return it to the codebase in a DM compatible form. Enable it in
sandbox_defconfig to test compilability.
Another platform using ftwdt010 will be submitted later.

Signed-off-by: Sergei Antonov 
---
 configs/sandbox_defconfig   |   1 +
 drivers/watchdog/Kconfig|   7 ++
 drivers/watchdog/Makefile   |   1 +
 drivers/watchdog/ftwdt010_wdt.c | 132 
 include/faraday/ftwdt010_wdt.h  |   3 -
 5 files changed, 141 insertions(+), 3 deletions(-)
 create mode 100644 drivers/watchdog/ftwdt010_wdt.c

diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 34c342b6f587..0c57e97bcb7e 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -320,6 +320,7 @@ CONFIG_WDT=y
 CONFIG_WDT_GPIO=y
 CONFIG_WDT_SANDBOX=y
 CONFIG_WDT_ALARM_SANDBOX=y
+CONFIG_WDT_FTWDT010=y
 CONFIG_FS_CBFS=y
 CONFIG_FS_CRAMFS=y
 CONFIG_ADDR_MAP=y
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index b5ac8f7f50dc..a4c8dac99046 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -161,6 +161,13 @@ config WDT_CORTINA
  This driver support all CPU ISAs supported by Cortina
  Access CA SoCs.
 
+config WDT_FTWDT010
+   bool "Faraday Technology ftwdt010 watchdog timer support"
+   depends on WDT
+   help
+ Faraday Technology ftwdt010 watchdog is an architecture independent
+ watchdog. It is usually used in SoC chip design.
+
 config WDT_GPIO
bool "External gpio watchdog support"
depends on WDT
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 446d961d7d2e..fffa338bef2f 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -26,6 +26,7 @@ obj-$(CONFIG_WDT_BOOKE) += booke_wdt.o
 obj-$(CONFIG_WDT_CORTINA) += cortina_wdt.o
 obj-$(CONFIG_WDT_ORION) += orion_wdt.o
 obj-$(CONFIG_WDT_CDNS) += cdns_wdt.o
+obj-$(CONFIG_WDT_FTWDT010) += ftwdt010_wdt.o
 obj-$(CONFIG_WDT_GPIO) += gpio_wdt.o
 obj-$(CONFIG_WDT_MAX6370) += max6370_wdt.o
 obj-$(CONFIG_WDT_MESON_GXBB) += meson_gxbb_wdt.o
diff --git a/drivers/watchdog/ftwdt010_wdt.c b/drivers/watchdog/ftwdt010_wdt.c
new file mode 100644
index ..5f4e42e58a47
--- /dev/null
+++ b/drivers/watchdog/ftwdt010_wdt.c
@@ -0,0 +1,132 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Watchdog driver for the FTWDT010 Watch Dog Driver
+ *
+ * (c) Copyright 2004 Faraday Technology Corp. (www.faraday-tech.com)
+ * Based on sa1100_wdt.c by Oleg Drokin 
+ * Based on SoftDog driver by Alan Cox 
+ *
+ * Copyright (C) 2011 Andes Technology Corporation
+ * Macpaul Lin, Andes Technology Corporation 
+ *
+ * 27/11/2004 Initial release, Faraday.
+ * 12/01/2011 Port to u-boot, Macpaul Lin.
+ * 22/08/2022 Port to DM
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct ftwdt010_wdt_priv {
+   struct ftwdt010_wdt __iomem *regs;
+};
+
+/*
+ * Set the watchdog time interval.
+ * Counter is 32 bit.
+ */
+static int ftwdt010_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
+{
+   struct ftwdt010_wdt_priv *priv = dev_get_priv(dev);
+   struct ftwdt010_wdt *wd = priv->regs;
+   unsigned int reg;
+
+   debug("Activating WDT %llu ms\n", timeout_ms);
+
+   /* Check if disabled */
+   if (readl(>wdcr) & ~FTWDT010_WDCR_ENABLE) {
+   printf("sorry, watchdog is disabled\n");
+   return -1;
+   }
+
+   /*
+* In a 66MHz system,
+* if you set WDLOAD as 0x03EF1480 (6600)
+* the reset timer is 1 second.
+*/
+   reg = FTWDT010_WDLOAD(timeout_ms * FTWDT010_TIMEOUT_FACTOR);
+
+   writel(reg, >wdload);
+
+   return 0;
+}
+
+static int ftwdt010_wdt_reset(struct udevice *dev)
+{
+   struct ftwdt010_wdt_priv *priv = dev_get_priv(dev);
+   struct ftwdt010_wdt *wd = priv->regs;
+
+   /* clear control register */
+   writel(0, >wdcr);
+
+   /* Write Magic number */
+   writel(FTWDT010_WDRESTART_MAGIC, >wdrestart);
+
+   /* Enable WDT */
+   writel((FTWDT010_WDCR_RST | FTWDT010_WDCR_ENABLE), >wdcr);
+
+   return 0;
+}
+
+static int ftwdt010_wdt_stop(struct udevice *dev)
+{
+   struct ftwdt010_wdt_priv *priv = dev_get_priv(dev);
+   struct ftwdt010_wdt *wd = priv->regs;
+
+   debug("Deactivating WDT..\n");
+
+   /*
+* It was defined with CONFIG_WATCHDOG_NOWAYOUT in Linux
+*
+* Shut off the timer.
+* Lock it in if it's a module and we defined ...NOWAYOUT
+*/
+   writel(0, >wdcr);
+   return 0;
+}
+
+static int ftwdt010_wdt_expire_now(struct udevice *dev, ulong flags)
+{
+   struct ftwdt010_wdt_priv *priv = dev_get_priv(dev);
+   struct ftwdt010_wdt *wd = priv->regs;
+
+   debug("Expiring WDT..\n");
+   writel(FTWDT010_WDLOAD(0), >wdload);
+   return ftwdt010_wdt_reset(dev);
+}
+
+static int 

Re: [RESEND PATCH v2] configs: imx8mn_bsh_smm_s2: remove console from bootargs

2023-02-13 Thread Stefano Babic

On 13.02.23 14:28, Michael Nazzareno Trimarchi wrote:

Hi Stefano

On Wed, Feb 8, 2023 at 9:15 AM Dario Binacchi
 wrote:


The Linux kernel device tree already specifies the device to be used for
boot console output with a stdout-path property under /chosen.

Commit 36b661dc919da ("Merge branch 'next'") re-added the console
setting that commit bede82f750752 ("configs: imx8mn_bsh_smm_s2: remove
console from bootargs") had previously removed.

Fixes: 36b661dc919da ("Merge branch 'next'")
Signed-off-by: Dario Binacchi 
Reviewed-by: Fabio Estevam 

---

Changes in v2:
- Add the 'Reviewed-by' tag.
- Improve commit message.

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

diff --git a/include/configs/imx8mn_bsh_smm_s2.h 
b/include/configs/imx8mn_bsh_smm_s2.h
index e97b8e871d22..deeed9c2f582 100644
--- a/include/configs/imx8mn_bsh_smm_s2.h
+++ b/include/configs/imx8mn_bsh_smm_s2.h
@@ -14,7 +14,7 @@
  #include 

  #define NANDARGS \
-   "nandargs=setenv bootargs console=${console} " \
+   "nandargs=setenv bootargs " \
 "${optargs} " \
 "mtdparts=${mtdparts} " \
 "root=${nandroot} " \
--


This patch is a regression fix, can you pick it?


I'll do it, thanks !

Stefano



Michael


2.32.0



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



Re: [RESEND PATCH v2] configs: imx8mn_bsh_smm_s2: remove console from bootargs

2023-02-13 Thread Michael Nazzareno Trimarchi
Hi Stefano

On Wed, Feb 8, 2023 at 9:15 AM Dario Binacchi
 wrote:
>
> The Linux kernel device tree already specifies the device to be used for
> boot console output with a stdout-path property under /chosen.
>
> Commit 36b661dc919da ("Merge branch 'next'") re-added the console
> setting that commit bede82f750752 ("configs: imx8mn_bsh_smm_s2: remove
> console from bootargs") had previously removed.
>
> Fixes: 36b661dc919da ("Merge branch 'next'")
> Signed-off-by: Dario Binacchi 
> Reviewed-by: Fabio Estevam 
>
> ---
>
> Changes in v2:
> - Add the 'Reviewed-by' tag.
> - Improve commit message.
>
>  include/configs/imx8mn_bsh_smm_s2.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/configs/imx8mn_bsh_smm_s2.h 
> b/include/configs/imx8mn_bsh_smm_s2.h
> index e97b8e871d22..deeed9c2f582 100644
> --- a/include/configs/imx8mn_bsh_smm_s2.h
> +++ b/include/configs/imx8mn_bsh_smm_s2.h
> @@ -14,7 +14,7 @@
>  #include 
>
>  #define NANDARGS \
> -   "nandargs=setenv bootargs console=${console} " \
> +   "nandargs=setenv bootargs " \
> "${optargs} " \
> "mtdparts=${mtdparts} " \
> "root=${nandroot} " \
> --

This patch is a regression fix, can you pick it?

Michael

> 2.32.0
>


Re: [PATCH v3 00/16] General Tegra improvements

2023-02-13 Thread Svyatoslav Ryhel
Hello! Thierry, may you check if these patches do not break anything on your
boards. I have tested them on my devices (T20 and T30) without any
issues. I am especially interested in T124 pre-dm i2c changes, iirc
you have a board I have changed.

Best Regards.
Svyatoslav R.

пт, 10 лют. 2023 р. о 18:35 Svyatoslav Ryhel  пише:
>
> I have asked Thierry to check if his boards work with these changes
> but got no response from him (at least yet). Others seem to have no
> interest.
>
> Best regards
> Svyatoslav R.
>
> пт, 10 лют. 2023 р. о 18:31 Tom Warren  пише:
> >
> > Where does testing/reviewing stand on these changes? I'd like to submit a 
> > PR early next week, but I can't until I know they won't break anything.
> >
> > -Original Message-
> > From: Svyatoslav Ryhel 
> > Sent: Friday, February 3, 2023 10:40 AM
> > To: Tom Warren ; Thierry Reding 
> > 
> > Cc: Ramin Khonsari ; Maxim Schwalm 
> > ; Dmitry Osipenko ; 
> > u-boot@lists.denx.de; Allen Martin ; Jagan Teki 
> > ; Lukasz Majewski ; Marcel 
> > Ziswiler ; Marek Vasut 
> > Subject: Re: [PATCH v3 00/16] General Tegra improvements
> >
> > External email: Use caution opening links or attachments
> >
> >
> > Thanks! I will shrink mailing list in the next iteration.
> >
> > Thierry, may you check if these patches do not break anything on your 
> > boards. I have tested them on my devices (T20 and T30) without any issues. 
> > I am especially interested in T124 pre-dm i2c changes, iirc you have a 
> > board I have changed.
> >
> > Best Regards.
> > Svyatoslav R.
> >
> > пт, 3 лют. 2023 р. о 19:30 Tom Warren  пише:
> > >
> > > I've applied these (v3) to TOT u-boot-tegra/master OK, and 'buildman 
> > > tegra' is OK.
> > >
> > > I don't have the HW to test all of these combos (T20, T30, T114, T124) - 
> > > they're mothballed in favor of my current work on T210/T186/T194/T234 
> > > (the last two w/no U-Boot). So I'd appreciate any 'Tested-by's from 
> > > anyone (Thierry, Marcel, Marek, etc.) that might be using these older 
> > > boards still. This is a substantive set of changes, and I don't want to 
> > > break anything.
> > >
> > > BTW - you can remove Stephen Warren from your CC list - he's moved out of 
> > > the group that's concerned w/L4T & upstream bootloaders, and probably 
> > > doesn't want to see this in his inbox any longer.
> > >
> > > Thanks,
> > >
> > > Tom
> > >
> > > -Original Message-
> > > From: Svyatoslav Ryhel 
> > > Sent: Friday, February 3, 2023 2:26 AM
> > > To: Tom Warren ; Stephen Warren
> > > ; Marcel Ziswiler ;
> > > Allen Martin ; Jagan Teki
> > > ; Lukasz Majewski ; Marek
> > > Vasut ; Svyatoslav Ryhel ; Ramin
> > > Khonsari ; Thierry Reding
> > > ; Maxim Schwalm ;
> > > Dmitry Osipenko 
> > > Cc: u-boot@lists.denx.de
> > > Subject: [PATCH v3 00/16] General Tegra improvements
> > >
> > > External email: Use caution opening links or attachments
> > >
> > >
> > > List of changes in patch set:
> > >  - add missing EXTPERIPH clocks for t30
> > >  - swap host1x and disp1 clock parents (as they should be)
> > >  - add clk_id_to_pll_id and clock_decode_pair helpers to use
> > >dts deeper (in tegra clocks often go in pair child - parent)
> > >  - include PLLD setup in T30 (DISP1 may use it as parent on
> > >some device)
> > >  - fix Tegra PWM parent clock inline with linux
> > >  - Tegra SLINK: patch to accept any word length (unlike 8bit
> > >aligned which was before)
> > >  - provide default USB gadget setup for existing Nvidia boards
> > >  - add late init function to be able to configure pre-boot stage
> > >(like uncovering serial number or setting mac address)
> > >  - create common pre-dm i2c write for PMIC (used on T30 and T124
> > >to configure basic PMIC voltages required to boot like cpu and
> > >core voltages)
> > >  - expose crypto module for all Tegra SoCs and implement BCT patching
> > >(ability to update bootloader from u-boot on production devices
> > >without need in host PC)
> > >
> > > ---
> > > Changelog from v2
> > >  - fixed T114 TEGRA114_CLK_PLL_E_OUT0
> > >  - adjusted pre-dm i2c write commit description
> > >  - added description file for ebtupdate command
> > >  - minor improvements of bct.c comments
> > >
> > > Changelog from v1
> > >  - rebased to latest u-boot master
> > >  - PLLD setup for T30 moved specifically into T30 area
> > > ---
> > >
> > > 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 

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

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

Because on A37xx the pinctrl driver needs to be probed before the GPIO
one can be probed as GPIO driver is using internal data that is filled in
by the pinctrl driver.

Regards,
Robert
>
> Reviewed-by: Simon Glass 



-- 
Robert Marko
Staff Embedded Linux Engineer
Sartura Ltd.
Lendavska ulica 16a
1 Zagreb, Croatia
Email: robert.ma...@sartura.hr
Web: www.sartura.hr


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

2023-02-13 Thread Masahisa Kojima
On Mon, 13 Feb 2023 at 18:46, Heinrich Schuchardt  wrote:
>
> On 2/13/23 10:42, Masahisa Kojima wrote:
> > Hi Heinrich,
> >
> > On Mon, 13 Feb 2023 at 16:44, Heinrich Schuchardt  
> > wrote:
> >>
> >> On 2/13/23 06:50, Masahisa Kojima wrote:
> >>> On Fri, 10 Feb 2023 at 20:57, Heinrich Schuchardt  
> >>> wrote:
> 
>  On 2/2/23 10:24, Masahisa Kojima wrote:
> > Current eficonfig_print_msg() does not show the return
> > value of EFI Boot/Runtime Services when the service call fails.
> > With this commit, user can know EFI_STATUS in the error message.
> 
>  Why do we need function eficonfig_print_msg()?
> 
>  I cannot see why the printing only parameter msg with log_err() should
>  not be good enough.
> >>>
> >>> ANSI_CLEAR_CONSOLE is sent before drawing the menu. I think it is
> >>> difficult for user
> >>> to know some error occurs by the user operation, user needs scroll up
> >>> to see the error message
> >>> when we use log_err(
> >> Understood. But why do we need the status value (or with this patch the
> >> long text for the status value)?
> >
> > At first, I planned to add additional error messages specific to some
> > status value, but it will increase the eficonfig_print_msg() calls.
>
> Which message remains unclear without the extra information?

Not for the specific message.

At first I planned to add the error message when the variable storage
is not enough to store the efi variable like:

ret = efi_set_variable_int(var_name, _global_variable_guid,
  EFI_VARIABLE_NON_VOLATILE |
  EFI_VARIABLE_BOOTSERVICE_ACCESS |
  EFI_VARIABLE_RUNTIME_ACCESS,
  opt[i].size, opt[i].lo, false);
- if (ret != EFI_SUCCESS)
+ if (ret != EFI_OUT_OF_RESOURCES)
+ efi_print_msg("variable storage is not enough");
+ else if (ret != EFI_XXX)
+ efi_print_msg("another error message");

This will result in an increase of efi_print_msg() calls,
I think it is better to print a status value or text.

Thanks,
Masahisa Kojima

>
>
> > Instead of adding eficonfig_print_msg() calls,
> > I think printing the status value(or text for the status value) will reduce 
> > the
> > code size eventually.
> > But printing the status code will not much help user to understand
> > what the error cause is.
> >
> > Thanks,
> > Masahisa Kojima
> >
> >>
> >> Best regards
> >>
> >> Heinrich
> >>
> >>>
> >>> Regards,
> >>> Masahisa Kojima
> >>>
> 
>  Best regards
> 
>  Heinrich
> 
> >
> > Signed-off-by: Masahisa Kojima 
> > ---
> > cmd/eficonfig.c   | 95 
> > +--
> > cmd/eficonfig_sbkey.c | 16 
> > include/efi_config.h  |  2 +-
> > 3 files changed, 93 insertions(+), 20 deletions(-)
> >
> > diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c
> > index 0a17b8cf34..b0c8637676 100644
> > --- a/cmd/eficonfig.c
> > +++ b/cmd/eficonfig.c
> > @@ -151,19 +151,90 @@ static void eficonfig_menu_adjust(struct efimenu 
> > *efi_menu, bool add)
> > #define eficonfig_menu_up(_a) eficonfig_menu_adjust(_a, false)
> > #define eficonfig_menu_down(_a) eficonfig_menu_adjust(_a, true)
> >
> > +struct efi_status_str {
> > + efi_status_t status;
> > + char *str;
> > +};
> > +
> > +static const struct efi_status_str status_str_table[] = {
> > + {EFI_LOAD_ERROR,"Load Error"},
> > + {EFI_INVALID_PARAMETER, "Invalid Parameter"},
> > + {EFI_UNSUPPORTED,   "Unsupported"},
> > + {EFI_BAD_BUFFER_SIZE,   "Bad Buffer Size"},
> > + {EFI_BUFFER_TOO_SMALL,  "Buffer Too Small"},
> > + {EFI_NOT_READY, "Not Ready"},
> > + {EFI_DEVICE_ERROR,  "Device Error"},
> > + {EFI_WRITE_PROTECTED,   "Write Protected"},
> > + {EFI_OUT_OF_RESOURCES,  "Out of Resources"},
> > + {EFI_VOLUME_CORRUPTED,  "Volume Corrupted"},
> > + {EFI_VOLUME_FULL,   "Volume Full"},
> > + {EFI_NO_MEDIA,  "No Media"},
> > + {EFI_MEDIA_CHANGED, "Media Changed"},
> > + {EFI_NOT_FOUND, "Not Found"},
> > + {EFI_ACCESS_DENIED, "Access Denied"},
> > + {EFI_NO_RESPONSE,   "No Response"},
> > + {EFI_NO_MAPPING,"No Mapping"},
> > + {EFI_TIMEOUT,   "Timeout"},
> > + {EFI_NOT_STARTED,   "Not Started"},
> > + {EFI_ALREADY_STARTED,   "Already Started"},
> > + {EFI_ABORTED,   "Aborted"},
> > + {EFI_ICMP_ERROR,"ICMP Error"},
> > + {EFI_TFTP_ERROR,"TFTP Error"},
> > + {EFI_PROTOCOL_ERROR,"Protocol Error"},
> > + {EFI_INCOMPATIBLE_VERSION,  "Incompatible Version"},
> > + 

Re: [PATCH 1/5] mtd/spinand: rework detect procedure for different READ_ID operation

2023-02-13 Thread Frieder Schrempf
On 10.02.23 12:57, Michael Nazzareno Trimarchi wrote:
> Hi
> 
> I will review
> 
> On Thu, Feb 9, 2023 at 5:52 PM Tom Rini  wrote:
>>
>> On Thu, Feb 09, 2023 at 10:24:47AM +0100, Frieder Schrempf wrote:
>>> Hi,
>>>
>>> On 10.01.23 12:58, Frieder Schrempf wrote:
 From: Mikhail Kshevetskiy 

 Currently there are 3 different variants of read_id implementation:
 1. opcode only. Found in GD5FxGQ4xF.
 2. opcode + 1 addr byte. Found in GD5GxGQ4xA/E
 3. opcode + 1 dummy byte. Found in other currently supported chips.

 Original implementation was for variant 1 and let detect function
 of chips with variant 2 and 3 to ignore the first byte. This isn't
 robust:

 1. For chips of variant 2, if SPI master doesn't keep MOSI low
 during read, chip will get a random id offset, and the entire id
 buffer will shift by that offset, causing detect failure.

 2. For chips of variant 1, if it happens to get a devid that equals
 to manufacture id of variant 2 or 3 chips, it'll get incorrectly
 detected.

 This patch reworks detect procedure to address problems above. New
 logic do detection for all variants separatedly, in 1-2-3 order.
 Since all current detect methods do exactly the same id matching
 procedure, unify them into core.c and remove detect method from
 manufacture_ops.

 This is a rework of Chuanhong Guo  patch
 submitted to linux kernel

 Signed-off-by: Mikhail Kshevetskiy 
 Signed-off-by: Frieder Schrempf 
>>>
>>> +Cc: Jagan, Tom
>>>
>>> Who is supposed to pick up these patches? Some of them have been around
>>> for some months (before I resent them).
>>>
>>> There is no maintainer for drivers/mtd/spinand/ and no maintainer for
>>> drivers/mtd/ in general.
>>>
>>> In Patchwork Jagan got assigned, but the get_maintainer.pl script didn't
>>> even add him to Cc, of course.
>>>
>>> Any ideas how to proceed?
>>
>> We don't have anyone dedicated to that area, yes, sadly. I've added
>> Michael and Dario as they've also been doing mtd-but-not-spi work of
>> late to see if they're interested. Or since you've long been working
>> here, would you like to more formally maintain the area? Thanks!
> 
> They can come from our tree. I will try to sort out all my duties weeked

Thanks Tom and Michael!

I just sent out a patch for the MAINTAINERS file to add Michael and
Dario as SPI NAND maintainers and myself as a reviewer. I hope that you
agree to handle it like this.


[PATCH 2/2] MAINTAINERS: Rename NAND FLASH to RAW NAND

2023-02-13 Thread Frieder Schrempf
From: Frieder Schrempf 

As there are other types of NAND flashes like SPI NAND, let's be
more specific.

Signed-off-by: Frieder Schrempf 
---
 MAINTAINERS | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index e40c401337..00ad83a8c7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1166,13 +1166,6 @@ S:   Maintained
 T: git https://source.denx.de/u-boot/custodians/u-boot-mmc.git
 F: drivers/mmc/
 
-NAND FLASH
-M: Dario Binacchi 
-M: Michael Trimarchi 
-S: Maintained
-T: git https://source.denx.de/u-boot/custodians/u-boot-nand-flash.git
-F: drivers/mtd/nand/raw/
-
 NETWORK
 M: Joe Hershberger 
 M: Ramon Fried 
@@ -1285,6 +1278,13 @@ S:   Maintained
 T: git https://source.denx.de/u-boot/custodians/u-boot-mpc85xx.git
 F: arch/powerpc/cpu/mpc85xx/
 
+RAW NAND
+M: Dario Binacchi 
+M: Michael Trimarchi 
+S: Maintained
+T: git https://source.denx.de/u-boot/custodians/u-boot-nand-flash.git
+F: drivers/mtd/nand/raw/
+
 RISC-V
 M: Rick Chen 
 M: Leo 
-- 
2.39.1



[PATCH 1/2] MAINTAINERS: Add entry for SPI NAND framework and drivers

2023-02-13 Thread Frieder Schrempf
From: Frieder Schrempf 

In [1] Michael agreed on taking patches for SPI NAND through the RAW
NAND tree. Add a dedicated entry to the MAINTAINERS file which adds
Michael and Dario as maintainers and myself as reviewer.

[1] https://lists.denx.de/pipermail/u-boot/2023-February/508571.html

Signed-off-by: Frieder Schrempf 
Cc: Jagan Teki 
Cc: Dario Binacchi 
Cc: Michael Nazzareno Trimarchi 
Cc: Tom Rini 
---
 MAINTAINERS | 8 
 1 file changed, 8 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index b9c505d5fa..e40c401337 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1375,6 +1375,14 @@ T:   git 
https://source.denx.de/u-boot/custodians/u-boot-spi.git
 F: drivers/spi/
 F: include/spi*
 
+SPI NAND
+M: Dario Binacchi 
+M: Michael Trimarchi 
+R: Frieder Schrempf 
+S: Maintained
+T: git https://source.denx.de/u-boot/custodians/u-boot-nand-flash.git
+F: drivers/mtd/nand/spi/
+
 SPI-NOR
 M: Jagan Teki 
 M: Vignesh R 
-- 
2.39.1



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

2023-02-13 Thread Heinrich Schuchardt

On 2/13/23 10:42, Masahisa Kojima wrote:

Hi Heinrich,

On Mon, 13 Feb 2023 at 16:44, Heinrich Schuchardt  wrote:


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

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


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

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


Why do we need function eficonfig_print_msg()?

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


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

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


At first, I planned to add additional error messages specific to some
status value, but it will increase the eficonfig_print_msg() calls.


Which message remains unclear without the extra information?



Instead of adding eficonfig_print_msg() calls,
I think printing the status value(or text for the status value) will reduce the
code size eventually.
But printing the status code will not much help user to understand
what the error cause is.

Thanks,
Masahisa Kojima



Best regards

Heinrich



Regards,
Masahisa Kojima



Best regards

Heinrich



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

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

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

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

2023-02-13 Thread Masahisa Kojima
Hi Heinrich,

On Mon, 13 Feb 2023 at 16:44, Heinrich Schuchardt  wrote:
>
> On 2/13/23 06:50, Masahisa Kojima wrote:
> > On Fri, 10 Feb 2023 at 20:57, Heinrich Schuchardt  
> > wrote:
> >>
> >> On 2/2/23 10:24, Masahisa Kojima wrote:
> >>> Current eficonfig_print_msg() does not show the return
> >>> value of EFI Boot/Runtime Services when the service call fails.
> >>> With this commit, user can know EFI_STATUS in the error message.
> >>
> >> Why do we need function eficonfig_print_msg()?
> >>
> >> I cannot see why the printing only parameter msg with log_err() should
> >> not be good enough.
> >
> > ANSI_CLEAR_CONSOLE is sent before drawing the menu. I think it is
> > difficult for user
> > to know some error occurs by the user operation, user needs scroll up
> > to see the error message
> > when we use log_err(
> Understood. But why do we need the status value (or with this patch the
> long text for the status value)?

At first, I planned to add additional error messages specific to some
status value, but it will increase the eficonfig_print_msg() calls.
Instead of adding eficonfig_print_msg() calls,
I think printing the status value(or text for the status value) will reduce the
code size eventually.
But printing the status code will not much help user to understand
what the error cause is.

Thanks,
Masahisa Kojima

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

Re: [PATCH 3/4] mtd/fpga: add fpga directory to mtd (with Cyclone 10)

2023-02-13 Thread Ulf Samuelsson




Den 2023-02-12 kl. 23:40, skrev Marek Vasut:

On 2/12/23 23:07, Ulf Samuelsson wrote:

Den 2023-02-12 kl. 21:01, skrev Marek Vasut:
 > On 2/12/23 20:52, Ulf Samuelsson wrote:
 >>
 >>
 >> Den 2023-02-12 kl. 20:31, skrev Marek Vasut:
 >>  > On 2/11/23 11:07, u-b...@emagii.com wrote:
 >>  >
 >>  > [...]
 >>  >
 >>  >> +static int cyc10_write(struct mtd_info *mtd, loff_t to, 
size_t len,

 >>  >> + size_t *retlen, const u_char *buf)
 >>  >> +{
 >>  >> +    struct udevice *dev = mtd->dev;
 >>  >> +    struct spi_slave *slave = dev_get_parent_priv(dev);
 >>  >> +    struct cyc10_plat *fpga = dev_get_plat(dev);
 >>  >> +    int ret;
 >>  >
 >>  > Do I read this right, that the 'write' callback is the only one 
doing

 >>  > meaningful work, all the other callbacks are just empty stubs ?
 >>  > Yes, you cannot read back the configuration data.
 >
 > That makes it look like any framework which supports "write" 
callback would be suitable, not just MTD framework.

 >
 >>  > Why not update drivers/fpga/cyclon2.c which is Passive Serial
 >>  > implementation already present in U-Boot for Altera Cyclone II 
FPGA ,
 >>  > with Cyclone 10 FPGA support ? I believe the PS protocol 
changed very

 >>  > little.
 >> Since the MTD command set is enough to configure the FPGA, the 
FPGA commands can be removed from the build. The FPGA command set 
requires you to supply addresses, but the MTD command set uses devices.

 >>
 >> So:
 >> * Smaller U-Boot image
 >
 > The MTD framework is rather large, compared to the trivial FPGA 
framework. Can you back this claim with any numbers ?


I am assuming that the MTD framework is needed anyway.


FPGA and MTD support is orthogonal, you cannot make that assumption.
Consider SoC-FPGA machine booting from eMMC, Altera Cyclone V SoC does 
support that mode of operation, and MTD support can be disabled.


If I look at Altera SOCFPGAs, I find that 21 defconfigs have MTD support 
and 3 do not.

* socfpga_agilex_defconfig
* socfpga_chameleonv3_defconfig
* socfpga_n5x_defconfig
so in most cases there would be a reduction in code size.


We certainly need it.
 >
 >> * Simplified user interface.
 >
 > If I am to select between 'fpga load' and 'mtd write' for FPGA 
bitstream loading , my obvious choice would be 'fpga load' . How is 
using 'mtd write' any better or simpler ?

 >
fpga load 0   ${loadaddr} ${filesize}
mtd write spy ${loadaddr}

The questions I ask myself.
So is "0" the "spy" FPGA or the "spx" FPGA?


You can use DT /aliases node to enumerate the FPGAs the same way i2c 
busses, SPI NORs, SD/MMC devices etc. are enumerated . Also have a look 
at e.g. 'net list' command, similar functionality can be added to the 
FPGA command to list all registered FPGAs.



Why should I have to remember the size of the FPGA bitstream?


Because it is not always possible to extract that information from the 
bitstream blob, remember, some of those blobs may be just raw binaries 
of the SRAM/flash content .



The size of the FPGA will be in the devicetree, so there is no need
to supply that in the command itself.

 >> * The FPGA is an SPI peripheral, so why not add it to the SPI part 
of the device tree?

 >
 > You can add the device into DT and still operate it using the 
U-Boot FPGA framework, just add the DT support. Why not do it that way ?





I don't think you can add the device into DT in U-Boot as it is today.
You can create FPGA contents and add that to the device tree, but not
the configuration itself. At least, I have not seen it.
If I have missed it, where is an example?


Have a look at the Linux FPGA DT bindings in 
Documentation/devicetree/bindings/fpga/ . You can implement parsing of 
those bindings into the U-Boot FPGA framework and then add your FPGA 
device configuration interface into the DT.




The "altr,fpga-passive-serial" driver is very close to what I did.
My driver supports a superset of a devicetree for that driver.
It does not look like U-Boot is setup to use that.

I feel that the FPGA manager needs a total rework to make this work
and I cannot justify that. If someone adds devicetree support to the 
FPGA manager, I will certainly look to adopt to it.



The FPGA framework is not really setup to use device-tree to describe
configuration.

Only 5 defconfigs in U-Boot uses the FPGA framework.
* astro_mcf5373l_defconfig
* syzygy_hub_defconfig
* xilinx_zynqmp_virt_defconfig
* xilinx_zynq_virt_defconfig


These two ^ cover very much every zynq 7000 and zynqmp device in 
existence, since the way those are used is in combination with provided 
custom board DT.



* bitmain_antminer_s9_defconfig


There is also arch/arm/mach-socfpga/Kconfig: imply FPGA_SOCFPGA , which 
activates the CONFIG_FPGA on all of Altera Cyclone V/Arria V/Stratix 
10/Agilex and whatever new SoCFPGA Intel has.



Their device trees have leafs for configuration:
* compatible = "fpga-region";
* compatible = "xlnx,zynq-devcfg-1.0";
Neither "fpga-region" or "xlnx,zynq-devcfg-1.0" have any 

  1   2   >