Re: [PATCH] arm: kirkwood: Enable uart0 dm-pre-reloc for Kirkwood boards

2023-01-31 Thread Michael Walle

Hi Tony,

Am 2023-02-01 02:11, schrieb Tony Dinh:

When DM_SERIAL is enabled, the device-tree property dm-pre-reloc is
required to boot over UART with kwboot. Enable this in a Kirkwood
common u-boot dtsi.


My (dev) board unfortunately, have a bootloader which can't boot over
serial. Could you elaborate that a bit more? Why is this required for
uart boot? kwboot will talk with the bootrom why does u-boot need
anything? Or will there just be no output until the uart is initialized?



Signed-off-by: Tony Dinh 
---

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


Is this new? AFAIK only -u-boot.dtsi is included
automatically.

-michael


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

2023-01-31 Thread Tony Dinh
Hi Stefan,

On Tue, Jan 31, 2023 at 10:48 PM Stefan Roese  wrote:
>
> Hi Tony,
>
> On 1/31/23 22:22, 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 
> > ---
> >
> > 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   |   6 +
> >   board/thecus/n2350/Makefile  |   6 +
> >   board/thecus/n2350/n2350.c   | 127 +++
> >   configs/n2350_defconfig  |  93 +
> >   include/configs/n2350.h  |  65 
> >   8 files changed, 755 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 =  > +   MBUS_ID(0x01, 0x1d) 0 0xfff0 0x10
> > +   MBUS_ID(0x09, 0x19) 0 0xf110 0x1
> > +   MBUS_ID(0x09, 0x15) 0 0xf111 0x1
> > +   MBUS_ID(0x0c, 0x04) 0 0xf120 0x10>;
> > +
> > + };
> > +
> > + 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 

Re: [PATCH] arm: kirkwood: Enable uart0 dm-pre-reloc for Kirkwood boards

2023-01-31 Thread Tony Dinh
Thanks Stefan!
Tony

On Tue, Jan 31, 2023 at 10:30 PM Stefan Roese  wrote:
>
> (Added Simon to Cc)
>
> On 2/1/23 02:11, Tony Dinh wrote:
> > When DM_SERIAL is enabled, the device-tree property dm-pre-reloc is
> > required to boot over UART with kwboot. Enable this in a Kirkwood
> > common u-boot dtsi.
> >
> > Signed-off-by: Tony Dinh 
>
> Reviewed-by: Stefan Roese 
>
> I just wanted to inform you, that Simon is currently busy with migration
> to a new tags. Please see here for more details:
>
> https://lore.kernel.org/u-boot/20230129012652.83432-1-...@chromium.org/
>
> Thanks,
> Stefan
>
> > ---
> >
> >   arch/arm/dts/kirkwood-u-boot.dtsi | 7 +++
> >   1 file changed, 7 insertions(+)
> >   create mode 100644 arch/arm/dts/kirkwood-u-boot.dtsi
> >
> > diff --git a/arch/arm/dts/kirkwood-u-boot.dtsi 
> > b/arch/arm/dts/kirkwood-u-boot.dtsi
> > new file mode 100644
> > index 00..f9e127234c
> > --- /dev/null
> > +++ b/arch/arm/dts/kirkwood-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: [RFC PATCH] riscv: cpu: check U-Mode before counteren write

2023-01-31 Thread Leo Liang
On Wed, Dec 14, 2022 at 08:58:43AM +0300, Nikita Shubin wrote:
> From: Nikita Shubin 
> 
> The Priv ISA states:
> "In systems without U-mode, the mcounteren register should
> not exist."
> 
> Check U-Mode is present in MISA before writing to counteren, otherwise
> we endup with Illegal Instruction exception on systems without U-Mode.
> 
> Also make checking MISA default for M-Mode.
> 
> Signed-off-by: Nikita Shubin 
> ---
> This seems obvious at first glance, but i've never seen 'u' extension 
> enywhere in "riscv,isa" device tree property, even qemu doesn't set this, 
> and if we simply enable this check - this will break existing board for sure.
> 
> We can rely on MISA completely if we are in M-Mode, as we currently check only
> 'd', 'f' and 'u', which are standart and nothing fancy.
> ---
>  arch/riscv/cpu/cpu.c | 16 
>  1 file changed, 8 insertions(+), 8 deletions(-)
Reviewed-by: Leo Yu-Chi Liang 


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

2023-01-31 Thread Stefan Roese

Hi Tony,

On 1/31/23 22:22, 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 
---

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   |   6 +
  board/thecus/n2350/Makefile  |   6 +
  board/thecus/n2350/n2350.c   | 127 +++
  configs/n2350_defconfig  |  93 +
  include/configs/n2350.h  |  65 
  8 files changed, 755 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>;
+
+   pinctrl-names = "default";
+
+   white_sata1 {
+   label = "n2350:white:sata1";
+   gpios = < 20 GPIO_ACTIVE_HIGH>;
+   linux,default-trigger = "ide-disk1";
+   };
+
+   

Re: [PATCH] arm: kirkwood: Enable uart0 dm-pre-reloc for Kirkwood boards

2023-01-31 Thread Stefan Roese

(Added Simon to Cc)

On 2/1/23 02:11, Tony Dinh wrote:

When DM_SERIAL is enabled, the device-tree property dm-pre-reloc is
required to boot over UART with kwboot. Enable this in a Kirkwood
common u-boot dtsi.

Signed-off-by: Tony Dinh 


Reviewed-by: Stefan Roese 

I just wanted to inform you, that Simon is currently busy with migration
to a new tags. Please see here for more details:

https://lore.kernel.org/u-boot/20230129012652.83432-1-...@chromium.org/

Thanks,
Stefan


---

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

diff --git a/arch/arm/dts/kirkwood-u-boot.dtsi 
b/arch/arm/dts/kirkwood-u-boot.dtsi
new file mode 100644
index 00..f9e127234c
--- /dev/null
+++ b/arch/arm/dts/kirkwood-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: [PATCH] arm: kirkwood: Use CONFIG_SYS_NS16550 with DM_SERIAL for Kirkwood boards

2023-01-31 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 


Reviewed-by: Stefan Roese 

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 08/11] configs: ae350: Enable v5l2 cache for AE350 platforms

2023-01-31 Thread Rick Chen
Hi Peter,

> From: Peter Yu-Chien Lin(林宇謙) 
> Sent: Thursday, January 19, 2023 3:06 PM
> To: u-boot@lists.denx.de
> Cc: Leo Yu-Chi Liang(梁育齊) ; Rick Jian-Zhi Chen(陳建志) 
> ; Peter Yu-Chien Lin(林宇謙) 
> Subject: [PATCH 08/11] configs: ae350: Enable v5l2 cache for AE350 platforms
>
> Enable cache-v5l2 driver for each AE350 defconfig.


Please refer to commit ca06444aac2c643db3a3f2eb37afc60fae15177e
and describe why it shall be enabled currently. And it can be enabled
by imply in Kconfig.

Thanks,
Rick

>
> Signed-off-by: Yu Chien Peter Lin 
> ---
>  configs/ae350_rv32_defconfig | 1 +
>  configs/ae350_rv32_spl_defconfig | 3 +++
>  configs/ae350_rv32_spl_xip_defconfig | 3 +++
>  configs/ae350_rv32_xip_defconfig | 1 +
>  configs/ae350_rv64_defconfig | 1 +
>  configs/ae350_rv64_spl_defconfig | 3 +++
>  configs/ae350_rv64_spl_xip_defconfig | 3 +++
>  configs/ae350_rv64_xip_defconfig | 1 +
>  8 files changed, 16 insertions(+)
>
> diff --git a/configs/ae350_rv32_defconfig b/configs/ae350_rv32_defconfig 
> index e5c8358e54..5bcc7b9526 100644
> --- a/configs/ae350_rv32_defconfig
> +++ b/configs/ae350_rv32_defconfig
> @@ -28,6 +28,7 @@ CONFIG_ENV_IS_IN_SPI_FLASH=y  
> CONFIG_SYS_RELOC_GD_ENV_ADDR=y  CONFIG_BOOTP_SEND_HOSTNAME=y  
> CONFIG_NET_RANDOM_ETHADDR=y
> +CONFIG_V5L2_CACHE=y
>  CONFIG_MMC=y
>  CONFIG_FTSDC010=y
>  CONFIG_FTSDC010_SDIO=y
> diff --git a/configs/ae350_rv32_spl_defconfig 
> b/configs/ae350_rv32_spl_defconfig
> index a66db65621..688c2c15cd 100644
> --- a/configs/ae350_rv32_spl_defconfig
> +++ b/configs/ae350_rv32_spl_defconfig
> @@ -22,6 +22,8 @@ CONFIG_BOOTDELAY=3
>  CONFIG_BOARD_EARLY_INIT_F=y
>  CONFIG_SPL_MAX_SIZE=0x10
>  CONFIG_SPL_BSS_START_ADDR=0x400
> +CONFIG_SPL_BOARD_INIT=y
> +CONFIG_SPL_CACHE=y
>  CONFIG_SYS_PBSIZE=1050
>  CONFIG_SYS_BOOTM_LEN=0x400
>  CONFIG_CMD_IMLS=y
> @@ -34,6 +36,7 @@ CONFIG_ENV_OVERWRITE=y  CONFIG_ENV_IS_IN_SPI_FLASH=y  
> CONFIG_BOOTP_SEND_HOSTNAME=y  CONFIG_NET_RANDOM_ETHADDR=y
> +CONFIG_V5L2_CACHE=y
>  CONFIG_MMC=y
>  CONFIG_FTSDC010=y
>  CONFIG_FTSDC010_SDIO=y
> diff --git a/configs/ae350_rv32_spl_xip_defconfig 
> b/configs/ae350_rv32_spl_xip_defconfig
> index 606962c0a7..07bef47e42 100644
> --- a/configs/ae350_rv32_spl_xip_defconfig
> +++ b/configs/ae350_rv32_spl_xip_defconfig
> @@ -23,6 +23,8 @@ CONFIG_BOOTDELAY=3
>  CONFIG_BOARD_EARLY_INIT_F=y
>  CONFIG_SPL_MAX_SIZE=0x10
>  CONFIG_SPL_BSS_START_ADDR=0x400
> +CONFIG_SPL_BOARD_INIT=y
> +CONFIG_SPL_CACHE=y
>  CONFIG_SYS_PBSIZE=1050
>  CONFIG_SYS_BOOTM_LEN=0x400
>  CONFIG_CMD_IMLS=y
> @@ -35,6 +37,7 @@ CONFIG_ENV_OVERWRITE=y  CONFIG_ENV_IS_IN_SPI_FLASH=y  
> CONFIG_BOOTP_SEND_HOSTNAME=y  CONFIG_NET_RANDOM_ETHADDR=y
> +CONFIG_V5L2_CACHE=y
>  CONFIG_MMC=y
>  CONFIG_FTSDC010=y
>  CONFIG_FTSDC010_SDIO=y
> diff --git a/configs/ae350_rv32_xip_defconfig 
> b/configs/ae350_rv32_xip_defconfig
> index 069a9d3982..235a496c58 100644
> --- a/configs/ae350_rv32_xip_defconfig
> +++ b/configs/ae350_rv32_xip_defconfig
> @@ -29,6 +29,7 @@ CONFIG_ENV_IS_IN_SPI_FLASH=y  
> CONFIG_SYS_RELOC_GD_ENV_ADDR=y  CONFIG_BOOTP_SEND_HOSTNAME=y  
> CONFIG_NET_RANDOM_ETHADDR=y
> +CONFIG_V5L2_CACHE=y
>  CONFIG_MMC=y
>  CONFIG_FTSDC010=y
>  CONFIG_FTSDC010_SDIO=y
> diff --git a/configs/ae350_rv64_defconfig b/configs/ae350_rv64_defconfig 
> index c373b99b95..af23f27ade 100644
> --- a/configs/ae350_rv64_defconfig
> +++ b/configs/ae350_rv64_defconfig
> @@ -28,6 +28,7 @@ CONFIG_ENV_IS_IN_SPI_FLASH=y  
> CONFIG_SYS_RELOC_GD_ENV_ADDR=y  CONFIG_BOOTP_SEND_HOSTNAME=y  
> CONFIG_NET_RANDOM_ETHADDR=y
> +CONFIG_V5L2_CACHE=y
>  CONFIG_MMC=y
>  CONFIG_FTSDC010=y
>  CONFIG_FTSDC010_SDIO=y
> diff --git a/configs/ae350_rv64_spl_defconfig 
> b/configs/ae350_rv64_spl_defconfig
> index f235db7990..295b56835f 100644
> --- a/configs/ae350_rv64_spl_defconfig
> +++ b/configs/ae350_rv64_spl_defconfig
> @@ -22,6 +22,8 @@ CONFIG_BOOTDELAY=3
>  CONFIG_BOARD_EARLY_INIT_F=y
>  CONFIG_SPL_MAX_SIZE=0x10
>  CONFIG_SPL_BSS_START_ADDR=0x400
> +CONFIG_SPL_BOARD_INIT=y
> +CONFIG_SPL_CACHE=y
>  CONFIG_SYS_PBSIZE=1050
>  CONFIG_SYS_BOOTM_LEN=0x400
>  CONFIG_CMD_IMLS=y
> @@ -34,6 +36,7 @@ CONFIG_ENV_OVERWRITE=y  CONFIG_ENV_IS_IN_SPI_FLASH=y  
> CONFIG_BOOTP_SEND_HOSTNAME=y  CONFIG_NET_RANDOM_ETHADDR=y
> +CONFIG_V5L2_CACHE=y
>  CONFIG_MMC=y
>  CONFIG_FTSDC010=y
>  CONFIG_FTSDC010_SDIO=y
> diff --git a/configs/ae350_rv64_spl_xip_defconfig 
> b/configs/ae350_rv64_spl_xip_defconfig
> index 4cbfd52fb1..497e6c0155 100644
> --- a/configs/ae350_rv64_spl_xip_defconfig
> +++ b/configs/ae350_rv64_spl_xip_defconfig
> @@ -23,6 +23,8 @@ CONFIG_BOOTDELAY=3
>  CONFIG_BOARD_EARLY_INIT_F=y
>  CONFIG_SPL_MAX_SIZE=0x10
>  CONFIG_SPL_BSS_START_ADDR=0x400
> +CONFIG_SPL_BOARD_INIT=y
> +CONFIG_SPL_CACHE=y
>  CONFIG_SYS_PBSIZE=1050
>  CONFIG_SYS_BOOTM_LEN=0x400
>  CONFIG_CMD_IMLS=y
> @@ -35,6 +37,7 @@ CONFIG_ENV_OVERWRITE=y  CONFIG_ENV_IS_IN_SPI_FLASH=y  
> CONFIG_BOOTP_SEND_HOSTNAME=y  CONFIG_NET_RANDOM_ETHADDR=y
> 

Re: [PATCH 03/11] board: AndesTech: ax25-ae350.c: Enable v5l2-cache in spl_board_init()

2023-01-31 Thread Rick Chen
> From: Peter Yu-Chien Lin(林宇謙) 
> Sent: Thursday, January 19, 2023 3:06 PM
> To: u-boot@lists.denx.de
> Cc: Leo Yu-Chi Liang(梁育齊) ; Rick Jian-Zhi Chen(陳建志) 
> ; Peter Yu-Chien Lin(林宇謙) 
> Subject: [PATCH 03/11] board: AndesTech: ax25-ae350.c: Enable v5l2-cache in 
> spl_board_init()
>
> The L2-cache is not enabled currently, the enbale_caches() will call the 
> v5l2_enable() callback to enable it in SPL.
>
> Signed-off-by: Yu Chien Peter Lin 
> ---
>  board/AndesTech/ax25-ae350/ax25-ae350.c | 17 +
>  1 file changed, 9 insertions(+), 8 deletions(-)

Reviewed-by: Rick Chen 


Re: [PATCH 02/11] riscv: Remove redundant Kconfig "RISCV_NDS_CACHE"

2023-01-31 Thread Rick Chen
> From: Peter Yu-Chien Lin(林宇謙) 
> Sent: Thursday, January 19, 2023 3:06 PM
> To: u-boot@lists.denx.de
> Cc: Leo Yu-Chi Liang(梁育齊) ; Rick Jian-Zhi Chen(陳建志) 
> ; Peter Yu-Chien Lin(林宇謙) 
> Subject: [PATCH 02/11] riscv: Remove redundant Kconfig "RISCV_NDS_CACHE"
>
> From: Leo Yu-Chi Liang 
>
> There is no need for RISCV_NDS_CACHE config to control cache switches.
>
> Signed-off-by: Leo Yu-Chi Liang 
> Reviewed-by: Yu Chien Peter Lin 
> ---
>  arch/riscv/cpu/ax25/Kconfig | 10 -
>  arch/riscv/cpu/ax25/cache.c | 84 +
>  drivers/cache/Kconfig   |  1 -
>  3 files changed, 2 insertions(+), 93 deletions(-)

Reviewed-by: Rick Chen 


Re: [PATCH 01/11] riscv: global_data.h: Correct the comment for PLICSW

2023-01-31 Thread Rick Chen
> From: Peter Yu-Chien Lin(林宇謙) 
> Sent: Thursday, January 19, 2023 3:06 PM
> To: u-boot@lists.denx.de
> Cc: Leo Yu-Chi Liang(梁育齊) ; Rick Jian-Zhi Chen(陳建志) 
> ; Peter Yu-Chien Lin(林宇謙) 
> Subject: [PATCH 01/11] riscv: global_data.h: Correct the comment for PLICSW
>
> PLIC is used for external interrupt, while PLICSW is an Andes-specific design 
> for software interrupt.
>
> Signed-off-by: Yu Chien Peter Lin 
> ---
>  arch/riscv/include/asm/global_data.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

It seems not relative to cache.

Other than that,
Reviewed-by: Rick Chen 

>
> diff --git a/arch/riscv/include/asm/global_data.h 
> b/arch/riscv/include/asm/global_data.h
> index 6fdc86dd8b..31ba72693d 100644
> --- a/arch/riscv/include/asm/global_data.h
> +++ b/arch/riscv/include/asm/global_data.h
> @@ -22,7 +22,7 @@ struct arch_global_data {
> void __iomem *clint;/* clint base address */
>  #endif
>  #ifdef CONFIG_ANDES_PLICSW
> -   void __iomem *plicsw;   /* plic base address */
> +   void __iomem *plicsw;   /* andes plicsw base address */
>  #endif
>  #if CONFIG_IS_ENABLED(SMP)
> struct ipi_data ipi[CONFIG_NR_CPUS];
> --
> 2.34.1


Re: [GIT PULL] Please pull u-boot-mmc master

2023-01-31 Thread Tom Rini
On Wed, Feb 01, 2023 at 08:38:35AM +0900, Jaehoon Chung wrote:

> Dear Tom,
> 
> Please pull u-boot-mmc master into u-boot master branch.
> If there is any problem, let me know, plz.
> 
> Best Regards,
> Jaehoon Chung
> 
> CI: https://source.denx.de/u-boot/custodians/u-boot-mmc/-/pipelines/14951
> 
> 
> The following changes since commit 30db474704405be823259851cbb76fa05366c8af:
> 
>   Prepare v2023.04-rc1 (2023-01-30 15:36:45 -0500)
> 
> are available in the Git repository at:
> 
>   g...@source.denx.de:u-boot/custodians/u-boot-mmc.git master
> 
> for you to fetch changes up to a1f8abf4686065f46ac840e956a1aeb68d90d969:
> 
>   mmc: zynq_sdhci: Add support and quirk for HS400 (2023-01-31 22:02:27 +0900)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [GIT PULL] Please pull u-boot-pmic master

2023-01-31 Thread Tom Rini
On Wed, Feb 01, 2023 at 08:17:42AM +0900, Jaehoon Chung wrote:

> Dear Tom,
> 
> Please pull u-boot-pmic master into u-boot master branch.
> If there is a problem, let me know, plz
> 
> Best Regards,
> Jaehoon Chung
> 
> CI: https://source.denx.de/u-boot/custodians/u-boot-pmic/-/pipelines/14954
> 
> 
> The following changes since commit 30db474704405be823259851cbb76fa05366c8af:
> 
>   Prepare v2023.04-rc1 (2023-01-30 15:36:45 -0500)
> 
> are available in the Git repository at:
> 
>   g...@source.denx.de:u-boot/custodians/u-boot-pmic.git master
> 
> for you to fetch changes up to 519fa7aa252789677939f0bd991bf26a4fe469ec:
> 
>   power: act8846_pmic: fix number of registers (2023-01-31 22:05:03 +0900)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH v2 11/12] ARM: dts: uniphier: Switch USB node to the original

2023-01-31 Thread Kunihiko Hayashi
UniPhier DT applies its own USB node for U-Boot due to the USB driver
constrains. After solving this issue, u-boot allows the original USB node.

After switching USB node, synchronization of USB node with Linux becomes
possible.

Signed-off-by: Kunihiko Hayashi 
---
 arch/arm/dts/uniphier-ld20.dtsi | 21 +
 arch/arm/dts/uniphier-pro4.dtsi | 42 ++---
 arch/arm/dts/uniphier-pxs2.dtsi | 42 ++---
 arch/arm/dts/uniphier-pxs3.dtsi | 42 ++---
 4 files changed, 7 insertions(+), 140 deletions(-)

diff --git a/arch/arm/dts/uniphier-ld20.dtsi b/arch/arm/dts/uniphier-ld20.dtsi
index 21a431ab7f..9155b39dfa 100644
--- a/arch/arm/dts/uniphier-ld20.dtsi
+++ b/arch/arm/dts/uniphier-ld20.dtsi
@@ -744,7 +744,7 @@
};
};
 
-   _usb: usb@65a0 {
+   usb: usb@65a0 {
compatible = "socionext,uniphier-dwc3", "snps,dwc3";
status = "disabled";
reg = <0x65a0 0xcd00>;
@@ -895,25 +895,6 @@
};
};
 
-   /* FIXME: U-Boot own node */
-   usb: usb@65b0 {
-   compatible = "socionext,uniphier-ld20-dwc3";
-   reg = <0x65b0 0x1000>;
-   #address-cells = <1>;
-   #size-cells = <1>;
-   ranges;
-   pinctrl-names = "default";
-   pinctrl-0 = <_usb0>, <_usb1>,
-   <_usb2>, <_usb3>;
-   dwc3@65a0 {
-   compatible = "snps,dwc3";
-   reg = <0x65a0 0x1>;
-   interrupts = <0 134 4>;
-   dr_mode = "host";
-   tx-fifo-resize;
-   };
-   };
-
pcie: pcie@6600 {
compatible = "socionext,uniphier-pcie", "snps,dw-pcie";
status = "disabled";
diff --git a/arch/arm/dts/uniphier-pro4.dtsi b/arch/arm/dts/uniphier-pro4.dtsi
index 0e0a30ab40..3412c800e3 100644
--- a/arch/arm/dts/uniphier-pro4.dtsi
+++ b/arch/arm/dts/uniphier-pro4.dtsi
@@ -503,7 +503,7 @@
};
};
 
-   _usb0: usb@65a0 {
+   usb0: usb@65a0 {
compatible = "socionext,uniphier-dwc3", "snps,dwc3";
status = "disabled";
reg = <0x65a0 0xcd00>;
@@ -557,26 +557,7 @@
};
};
 
-   /* FIXME: U-Boot own node */
-   usb0: usb@65b0 {
-   compatible = "socionext,uniphier-pro4-dwc3";
-   status = "disabled";
-   reg = <0x65b0 0x1000>;
-   #address-cells = <1>;
-   #size-cells = <1>;
-   ranges;
-   pinctrl-names = "default";
-   pinctrl-0 = <_usb0>;
-   dwc3@65a0 {
-   compatible = "snps,dwc3";
-   reg = <0x65a0 0x1>;
-   interrupts = <0 134 4>;
-   dr_mode = "host";
-   tx-fifo-resize;
-   };
-   };
-
-   _usb1: usb@65c0 {
+   usb1: usb@65c0 {
compatible = "socionext,uniphier-dwc3", "snps,dwc3";
status = "disabled";
reg = <0x65c0 0xcd00>;
@@ -618,25 +599,6 @@
};
};
 
-   /* FIXME: U-Boot own node */
-   usb1: usb@65d0 {
-   compatible = "socionext,uniphier-pro4-dwc3";
-   status = "disabled";
-   reg = <0x65d0 0x1000>;
-   #address-cells = <1>;
-   #size-cells = <1>;
-   ranges;
-   pinctrl-names = "default";
-   pinctrl-0 = <_usb1>;
-   dwc3@65c0 {
-   compatible = "snps,dwc3";
-   reg = <0x65c0 0x1>;
-   interrupts = <0 137 4>;
-   dr_mode = "host";
-   tx-fifo-resize;
-   };
-   };
-
nand: nand-controller@6800 {
compatible = "socionext,uniphier-denali-nand-v5a";
status = "disabled";
diff --git a/arch/arm/dts/uniphier-pxs2.dtsi b/arch/arm/dts/uniphier-pxs2.dtsi
index cafa14e22e..da855e3f71 100644
--- 

[PATCH v2 04/12] usb: dwc3-generic: Export glue structures and functions

2023-01-31 Thread Kunihiko Hayashi
In order to allow external SoC-dependent glue drivers to use dwc3-generic
functions, push the glue structures and export the functions to a header
file.

The exported structures and functions are:

- struct dwc3_glue_data
- struct dwc3_glue_ops
- dwc3_glue_bind()
- dwc3_glue_probe()
- dwc3_glue_remove()

The SoC-dependent glue drivers can only define their own wrapper driver
and specify these functions. The drivers can also add their own compatible
strings and configure functions.

Signed-off-by: Kunihiko Hayashi 
Reviewed-by: Marek Vasut 
---
 drivers/usb/dwc3/dwc3-generic.c | 18 --
 drivers/usb/dwc3/dwc3-generic.h | 32 
 2 files changed, 36 insertions(+), 14 deletions(-)
 create mode 100644 drivers/usb/dwc3/dwc3-generic.h

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 8fa56e1ac1..4576390ec7 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -28,11 +28,7 @@
 #include 
 #include 
 
-struct dwc3_glue_data {
-   struct clk_bulk clks;
-   struct reset_ctl_bulk   resets;
-   fdt_addr_t regs;
-};
+#include "dwc3-generic.h"
 
 struct dwc3_generic_plat {
fdt_addr_t base;
@@ -275,12 +271,6 @@ U_BOOT_DRIVER(dwc3_generic_host) = {
 };
 #endif
 
-struct dwc3_glue_ops {
-   int (*glue_get_ctrl_dev)(struct udevice *parent, ofnode *node);
-   void (*glue_configure)(struct udevice *dev, int index,
-  enum usb_dr_mode mode);
-};
-
 void dwc3_imx8mp_glue_configure(struct udevice *dev, int index,
enum usb_dr_mode mode)
 {
@@ -464,7 +454,7 @@ static int dwc3_glue_bind_common(struct udevice *parent, 
ofnode node)
return 0;
 }
 
-static int dwc3_glue_bind(struct udevice *parent)
+int dwc3_glue_bind(struct udevice *parent)
 {
struct dwc3_glue_ops *ops = (struct dwc3_glue_ops 
*)dev_get_driver_data(parent);
ofnode node;
@@ -531,7 +521,7 @@ static int dwc3_glue_clk_init(struct udevice *dev,
return 0;
 }
 
-static int dwc3_glue_probe(struct udevice *dev)
+int dwc3_glue_probe(struct udevice *dev)
 {
struct dwc3_glue_ops *ops = (struct dwc3_glue_ops 
*)dev_get_driver_data(dev);
struct dwc3_glue_data *glue = dev_get_plat(dev);
@@ -597,7 +587,7 @@ static int dwc3_glue_probe(struct udevice *dev)
return 0;
 }
 
-static int dwc3_glue_remove(struct udevice *dev)
+int dwc3_glue_remove(struct udevice *dev)
 {
struct dwc3_glue_data *glue = dev_get_plat(dev);
 
diff --git a/drivers/usb/dwc3/dwc3-generic.h b/drivers/usb/dwc3/dwc3-generic.h
new file mode 100644
index 00..824f678841
--- /dev/null
+++ b/drivers/usb/dwc3/dwc3-generic.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * dwc3-generic.h - Generic DWC3 Glue layer header
+ *
+ * Copyright (C) 2016 - 2018 Xilinx, Inc.
+ * Copyright (C) 2023 Socionext Inc.
+ */
+
+#ifndef __DRIVERS_USB_DWC3_GENERIC_H
+#define __DRIVERS_USB_DWC3_GENERIC_H
+
+#include 
+#include 
+#include 
+
+struct dwc3_glue_data {
+   struct clk_bulk clks;
+   struct reset_ctl_bulk   resets;
+   fdt_addr_t regs;
+};
+
+struct dwc3_glue_ops {
+   int (*glue_get_ctrl_dev)(struct udevice *parent, ofnode *node);
+   void (*glue_configure)(struct udevice *dev, int index,
+  enum usb_dr_mode mode);
+};
+
+int dwc3_glue_bind(struct udevice *parent);
+int dwc3_glue_probe(struct udevice *dev);
+int dwc3_glue_remove(struct udevice *dev);
+
+#endif
-- 
2.25.1



[PATCH v2 10/12] ARM: dts: uniphier: Fix node names and missing reg property in USB glue node

2023-01-31 Thread Kunihiko Hayashi
The node name should follow the generic name list in DT specification.
This moves "reset" to "reset-controller", "hs-phy" and "ss-phy" to "phy"
in the USB glue node.

And the node should have reg property to define the register region.

Signed-off-by: Kunihiko Hayashi 
---
 arch/arm/dts/uniphier-ld20.dtsi | 15 ---
 arch/arm/dts/uniphier-pro4.dtsi |  7 ---
 arch/arm/dts/uniphier-pro5.dtsi | 15 ---
 arch/arm/dts/uniphier-pxs2.dtsi | 20 +++-
 arch/arm/dts/uniphier-pxs3.dtsi | 20 +++-
 5 files changed, 42 insertions(+), 35 deletions(-)

diff --git a/arch/arm/dts/uniphier-ld20.dtsi b/arch/arm/dts/uniphier-ld20.dtsi
index 4549935c42..21a431ab7f 100644
--- a/arch/arm/dts/uniphier-ld20.dtsi
+++ b/arch/arm/dts/uniphier-ld20.dtsi
@@ -765,11 +765,12 @@
usb-glue@65b0 {
compatible = "socionext,uniphier-ld20-dwc3-glue",
 "simple-mfd";
+   reg = <0x65b0 0x4000>;
#address-cells = <1>;
#size-cells = <1>;
ranges = <0 0x65b0 0x400>;
 
-   usb_rst: reset@0 {
+   usb_rst: reset-controller@0 {
compatible = 
"socionext,uniphier-ld20-usb3-reset";
reg = <0x0 0x4>;
#reset-cells = <1>;
@@ -815,7 +816,7 @@
resets = <_rst 14>;
};
 
-   usb_hsphy0: hs-phy@200 {
+   usb_hsphy0: phy@200 {
compatible = 
"socionext,uniphier-ld20-usb3-hsphy";
reg = <0x200 0x10>;
#phy-cells = <0>;
@@ -829,7 +830,7 @@
  <_hs_i0>;
};
 
-   usb_hsphy1: hs-phy@210 {
+   usb_hsphy1: phy@210 {
compatible = 
"socionext,uniphier-ld20-usb3-hsphy";
reg = <0x210 0x10>;
#phy-cells = <0>;
@@ -843,7 +844,7 @@
  <_hs_i0>;
};
 
-   usb_hsphy2: hs-phy@220 {
+   usb_hsphy2: phy@220 {
compatible = 
"socionext,uniphier-ld20-usb3-hsphy";
reg = <0x220 0x10>;
#phy-cells = <0>;
@@ -857,7 +858,7 @@
  <_hs_i2>;
};
 
-   usb_hsphy3: hs-phy@230 {
+   usb_hsphy3: phy@230 {
compatible = 
"socionext,uniphier-ld20-usb3-hsphy";
reg = <0x230 0x10>;
#phy-cells = <0>;
@@ -871,7 +872,7 @@
  <_hs_i2>;
};
 
-   usb_ssphy0: ss-phy@300 {
+   usb_ssphy0: phy@300 {
compatible = 
"socionext,uniphier-ld20-usb3-ssphy";
reg = <0x300 0x10>;
#phy-cells = <0>;
@@ -882,7 +883,7 @@
vbus-supply = <_vbus0>;
};
 
-   usb_ssphy1: ss-phy@310 {
+   usb_ssphy1: phy@310 {
compatible = 
"socionext,uniphier-ld20-usb3-ssphy";
reg = <0x310 0x10>;
#phy-cells = <0>;
diff --git a/arch/arm/dts/uniphier-pro4.dtsi b/arch/arm/dts/uniphier-pro4.dtsi
index 9dae4e9b23..0e0a30ab40 100644
--- a/arch/arm/dts/uniphier-pro4.dtsi
+++ b/arch/arm/dts/uniphier-pro4.dtsi
@@ -521,6 +521,7 @@
usb-glue@65b0 {
compatible = "socionext,uniphier-pro4-dwc3-glue",
 "simple-mfd";
+   reg = <0x65b0 0x100>;
#address-cells = <1>;
#size-cells = <1>;
ranges = <0 0x65b0 0x100>;
@@ -534,7 +535,7 @@
resets = <_rst 12>, <_rst 14>;
};
 
-   usb0_ssphy: ss-phy@10 {
+   usb0_ssphy: phy@10 {
compatible = 
"socionext,uniphier-pro4-usb3-ssphy";
reg = <0x10 0x10>;
#phy-cells = <0>;
@@ -545,7 +546,7 @@
vbus-supply = <_vbus>;
};
 
-   usb0_rst: reset@40 {
+   usb0_rst: reset-controller@40 {
compatible = 

[PATCH v2 09/12] phy: socionext: Add UniPhier USB3 PHY driver

2023-01-31 Thread Kunihiko Hayashi
Add USB3 PHY driver support to control clocks and resets for the phy.

Signed-off-by: Kunihiko Hayashi 
---
 configs/uniphier_v8_defconfig |  1 +
 drivers/phy/socionext/Kconfig |  7 ++
 drivers/phy/socionext/Makefile|  1 +
 drivers/phy/socionext/phy-uniphier-usb3.c | 89 +++
 4 files changed, 98 insertions(+)
 create mode 100644 drivers/phy/socionext/phy-uniphier-usb3.c

diff --git a/configs/uniphier_v8_defconfig b/configs/uniphier_v8_defconfig
index 6a0e2666cf..5cfa9fc01d 100644
--- a/configs/uniphier_v8_defconfig
+++ b/configs/uniphier_v8_defconfig
@@ -78,3 +78,4 @@ CONFIG_USB_DWC3=y
 CONFIG_USB_DWC3_UNIPHIER=y
 CONFIG_PANIC_HANG=y
 CONFIG_FDT_FIXUP_PARTITIONS=y
+CONFIG_PHY_UNIPHIER_USB3=y
diff --git a/drivers/phy/socionext/Kconfig b/drivers/phy/socionext/Kconfig
index bcd579e98e..fc63f4c042 100644
--- a/drivers/phy/socionext/Kconfig
+++ b/drivers/phy/socionext/Kconfig
@@ -10,3 +10,10 @@ config PHY_UNIPHIER_PCIE
help
  Enable this to support PHY implemented in PCIe controller
  on UniPhier SoCs.
+
+config PHY_UNIPHIER_USB3
+   bool "UniPhier USB3 PHY driver"
+   depends on PHY && ARCH_UNIPHIER
+   help
+ Enable this to support PHY implemented in USB3 controller
+ on UniPhier SoCs.
diff --git a/drivers/phy/socionext/Makefile b/drivers/phy/socionext/Makefile
index 5484360b70..94d3aa68cf 100644
--- a/drivers/phy/socionext/Makefile
+++ b/drivers/phy/socionext/Makefile
@@ -4,3 +4,4 @@
 #
 
 obj-$(CONFIG_PHY_UNIPHIER_PCIE)+= phy-uniphier-pcie.o
+obj-$(CONFIG_PHY_UNIPHIER_USB3)+= phy-uniphier-usb3.o
diff --git a/drivers/phy/socionext/phy-uniphier-usb3.c 
b/drivers/phy/socionext/phy-uniphier-usb3.c
new file mode 100644
index 00..a2e44a52c1
--- /dev/null
+++ b/drivers/phy/socionext/phy-uniphier-usb3.c
@@ -0,0 +1,89 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * phy_uniphier_usb3.c - Socionext UniPhier Usb3 PHY driver
+ * Copyright 2019-2021 Socionext, Inc.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+struct uniphier_usb3phy_priv {
+   struct clk_bulk clks;
+   struct reset_ctl_bulk rsts;
+};
+
+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) {
+   clk_release_bulk(>clks);
+   return ret;
+   }
+
+   ret = reset_deassert_bulk(>rsts);
+   if (ret) {
+   reset_release_bulk(>rsts);
+   return ret;
+   }
+
+   return 0;
+}
+
+static int uniphier_usb3phy_probe(struct udevice *dev)
+{
+   struct uniphier_usb3phy_priv *priv = dev_get_priv(dev);
+   int ret;
+
+   ret = clk_get_bulk(dev, >clks);
+   if (ret) {
+   if (ret != -ENOSYS && ret != -ENOENT) {
+   printf("Failed to get clocks\n");
+   return ret;
+   }
+   }
+
+   ret = reset_get_bulk(dev, >rsts);
+   if (ret) {
+   if (ret != -ENOSYS && ret != -ENOENT) {
+   printf("Failed to get resets\n");
+   return ret;
+   }
+   }
+
+   return 0;
+}
+
+static struct phy_ops uniphier_usb3phy_ops = {
+   .init = uniphier_usb3phy_init,
+};
+
+static const struct udevice_id uniphier_usb3phy_ids[] = {
+   { .compatible = "socionext,uniphier-pro4-usb3-ssphy" },
+   { .compatible = "socionext,uniphier-pro5-usb3-hsphy" },
+   { .compatible = "socionext,uniphier-pro5-usb3-ssphy" },
+   { .compatible = "socionext,uniphier-pxs2-usb3-hsphy" },
+   { .compatible = "socionext,uniphier-pxs2-usb3-ssphy" },
+   { .compatible = "socionext,uniphier-ld20-usb3-hsphy" },
+   { .compatible = "socionext,uniphier-ld20-usb3-ssphy" },
+   { .compatible = "socionext,uniphier-pxs3-usb3-hsphy" },
+   { .compatible = "socionext,uniphier-pxs3-usb3-ssphy" },
+   { .compatible = "socionext,uniphier-nx1-usb3-hsphy" },
+   { .compatible = "socionext,uniphier-nx1-usb3-ssphy" },
+   { }
+};
+
+U_BOOT_DRIVER(uniphier_usb3_phy) = {
+   .name   = "uniphier-usb3-phy",
+   .id = UCLASS_PHY,
+   .of_match   = uniphier_usb3phy_ids,
+   .ops= _usb3phy_ops,
+   .probe  = uniphier_usb3phy_probe,
+   .priv_auto  = sizeof(struct uniphier_usb3phy_priv),
+};
-- 
2.25.1



[PATCH v2 12/12] uniphier_defconfig: Disable USB_XHCI_DWC3

2023-01-31 Thread Kunihiko Hayashi
Replacing with dwc3-generic, no need USB_XHCI_DWC3 anymore.

Signed-off-by: Kunihiko Hayashi 
Reviewed-by: Marek Vasut 
---
 configs/uniphier_v7_defconfig | 1 -
 configs/uniphier_v8_defconfig | 1 -
 2 files changed, 2 deletions(-)

diff --git a/configs/uniphier_v7_defconfig b/configs/uniphier_v7_defconfig
index d626968c76..03feb04b93 100644
--- a/configs/uniphier_v7_defconfig
+++ b/configs/uniphier_v7_defconfig
@@ -82,7 +82,6 @@ CONFIG_DM_SPI=y
 CONFIG_UNIPHIER_SPI=y
 CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
-CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_GENERIC=y
 CONFIG_USB_DWC3=y
diff --git a/configs/uniphier_v8_defconfig b/configs/uniphier_v8_defconfig
index 5cfa9fc01d..93520e01a1 100644
--- a/configs/uniphier_v8_defconfig
+++ b/configs/uniphier_v8_defconfig
@@ -71,7 +71,6 @@ CONFIG_SYSRESET=y
 CONFIG_SYSRESET_PSCI=y
 CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
-CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_GENERIC=y
 CONFIG_USB_DWC3=y
-- 
2.25.1



[PATCH v2 06/12] usb: dwc3-uniphier: Use dwc3-generic instead of xhci-dwc3

2023-01-31 Thread Kunihiko Hayashi
dwc3-uniphier depends on xhci-dwc3 framework, however, it is preferable
to use dwc3-generic.

This driver calls the exported dwc3-generic functions and redefine
the SoC-dependent operations to fit dwc3-generic.

Signed-off-by: Kunihiko Hayashi 
Reviewed-by: Marek Vasut 
---
 drivers/usb/dwc3/Kconfig |   3 +-
 drivers/usb/dwc3/dwc3-uniphier.c | 116 ---
 2 files changed, 77 insertions(+), 42 deletions(-)

diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index f010291d02..69801eeb81 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -55,7 +55,8 @@ config USB_DWC3_MESON_GXL
 
 config USB_DWC3_UNIPHIER
bool "DesignWare USB3 Host Support on UniPhier Platforms"
-   depends on ARCH_UNIPHIER && USB_XHCI_DWC3
+   depends on ARCH_UNIPHIER && USB_DWC3
+   select USB_DWC3_GENERIC
help
  Support of USB2/3 functionality in Socionext UniPhier platforms.
  Say 'Y' here if you have one such device.
diff --git a/drivers/usb/dwc3/dwc3-uniphier.c b/drivers/usb/dwc3/dwc3-uniphier.c
index 54b52dcd66..ab85428a70 100644
--- a/drivers/usb/dwc3/dwc3-uniphier.c
+++ b/drivers/usb/dwc3/dwc3-uniphier.c
@@ -4,14 +4,17 @@
  *
  * Copyright (C) 2016-2017 Socionext Inc.
  *   Author: Masahiro Yamada 
+ *   Author: Kunihiko Hayashi 
  */
 
 #include 
-#include 
+#include 
 #include 
-#include 
-#include 
-#include 
+#include 
+
+#include "core.h"
+#include "gadget.h"
+#include "dwc3-generic.h"
 
 #define UNIPHIER_PRO4_DWC3_RESET   0x40
 #define   UNIPHIER_PRO4_DWC3_RESET_XIOMMU  BIT(5)
@@ -27,8 +30,11 @@
 #define UNIPHIER_PXS2_DWC3_RESET   0x00
 #define   UNIPHIER_PXS2_DWC3_RESET_XLINK   BIT(15)
 
-static int uniphier_pro4_dwc3_init(void __iomem *regs)
+static void uniphier_pro4_dwc3_init(struct udevice *dev, int index,
+   enum usb_dr_mode mode)
 {
+   struct dwc3_glue_data *glue = dev_get_plat(dev);
+   void *regs = map_physmem(glue->regs, glue->size, MAP_NOCACHE);
u32 tmp;
 
tmp = readl(regs + UNIPHIER_PRO4_DWC3_RESET);
@@ -36,11 +42,14 @@ static int uniphier_pro4_dwc3_init(void __iomem *regs)
tmp |= UNIPHIER_PRO4_DWC3_RESET_XIOMMU | UNIPHIER_PRO4_DWC3_RESET_XLINK;
writel(tmp, regs + UNIPHIER_PRO4_DWC3_RESET);
 
-   return 0;
+   unmap_physmem(regs, MAP_NOCACHE);
 }
 
-static int uniphier_pro5_dwc3_init(void __iomem *regs)
+static void uniphier_pro5_dwc3_init(struct udevice *dev, int index,
+   enum usb_dr_mode mode)
 {
+   struct dwc3_glue_data *glue = dev_get_plat(dev);
+   void *regs = map_physmem(glue->regs, glue->size, MAP_NOCACHE);
u32 tmp;
 
tmp = readl(regs + UNIPHIER_PRO5_DWC3_RESET);
@@ -49,72 +58,97 @@ static int uniphier_pro5_dwc3_init(void __iomem *regs)
tmp |= UNIPHIER_PRO5_DWC3_RESET_XLINK | UNIPHIER_PRO5_DWC3_RESET_XIOMMU;
writel(tmp, regs + UNIPHIER_PRO5_DWC3_RESET);
 
-   return 0;
+   unmap_physmem(regs, MAP_NOCACHE);
 }
 
-static int uniphier_pxs2_dwc3_init(void __iomem *regs)
+static void uniphier_pxs2_dwc3_init(struct udevice *dev, int index,
+   enum usb_dr_mode mode)
 {
+   struct dwc3_glue_data *glue = dev_get_plat(dev);
+   void *regs = map_physmem(glue->regs, glue->size, MAP_NOCACHE);
u32 tmp;
 
tmp = readl(regs + UNIPHIER_PXS2_DWC3_RESET);
tmp |= UNIPHIER_PXS2_DWC3_RESET_XLINK;
writel(tmp, regs + UNIPHIER_PXS2_DWC3_RESET);
 
-   return 0;
+   unmap_physmem(regs, MAP_NOCACHE);
 }
 
-static int uniphier_dwc3_probe(struct udevice *dev)
+static int dwc3_uniphier_glue_get_ctrl_dev(struct udevice *dev, ofnode *node)
 {
-   fdt_addr_t base;
-   void __iomem *regs;
-   int (*init)(void __iomem *regs);
-   int ret;
+   struct udevice *child;
+   const char *name;
+   ofnode subnode;
+
+   /*
+* "controller reset" belongs to glue logic, and it should be
+* accessible in .glue_configure() before access to the controller
+* begins.
+*/
+   ofnode_for_each_subnode(subnode, dev_ofnode(dev)) {
+   name = ofnode_get_name(subnode);
+   if (!strncmp(name, "reset", 5))
+   device_bind_driver_to_node(dev, "uniphier-reset",
+  name, subnode, );
+   }
+
+   /* Get controller node that is placed separately from the glue node */
+   *node = ofnode_by_compatible(dev_ofnode(dev->parent),
+"socionext,uniphier-dwc3");
 
-   base = dev_read_addr(dev);
-   if (base == FDT_ADDR_T_NONE)
-   return -EINVAL;
-
-   regs = ioremap(base, SZ_32K);
-   if (!regs)
-   return -ENOMEM;
+   return 0;
+}
 
-   init = (typeof(init))dev_get_driver_data(dev);
-   ret = init(regs);
-   if (ret)
-   dev_err(dev, "failed 

[PATCH v2 08/12] clk: uniphier: Add missing USB SS-PHY clocks

2023-01-31 Thread Kunihiko Hayashi
The USB SS-PHY needs its own clock, however, some clocks don't have
clock gates. Define missing clock entries for the PHY as reference
clock.

Signed-off-by: Kunihiko Hayashi 
---
 drivers/clk/uniphier/clk-uniphier-sys.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/clk/uniphier/clk-uniphier-sys.c 
b/drivers/clk/uniphier/clk-uniphier-sys.c
index ff5d364f59..3b8595fe61 100644
--- a/drivers/clk/uniphier/clk-uniphier-sys.c
+++ b/drivers/clk/uniphier/clk-uniphier-sys.c
@@ -28,7 +28,10 @@ const struct uniphier_clk_data uniphier_pxs2_sys_clk_data[] 
= {
UNIPHIER_CLK_GATE_SIMPLE(14, 0x2104, 16),   /* usb30 (Pro4, Pro5, 
PXs2) */
UNIPHIER_CLK_GATE_SIMPLE(15, 0x2104, 17),   /* usb31 (Pro4, Pro5, 
PXs2) */
UNIPHIER_CLK_GATE_SIMPLE(16, 0x2104, 19),   /* usb30-phy (PXs2) */
+   UNIPHIER_CLK_RATE(17, 2500),/* usb30-phy2 (PXs2) */
+   UNIPHIER_CLK_RATE(18, 2500),/* usb30-phy3 (PXs2) */
UNIPHIER_CLK_GATE_SIMPLE(20, 0x2104, 20),   /* usb31-phy (PXs2) */
+   UNIPHIER_CLK_RATE(21, 2500),/* usb31-phy2 (PXs2) */
UNIPHIER_CLK_GATE_SIMPLE(24, 0x2108, 2),/* pcie (Pro5) */
{ /* sentinel */ }
 #endif
@@ -44,6 +47,8 @@ const struct uniphier_clk_data uniphier_ld20_sys_clk_data[] = 
{
UNIPHIER_CLK_GATE_SIMPLE(14, 0x210c, 14),   /* usb30 (LD20) */
UNIPHIER_CLK_GATE_SIMPLE(16, 0x210c, 12),   /* usb30-phy0 (LD20) */
UNIPHIER_CLK_GATE_SIMPLE(17, 0x210c, 13),   /* usb30-phy1 (LD20) */
+   UNIPHIER_CLK_RATE(18, 2500),/* usb30-phy2 (LD20) */
+   UNIPHIER_CLK_RATE(19, 2500),/* usb30-phy3 (LD20) */
UNIPHIER_CLK_GATE_SIMPLE(24, 0x210c, 4),/* pcie */
{ /* sentinel */ }
 #endif
-- 
2.25.1



[PATCH v2 05/12] usb: dwc3-generic: Add the size of regs property to glue structure

2023-01-31 Thread Kunihiko Hayashi
Add the size of regs property to the glue structure to correctly
specify the register region to map.

Signed-off-by: Kunihiko Hayashi 
Reviewed-by: Marek Vasut 
---
 drivers/usb/dwc3/dwc3-generic.c | 2 +-
 drivers/usb/dwc3/dwc3-generic.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 4576390ec7..acbf7acb19 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -542,7 +542,7 @@ int dwc3_glue_probe(struct udevice *dev)
phy.dev = NULL;
}
 
-   glue->regs = dev_read_addr(dev);
+   glue->regs = dev_read_addr_size_index(dev, 0, >size);
 
ret = dwc3_glue_clk_init(dev, glue);
if (ret)
diff --git a/drivers/usb/dwc3/dwc3-generic.h b/drivers/usb/dwc3/dwc3-generic.h
index 824f678841..40902c8923 100644
--- a/drivers/usb/dwc3/dwc3-generic.h
+++ b/drivers/usb/dwc3/dwc3-generic.h
@@ -17,6 +17,7 @@ struct dwc3_glue_data {
struct clk_bulk clks;
struct reset_ctl_bulk   resets;
fdt_addr_t regs;
+   fdt_size_t size;
 };
 
 struct dwc3_glue_ops {
-- 
2.25.1



[PATCH v2 03/12] usb: dwc3-generic: Add clock initialization in child DT node

2023-01-31 Thread Kunihiko Hayashi
Same as the reset cotnrol, should add a clock initialization in child DT
node, if the glue node doesn't have any clocks.

Signed-off-by: Kunihiko Hayashi 
---
 drivers/usb/dwc3/dwc3-generic.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index e32003d68e..8fa56e1ac1 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -572,6 +572,12 @@ static int dwc3_glue_probe(struct udevice *dev)
if (ret)
return ret;
 
+   if (glue->clks.count == 0) {
+   ret = dwc3_glue_clk_init(child, glue);
+   if (ret)
+   return ret;
+   }
+
if (glue->resets.count == 0) {
ret = dwc3_glue_reset_init(child, glue);
if (ret)
-- 
2.25.1



[PATCH v2 07/12] reset: uniphier: Add USB glue reset support

2023-01-31 Thread Kunihiko Hayashi
Add reset control support in USB glue logic. This needs to control
the external clocks and resets for the logic before accessing the
glue logic.

Signed-off-by: Kunihiko Hayashi 
---
 drivers/reset/reset-uniphier.c | 78 +-
 1 file changed, 77 insertions(+), 1 deletion(-)

diff --git a/drivers/reset/reset-uniphier.c b/drivers/reset/reset-uniphier.c
index 7adae51873..35e3ccebd7 100644
--- a/drivers/reset/reset-uniphier.c
+++ b/drivers/reset/reset-uniphier.c
@@ -2,6 +2,7 @@
 /*
  * Copyright (C) 2016 Socionext Inc.
  *   Author: Masahiro Yamada 
+ *   Author: Kunihiko Hayashi 
  */
 
 #include 
@@ -9,6 +10,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -178,10 +181,17 @@ static const struct uniphier_reset_data 
uniphier_pro4_peri_reset_data[] = {
UNIPHIER_RESET_END,
 };
 
+/* Glue reset data */
+static const struct uniphier_reset_data uniphier_pro4_usb3_reset_data[] = {
+   UNIPHIER_RESETX(15, 0, 15)
+};
+
 /* core implementaton */
 struct uniphier_reset_priv {
void __iomem *base;
const struct uniphier_reset_data *data;
+   struct clk_bulk clks;
+   struct reset_ctl_bulk   rsts;
 };
 
 static int uniphier_reset_update(struct reset_ctl *reset_ctl, int assert)
@@ -233,10 +243,47 @@ static const struct reset_ops uniphier_reset_ops = {
.rst_deassert = uniphier_reset_deassert,
 };
 
+static int uniphier_reset_rst_init(struct udevice *dev)
+{
+   struct uniphier_reset_priv *priv = dev_get_priv(dev);
+   int ret;
+
+   ret = reset_get_bulk(dev, >rsts);
+   if (ret == -ENOSYS || ret == -ENOENT)
+   return 0;
+   else if (ret)
+   return ret;
+
+   ret = reset_deassert_bulk(>rsts);
+   if (ret)
+   reset_release_bulk(>rsts);
+
+   return ret;
+}
+
+static int uniphier_reset_clk_init(struct udevice *dev)
+{
+   struct uniphier_reset_priv *priv = dev_get_priv(dev);
+   int ret;
+
+   ret = clk_get_bulk(dev, >clks);
+   if (ret == -ENOSYS || ret == -ENOENT)
+   return 0;
+   if (ret)
+   return ret;
+
+   ret = clk_enable_bulk(>clks);
+   if (ret)
+   clk_release_bulk(>clks);
+
+   return ret;
+}
+
 static int uniphier_reset_probe(struct udevice *dev)
 {
struct uniphier_reset_priv *priv = dev_get_priv(dev);
fdt_addr_t addr;
+   int ret;
 
addr = dev_read_addr(dev->parent);
if (addr == FDT_ADDR_T_NONE)
@@ -248,7 +295,11 @@ static int uniphier_reset_probe(struct udevice *dev)
 
priv->data = (void *)dev_get_driver_data(dev);
 
-   return 0;
+   ret = uniphier_reset_clk_init(dev);
+   if (ret)
+   return ret;
+
+   return uniphier_reset_rst_init(dev);
 }
 
 static const struct udevice_id uniphier_reset_match[] = {
@@ -355,6 +406,31 @@ static const struct udevice_id uniphier_reset_match[] = {
.compatible = "socionext,uniphier-pxs3-peri-reset",
.data = (ulong)uniphier_pro4_peri_reset_data,
},
+   /* USB glue reset */
+   {
+   .compatible = "socionext,uniphier-pro4-usb3-reset",
+   .data = (ulong)uniphier_pro4_usb3_reset_data,
+   },
+   {
+   .compatible = "socionext,uniphier-pro5-usb3-reset",
+   .data = (ulong)uniphier_pro4_usb3_reset_data,
+   },
+   {
+   .compatible = "socionext,uniphier-pxs2-usb3-reset",
+   .data = (ulong)uniphier_pro4_usb3_reset_data,
+   },
+   {
+   .compatible = "socionext,uniphier-ld20-usb3-reset",
+   .data = (ulong)uniphier_pro4_usb3_reset_data,
+   },
+   {
+   .compatible = "socionext,uniphier-pxs3-usb3-reset",
+   .data = (ulong)uniphier_pro4_usb3_reset_data,
+   },
+   {
+   .compatible = "socionext,uniphier-nx1-usb3-reset",
+   .data = (ulong)uniphier_pro4_usb3_reset_data,
+   },
{ /* sentinel */ }
 };
 
-- 
2.25.1



[PATCH v2 02/12] usb: dwc3-generic: Allow different controller DT node pattern

2023-01-31 Thread Kunihiko Hayashi
The most of devicetree has the following USB node structure.
The controller node is placed as a child node of the glue node.
Current dwc3-generic driver works on this premise.

glue {
/* glue node */
usb {
/* controller node */
};
};

However, UniPhier original devicetree has the following USB node structure.
The controller node is separately placed from the glue node.

usb {
/* controller node */
};
glue {
/* glue node */
};

In dwc_glue_bind(), this patch provides .glue_get_ctrl_dev() callback to
get such a controller node and binds the driver related to the node.

If this callback isn't defined, dwc_glue_bind() looks for the controller
nodes from the child nodes, as before.

Suggested-by: Marek Vasut 
Signed-off-by: Kunihiko Hayashi 
---
 drivers/usb/dwc3/dwc3-generic.c | 93 -
 1 file changed, 57 insertions(+), 36 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 42e92478f2..e32003d68e 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -276,6 +276,7 @@ U_BOOT_DRIVER(dwc3_generic_host) = {
 #endif
 
 struct dwc3_glue_ops {
+   int (*glue_get_ctrl_dev)(struct udevice *parent, ofnode *node);
void (*glue_configure)(struct udevice *dev, int index,
   enum usb_dr_mode mode);
 };
@@ -415,54 +416,74 @@ struct dwc3_glue_ops ti_ops = {
.glue_configure = dwc3_ti_glue_configure,
 };
 
-static int dwc3_glue_bind(struct udevice *parent)
+static int dwc3_glue_bind_common(struct udevice *parent, ofnode node)
 {
-   ofnode node;
-   int ret;
+   const char *name = ofnode_get_name(node);
+   const char *driver = NULL;
enum usb_dr_mode dr_mode;
+   struct udevice *dev;
+   int ret;
 
-   dr_mode = usb_get_dr_mode(dev_ofnode(parent));
-
-   ofnode_for_each_subnode(node, dev_ofnode(parent)) {
-   const char *name = ofnode_get_name(node);
-   struct udevice *dev;
-   const char *driver = NULL;
-
-   debug("%s: subnode name: %s\n", __func__, name);
+   debug("%s: subnode name: %s\n", __func__, name);
 
-   /* if the parent node doesn't have a mode check the leaf */
-   if (!dr_mode)
-   dr_mode = usb_get_dr_mode(node);
+   /* if the parent node doesn't have a mode check the leaf */
+   dr_mode = usb_get_dr_mode(dev_ofnode(parent));
+   if (!dr_mode)
+   dr_mode = usb_get_dr_mode(node);
 
-   switch (dr_mode) {
-   case USB_DR_MODE_PERIPHERAL:
-   case USB_DR_MODE_OTG:
+   switch (dr_mode) {
+   case USB_DR_MODE_PERIPHERAL:
+   case USB_DR_MODE_OTG:
 #if CONFIG_IS_ENABLED(DM_USB_GADGET)
-   debug("%s: dr_mode: OTG or Peripheral\n", __func__);
-   driver = "dwc3-generic-peripheral";
+   debug("%s: dr_mode: OTG or Peripheral\n", __func__);
+   driver = "dwc3-generic-peripheral";
 #endif
-   break;
+   break;
 #if defined(CONFIG_SPL_USB_HOST) || !defined(CONFIG_SPL_BUILD)
-   case USB_DR_MODE_HOST:
-   debug("%s: dr_mode: HOST\n", __func__);
-   driver = "dwc3-generic-host";
-   break;
+   case USB_DR_MODE_HOST:
+   debug("%s: dr_mode: HOST\n", __func__);
+   driver = "dwc3-generic-host";
+   break;
 #endif
-   default:
-   debug("%s: unsupported dr_mode\n", __func__);
-   return -ENODEV;
-   };
+   default:
+   debug("%s: unsupported dr_mode\n", __func__);
+   return -ENODEV;
+   };
 
-   if (!driver)
-   continue;
+   if (!driver)
+   return -ENXIO;
+
+   ret = device_bind_driver_to_node(parent, driver, name,
+node, );
+   if (ret) {
+   debug("%s: not able to bind usb device mode\n",
+ __func__);
+   return ret;
+   }
+
+   return 0;
+}
+
+static int dwc3_glue_bind(struct udevice *parent)
+{
+   struct dwc3_glue_ops *ops = (struct dwc3_glue_ops 
*)dev_get_driver_data(parent);
+   ofnode node;
+   int ret;
 
-   ret = device_bind_driver_to_node(parent, driver, name,
-node, );
-   if (ret) {
-   debug("%s: not able to bind usb device mode\n",
- __func__);
+   if (ops && ops->glue_get_ctrl_dev) {
+   ret = ops->glue_get_ctrl_dev(parent, );
+   if (ret)
+   return ret;
+
+   return dwc3_glue_bind_common(parent, node);
+   }
+
+   

[PATCH v2 00/12] usb: dwc3: Refactor dwc3-generic and apply to dwc3-uniphier

2023-01-31 Thread Kunihiko Hayashi
This series achieves refactoring of dwc3-generic.

First, dwc3-generic allows DT controller nodes to be children of glue nodes,
but outside of glue nodes.

To achieve this goal, define a glue-specific function to get controller node,
look up more reference clocks in the controller node, and initialize clocks
in children of glue node before access to the controller,

Next, this series exports the structures and functions from the driver source
to the header, and replaces dwc3-uniphier driver as one implementation using
them. This expects dwc3-generic to prevent more SoC-dependent codes.

The dwc3-uniphier has original USB node, however, tentatively added its own
node dedicated to U-Boot. After this refactoring, the driver needs to add
clock entries and PHY driver to enable them corresponding to the properties
in the original node.

PATCH 1 has been provided below.
  
https://patchwork.ozlabs.org/project/uboot/patch/20221215223822.137739-1-ma...@denx.de/

PATCH 2 is based on the suggested patch from Marek.

PATCH 4-6 and 12 have been already reviewed in the previous v1.
  https://lists.denx.de/pipermail/u-boot/2023-January/505689.html

Changes since v1:
- Add PATCH 1 to refer to the clock in top level generic node
- Add PATCH 2 to allow controller DT node outside of glue node
- Add PATCH 3 to initialize clocks in children of glue node
- Update dwc3_glue_ops to add the function to get controller device
- Add PATCH 7 to support USB glue reset
- Add PATCH 8 to add missing PHY clocks
- Add PATCH 9 to enable the driver to enable PHY clocks and resets
- Add PATCH 10 to fix node names and missing properties
- Add PATCH 11 to switch to the original USB node in DT

Kunihiko Hayashi (11):
  usb: dwc3-generic: Allow different controller DT node pattern
  usb: dwc3-generic: Add clock initialization in child DT node
  usb: dwc3-generic: Export glue structures and functions
  usb: dwc3-generic: Add the size of regs property to glue structure
  usb: dwc3-uniphier: Use dwc3-generic instead of xhci-dwc3
  reset: uniphier: Add USB glue reset support
  clk: uniphier: Add missing USB SS-PHY clocks
  phy: socionext: Add UniPhier USB3 PHY driver
  ARM: dts: uniphier: Fix node names and missing reg property in USB
glue node
  ARM: dts: uniphier: Switch USB node to the original
  uniphier_defconfig: Disable USB_XHCI_DWC3

Marek Vasut (1):
  usb: dwc3: Look up reference clock DT phandle in both controller DT
nodes

 arch/arm/dts/uniphier-ld20.dtsi   |  36 ++
 arch/arm/dts/uniphier-pro4.dtsi   |  49 +---
 arch/arm/dts/uniphier-pro5.dtsi   |  15 +--
 arch/arm/dts/uniphier-pxs2.dtsi   |  62 +++---
 arch/arm/dts/uniphier-pxs3.dtsi   |  62 +++---
 configs/uniphier_v7_defconfig |   1 -
 configs/uniphier_v8_defconfig |   2 +-
 drivers/clk/uniphier/clk-uniphier-sys.c   |   5 +
 drivers/phy/socionext/Kconfig |   7 ++
 drivers/phy/socionext/Makefile|   1 +
 drivers/phy/socionext/phy-uniphier-usb3.c |  89 +++
 drivers/reset/reset-uniphier.c|  78 -
 drivers/usb/dwc3/Kconfig  |   3 +-
 drivers/usb/dwc3/dwc3-generic.c   | 132 ++
 drivers/usb/dwc3/dwc3-generic.h   |  33 ++
 drivers/usb/dwc3/dwc3-uniphier.c  | 116 ---
 16 files changed, 422 insertions(+), 269 deletions(-)
 create mode 100644 drivers/phy/socionext/phy-uniphier-usb3.c
 create mode 100644 drivers/usb/dwc3/dwc3-generic.h

-- 
2.25.1



[PATCH v2 01/12] usb: dwc3: Look up reference clock DT phandle in both controller DT nodes

2023-01-31 Thread Kunihiko Hayashi
From: Marek Vasut 

There are currently four disparate placement possibilities of DWC3
reference clock phandle in SoC DTs:
- in top level glue node, with generic subnode without clock (ZynqMP)
- in top level generic node, with no subnode (i.MX8MQ)
- in generic subnode, with other clock in top level node (i.MX8MP)
- in both top level node and generic subnode (Rockchip)

Cover all the possibilities here by looking into both nodes, start
with the top level node as that seems to be used in majority of DTs
to reference the clock.

Signed-off-by: Marek Vasut 
Acked-by: Kunihiko Hayashi 
---
 drivers/usb/dwc3/dwc3-generic.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 78966718d0..42e92478f2 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -68,10 +68,27 @@ static int dwc3_generic_probe(struct udevice *dev,
 #if CONFIG_IS_ENABLED(OF_CONTROL)
dwc3_of_parse(dwc3);
 
+   /*
+* There are currently four disparate placement possibilities of DWC3
+* reference clock phandle in SoC DTs:
+* - in top level glue node, with generic subnode without clock (ZynqMP)
+* - in top level generic node, with no subnode (i.MX8MQ)
+* - in generic subnode, with other clock in top level node (i.MX8MP)
+* - in both top level node and generic subnode (Rockchip)
+* Cover all the possibilities here by looking into both nodes, start
+* with the top level node as that seems to be used in majority of DTs
+* to reference the clock.
+*/
node = dev_ofnode(dev->parent);
index = ofnode_stringlist_search(node, "clock-names", "ref");
if (index < 0)
index = ofnode_stringlist_search(node, "clock-names", 
"ref_clk");
+   if (index < 0) {
+   node = dev_ofnode(dev);
+   index = ofnode_stringlist_search(node, "clock-names", "ref");
+   if (index < 0)
+   index = ofnode_stringlist_search(node, "clock-names", 
"ref_clk");
+   }
if (index >= 0)
dwc3->ref_clk = >clks.clks[index];
 #endif
-- 
2.25.1



[PATCH] arm: kirkwood: Enable uart0 dm-pre-reloc for Kirkwood boards

2023-01-31 Thread Tony Dinh
When DM_SERIAL is enabled, the device-tree property dm-pre-reloc is
required to boot over UART with kwboot. Enable this in a Kirkwood
common u-boot dtsi.

Signed-off-by: Tony Dinh 
---

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

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



Re: [PATCH v2 0/5] net: sun8i-emac: Allwinner D1 Support

2023-01-31 Thread Andre Przywara
On Sun, 22 Jan 2023 16:51:01 -0600
Samuel Holland  wrote:

Hi Joe, Ramon,

> D1 is a RISC-V SoC containing an EMAC compatible with the A64 EMAC. In a
> very roundabout way, this series finishes adding support for the D1 EMAC:
> patch 4 resolves a compiler warning when building the driver for RISC-V.
> The rest of the series is just cleanup requested by Jagan.

So I reviewed, but also tested this series on an H3, A64, H6 and R40
board, and Ethernet still worked on all of them.
How do we handle the merge? Do you want to ACK the patches, and I
take them through the sunxi tree? Or do you want to take the series?
Patchwork put this on my plate, but get_maintainer.pl listed you two as
the maintainers.

Cheers,
Andre


> Changes in v2:
>  - Add a structure for driver data, and put the syscon offset there
> 
> Samuel Holland (5):
>   net: sun8i-emac: Add a structure for variant data
>   net: sun8i-emac: Add a flag for RMII support
>   net: sun8i-emac: Add a flag for the internal PHY switch
>   net: sun8i-emac: Use common syscon setup for R40
>   net: sun8i-emac: Remove the SoC variant ID
> 
>  drivers/net/sun8i_emac.c | 96 ++--
>  1 file changed, 53 insertions(+), 43 deletions(-)
> 



Re: [PATCH 01/11] imx: implement get_effective_memsize

2023-01-31 Thread Peng Fan




On 1/31/2023 7:10 PM, Stefano Babic wrote:

On 31.01.23 12:02, Fabio Estevam wrote:

Hi Peng,

On Mon, Nov 7, 2022 at 4:13 AM Peng Fan (OSS)  
wrote:


From: Peng Fan 

To i.MX6/7 which has 2GB memory, the upper 4KB cut off, will cause the
top 1MB not mapped as normal memory, because ARMV7-A use section
mapping. So implement i.MX6/7 specific get_effective_memsize to fix the
issue.

Fixes: 777706bc("common/memsize.c: Fix get_effective_memsize() to 
check for overflow")


This commit has been reverted in master for non-Power PC platforms:

commit d1f4b090dd17ee11373859f2c91af94bf254af7a
Author: Pali Rohár 
Date:   Sat Jan 7 22:55:26 2023 +0100

 common/memsize.c: Check for overflow in get_effective_memsize()
only for mpc85xx

 This reverts commit 777706bc ("common/memsize.c: Fix
 get_effective_memsize() to check for overflow") for non-mpc85xx 
platforms.


 The changes to this generic function, which is intended to help with
 32bit platforms with large amounts of memory has unintended side 
effects

 (which in turn lead to boot failures) on other platforms which were
 previously functional.

 For now do overflow check only for powerpc mpc85xx platform. It 
is needed
 to prevent crashing of P1/P2 boards with 4GB DDR module in 32-bit 
mode.


 Fixes: 777706bc ("common/memsize.c: Fix
get_effective_memsize() to check for overflow")
 Signed-off-by: Pali Rohár 

Can this patch be discarded then?

I just noticed that Stefano applied it to u-boot-imx master-next branch.



Yes, it is in test - I could let it out for the moment, waiting for 
Peng's answer.



Yes, this patch could dropped, since the common code already has fix.

Thanks,
Peng.



Regards,
Stefano



[PATCH v7] board: mntre: imx8mq: Add MNT Reform 2 board support

2023-01-31 Thread Patrick Wildt
The MNT Reform 2 is a modular DIY laptop.  In its initial version it
is based on the BoundaryDevices i.MX8MQ SoM.  Some parts have been
lifted from BoundaryDevices official U-Boot downstream project.

Signed-off-by: Patrick Wildt 
---
Changes since v6:
- Cleaned up some CONFIG_* pollution.
Changes since v5:
- Adjusted to further Binman changes.
- Adjusted to further Kconfig conversions.
- Removed some phy init in favor of DM.
- Removed some pinmux which are now handled by DM_SERIAL.
- Compared with Librem5/EVK and adjusted for similarity.
Changes since v4:
- Adjusted to Kconfig conversions.
- Removed U-Boot-specific device tree changes.
- Synced device tree to Linux v5.19-rc3.
Changes since v3:
- Adjusted to Binman changes in main branch.
- Cleaned up environment variables akin to i.MX8MM.
- Added vendor-prefix to device tree filename.
- Provided ramdisk_addr_r.
Changes since v2:
- Switched to Binman.
Changes since v1:
- Synced DTS with files in Linux git repo.
- Added support for USB host ports.

 arch/arm/dts/imx8mq-mnt-reform2-u-boot.dtsi   |   11 +
 arch/arm/mach-imx/imx8m/Kconfig   |7 +
 board/mntre/imx8mq_reform2/Kconfig|   15 +
 board/mntre/imx8mq_reform2/MAINTAINERS|7 +
 board/mntre/imx8mq_reform2/Makefile   |   12 +
 board/mntre/imx8mq_reform2/imx8mq_reform2.c   |  171 +++
 board/mntre/imx8mq_reform2/lpddr4_timing.c| 1014 +
 .../mntre/imx8mq_reform2/lpddr4_timing_ch2.h  |   95 ++
 board/mntre/imx8mq_reform2/spl.c  |  260 +
 configs/imx8mq_reform2_defconfig  |  107 ++
 include/configs/imx8mq_reform2.h  |   66 ++
 11 files changed, 1765 insertions(+)
 create mode 100644 arch/arm/dts/imx8mq-mnt-reform2-u-boot.dtsi
 create mode 100644 board/mntre/imx8mq_reform2/Kconfig
 create mode 100644 board/mntre/imx8mq_reform2/MAINTAINERS
 create mode 100644 board/mntre/imx8mq_reform2/Makefile
 create mode 100644 board/mntre/imx8mq_reform2/imx8mq_reform2.c
 create mode 100644 board/mntre/imx8mq_reform2/lpddr4_timing.c
 create mode 100644 board/mntre/imx8mq_reform2/lpddr4_timing_ch2.h
 create mode 100644 board/mntre/imx8mq_reform2/spl.c
 create mode 100644 configs/imx8mq_reform2_defconfig
 create mode 100644 include/configs/imx8mq_reform2.h

diff --git a/arch/arm/dts/imx8mq-mnt-reform2-u-boot.dtsi 
b/arch/arm/dts/imx8mq-mnt-reform2-u-boot.dtsi
new file mode 100644
index 00..e0a6fc5470
--- /dev/null
+++ b/arch/arm/dts/imx8mq-mnt-reform2-u-boot.dtsi
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+
+#include "imx8mq-u-boot.dtsi"
+
+_uart1 {
+   u-boot,dm-spl;
+};
+
+ { /* console */
+   u-boot,dm-spl;
+};
diff --git a/arch/arm/mach-imx/imx8m/Kconfig b/arch/arm/mach-imx/imx8m/Kconfig
index a0715e8091..2049efb131 100644
--- a/arch/arm/mach-imx/imx8m/Kconfig
+++ b/arch/arm/mach-imx/imx8m/Kconfig
@@ -51,6 +51,12 @@ config TARGET_IMX8MQ_PHANBELL
select IMX8MQ
select IMX8M_LPDDR4
 
+config TARGET_IMX8MQ_REFORM2
+   bool "imx8mq_reform2"
+   select BINMAN
+   select IMX8MQ
+   select IMX8M_LPDDR4
+
 config TARGET_IMX8MM_DATA_MODUL_EDM_SBC
bool "Data Modul eDM SBC i.MX8M Mini"
select BINMAN
@@ -320,6 +326,7 @@ source "board/kontron/pitx_imx8m/Kconfig"
 source "board/kontron/sl-mx8mm/Kconfig"
 source "board/menlo/mx8menlo/Kconfig"
 source "board/msc/sm2s_imx8mp/Kconfig"
+source "board/mntre/imx8mq_reform2/Kconfig"
 source "board/phytec/phycore_imx8mm/Kconfig"
 source "board/phytec/phycore_imx8mp/Kconfig"
 source "board/purism/librem5/Kconfig"
diff --git a/board/mntre/imx8mq_reform2/Kconfig 
b/board/mntre/imx8mq_reform2/Kconfig
new file mode 100644
index 00..f9260cb7f5
--- /dev/null
+++ b/board/mntre/imx8mq_reform2/Kconfig
@@ -0,0 +1,15 @@
+if TARGET_IMX8MQ_REFORM2
+
+config SYS_BOARD
+   default "imx8mq_reform2"
+
+config SYS_VENDOR
+   default "mntre"
+
+config SYS_CONFIG_NAME
+   default "imx8mq_reform2"
+
+config IMX_CONFIG
+   default "arch/arm/mach-imx/imx8m/imximage.cfg"
+
+endif
diff --git a/board/mntre/imx8mq_reform2/MAINTAINERS 
b/board/mntre/imx8mq_reform2/MAINTAINERS
new file mode 100644
index 00..946f287ecf
--- /dev/null
+++ b/board/mntre/imx8mq_reform2/MAINTAINERS
@@ -0,0 +1,7 @@
+REFORM2 IMX8MQ BOARD
+M: Lukas F. Hartmann 
+M: Patrick Wildt 
+S: Maintained
+F: board/mntre/imx8mq_reform2/
+F: include/configs/imx8mq_reform2.h
+F: configs/imx8mq_reform2_defconfig
diff --git a/board/mntre/imx8mq_reform2/Makefile 
b/board/mntre/imx8mq_reform2/Makefile
new file mode 100644
index 00..2efd56bb4a
--- /dev/null
+++ b/board/mntre/imx8mq_reform2/Makefile
@@ -0,0 +1,12 @@
+#
+# Copyright 2017 NXP
+#
+# SPDX-License-Identifier:  GPL-2.0+
+#
+
+obj-y += imx8mq_reform2.o
+
+ifdef CONFIG_SPL_BUILD
+obj-y += spl.o
+obj-$(CONFIG_IMX8M_LPDDR4) += lpddr4_timing.o
+endif
diff --git a/board/mntre/imx8mq_reform2/imx8mq_reform2.c 
b/board/mntre/imx8mq_reform2/imx8mq_reform2.c
new file 

Re: [PATCH v6] board: mntre: imx8mq: Add MNT Reform 2 board support

2023-01-31 Thread Patrick Wildt
Am Tue, Jan 31, 2023 at 06:00:31PM +0100 schrieb Stefano Babic:
> On 19.01.23 20:56, Patrick Wildt wrote:
> > The MNT Reform 2 is a modular DIY laptop.  In its initial version it
> > is based on the BoundaryDevices i.MX8MQ SoM.  Some parts have been
> > lifted from BoundaryDevices official U-Boot downstream project.
> > 
> > Signed-off-by: Patrick Wildt 
> > ---
> > Changes since v5:
> > - Adjusted to further Binman changes.
> > - Adjusted to further Kconfig conversions.
> > - Removed some phy init in favor of DM.
> > - Removed some pinmux which are now handled by DM_SERIAL.
> > - Compared with Librem5/EVK and adjusted for similarity.
> > Changes since v4:
> > - Adjusted to Kconfig conversions.
> > - Removed U-Boot-specific device tree changes.
> > - Synced device tree to Linux v5.19-rc3.
> > Changes since v3:
> > - Adjusted to Binman changes in main branch.
> > - Cleaned up environment variables akin to i.MX8MM.
> > - Added vendor-prefix to device tree filename.
> > - Provided ramdisk_addr_r.
> > Changes since v2:
> > - Switched to Binman.
> > Changes since v1:
> > - Synced DTS with files in Linux git repo.
> > - Added support for USB host ports.
> > 
> >   arch/arm/dts/imx8mq-mnt-reform2-u-boot.dtsi   |   11 +
> >   arch/arm/mach-imx/imx8m/Kconfig   |7 +
> >   board/mntre/imx8mq_reform2/Kconfig|   15 +
> >   board/mntre/imx8mq_reform2/MAINTAINERS|7 +
> >   board/mntre/imx8mq_reform2/Makefile   |   12 +
> >   board/mntre/imx8mq_reform2/imx8mq_reform2.c   |  171 +++
> >   board/mntre/imx8mq_reform2/lpddr4_timing.c| 1014 +
> >   .../mntre/imx8mq_reform2/lpddr4_timing_ch2.h  |   95 ++
> >   board/mntre/imx8mq_reform2/spl.c  |  260 +
> >   configs/imx8mq_reform2_defconfig  |  107 ++
> >   include/configs/imx8mq_reform2.h  |   66 ++
> >   11 files changed, 1765 insertions(+)
> >   create mode 100644 arch/arm/dts/imx8mq-mnt-reform2-u-boot.dtsi
> >   create mode 100644 board/mntre/imx8mq_reform2/Kconfig
> >   create mode 100644 board/mntre/imx8mq_reform2/MAINTAINERS
> >   create mode 100644 board/mntre/imx8mq_reform2/Makefile
> >   create mode 100644 board/mntre/imx8mq_reform2/imx8mq_reform2.c
> >   create mode 100644 board/mntre/imx8mq_reform2/lpddr4_timing.c
> >   create mode 100644 board/mntre/imx8mq_reform2/lpddr4_timing_ch2.h
> >   create mode 100644 board/mntre/imx8mq_reform2/spl.c
> >   create mode 100644 configs/imx8mq_reform2_defconfig
> >   create mode 100644 include/configs/imx8mq_reform2.h
> > 
> > diff --git a/arch/arm/dts/imx8mq-mnt-reform2-u-boot.dtsi 
> > b/arch/arm/dts/imx8mq-mnt-reform2-u-boot.dtsi
> > new file mode 100644
> > index 00..e0a6fc5470
> > --- /dev/null
> > +++ b/arch/arm/dts/imx8mq-mnt-reform2-u-boot.dtsi
> > @@ -0,0 +1,11 @@
> > +// SPDX-License-Identifier: (GPL-2.0 OR MIT)
> > +
> > +#include "imx8mq-u-boot.dtsi"
> > +
> > +_uart1 {
> > +   u-boot,dm-spl;
> > +};
> > +
> > + { /* console */
> > +   u-boot,dm-spl;
> > +};
> > diff --git a/arch/arm/mach-imx/imx8m/Kconfig 
> > b/arch/arm/mach-imx/imx8m/Kconfig
> > index a0715e8091..2049efb131 100644
> > --- a/arch/arm/mach-imx/imx8m/Kconfig
> > +++ b/arch/arm/mach-imx/imx8m/Kconfig
> > @@ -51,6 +51,12 @@ config TARGET_IMX8MQ_PHANBELL
> > select IMX8MQ
> > select IMX8M_LPDDR4
> > +config TARGET_IMX8MQ_REFORM2
> > +   bool "imx8mq_reform2"
> > +   select BINMAN
> > +   select IMX8MQ
> > +   select IMX8M_LPDDR4
> > +
> >   config TARGET_IMX8MM_DATA_MODUL_EDM_SBC
> > bool "Data Modul eDM SBC i.MX8M Mini"
> > select BINMAN
> > @@ -320,6 +326,7 @@ source "board/kontron/pitx_imx8m/Kconfig"
> >   source "board/kontron/sl-mx8mm/Kconfig"
> >   source "board/menlo/mx8menlo/Kconfig"
> >   source "board/msc/sm2s_imx8mp/Kconfig"
> > +source "board/mntre/imx8mq_reform2/Kconfig"
> >   source "board/phytec/phycore_imx8mm/Kconfig"
> >   source "board/phytec/phycore_imx8mp/Kconfig"
> >   source "board/purism/librem5/Kconfig"
> > diff --git a/board/mntre/imx8mq_reform2/Kconfig 
> > b/board/mntre/imx8mq_reform2/Kconfig
> > new file mode 100644
> > index 00..f9260cb7f5
> > --- /dev/null
> > +++ b/board/mntre/imx8mq_reform2/Kconfig
> > @@ -0,0 +1,15 @@
> > +if TARGET_IMX8MQ_REFORM2
> > +
> > +config SYS_BOARD
> > +   default "imx8mq_reform2"
> > +
> > +config SYS_VENDOR
> > +   default "mntre"
> > +
> > +config SYS_CONFIG_NAME
> > +   default "imx8mq_reform2"
> > +
> > +config IMX_CONFIG
> > +   default "arch/arm/mach-imx/imx8m/imximage.cfg"
> > +
> > +endif
> > diff --git a/board/mntre/imx8mq_reform2/MAINTAINERS 
> > b/board/mntre/imx8mq_reform2/MAINTAINERS
> > new file mode 100644
> > index 00..946f287ecf
> > --- /dev/null
> > +++ b/board/mntre/imx8mq_reform2/MAINTAINERS
> > @@ -0,0 +1,7 @@
> > +REFORM2 IMX8MQ BOARD
> > +M: Lukas F. Hartmann 
> > +M: Patrick Wildt 
> > +S: Maintained
> > +F: board/mntre/imx8mq_reform2/
> > +F: include/configs/imx8mq_reform2.h
> > +F: configs/imx8mq_reform2_defconfig
> > 

Re: [PATCH] env: mmc: Fix offset issue for env save

2023-01-31 Thread Jaehoon Chung
On 1/31/23 15:41, Ye Li wrote:
> Fix the issue in commit 46c9016 (env: mcc: Drop unnecessary #ifdefs)
> If CONFIG_SYS_REDUNDAND_ENVIRONMENT is not defined, the offset value
> becomes undetermined, so write env to unexpected offset.
> 
> Signed-off-by: Ye Li 

Reviewed-by: Jaehoon Chung 

Best Regards,
Jaehoon Chung

> ---
>  env/mmc.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/env/mmc.c b/env/mmc.c
> index 8576141..5b01f65 100644
> --- a/env/mmc.c
> +++ b/env/mmc.c
> @@ -273,11 +273,11 @@ static int env_mmc_save(void)
>   if (ret)
>   goto fini;
>   }
> + }
>  
> - if (mmc_get_env_addr(mmc, copy, )) {
> - ret = 1;
> - goto fini;
> - }
> + if (mmc_get_env_addr(mmc, copy, )) {
> + ret = 1;
> + goto fini;
>   }
>  
>   printf("Writing to %sMMC(%d)... ", copy ? "redundant " : "", dev);



[GIT PULL] Please pull u-boot-mmc master

2023-01-31 Thread Jaehoon Chung
Dear Tom,

Please pull u-boot-mmc master into u-boot master branch.
If there is any problem, let me know, plz.

Best Regards,
Jaehoon Chung

CI: https://source.denx.de/u-boot/custodians/u-boot-mmc/-/pipelines/14951


The following changes since commit 30db474704405be823259851cbb76fa05366c8af:

  Prepare v2023.04-rc1 (2023-01-30 15:36:45 -0500)

are available in the Git repository at:

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

for you to fetch changes up to a1f8abf4686065f46ac840e956a1aeb68d90d969:

  mmc: zynq_sdhci: Add support and quirk for HS400 (2023-01-31 22:02:27 +0900)


Ashok Reddy Soma (4):
  mmc: zynq_sdhci: Add support for eMMC5.1 for Versal NET platform
  mmc: sdhci: Check and call config_dll callback functions
  mmc: sdhci: Enable HS400 support if available in caps
  mmc: zynq_sdhci: Add support and quirk for HS400

Marek Vasut (1):
  cmd: mmc: Expand bkops handling

 cmd/mmc.c|  49 ++--
 drivers/mmc/mmc.c|  14 ++-
 drivers/mmc/sdhci.c  |  20 
 drivers/mmc/zynq_sdhci.c | 292 ++-
 include/mmc.h|  14 ++-
 include/sdhci.h  |   5 +
 6 files changed, 375 insertions(+), 19 deletions(-)


Re: [PATCH 07/13] mmc: renesas-sdhi: Flag non-standard SDnH handling for V3M

2023-01-31 Thread Jaehoon Chung
On 1/27/23 05:06, Marek Vasut wrote:
> From: Hai Pham 
> 
> V3M handles SDnH differently than other Gen3 SoCs, so let's add a
> separate entry for that. This will allow better SDnH handling in the
> future.
> 
> Based on Linux commit 627151b4966f ("mmc: renesas_sdhi: Flag
> non-standard SDnH handling for V3M") by Wolfram Sang
> 
> Signed-off-by: Hai Pham 

Reviewed-by: Jaehoon Chung 

Best Regards,
Jaehoon Chung

> ---
>  drivers/mmc/renesas-sdhi.c | 6 ++
>  drivers/mmc/tmio-common.h  | 1 +
>  2 files changed, 7 insertions(+)
> 
> diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c
> index f85ced26ed8..f30d7847bf2 100644
> --- a/drivers/mmc/renesas-sdhi.c
> +++ b/drivers/mmc/renesas-sdhi.c
> @@ -930,6 +930,12 @@ static void renesas_sdhi_filter_caps(struct udevice *dev)
>   priv->read_poll_flag = TMIO_SD_DMA_INFO1_END_RD;
>   else
>   priv->read_poll_flag = TMIO_SD_DMA_INFO1_END_RD2;
> +
> + /* V3M handles SD0H differently than other Gen3 SoCs */
> + if (rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A77970)
> + priv->needs_clkh_fallback = true;
> + else
> + priv->needs_clkh_fallback = false;
>  }
>  
>  static int renesas_sdhi_probe(struct udevice *dev)
> diff --git a/drivers/mmc/tmio-common.h b/drivers/mmc/tmio-common.h
> index 59d5a0e22e9..e517ed978bf 100644
> --- a/drivers/mmc/tmio-common.h
> +++ b/drivers/mmc/tmio-common.h
> @@ -151,6 +151,7 @@ struct tmio_sd_priv {
>   u8  hs400_bad_tap;
>   const u8*adjust_hs400_calib_table;
>   u32 quirks;
> + boolneeds_clkh_fallback;
>  #endif
>   ulong (*clk_get_rate)(struct tmio_sd_priv *);
>  };



Re: [PATCH 06/13] mmc: renesas-sdhi: Drop R-Car H3 ES3.0 HS400 calibration table

2023-01-31 Thread Jaehoon Chung
On 1/27/23 05:06, Marek Vasut wrote:
> From: Hai Pham 
> 
> It is unnecessary, so clean it up.
> 
> Reviewed-by: Marek Vasut 
> Signed-off-by: Hai Pham 
> Signed-off-by: Marek Vasut  # update commit 
> message, mention ES3.0

Reviewed-by: Jaehoon Chung 

Best Regards,
Jaehoon Chung

> ---
>  drivers/mmc/renesas-sdhi.c | 16 
>  1 file changed, 16 deletions(-)
> 
> diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c
> index 95db8aca931..f85ced26ed8 100644
> --- a/drivers/mmc/renesas-sdhi.c
> +++ b/drivers/mmc/renesas-sdhi.c
> @@ -71,13 +71,6 @@
>  
>  #define CALIB_TABLE_MAX  (RENESAS_SDHI_SCC_TMPPORT_CALIB_CODE_MASK + 1)
>  
> -static const u8 r8a7795_calib_table[2][CALIB_TABLE_MAX] = {
> - { 0,  0,  0,  0,  0,  1,  1,  2,  3,  4,  5,  5,  6,  6,  7, 11,
> -  15, 16, 16, 17, 17, 17, 17, 17, 18, 18, 18, 18, 19, 20, 21, 21 },
> - { 3,  3,  4,  4,  5,  6,  6,  7,  8,  8,  9,  9, 10, 11, 12, 15,
> -  16, 16, 17, 17, 17, 17, 17, 18, 18, 18, 18, 19, 20, 21, 22, 22 }
> -};
> -
>  static const u8 r8a7796_rev13_calib_table[2][CALIB_TABLE_MAX] = {
>   { 3,  3,  3,  3,  3,  3,  3,  4,  4,  5,  6,  7,  8,  9, 10, 15,
>16, 16, 16, 16, 16, 16, 17, 18, 18, 19, 20, 21, 22, 23, 24, 25 },
> @@ -886,15 +879,6 @@ static void renesas_sdhi_filter_caps(struct udevice *dev)
>   (rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A77965))
>   priv->hs400_bad_tap = BIT(2) | BIT(3) | BIT(6) | BIT(7);
>  
> - /* H3 ES3.0 can use HS400 with manual adjustment */
> - if ((rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A7795) &&
> - (rmobile_get_cpu_rev_integer() >= 3)) {
> - priv->adjust_hs400_enable = true;
> - priv->adjust_hs400_offset = 0;
> - priv->adjust_hs400_calib_table =
> - r8a7795_calib_table[!rmobile_is_gen3_mmc0(priv)];
> - }
> -
>   /* M3W ES1.x for x>2 can use HS400 with manual adjustment and taps */
>   if ((rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A7796) &&
>   (rmobile_get_cpu_rev_integer() == 1) &&



Re: [PATCH 05/13] mmc: renesas-sdhi: Add R8A77961 M3-W+ support

2023-01-31 Thread Jaehoon Chung
On 1/27/23 05:05, Marek Vasut wrote:
> From: Hai Pham 
> 
> Support R8A77961 M3-W+ SoC.
> 
> Reviewed-by: Marek Vasut 
> Signed-off-by: Hai Pham 
> Signed-off-by: Marek Vasut 

Reviewed-by: Jaehoon Chung 

Best Regards,
Jaehoon Chung

> ---
>  drivers/mmc/renesas-sdhi.c | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c
> index 90e8aaddb05..95db8aca931 100644
> --- a/drivers/mmc/renesas-sdhi.c
> +++ b/drivers/mmc/renesas-sdhi.c
> @@ -836,6 +836,7 @@ static const struct udevice_id renesas_sdhi_match[] = {
>   { .compatible = "renesas,sdhi-r8a7794", .data = RENESAS_GEN2_QUIRKS },
>   { .compatible = "renesas,sdhi-r8a7795", .data = RENESAS_GEN3_QUIRKS },
>   { .compatible = "renesas,sdhi-r8a7796", .data = RENESAS_GEN3_QUIRKS },
> + { .compatible = "renesas,sdhi-r8a77961", .data = RENESAS_GEN3_QUIRKS },
>   { .compatible = "renesas,rcar-gen3-sdhi", .data = RENESAS_GEN3_QUIRKS },
>   { .compatible = "renesas,sdhi-r8a77965", .data = RENESAS_GEN3_QUIRKS },
>   { .compatible = "renesas,sdhi-r8a77970", .data = RENESAS_GEN3_QUIRKS },
> @@ -905,6 +906,11 @@ static void renesas_sdhi_filter_caps(struct udevice *dev)
>   r8a7796_rev13_calib_table[!rmobile_is_gen3_mmc0(priv)];
>   }
>  
> + /* M3W+ bad taps */
> + if ((rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A7796) &&
> + (rmobile_get_cpu_rev_integer() == 3))
> + priv->hs400_bad_tap = BIT(1) | BIT(3) | BIT(5) | BIT(7);
> +
>   /* M3N can use HS400 with manual adjustment */
>   if (rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A77965) {
>   priv->adjust_hs400_enable = true;



Re: [PATCH 04/13] mmc: renesas-sdhi: Adjust HS400 calibration offsets for M3-W r1.3

2023-01-31 Thread Jaehoon Chung
On 1/27/23 05:05, Marek Vasut wrote:
> From: Hai Pham 
> 
> Still uses 0x3 for now, adjust the offset value to TMPPORT3 accordingly
> 
> Reviewed-by: Marek Vasut 
> Signed-off-by: Hai Pham 
> Signed-off-by: Marek Vasut 

Reviewed-by: Jaehoon Chung 

Best Regards,
Jaehoon Chung

> ---
>  drivers/mmc/renesas-sdhi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c
> index f9155bc44de..90e8aaddb05 100644
> --- a/drivers/mmc/renesas-sdhi.c
> +++ b/drivers/mmc/renesas-sdhi.c
> @@ -899,7 +899,7 @@ static void renesas_sdhi_filter_caps(struct udevice *dev)
>   (rmobile_get_cpu_rev_integer() == 1) &&
>   (rmobile_get_cpu_rev_fraction() > 2)) {
>   priv->adjust_hs400_enable = true;
> - priv->adjust_hs400_offset = 0;
> + priv->adjust_hs400_offset = 3;
>   priv->hs400_bad_tap = BIT(1) | BIT(3) | BIT(5) | BIT(7);
>   priv->adjust_hs400_calib_table =
>   r8a7796_rev13_calib_table[!rmobile_is_gen3_mmc0(priv)];



Re: [PATCH 03/13] mmc: renesas-sdhi: Adjust HS400 calibration tables

2023-01-31 Thread Jaehoon Chung
On 1/27/23 05:05, Marek Vasut wrote:
> From: Hai Pham 
> 
> Adjust HS400 calibration tables based on Linux settings
> 
> Reviewed-by: Marek Vasut 
> Signed-off-by: Hai Pham 
> Signed-off-by: Marek Vasut 

Reviewed-by: Jaehoon Chung 

Best Regards,
Jaehoon Chung

> ---
>  drivers/mmc/renesas-sdhi.c | 20 ++--
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c
> index 3ec0444700e..f9155bc44de 100644
> --- a/drivers/mmc/renesas-sdhi.c
> +++ b/drivers/mmc/renesas-sdhi.c
> @@ -79,24 +79,24 @@ static const u8 r8a7795_calib_table[2][CALIB_TABLE_MAX] = 
> {
>  };
>  
>  static const u8 r8a7796_rev13_calib_table[2][CALIB_TABLE_MAX] = {
> - { 0,  0,  0,  0,  2,  3,  4,  4,  5,  6,  7,  7,  8,  9,  9, 10,
> -  11, 12, 13, 15, 16, 17, 17, 18, 19, 19, 20, 21, 21, 22, 23, 23 },
> - { 1,  2,  2,  3,  4,  4,  5,  6,  6,  7,  8,  9,  9, 10, 11, 12,
> -  13, 14, 15, 16, 17, 17, 18, 19, 20, 20, 21, 22, 22, 23, 24, 24 }
> + { 3,  3,  3,  3,  3,  3,  3,  4,  4,  5,  6,  7,  8,  9, 10, 15,
> +  16, 16, 16, 16, 16, 16, 17, 18, 18, 19, 20, 21, 22, 23, 24, 25 },
> + { 5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  6,  7,  8, 11,
> +  12, 17, 18, 18, 18, 18, 18, 18, 18, 19, 20, 21, 22, 23, 25, 25 }
>  };
>  
>  static const u8 r8a77965_calib_table[2][CALIB_TABLE_MAX] = {
> - { 0,  1,  2,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 15,
> -  16, 17, 18, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 29 },
> - { 0,  1,  2,  2,  2,  3,  4,  5,  6,  7,  9, 10, 11, 12, 13, 15,
> -  16, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31 }
> + { 1,  2,  6,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 15, 15, 16,
> +  17, 18, 19, 20, 21, 22, 23, 24, 25, 25, 26, 27, 28, 29, 30, 31 },
> + { 2,  3,  4,  4,  5,  6,  7,  9, 10, 11, 12, 13, 14, 15, 16, 17,
> +  17, 17, 20, 21, 22, 23, 24, 25, 27, 28, 29, 30, 31, 31, 31, 31 }
>  };
>  
>  static const u8 r8a77990_calib_table[2][CALIB_TABLE_MAX] = {
>   { 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
> 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0 },
> - { 0,  0,  1,  2,  3,  4,  4,  4,  4,  5,  5,  6,  7,  8, 10, 11,
> -  12, 13, 14, 16, 17, 18, 18, 18, 19, 19, 20, 24, 26, 26, 26, 26 }
> + { 0,  0,  0,  1,  2,  3,  3,  4,  4,  4,  5,  5,  6,  8,  9, 10,
> +  11, 12, 13, 15, 16, 17, 17, 18, 18, 19, 20, 22, 24, 25, 26, 26 }
>  };
>  
>  static int rmobile_is_gen3_mmc0(struct tmio_sd_priv *priv)



Re: [PATCH 02/13] mmc: renesas-sdhi: Filter out HS400 on M3-W r1.2, V3M, V3H r1.x, D3

2023-01-31 Thread Jaehoon Chung
On 1/27/23 05:05, Marek Vasut wrote:
> From: Hai Pham 
> 
> Further filter out HS400 support on certain SoCs.
> 
> Since M3-W r1.2 does not support HS400, drop the calibration table and
> rename the one for M3-W r1.3 to r8a7796_rev13_calib_table
> 
> Reviewed-by: Marek Vasut 
> Signed-off-by: Hai Pham 
> Signed-off-by: Marek Vasut 

Reviewed-by: Jaehoon Chung 

Best Regards,
Jaehoon Chung

> ---
>  drivers/mmc/renesas-sdhi.c | 29 -
>  1 file changed, 8 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c
> index 9f8a272d03d..3ec0444700e 100644
> --- a/drivers/mmc/renesas-sdhi.c
> +++ b/drivers/mmc/renesas-sdhi.c
> @@ -78,14 +78,7 @@ static const u8 r8a7795_calib_table[2][CALIB_TABLE_MAX] = {
>16, 16, 17, 17, 17, 17, 17, 18, 18, 18, 18, 19, 20, 21, 22, 22 }
>  };
>  
> -static const u8 r8a7796_rev1_calib_table[2][CALIB_TABLE_MAX] = {
> - { 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  2,  3,  4,  9,
> -  15, 15, 15, 16, 16, 16, 16, 16, 17, 18, 19, 20, 21, 21, 22, 22 },
> - { 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,
> -   2,  9, 16, 17, 17, 17, 18, 18, 18, 18, 19, 20, 21, 22, 23, 24}
> -};
> -
> -static const u8 r8a7796_rev3_calib_table[2][CALIB_TABLE_MAX] = {
> +static const u8 r8a7796_rev13_calib_table[2][CALIB_TABLE_MAX] = {
>   { 0,  0,  0,  0,  2,  3,  4,  4,  5,  6,  7,  7,  8,  9,  9, 10,
>11, 12, 13, 15, 16, 17, 17, 18, 19, 19, 20, 21, 21, 22, 23, 23 },
>   { 1,  2,  2,  3,  4,  4,  5,  6,  6,  7,  8,  9,  9, 10, 11, 12,
> @@ -871,12 +864,16 @@ static void renesas_sdhi_filter_caps(struct udevice 
> *dev)
>  CONFIG_IS_ENABLED(MMC_HS400_SUPPORT)
>   struct tmio_sd_plat *plat = dev_get_plat(dev);
>  
> - /* HS400 is not supported on H3 ES1.x and M3W ES1.0, ES1.1 */
> + /* HS400 is not supported on H3 ES1.x, M3W ES1.[012], V3M, V3H ES1.x, 
> D3 */
>   if (((rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A7795) &&
>   (rmobile_get_cpu_rev_integer() <= 1)) ||
>   ((rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A7796) &&
>   (rmobile_get_cpu_rev_integer() == 1) &&
> - (rmobile_get_cpu_rev_fraction() < 2)))
> + (rmobile_get_cpu_rev_fraction() <= 2)) ||
> + (rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A77970) ||
> + ((rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A77980) &&
> + (rmobile_get_cpu_rev_integer() <= 1)) ||
> + (rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A77995))
>   plat->cfg.host_caps &= ~MMC_MODE_HS400;
>  
>   /* H3 ES2.0, ES3.0 and M3W ES1.2 and M3N bad taps */
> @@ -897,16 +894,6 @@ static void renesas_sdhi_filter_caps(struct udevice *dev)
>   r8a7795_calib_table[!rmobile_is_gen3_mmc0(priv)];
>   }
>  
> - /* M3W ES1.2 can use HS400 with manual adjustment */
> - if ((rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A7796) &&
> - (rmobile_get_cpu_rev_integer() == 1) &&
> - (rmobile_get_cpu_rev_fraction() == 2)) {
> - priv->adjust_hs400_enable = true;
> - priv->adjust_hs400_offset = 3;
> - priv->adjust_hs400_calib_table =
> - r8a7796_rev1_calib_table[!rmobile_is_gen3_mmc0(priv)];
> - }
> -
>   /* M3W ES1.x for x>2 can use HS400 with manual adjustment and taps */
>   if ((rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A7796) &&
>   (rmobile_get_cpu_rev_integer() == 1) &&
> @@ -915,7 +902,7 @@ static void renesas_sdhi_filter_caps(struct udevice *dev)
>   priv->adjust_hs400_offset = 0;
>   priv->hs400_bad_tap = BIT(1) | BIT(3) | BIT(5) | BIT(7);
>   priv->adjust_hs400_calib_table =
> - r8a7796_rev3_calib_table[!rmobile_is_gen3_mmc0(priv)];
> + r8a7796_rev13_calib_table[!rmobile_is_gen3_mmc0(priv)];
>   }
>  
>   /* M3N can use HS400 with manual adjustment */



[GIT PULL] Please pull u-boot-pmic master

2023-01-31 Thread Jaehoon Chung
Dear Tom,

Please pull u-boot-pmic master into u-boot master branch.
If there is a problem, let me know, plz

Best Regards,
Jaehoon Chung

CI: https://source.denx.de/u-boot/custodians/u-boot-pmic/-/pipelines/14954


The following changes since commit 30db474704405be823259851cbb76fa05366c8af:

  Prepare v2023.04-rc1 (2023-01-30 15:36:45 -0500)

are available in the Git repository at:

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

for you to fetch changes up to 519fa7aa252789677939f0bd991bf26a4fe469ec:

  power: act8846_pmic: fix number of registers (2023-01-31 22:05:03 +0900)


John Keeping (1):
  power: act8846_pmic: fix number of registers

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


[PATCH] cmd: Add a SEAMA image load command

2023-01-31 Thread Linus Walleij
Add a command to load SEAMA (Seattle Image), a NAND flash
on-flash storage format.

This type of flash image is found in some D-Link routers such
as DIR-645, DIR-842, DIR-859, DIR-860L, DIR-885L, DIR890L and
DCH-M225, as well as in WD and NEC routers on the ath79
(MIPS), Broadcom BCM53xx, and RAMIPS platforms.

This U-Boot command will read and decode a SEAMA image from
raw NAND flash on any platform. As it is always using big endian
format for the data decoding is always necessary on platforms
such as ARM.

The command is needed to read a SEAMA-encoded boot image on the
D-Link DIR-890L router for boot from NAND flash in an upcoming
port of U-Boot to the Broadcom Northstar (BCM4709, BCM53xx)
architecture.

A basic test and documentation is added as well. The test must
be run on a target with NAND flash support and at least one
resident SEAMA image in flash.

Cc: Rafał Miłecki 
Signed-off-by: Linus Walleij 
---
 MAINTAINERS |   7 ++
 README  |   1 +
 cmd/Kconfig |   6 ++
 cmd/Makefile|   1 +
 cmd/seama.c | 158 
 doc/usage/cmd/seama.rst |  60 +++
 doc/usage/index.rst |   1 +
 include/test/suites.h   |   1 +
 test/cmd/Makefile   |   1 +
 test/cmd/seama.c|  71 ++
 test/cmd_ut.c   |   6 ++
 11 files changed, 313 insertions(+)
 create mode 100644 cmd/seama.c
 create mode 100644 doc/usage/cmd/seama.rst
 create mode 100644 test/cmd/seama.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 2dd2b46fcda6..359fde15936c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1329,6 +1329,13 @@ F:   arch/sandbox/
 F: doc/arch/sandbox.rst
 F: include/dt-bindings/*/sandbox*.h
 
+SEAMA
+M: Linus Walleij 
+S: Maintained
+F: cmd/seama.c
+F: doc/usage/cmd/seama.rst
+F: test/cmd/seama.c
+
 SEMIHOSTING
 R: Sean Anderson 
 S: Orphaned
diff --git a/README b/README
index edce7890c0f9..9cc0c981c43c 100644
--- a/README
+++ b/README
@@ -1810,6 +1810,7 @@ sspi  - SPI utility commands
 base   - print or set address offset
 printenv- print environment variables
 pwm- control pwm channels
+seama   - load SEAMA NAND image
 setenv - set environment variables
 saveenv - save environment variables to persistent storage
 protect - enable or disable FLASH write protection
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 4fe2c75de256..ead98c39cdee 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -337,6 +337,12 @@ config BOOTM_RTEMS
help
  Support booting RTEMS images via the bootm command.
 
+config CMD_SEAMA
+   bool "Support read SEAMA NAND images"
+   depends on MTD_RAW_NAND
+   help
+ Support reading NAND Seattle Image (SEAMA) images.
+
 config CMD_VBE
bool "vbe - Verified Boot for Embedded"
depends on BOOTMETH_VBE
diff --git a/cmd/Makefile b/cmd/Makefile
index 0b6a96c1d914..4fea084b44fa 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -156,6 +156,7 @@ obj-$(CONFIG_SANDBOX) += sb.o
 obj-$(CONFIG_CMD_SF) += sf.o
 obj-$(CONFIG_CMD_SCSI) += scsi.o disk.o
 obj-$(CONFIG_CMD_SHA1SUM) += sha1sum.o
+obj-$(CONFIG_CMD_SEAMA) += seama.o
 obj-$(CONFIG_CMD_SETEXPR) += setexpr.o
 obj-$(CONFIG_CMD_SETEXPR_FMT) += printf.o
 obj-$(CONFIG_CMD_SPI) += spi.o
diff --git a/cmd/seama.c b/cmd/seama.c
new file mode 100644
index ..3aafb43c48a0
--- /dev/null
+++ b/cmd/seama.c
@@ -0,0 +1,158 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2023 Linus Walleij 
+ * Support for the "SEAttle iMAge" SEAMA NAND image format
+ */
+
+#include 
+#include 
+#include 
+
+/*
+ * All SEAMA data is stored in the flash in "network endianness"
+ * i.e. big endian, which means that it needs to be byte-swapped
+ * on all little endian platforms.
+ *
+ * structure for a SEAMA entity in NAND flash:
+ *
+ * 32 bit SEAMA magic 0x5EA3A417
+ * 16 bit reserved
+ * 16 bit metadata size (following the header)
+ * 32 bit image size
+ * 16 bytes MD5 digest of the image
+ * meta data
+ * ... image data ...
+ *
+ * Then if a new SEAMA magic follows, that is the next image.
+ */
+
+#define SEAMA_MAGIC0x5EA3A417
+#define SEAMA_HDR_NO_META_SZ   28
+#define SEAMA_MAX_META_SZ  (1024 - SEAMA_HDR_NO_META_SZ)
+
+struct seama_header {
+   u32 magic;
+   u32 meta_size;
+   u32 image_size;
+   u8 md5[16];
+   u8 metadata[SEAMA_MAX_META_SZ];
+};
+
+static struct seama_header shdr;
+
+static int env_set_val(const char *varname, ulong val)
+{
+   int ret;
+
+   ret = env_set_hex(varname, val);
+   if (ret)
+   printf("Failed to %s env var\n", varname);
+
+   return ret;
+}
+
+static int do_seama_load_image(struct cmd_tbl *cmdtp, int flag, int argc,
+  char *const argv[])
+{
+   struct mtd_info *mtd;
+   uintptr_t load_addr;
+   unsigned long image_index;
+   u32 len;
+   size_t readsz;
+   int ret;
+   u32 *start;
+   u32 *offset;
+  

Re: [PATCH v9 0/8] Add MV88E6xxx DSA driver and use on gwventana

2023-01-31 Thread Tim Harvey
On Wed, Jan 25, 2023 at 9:26 AM Tim Harvey  wrote:
>
> On Wed, Nov 30, 2022 at 4:26 PM Vladimir Oltean  
> wrote:
> >
> > On Wed, Nov 30, 2022 at 03:27:04PM -0800, Tim Harvey wrote:
> > > That's the same head that I based them off of and I just did the
> > > following and it worked fine:
> > > cd /tmp
> > > git clone git://git.denx.de/u-boot.git
> > > cd u-boot
> > > wget https://patchwork.ozlabs.org/series/330704/mbox/ -O mbox
> > > git am mbox
> > >
> > > Looks like only the last patch failed right?
> >
> > Yeah, only the last patch failed. I converted them again to mbox format
> > using my super awkward procmail-based mail-to-mbox scripts, and now it
> > seems that git-am eats them just fine. I had taken a look at the last
> > patch context, and it looked identical to what was in tree, so I didn't
> > understand what was wrong.
> >
> > Anyway, I just wanted to make sure that the dsa sandbox tests still
> > pass, which they do. I'm away from my boards right now, so I won't be
> > able to change U-Boot remotely to do a live check.
>
> Joe,
>
> These have been lingering for some time. Will you pick up at least the first 
> 7?
>
> Best Regards,
>
> Tim

gentle ping

I'm not sure what needs to be done to get this series merged.

Tim Harvey (8):
  net: mdio-uclass: scan for dm mdio children on post-bind
  net: dsa: move cpu port probe to dsa_post_probe
  net: dsa: ensure dsa driver has proper ops
  net: dsa: allow rcv() and xmit() to be optional
  net: ksz9477: remove unnecessary xmit and recv functions
  net: fec: add support for DM_MDIO
  net: add MV88E6xxx DSA driver
  board: gw_ventana: enable MV88E61XX DSA support

The first 7 should go through Joe/Ramon I would think and the last
through Stefano.

Best Regards,

Tim


RE: [0/4] Add eMMC 5.1 support for Versal NET

2023-01-31 Thread Jaehoon Chung
Hi,

> -Original Message-
> From: Michal Simek 
> Sent: Tuesday, January 31, 2023 10:08 PM
> To: Jaehoon Chung ; 'Ashok Reddy Soma' 
> ; u-
> b...@lists.denx.de
> Cc: peng@nxp.com; kever.y...@rock-chips.com; 
> hayashi.kunih...@socionext.com;
> alpernebiya...@gmail.com; xypron.g...@gmx.de; g...@amd.com
> Subject: Re: [0/4] Add eMMC 5.1 support for Versal NET
> 
> Hi Jaehoon,
> 
> On 1/26/23 03:29, Jaehoon Chung wrote:
> > Hi,
> >
> >> -Original Message-
> >> From: Michal Simek 
> >> Sent: Tuesday, January 24, 2023 10:02 PM
> >> To: Ashok Reddy Soma ; u-boot@lists.denx.de; 
> >> Jaehoon Chung
> >> 
> >> Cc: peng@nxp.com; kever.y...@rock-chips.com; 
> >> hayashi.kunih...@socionext.com;
> >> alpernebiya...@gmail.com; xypron.g...@gmx.de; g...@amd.com
> >> Subject: Re: [0/4] Add eMMC 5.1 support for Versal NET
> >>
> >> Hi Jaehoon,
> >>
> >> On 1/10/23 12:31, Ashok Reddy Soma wrote:
> >>> This patch series,
> >>>- Add support for eMMC5.1 on Versal NET platform by adding new 
> >>> compatible
> >>>  string and PHY support.
> >>>- Add support for input and output tap delays for eMMC
> >>>- Add support for enabling HS400 in host capabilities by checking 
> >>> quirk.
> >>>- Add quirk to support HS400 for Versal NET
> >>>
> >>> Ashok Reddy Soma (4):
> >>> mmc: zynq_sdhci: Add support for eMMC5.1 for Versal NET platform
> >>> mmc: sdhci: Check and call config_dll callback functions
> >>> mmc: sdhci: Enable HS400 support if available in caps
> >>> mmc: zynq_sdhci: Add support and quirk for HS400
> >>>
> >>>drivers/mmc/sdhci.c  |  20 +++
> >>>drivers/mmc/zynq_sdhci.c | 292 ++-
> >>>include/sdhci.h  |   5 +
> >>>3 files changed, 314 insertions(+), 3 deletions(-)
> >>>
> >>
> >> Can you please review this series?
> >
> > Sorry for too late. I will review them.
> 
> I see you just reviewed it. Are you going to pick it up to your tree or do you
> want me to queue it via my tree? Both ways work for me.

I have picked this and I will do PR today.  

Best Regards,
Jaehoon Chung

> 
> Thanks,
> Michal



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

2023-01-31 Thread Tom Rini
On Tue, Jan 31, 2023 at 02:06:54PM -0800, Tony Dinh wrote:

> CONFIG_SYS_NS16550 is required when DM_SERIAL is enabled for
> Kirkwood boards.
> 
> Signed-off-by: Tony Dinh 

Reviewed-by: Tom Rini 

-- 
Tom


signature.asc
Description: PGP signature


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

2023-01-31 Thread Tony Dinh
CONFIG_SYS_NS16550 is required when DM_SERIAL is enabled for
Kirkwood boards.

Signed-off-by: Tony Dinh 
---

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



Re: [PATCH 00/32] RFC: Migrate to split config

2023-01-31 Thread Tom Rini
On Tue, Jan 31, 2023 at 08:26:30AM -0700, Simon Glass wrote:

> U-Boot uses an SPL prefix on CONFIG options to indicate when an option
> relates to SPL. For example, while CONFIG_TEXT_BASE is the text base for
> U-Boot proper, CONFIG_SPL_TEXT_BASE is the text base for SPL.
> 
> Within the code it is possible do things like CONFIG_VAL(TEXT_BASE) to
> get that value. It returns the appropriate option, depending on the phase
> being built.
> 
> The same applies for boolean options, like CONFIG_BLK and CONFIG_SPL_BLK
> but in that case we use CONFIG_IS_ENABLED(BLK) to obtain the value.
> 
> For Makefiles we use an SPL_TPL_ macro which evalutes either to empty,
> SPL, TPL or even VPL depending on the build phase. So we can do things
> like:
> 
>obj-$(CONFIG_$(SPL_TPL_)CLK) += clk-uclass.o
> 
> To complicate things a little, some options like CONFIG_ARCH_APPLE do not
> have an SPL version, so people have to remember to use IS_ENABLED()
> instead of CONFIG_IS_ENABLED(). If the latter is used, the value will be
> false.
> 
> All of this is rather confusing, since:
> 
> - people have to know whether to use IS_ENABLED() or CONFIG_IS_ENABLED()
> - the Makefiles are cluttered with $(SPL_TPL_) constructs
> - plain use of a CONFIG option (e.g. #ifdef CONFIG_CLK) may be correct in
>   some cases but not in others
> 
> This series updates U-Boot to use separate config files for each phase of
> the build. It drops use of CONFIG_IS_ENABLED() and SPL_TPL_ as well.
> 
> For now this series does not fully work due to inconsistencies in the
> Kconfig options. Many of these have been fixed [1] [2a] [2b] but more
> remain.
> 
> This series is available at u-boot-dm/splc-working
> 
> [1] https://patchwork.ozlabs.org/project/uboot/list/?series=339004
> [2a] https://patchwork.ozlabs.org/project/uboot/list/?series=339199=*
> [2b] https://patchwork.ozlabs.org/project/uboot/list/?series=339208=*

To summarize what I said on IRC, it's going to depend on what this looks
like once every board is expected to build and boot, which isn't the
case today, as there's more "dummy" or in other words, def_bool n
symbols added, so that we don't change things before/after this series.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v7 0/3] Timer support for ARM Tegra

2023-01-31 Thread Svyatoslav Ryhel
I will upload v8 tomorrow once I have some time.

Yes, Timer series should go first since some clock related commits of
"General Tegra improvements" may conflict. Those are not direct
dependencies but rather changed code overlaps.

Thanks

Best Regards.
Svyatoslav R.

вт, 31 січ. 2023 р. о 22:27 Tom Warren  пише:
>
> OK, I'll wait for your v8 with the adjusted timer enabling.
>
> Does this series need to go in first before your recent 16-patch series 
> "General Tegra improvements"? i.e. are there any dependencies?
>
> Tom
> -Original Message-
> From: Svyatoslav Ryhel 
> Sent: Tuesday, January 31, 2023 8:26 AM
> To: Tom Warren 
> Cc: Thierry Reding ; Rayagonda Kokatanur 
> ; Marek Vasut ; Maxim 
> Schwalm ; Dmitry Osipenko ; Jonas 
> Schwöbel ; Agneli ; Heinrich 
> Schuchardt ; Michal Simek ; Stefan 
> Roese ; Eugen Hristev ; Michael 
> Walle ; Simon Glass ; Jim Liu 
> ; William Zhang ; Rick Chen 
> ; Stefan Herbrechtsmeier 
> ; Andre Przywara 
> ; Jaehoon Chung ; 
> u-boot@lists.denx.de
> Subject: Re: [PATCH v7 0/3] Timer support for ARM Tegra
>
> External email: Use caution opening links or attachments
>
>
> Yes, it works perfectly fine on the T20/T30/T124/T186 and T210, T114 board no 
> one has on hand. Timer enabling has to be adjusted as Thierry suggested.
>
> вт, 31 січ. 2023 р. о 17:18 Tom Warren  пише:
> >
> > Has this been tested yet? I want to get it into the next PR, and I need a 
> > tested-by for V7 before I can do that.
> >
> > Thanks,
> >
> > Tom
> >
> > -Original Message-
> > From: Svyatoslav R. 
> > Sent: Friday, January 27, 2023 1:28 PM
> > To: Thierry Reding 
> > Cc: Rayagonda Kokatanur ; Tom Warren
> > ; Marek Vasut ; Maxim Schwalm
> > ; Dmitry Osipenko ; Jonas
> > Schwöbel ; Agneli ;
> > Heinrich Schuchardt ; Michal Simek
> > ; Stefan Roese ; Eugen Hristev
> > ; Michael Walle ; Simon
> > Glass ; Jim Liu ; William
> > Zhang ; Rick Chen ;
> > Stefan Herbrechtsmeier ; Andre
> > Przywara ; Jaehoon Chung
> > ; u-boot@lists.denx.de
> > Subject: Re: [PATCH v7 0/3] Timer support for ARM Tegra
> >
> > External email: Use caution opening links or attachments
> >
> >
> > On 1/27/23 19:15, Thierry Reding wrote:
> > > On Fri, Jan 27, 2023 at 09:13:09AM +0200, Svyatoslav Ryhel wrote:
> > >> - ARM: tegra: remap clock_osc_freq for all Tegra family Enum
> > >> clock_osc_freq was designed to use only with T20.
> > >> This patch remaps it to use additional frequencies, added in
> > >> T30+ SoC while maintaining backwards compatibility with T20.
> > >>
> > >> - drivers: timer: add timer driver for ARMv7 based Tegra devices
> > >> Add timer support for T20/T30/T114/T124 and T210 based devices.
> > >> Driver is based on DM, has device tree support and can be used on
> > >> SPL and early boot stage.
> > >>
> > >> Arm64 Tegra (apart T210) according to comment in tegra-common.h use
> > >> architected timer.
> > >>
> > >> - ARM: tegra: include timer as default option Enable TIMER as
> > >> default option for all Tegra devices and enable TEGRA_TIMER for
> > >> TEGRA_ARMV7_COMMON and TEGRA210.
> > >> Additionally enable SPL_TIMER if build as SPL part and drop
> > >> deprecated configs from common header.
> > >>
> > >> P. S. I have no arm64 Tegra and according to comment in
> > >> tegra-common.h Use the Tegra US timer on ARMv7, but the architected
> > >> timer on ARMv8.
> > >>
> > >> ---
> > >> Changeog from V6
> > >>   - use clk_m as timer calibration clock (this should properly fix T210)
> > >>   - enable timer for T210
> > >>
> > >> Changed from v5:
> > >>   - added paz00 tester
> > >>
> > >> Changed from v4:
> > >>   - added comments
> > >>
> > >> Changed from v3:
> > >>   - removed BOOTSTAGE ifdefs
> > >>   - use early timer on boot stage unconditionally
> > >> ---
> > >> Svyatoslav Ryhel (3):
> > >>ARM: tegra: remap clock_osc_freq for all Tegra family
> > >>drivers: timer: add driver for ARMv7 based Tegra devices and T210
> > >>ARM: tegra: include timer as default option
> > >>
> > >>   arch/arm/Kconfig|   1 +
> > >>   arch/arm/include/asm/arch-tegra/clock.h |   9 +-
> > >>   arch/arm/mach-tegra/Kconfig |   3 +
> > >>   arch/arm/mach-tegra/clock.c |  17 +++-
> > >>   arch/arm/mach-tegra/cpu.c   |  70 ++---
> > >>   arch/arm/mach-tegra/tegra114/clock.c|  13 +--
> > >>   arch/arm/mach-tegra/tegra124/clock.c|  13 +--
> > >>   arch/arm/mach-tegra/tegra20/clock.c |   4 +-
> > >>   arch/arm/mach-tegra/tegra210/clock.c|  22 +---
> > >>   arch/arm/mach-tegra/tegra30/clock.c |  10 +-
> > >>   drivers/timer/Kconfig   |   8 ++
> > >>   drivers/timer/Makefile  |   1 +
> > >>   drivers/timer/tegra-timer.c | 130 
> > >>   drivers/usb/host/ehci-tegra.c   |  46 +++--
> > >>   include/configs/tegra-common.h  |   6 --
> > >>   15 files changed, 274 insertions(+), 79 deletions(-)
> > >>   create mode 100644 

Re: [GIT PULL] Please pull u-boot-amlogic-20230131

2023-01-31 Thread Tom Rini
On Tue, Jan 31, 2023 at 09:48:09AM +0100, Neil Armstrong wrote:

> 
> Hi Tom,
> 
> Sorry for the late PR, here's changes for next release:
> - Switch USB Gadget to DM ! Finally, the last legacy bit is now over
> - Add new boards:
>  - Odroid Go Ultra, a portable console based on S922X
>  - Odroid-N2L, a smaller version of the N2+
> 
> The PR also contains:
> - jethub j100: add rescue boot from microSD
> - move meson sm command to cmd/meson and add efusedump sub-command
> 
> The CI job is at 
> https://source.denx.de/u-boot/custodians/u-boot-amlogic/pipelines/14947
> 
> Thanks,
> Neil
> 
> The following changes since commit 7b84c973b96775576dcff228d865e8570be26c82:
> 
>   ns16650: Correct CONFIG_SYS_NS16550_MEM32 platforms (2023-01-09 11:30:49 
> -0500)
> 
> are available in the Git repository at:
> 
>   https://source.denx.de/u-boot/custodians/u-boot-amlogic.git 
> tags/u-boot-amlogic-20230131
> 
> for you to fetch changes up to 8f5e9de121003bfd9a64a5b3a503c0fbd02af823:
> 
>   ARM: meson: Add support for Odroid-N2L (2023-01-30 14:24:17 +0100)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


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

2023-01-31 Thread Tony Dinh
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 
---

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   |   6 +
 board/thecus/n2350/Makefile  |   6 +
 board/thecus/n2350/n2350.c   | 127 +++
 configs/n2350_defconfig  |  93 +
 include/configs/n2350.h  |  65 
 8 files changed, 755 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>;
+
+   pinctrl-names = "default";
+
+   white_sata1 {
+   label = "n2350:white:sata1";
+   gpios = < 20 GPIO_ACTIVE_HIGH>;
+   linux,default-trigger = "ide-disk1";
+   };
+
+   red_sata1 {
+   label = 

[PATCH 2/2] board: gateworks: venice: poll I2C lines to wait for GSC firmware

2023-01-31 Thread sbabic
> In some situations the GSC firmware where the EEPROM containing the
> model and DRAM configuration may not be ready by the time the SoC
> is ready to talk to it over I2C.
> Instead of a hard delay, poll the I2C lines to wait until they are
> released to avoid the I2C drivers 'Arbitation lost' error message.
> Signed-off-by: Tim Harvey 
> Reviewed-by: Fabio Estevam 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH v1] imx8: scu_api: sync sc_rm_is_pad_owned api change

2023-01-31 Thread sbabic
> From: Ye Li 
> SCFW has fixed a overflow issue in sc_rm_is_pad_owned API. This
> requires u-boot to update API implementation, since it will cause
> compatible issue. Otherwise all pad checking will have problem and
> cause pad setting not continue.
> Due to the compatible issue, the new u-boot only works with new
> SCFW (API version: 1.21 and later).
> old scfw + old u-boot: API overflow issue
> old scfw + new u-boot, or new scfw + old u-boot: API compatible issue
> new scfw + new u-boot: Working
> Signed-off-by: Ye Li 
> Reviewed-by : Jason Liu 
> Signed-off-by: Marcel Ziswiler 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH] configs: imx8m: Prepare imx8m-beacon boards for HAB support

2023-01-31 Thread sbabic
> In order to enable HAB, FSL_CAAM, ARCH_MISC_INIT and
> SPL_CRYPTO should be enabled in Kconfig like other i.MX8M
> boards.
> Signed-off-by: Adam Ford 
> diff --git a/arch/arm/mach-imx/imx8m/Kconfig b/arch/arm/mach-imx/imx8m/Kconfig
> index a0715e8091..eadb2234b0 100644
> --- a/arch/arm/mach-imx/imx8m/Kconfig
> +++ b/arch/arm/mach-imx/imx8m/Kconfig
> @@ -233,6 +233,9 @@ config TARGET_IMX8MM_BEACON
>   select IMX8MM
>   select SUPPORT_SPL
>   select IMX8M_LPDDR4
> + select FSL_CAAM
> + select ARCH_MISC_INIT
> + select SPL_CRYPTO if SPL
>  
>  config TARGET_IMX8MN_BEACON
>   bool "imx8mn Beacon Embedded devkit"
> @@ -240,6 +243,9 @@ config TARGET_IMX8MN_BEACON
>   select IMX8MN
>   select SUPPORT_SPL
>   select IMX8M_LPDDR4
> + select FSL_CAAM
> + select ARCH_MISC_INIT
> + select SPL_CRYPTO if SPL
>  
>  config TARGET_PHYCORE_IMX8MM
>   bool "PHYTEC PHYCORE i.MX8MM"
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH] arm64: dts: imx8m{m, n}-venice-gw7902: add gpio pins for new board revision

2023-01-31 Thread sbabic
> Add gpio pins present on new board revision:
>  * LTE modem support (imx8mm-gw7902 only)
>   - lte_pwr#
>   - lte_rst
>   - lte_int
>  * M2 power enable
>   - m2_pwr_en
>  * off-board 4.0V supply
>   - vdd_4p0_en
> Signed-off-by: Tim Harvey 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH] arm: dts: imx8mn-u-boot: use versioned ddr4 firmware

2023-01-31 Thread sbabic
> NXP tested imx8mn-ddr4 with firmware version 201810 only. Use this
> version for all imx8mn targets with DRAM DDR4.
> Fixes: 93c4c0e4dd1 ("arm: dts: imx8mn-u-boot: Create common 
> imx8mn-u-boot.dtsi")
> Signed-off-by: Oleksandr Suvorov 
> Reviewed-by: Fabio Estevam 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH] engicam: imx6: migrate to DM_SERIAL

2023-01-31 Thread sbabic
> From: Michael Trimarchi 
> Add the needed DT overrides and configs to enable UART in SPL.
> Cc: Fabio Estevam 
> Signed-off-by: Michael Trimarchi 
> Tested-by: Suniel Mahesh 
> Reviewed-by: Fabio Estevam 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH 1/1] configs: imx8mp_evk: revert to old ram settings

2023-01-31 Thread sbabic
> The 'commit 864ac2cf383e ("board: imx8mp: Add Engicam
> i.Core MX8M Plus EDIMM2.2 Starter Kit")' has changed the imx8mp evk ram
> settings from 6GB ram to 2GB.
> This changeset reverts the above change.
> Signed-off-by: Manoj Sai 
> Reported-by  : Peter Bergin 
> Reviewed-by: Peng Fan 
> Reviewed-by: Fabio Estevam 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH 2/2] imx: mx6sabresd: convert to DM_I2C

2023-01-31 Thread sbabic
> From: Peng Fan 
> Convert to DM_I2C
> Signed-off-by: Peng Fan 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH] configs: imx8mn_beacon_fspi: Add config for booting from QSPI

2023-01-31 Thread sbabic
> The imx8mn-beacon SOM has a QSPI part on it connected to the
> FlexSPI controller.  Add a defconfig option which supports
> booting from the QSPI NOR flash instead of sd/mmc.
> Signed-off-by: Adam Ford 
> diff --git a/configs/imx8mn_beacon_fspi_defconfig 
> b/configs/imx8mn_beacon_fspi_defconfig
> new file mode 100644
> index 00..27b60824f3
> --- /dev/null
> +++ b/configs/imx8mn_beacon_fspi_defconfig
> @@ -0,0 +1,156 @@
> +CONFIG_ARM=y
> +CONFIG_ARCH_IMX8M=y
> +CONFIG_TEXT_BASE=0x4020
> +CONFIG_SYS_MALLOC_LEN=0x200
> +CONFIG_SPL_GPIO=y
> +CONFIG_SPL_LIBCOMMON_SUPPORT=y
> +CONFIG_SPL_LIBGENERIC_SUPPORT=y
> +CONFIG_NR_DRAM_BANKS=1
> +CONFIG_ENV_SIZE=0x2000
> +CONFIG_ENV_OFFSET=0xDE00
> +CONFIG_DM_GPIO=y
> +CONFIG_DEFAULT_DEVICE_TREE="imx8mn-beacon-kit"
> +CONFIG_SPL_TEXT_BASE=0x912000
> +CONFIG_TARGET_IMX8MN_BEACON=y
> +CONFIG_SYS_PROMPT="u-boot=> "
> +CONFIG_SPL_SERIAL=y
> +CONFIG_SPL_DRIVERS_MISC=y
> +CONFIG_SPL=y
> +CONFIG_SPL_IMX_ROMAPI_LOADADDR=0x4800
> +CONFIG_SYS_LOAD_ADDR=0x4200
> +CONFIG_SYS_MEMTEST_START=0x4000
> +CONFIG_SYS_MEMTEST_END=0x4400
> +CONFIG_LTO=y
> +CONFIG_REMAKE_ELF=y
> +CONFIG_SYS_MONITOR_LEN=524288
> +CONFIG_FIT=y
> +CONFIG_FIT_EXTERNAL_OFFSET=0x3000
> +CONFIG_SPL_LOAD_FIT=y
> +# CONFIG_USE_SPL_FIT_GENERATOR is not set
> +CONFIG_OF_SYSTEM_SETUP=y
> +CONFIG_USE_BOOTCOMMAND=y
> +CONFIG_BOOTCOMMAND="mmc dev ${mmcdev}; if mmc rescan; then if run 
> loadbootscript; then run bootscript; else if run loadimage; then run mmcboot; 
> else run netboot; fi; fi; else booti ${loadaddr} - ${fdt_addr}; fi"
> +CONFIG_DEFAULT_FDT_FILE="imx8mn-beacon-kit.dtb"
> +CONFIG_ARCH_MISC_INIT=y
> +CONFIG_SPL_MAX_SIZE=0x25000
> +CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
> +CONFIG_SPL_BSS_START_ADDR=0x95
> +CONFIG_SPL_BSS_MAX_SIZE=0x2000
> +CONFIG_SPL_BOARD_INIT=y
> +CONFIG_SPL_BOOTROM_SUPPORT=y
> +# CONFIG_SPL_SHARES_INIT_SP_ADDR is not set
> +CONFIG_SPL_STACK=0x98
> +CONFIG_SYS_SPL_MALLOC=y
> +CONFIG_HAS_CUSTOM_SPL_MALLOC_START=y
> +CONFIG_CUSTOM_SYS_SPL_MALLOC_ADDR=0x4220
> +CONFIG_SYS_SPL_MALLOC_SIZE=0x8
> +CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
> +CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x300
> +CONFIG_SPL_I2C=y
> +CONFIG_SPL_POWER=y
> +CONFIG_SPL_WATCHDOG=y
> +CONFIG_HUSH_PARSER=y
> +CONFIG_SYS_MAXARGS=64
> +CONFIG_SYS_CBSIZE=2048
> +CONFIG_SYS_PBSIZE=2074
> +# CONFIG_BOOTM_NETBSD is not set
> +CONFIG_SYS_BOOTM_LEN=0x80
> +# CONFIG_CMD_EXPORTENV is not set
> +# CONFIG_CMD_IMPORTENV is not set
> +CONFIG_CMD_ERASEENV=y
> +# CONFIG_CMD_CRC32 is not set
> +CONFIG_CMD_MEMTEST=y
> +CONFIG_CMD_CLK=y
> +CONFIG_CMD_FUSE=y
> +CONFIG_CMD_GPIO=y
> +CONFIG_CMD_I2C=y
> +CONFIG_CMD_MMC=y
> +CONFIG_CMD_PART=y
> +CONFIG_CMD_SPI=y
> +CONFIG_CMD_DHCP=y
> +CONFIG_CMD_MII=y
> +CONFIG_CMD_PING=y
> +CONFIG_CMD_CACHE=y
> +CONFIG_CMD_REGULATOR=y
> +CONFIG_CMD_EXT2=y
> +CONFIG_CMD_EXT4=y
> +CONFIG_CMD_EXT4_WRITE=y
> +CONFIG_CMD_FAT=y
> +CONFIG_OF_CONTROL=y
> +CONFIG_SPL_OF_CONTROL=y
> +CONFIG_ENV_OVERWRITE=y
> +CONFIG_ENV_IS_NOWHERE=y
> +CONFIG_ENV_IS_IN_MMC=y
> +CONFIG_SYS_RELOC_GD_ENV_ADDR=y
> +CONFIG_SYS_MMC_ENV_DEV=2
> +CONFIG_SYS_MMC_ENV_PART=2
> +CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
> +CONFIG_USE_ETHPRIME=y
> +CONFIG_ETHPRIME="FEC"
> +CONFIG_NET_RANDOM_ETHADDR=y
> +CONFIG_SPL_DM=y
> +CONFIG_REGMAP=y
> +CONFIG_SYSCON=y
> +CONFIG_SPL_CLK_IMX8MN=y
> +CONFIG_CLK_IMX8MN=y
> +CONFIG_USB_FUNCTION_FASTBOOT=y
> +CONFIG_FASTBOOT_BUF_ADDR=0x4280
> +CONFIG_FASTBOOT_BUF_SIZE=0x4000
> +CONFIG_FASTBOOT_FLASH=y
> +CONFIG_FASTBOOT_FLASH_MMC_DEV=0
> +CONFIG_MXC_GPIO=y
> +CONFIG_DM_PCA953X=y
> +CONFIG_DM_I2C=y
> +CONFIG_SUPPORT_EMMC_BOOT=y
> +CONFIG_MMC_IO_VOLTAGE=y
> +CONFIG_MMC_UHS_SUPPORT=y
> +CONFIG_MMC_HS400_ES_SUPPORT=y
> +CONFIG_MMC_HS400_SUPPORT=y
> +CONFIG_FSL_USDHC=y
> +CONFIG_MTD=y
> +CONFIG_DM_MTD=y
> +CONFIG_DM_SPI_FLASH=y
> +CONFIG_SF_DEFAULT_SPEED=4000
> +CONFIG_SPI_FLASH_BAR=y
> +CONFIG_SPI_FLASH_STMICRO=y
> +CONFIG_SPI_FLASH_MTD=y
> +CONFIG_PHYLIB=y
> +CONFIG_PHY_ATHEROS=y
> +CONFIG_PHY_GIGE=y
> +CONFIG_FEC_MXC=y
> +CONFIG_MII=y
> +CONFIG_PINCTRL=y
> +CONFIG_SPL_PINCTRL=y
> +CONFIG_PINCTRL_IMX8M=y
> +CONFIG_DM_PMIC=y
> +# CONFIG_SPL_PMIC_CHILDREN is not set
> +CONFIG_DM_PMIC_BD71837=y
> +CONFIG_SPL_DM_PMIC_BD71837=y
> +CONFIG_DM_REGULATOR=y
> +CONFIG_DM_REGULATOR_BD71837=y
> +CONFIG_DM_REGULATOR_FIXED=y
> +CONFIG_DM_REGULATOR_GPIO=y
> +CONFIG_DM_RESET=y
> +CONFIG_DM_SERIAL=y
> +CONFIG_MXC_UART=y
> +CONFIG_SPI=y
> +CONFIG_DM_SPI=y
> +CONFIG_NXP_FSPI=y
> +CONFIG_SYSRESET=y
> +CONFIG_SPL_SYSRESET=y
> +CONFIG_SYSRESET_PSCI=y
> +CONFIG_SYSRESET_WATCHDOG=y
> +CONFIG_DM_THERMAL=y
> +CONFIG_USB=y
> +# CONFIG_SPL_DM_USB is not set
> +CONFIG_USB_EHCI_HCD=y
> +CONFIG_USB_GADGET=y
> +CONFIG_USB_GADGET_MANUFACTURER="FSL"
> +CONFIG_USB_GADGET_VENDOR_NUM=0x0525
> +CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
> +CONFIG_CI_UDC=y
> +CONFIG_SDP_LOADADDR=0x0
> +CONFIG_IMX_WATCHDOG=y
> +CONFIG_OF_LIBFDT_OVERLAY=y
> +CONFIG_FSPI_CONF_HEADER=y
> +CONFIG_FSPI_CONF_FILE="fspi_header.bin"

[PATCH 1/2] arm: dts: imx8m*-venice-*: add I2C GPIO bus recovery support

2023-01-31 Thread sbabic
> Add I2C GPIO bus recovery support by adding scl-gpios and sda-gpios for the
> various I2C busses on Gateworks Venice boards.
> Signed-off-by: Tim Harvey 
> Reviewed-by: Fabio Estevam 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH] imx8mq_pins: fix configuration for UART4 on ECSPI2 pads

2023-01-31 Thread sbabic
> When routing UART4 using the ECSPI2 pads, register
> IOMUXC_UART4_RXD_SELECT_INPUT (offset 0x050C) should be changed only
> when dealing with RX, as its name suggests.
> Signed-off-by: Arnaud Ferraris 
> Reviewed-by: Fabio Estevam 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH 1/2] imx: mx6sabreauto: convert to DM_I2C

2023-01-31 Thread sbabic
> From: Peng Fan 
> Convert to DM_I2C
> Signed-off-by: Peng Fan 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=
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: [PATCH v7 0/3] Timer support for ARM Tegra

2023-01-31 Thread Tom Warren
OK, I'll wait for your v8 with the adjusted timer enabling.

Does this series need to go in first before your recent 16-patch series 
"General Tegra improvements"? i.e. are there any dependencies?

Tom
-Original Message-
From: Svyatoslav Ryhel  
Sent: Tuesday, January 31, 2023 8:26 AM
To: Tom Warren 
Cc: Thierry Reding ; Rayagonda Kokatanur 
; Marek Vasut ; Maxim Schwalm 
; Dmitry Osipenko ; Jonas Schwöbel 
; Agneli ; Heinrich Schuchardt 
; Michal Simek ; Stefan Roese 
; Eugen Hristev ; Michael Walle 
; Simon Glass ; Jim Liu 
; William Zhang ; Rick Chen 
; Stefan Herbrechtsmeier 
; Andre Przywara 
; Jaehoon Chung ; 
u-boot@lists.denx.de
Subject: Re: [PATCH v7 0/3] Timer support for ARM Tegra

External email: Use caution opening links or attachments


Yes, it works perfectly fine on the T20/T30/T124/T186 and T210, T114 board no 
one has on hand. Timer enabling has to be adjusted as Thierry suggested.

вт, 31 січ. 2023 р. о 17:18 Tom Warren  пише:
>
> Has this been tested yet? I want to get it into the next PR, and I need a 
> tested-by for V7 before I can do that.
>
> Thanks,
>
> Tom
>
> -Original Message-
> From: Svyatoslav R. 
> Sent: Friday, January 27, 2023 1:28 PM
> To: Thierry Reding 
> Cc: Rayagonda Kokatanur ; Tom Warren 
> ; Marek Vasut ; Maxim Schwalm 
> ; Dmitry Osipenko ; Jonas 
> Schwöbel ; Agneli ; 
> Heinrich Schuchardt ; Michal Simek 
> ; Stefan Roese ; Eugen Hristev 
> ; Michael Walle ; Simon 
> Glass ; Jim Liu ; William 
> Zhang ; Rick Chen ; 
> Stefan Herbrechtsmeier ; Andre 
> Przywara ; Jaehoon Chung 
> ; u-boot@lists.denx.de
> Subject: Re: [PATCH v7 0/3] Timer support for ARM Tegra
>
> External email: Use caution opening links or attachments
>
>
> On 1/27/23 19:15, Thierry Reding wrote:
> > On Fri, Jan 27, 2023 at 09:13:09AM +0200, Svyatoslav Ryhel wrote:
> >> - ARM: tegra: remap clock_osc_freq for all Tegra family Enum 
> >> clock_osc_freq was designed to use only with T20.
> >> This patch remaps it to use additional frequencies, added in
> >> T30+ SoC while maintaining backwards compatibility with T20.
> >>
> >> - drivers: timer: add timer driver for ARMv7 based Tegra devices 
> >> Add timer support for T20/T30/T114/T124 and T210 based devices.
> >> Driver is based on DM, has device tree support and can be used on 
> >> SPL and early boot stage.
> >>
> >> Arm64 Tegra (apart T210) according to comment in tegra-common.h use 
> >> architected timer.
> >>
> >> - ARM: tegra: include timer as default option Enable TIMER as 
> >> default option for all Tegra devices and enable TEGRA_TIMER for 
> >> TEGRA_ARMV7_COMMON and TEGRA210.
> >> Additionally enable SPL_TIMER if build as SPL part and drop 
> >> deprecated configs from common header.
> >>
> >> P. S. I have no arm64 Tegra and according to comment in 
> >> tegra-common.h Use the Tegra US timer on ARMv7, but the architected 
> >> timer on ARMv8.
> >>
> >> ---
> >> Changeog from V6
> >>   - use clk_m as timer calibration clock (this should properly fix T210)
> >>   - enable timer for T210
> >>
> >> Changed from v5:
> >>   - added paz00 tester
> >>
> >> Changed from v4:
> >>   - added comments
> >>
> >> Changed from v3:
> >>   - removed BOOTSTAGE ifdefs
> >>   - use early timer on boot stage unconditionally
> >> ---
> >> Svyatoslav Ryhel (3):
> >>ARM: tegra: remap clock_osc_freq for all Tegra family
> >>drivers: timer: add driver for ARMv7 based Tegra devices and T210
> >>ARM: tegra: include timer as default option
> >>
> >>   arch/arm/Kconfig|   1 +
> >>   arch/arm/include/asm/arch-tegra/clock.h |   9 +-
> >>   arch/arm/mach-tegra/Kconfig |   3 +
> >>   arch/arm/mach-tegra/clock.c |  17 +++-
> >>   arch/arm/mach-tegra/cpu.c   |  70 ++---
> >>   arch/arm/mach-tegra/tegra114/clock.c|  13 +--
> >>   arch/arm/mach-tegra/tegra124/clock.c|  13 +--
> >>   arch/arm/mach-tegra/tegra20/clock.c |   4 +-
> >>   arch/arm/mach-tegra/tegra210/clock.c|  22 +---
> >>   arch/arm/mach-tegra/tegra30/clock.c |  10 +-
> >>   drivers/timer/Kconfig   |   8 ++
> >>   drivers/timer/Makefile  |   1 +
> >>   drivers/timer/tegra-timer.c | 130 
> >>   drivers/usb/host/ehci-tegra.c   |  46 +++--
> >>   include/configs/tegra-common.h  |   6 --
> >>   15 files changed, 274 insertions(+), 79 deletions(-)
> >>   create mode 100644 drivers/timer/tegra-timer.c
> > Ugh... turns out I had completely messed up the testing on Tegra186 
> > and it wasn't working at all. The problem is that the selection of 
> > the TIMER symbol for all of Tegra causes the driver model to be 
> > used, but there is no DM driver for the architected timer that's used on 
> > Tegra186.
> >
> > The quickest fix would be to do this:
> >
> > --- >8 ---
> > diff --git a/arch/arm/mach-tegra/Kconfig 
> > b/arch/arm/mach-tegra/Kconfig index b50eec5b8c9b..05c8ce0e08dd 
> > 100644
> > --- 

[PATCH] RFC: CI: add test/usage_of_is_enabled_check.sh

2023-01-31 Thread Troy Kisky
Add script usage_of_is_enabled_check to print any configs that
use CONFIG_IS_ENABLED instead of IS_ENABLED and vice versa.

Add usage_of_is_enabled_commit.sh to generate commits to fix the above
issues.

Signed-off-by: Troy Kisky 
---
 .azure-pipelines.yml   | 11 
 .gitlab-ci.yml |  5 
 test/usage_of_is_enabled_check.sh  | 41 ++
 test/usage_of_is_enabled_commit.sh | 38 +++
 4 files changed, 95 insertions(+)
 create mode 100755 test/usage_of_is_enabled_check.sh
 create mode 100755 test/usage_of_is_enabled_commit.sh

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 5673bb76afb..8e227512765 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -67,6 +67,17 @@ stages:
   :^doc/ :^arch/arm/dts/ :^scripts/kconfig/lkc.h
   :^include/linux/kconfig.h :^tools/ && exit 1 || exit 0
 
+  - job: check_usage_of_is_enabled
+displayName: 'Check usage of CONFIG_IS_ENABLED vs IS_ENABLED'
+pool:
+  vmImage: $(ubuntu_vm)
+container:
+  image: $(ci_runner_image)
+  options: $(container_option)
+steps:
+  # generate list of SPL configs
+  - script: test/usage_of_is_enabled_check.sh
+
   - job: cppcheck
 displayName: 'Static code analysis with cppcheck'
 pool:
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index aaf9d25abfc..6bb8efef258 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -134,6 +134,11 @@ check for new CONFIG symbols outside Kconfig:
 :^doc/ :^arch/arm/dts/ :^scripts/kconfig/lkc.h
 :^include/linux/kconfig.h :^tools/ && exit 1 || exit 0
 
+check usage of CONFIG_IS_ENABLED vs IS_ENABLED:
+  stage: testsuites
+  script:
+- ./test/usage_of_is_enabled_check.sh
+
 # QA jobs for code analytics
 # static code analysis with cppcheck (we can add --enable=all later)
 cppcheck:
diff --git a/test/usage_of_is_enabled_check.sh 
b/test/usage_of_is_enabled_check.sh
new file mode 100755
index 000..0bc9bff8bd1
--- /dev/null
+++ b/test/usage_of_is_enabled_check.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+# generate list of CONFIGs that should use CONFIG_IS_ENABLED
+{ { git grep 'obj-$(CONFIG_$(SPL_'|grep Makefile|sed -e "s/SPL_TPL_/SPL_/"| \
+sed -n -r 's/obj\-\$\(CONFIG_\$\(SPL_\)([0-9a-zA-Z_]+)\)/\n\{\1\}\n/gp'| \
+sed -n -r 's/\{([0-9a-zA-Z_]+)\}/\1/p'; } ;\
+{ git grep -E 'config [ST]PL_'|grep Kconfig| \
+sed -n -r "s/config [ST]PL_([0-9a-zA-Z_]+)/\n\{\1\}\n/p" |
+sed -n -r 's/\{([0-9a-zA-Z_]+)\}/\1/p'; } ; \
+git grep -E 'CONFIG_IS_ENABLED\(CMD_'|sed -n -e 
"s/\(CONFIG_IS_ENABLED(CMD_[0-9a-zA-Z_]*)\)/\n\1\n/gp"| \
+sed -n -r "s/CONFIG_IS_ENABLED\((CMD_[0-9a-zA-Z_]+)\)/\1/p"; \
+echo -e "\
+BZIP2\n\
+CONFIG_CLK\n\
+DM_EVENT\n\
+EFI_DEVICE_PATH_TO_TEXT\n\
+EFI_LOADER\n\
+ERRNO_STR\n\
+GENERATE_SMBIOS_TABLE\n\
+";\
+} | sort -u >splcfg.tmp
+
+{
+# generate list of CONFIGs that incorrectly use CONFIG_IS_ENABLED
+git grep CONFIG_IS_ENABLED|sed -n -e 
"s/\(CONFIG_IS_ENABLED([0-9a-zA-Z_]*)\)/\n\1\n/gp"| \
+sed -n -r "s/CONFIG_IS_ENABLED\(([0-9a-zA-Z_]+)\)/\1/p" |sort -u| comm -23 - 
splcfg.tmp ;
+
+# generate list of CONFIGs that incorrectly use IS_ENABLED
+git grep -w IS_ENABLED|sed -n -e 
"s/\(IS_ENABLED(CONFIG_[0-9a-zA-Z_]*)\)/\n\1\n/gp"| \
+sed -n -r "s/IS_ENABLED\(CONFIG_([0-9a-zA-Z_]+)\)/\1/p" |sort -u| join - 
splcfg.tmp;
+} | grep -vw FOO;
+if [ $? -eq 0 ] ; then
+   echo "The above may have incorrect usage of 
IS_ENABLED/CONFIG_IS_ENABLED"
+   echo "Run test/usage_of_is_enabled_commit.sh and squash with 
appropriate commit"
+   ret=1;
+else
+   ret=0;
+fi
+
+rm splcfg.tmp
+exit ${ret}
+
diff --git a/test/usage_of_is_enabled_commit.sh 
b/test/usage_of_is_enabled_commit.sh
new file mode 100755
index 000..f776d0c69ab
--- /dev/null
+++ b/test/usage_of_is_enabled_commit.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+# generate list of CONFIGs that should use CONFIG_IS_ENABLED
+{ { git grep 'obj-$(CONFIG_$(SPL_'|grep Makefile|sed -e "s/SPL_TPL_/SPL_/"| \
+sed -n -r 's/obj\-\$\(CONFIG_\$\(SPL_\)([0-9a-zA-Z_]+)\)/\n\{\1\}\n/gp'| \
+sed -n -r 's/\{([0-9a-zA-Z_]+)\}/\1/p'; } ;\
+{ git grep -E 'config [ST]PL_'|grep Kconfig| \
+sed -n -r "s/config [ST]PL_([0-9a-zA-Z_]+)/\n\{\1\}\n/p" |
+sed -n -r 's/\{([0-9a-zA-Z_]+)\}/\1/p'; } ; \
+git grep -E 'CONFIG_IS_ENABLED\(CMD_'|sed -n -e 
"s/\(CONFIG_IS_ENABLED(CMD_[0-9a-zA-Z_]*)\)/\n\1\n/gp"| \
+sed -n -r "s/CONFIG_IS_ENABLED\((CMD_[0-9a-zA-Z_]+)\)/\1/p"; \
+echo -e "\
+BZIP2\n\
+CONFIG_CLK\n\
+DM_EVENT\n\
+EFI_DEVICE_PATH_TO_TEXT\n\
+EFI_LOADER\n\
+ERRNO_STR\n\
+GENERATE_SMBIOS_TABLE\n\
+";\
+} | sort -u >splcfg.tmp
+
+
+git grep CONFIG_IS_ENABLED|sed -n -e 
"s/\(CONFIG_IS_ENABLED([0-9a-zA-Z_]*)\)/\n\1\n/gp"| \
+sed -n -r "s/CONFIG_IS_ENABLED\(([0-9a-zA-Z_]+)\)/\1/p" |sort -u|grep -vw FOO| 
\
+comm -23 - splcfg.tmp|xargs -I {} \
+sh -c "git grep -l 'CONFIG_IS_ENABLED({})' | \
+xargs -IFile sh -c \"sed -i -e 
\\\"s/CONFIG_IS_ENABLED({})/IS_ENABLED(CONFIG_{})/g\\\" File\" ; \

Re: [PATCH] doc: Add documentation for CZ.NIC Turris routers

2023-01-31 Thread Pali Rohár
Gentle ping? Does CZ.NIC care about Turris routers and u-boot support?

On Monday 07 November 2022 21:28:31 Pali Rohár wrote:
> Hello! Just beware of these two commits which renamed files mentioned in patch
> https://source.denx.de/u-boot/u-boot/-/commit/87ac4b4b4ca5f00e2ddcdac41c9dc691ab2aecf1
> https://source.denx.de/u-boot/u-boot/-/commit/d8fa0a76681af3ecea3941f5c743332dd76c7543
> So documentation in v2 now needs to be updated to address those renamed files.
> 
> On Tuesday 01 November 2022 23:10:00 Josef Schlehofer wrote:
> > Hey Pali,
> > 
> > Thanks for letting me know about it!
> > 
> > I will prepare new version tomorrow and send it as v2.
> > 
> > Regards,
> > Josef
> > 
> > On 01. 11. 22 23:07, Pali Rohár wrote:
> > > + Lukáš and Josef from CZ.NIC
> > > 
> > > On Monday 03 October 2022 22:25:05 Pali Rohár wrote:
> > > > + Štěpán from CZ.NIC. Please look at the Heinrich comments below and
> > > > prepare a new version with fixes... I will let it to you right now.
> > > > 
> > > > On Monday 26 September 2022 13:30:02 Heinrich Schuchardt wrote:
> > > > > On 9/23/22 13:36, Pali Rohár wrote:
> > > > > > This patch adds a new documentation for all released CZ.NIC Turris 
> > > > > > routers.
> > > > > > 
> > > > > > Signed-off-by: Pali Rohár 
> > > > > > ---
> > > > > >doc/board/CZ.NIC/index.rst  |   9 +
> > > > > >doc/board/CZ.NIC/turris.rst | 323 
> > > > > > 
> > > > > >doc/board/index.rst |   1 +
> > > > > >3 files changed, 333 insertions(+)
> > > > > >create mode 100644 doc/board/CZ.NIC/index.rst
> > > > > >create mode 100644 doc/board/CZ.NIC/turris.rst
> > > > > > 
> > > > > > diff --git a/doc/board/CZ.NIC/index.rst b/doc/board/CZ.NIC/index.rst
> > > > > > new file mode 100644
> > > > > > index ..19ec6af2f389
> > > > > > --- /dev/null
> > > > > > +++ b/doc/board/CZ.NIC/index.rst
> > > > > > @@ -0,0 +1,9 @@
> > > > > > +.. SPDX-License-Identifier: GPL-2.0+
> > > > > > +
> > > > > > +CZ.NIC
> > > > > > +==
> > > > > > +
> > > > > > +.. toctree::
> > > > > > +   :maxdepth: 2
> > > > > > +
> > > > > > +   turris
> > > > > > diff --git a/doc/board/CZ.NIC/turris.rst 
> > > > > > b/doc/board/CZ.NIC/turris.rst
> > > > > > new file mode 100644
> > > > > > index ..b82dea4e0786
> > > > > > --- /dev/null
> > > > > > +++ b/doc/board/CZ.NIC/turris.rst
> > > > > > @@ -0,0 +1,323 @@
> > > > > > +.. SPDX-License-Identifier: GPL-2.0+
> > > > > > +
> > > > > > +CZ.NIC Turris routers
> > > > > > +=
> > > > > > +
> > > > > > +CZ.NIC develops open source Turris routers: Turris 1.0, Turris 
> > > > > > 1.1, Turris Omnia, and Turris Mox. This document describes a U-Boot 
> > > > > > deployment (compilation, flashing, resetting) on these routers.
> > > > > > +
> > > > > > +Turris 1.x
> > > > > > +--
> > > > > > +
> > > > > > +Turris 1.0 and Turris 1.1 boards contain Freescale P2020 CPUs with 
> > > > > > two PowerPC e500v2 cores which BootROM (or CPU directly) can load 
> > > > > > and boot U-Boot bootloader from various locations. For Turris 1.x 
> > > > > > boards, only Flash NOR and SD cards are supported. P2020 CPU cannot 
> > > > > > download bootloader via UART like other platforms. For loading the 
> > > > > > U-Boot bootloader from Flash NOR (which is the default) it is 
> > > > > > needed to put SW1 dip switches on the board to position 11001010, 
> > > > > > and for the SD card to position 01101010 respectively. Note that 
> > > > > > this controls the source from which P2020 loads U-Boot, not from 
> > > > > > which U-Boot loads boot script or kernel. Boot procedures from SD 
> > > > > > card and Flash NOR are different, hence U-Boot binaries need to be 
> > > > > > compiled differently.
> > > > > > +
> > > > > > +More information about Turris 1.x, including the complete HW 
> > > > > > documentation (together with the SW1 dip switch options) and Altium 
> > > > > > design files, can be found on: 
> > > > > > https://docs.turris.cz/hw/turris-1x/turris-1x/
> > > > > > +
> > > > > > +Compilation
> > > > > > +^^^
> > > > > > +
> > > > > > +To compile the Flash NOR version, run::
> > > > > > +
> > > > > > +$ make CROSS_COMPILE=powerpc-linux-gnuspe- 
> > > > > > turris_1x_nor_defconfig
> > > > > > +$ make CROSS_COMPILE=powerpc-linux-gnuspe- u-boot-with-dtb.bin
> > > > > > +
> > > > > > +It will produce a flashable binary file ``u-boot-with-dtb.bin``.
> > > > > > +
> > > > > > +To compile the SD card version, run::
> > > > > > +
> > > > > > +$ make CROSS_COMPILE=powerpc-linux-gnuspe- 
> > > > > > turris_1x_sdcard_defconfig
> > > > > > +$ make CROSS_COMPILE=powerpc-linux-gnuspe- u-boot-with-spl.bin
> > > > > > +
> > > > > > +It will produce a bootable binary file ``u-boot-with-spl.bin``.
> > > > > > +
> > > > > > +Flashing
> > > > > > +
> > > > > > +
> > > > > > +To flash the new U-Boot version into Flash NOR, load binary 
> > > > > > ``u-boot-with-dtb.bin`` 

Re: [PATCH v6] board: mntre: imx8mq: Add MNT Reform 2 board support

2023-01-31 Thread Stefano Babic

On 19.01.23 20:56, Patrick Wildt wrote:

The MNT Reform 2 is a modular DIY laptop.  In its initial version it
is based on the BoundaryDevices i.MX8MQ SoM.  Some parts have been
lifted from BoundaryDevices official U-Boot downstream project.

Signed-off-by: Patrick Wildt 
---
Changes since v5:
- Adjusted to further Binman changes.
- Adjusted to further Kconfig conversions.
- Removed some phy init in favor of DM.
- Removed some pinmux which are now handled by DM_SERIAL.
- Compared with Librem5/EVK and adjusted for similarity.
Changes since v4:
- Adjusted to Kconfig conversions.
- Removed U-Boot-specific device tree changes.
- Synced device tree to Linux v5.19-rc3.
Changes since v3:
- Adjusted to Binman changes in main branch.
- Cleaned up environment variables akin to i.MX8MM.
- Added vendor-prefix to device tree filename.
- Provided ramdisk_addr_r.
Changes since v2:
- Switched to Binman.
Changes since v1:
- Synced DTS with files in Linux git repo.
- Added support for USB host ports.

  arch/arm/dts/imx8mq-mnt-reform2-u-boot.dtsi   |   11 +
  arch/arm/mach-imx/imx8m/Kconfig   |7 +
  board/mntre/imx8mq_reform2/Kconfig|   15 +
  board/mntre/imx8mq_reform2/MAINTAINERS|7 +
  board/mntre/imx8mq_reform2/Makefile   |   12 +
  board/mntre/imx8mq_reform2/imx8mq_reform2.c   |  171 +++
  board/mntre/imx8mq_reform2/lpddr4_timing.c| 1014 +
  .../mntre/imx8mq_reform2/lpddr4_timing_ch2.h  |   95 ++
  board/mntre/imx8mq_reform2/spl.c  |  260 +
  configs/imx8mq_reform2_defconfig  |  107 ++
  include/configs/imx8mq_reform2.h  |   66 ++
  11 files changed, 1765 insertions(+)
  create mode 100644 arch/arm/dts/imx8mq-mnt-reform2-u-boot.dtsi
  create mode 100644 board/mntre/imx8mq_reform2/Kconfig
  create mode 100644 board/mntre/imx8mq_reform2/MAINTAINERS
  create mode 100644 board/mntre/imx8mq_reform2/Makefile
  create mode 100644 board/mntre/imx8mq_reform2/imx8mq_reform2.c
  create mode 100644 board/mntre/imx8mq_reform2/lpddr4_timing.c
  create mode 100644 board/mntre/imx8mq_reform2/lpddr4_timing_ch2.h
  create mode 100644 board/mntre/imx8mq_reform2/spl.c
  create mode 100644 configs/imx8mq_reform2_defconfig
  create mode 100644 include/configs/imx8mq_reform2.h

diff --git a/arch/arm/dts/imx8mq-mnt-reform2-u-boot.dtsi 
b/arch/arm/dts/imx8mq-mnt-reform2-u-boot.dtsi
new file mode 100644
index 00..e0a6fc5470
--- /dev/null
+++ b/arch/arm/dts/imx8mq-mnt-reform2-u-boot.dtsi
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+
+#include "imx8mq-u-boot.dtsi"
+
+_uart1 {
+   u-boot,dm-spl;
+};
+
+ { /* console */
+   u-boot,dm-spl;
+};
diff --git a/arch/arm/mach-imx/imx8m/Kconfig b/arch/arm/mach-imx/imx8m/Kconfig
index a0715e8091..2049efb131 100644
--- a/arch/arm/mach-imx/imx8m/Kconfig
+++ b/arch/arm/mach-imx/imx8m/Kconfig
@@ -51,6 +51,12 @@ config TARGET_IMX8MQ_PHANBELL
select IMX8MQ
select IMX8M_LPDDR4
  
+config TARGET_IMX8MQ_REFORM2

+   bool "imx8mq_reform2"
+   select BINMAN
+   select IMX8MQ
+   select IMX8M_LPDDR4
+
  config TARGET_IMX8MM_DATA_MODUL_EDM_SBC
bool "Data Modul eDM SBC i.MX8M Mini"
select BINMAN
@@ -320,6 +326,7 @@ source "board/kontron/pitx_imx8m/Kconfig"
  source "board/kontron/sl-mx8mm/Kconfig"
  source "board/menlo/mx8menlo/Kconfig"
  source "board/msc/sm2s_imx8mp/Kconfig"
+source "board/mntre/imx8mq_reform2/Kconfig"
  source "board/phytec/phycore_imx8mm/Kconfig"
  source "board/phytec/phycore_imx8mp/Kconfig"
  source "board/purism/librem5/Kconfig"
diff --git a/board/mntre/imx8mq_reform2/Kconfig 
b/board/mntre/imx8mq_reform2/Kconfig
new file mode 100644
index 00..f9260cb7f5
--- /dev/null
+++ b/board/mntre/imx8mq_reform2/Kconfig
@@ -0,0 +1,15 @@
+if TARGET_IMX8MQ_REFORM2
+
+config SYS_BOARD
+   default "imx8mq_reform2"
+
+config SYS_VENDOR
+   default "mntre"
+
+config SYS_CONFIG_NAME
+   default "imx8mq_reform2"
+
+config IMX_CONFIG
+   default "arch/arm/mach-imx/imx8m/imximage.cfg"
+
+endif
diff --git a/board/mntre/imx8mq_reform2/MAINTAINERS 
b/board/mntre/imx8mq_reform2/MAINTAINERS
new file mode 100644
index 00..946f287ecf
--- /dev/null
+++ b/board/mntre/imx8mq_reform2/MAINTAINERS
@@ -0,0 +1,7 @@
+REFORM2 IMX8MQ BOARD
+M: Lukas F. Hartmann 
+M: Patrick Wildt 
+S: Maintained
+F: board/mntre/imx8mq_reform2/
+F: include/configs/imx8mq_reform2.h
+F: configs/imx8mq_reform2_defconfig
diff --git a/board/mntre/imx8mq_reform2/Makefile 
b/board/mntre/imx8mq_reform2/Makefile
new file mode 100644
index 00..2efd56bb4a
--- /dev/null
+++ b/board/mntre/imx8mq_reform2/Makefile
@@ -0,0 +1,12 @@
+#
+# Copyright 2017 NXP
+#
+# SPDX-License-Identifier:  GPL-2.0+
+#
+
+obj-y += imx8mq_reform2.o
+
+ifdef CONFIG_SPL_BUILD
+obj-y += spl.o
+obj-$(CONFIG_IMX8M_LPDDR4) += lpddr4_timing.o
+endif
diff --git a/board/mntre/imx8mq_reform2/imx8mq_reform2.c 

Re: [PATCH 088/171] Correct SPL uses of FASTBOOT_FLASH_NAND

2023-01-31 Thread Mattijs Korpershoek
On Mon, Jan 30, 2023 at 07:42, Simon Glass  wrote:

> This converts 3 usages of this option to the non-SPL form, since there is
> no SPL_FASTBOOT_FLASH_NAND defined in Kconfig
>
> Signed-off-by: Simon Glass 

Reviewed-by: Mattijs Korpershoek 

> ---
>
>  drivers/fastboot/fb_command.c | 4 ++--
>  drivers/fastboot/fb_getvar.c  | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c
> index 5a3fb69b3f7..71cfaec6e9d 100644
> --- a/drivers/fastboot/fb_command.c
> +++ b/drivers/fastboot/fb_command.c
> @@ -299,7 +299,7 @@ static void __maybe_unused flash(char *cmd_parameter, 
> char *response)
>   fastboot_mmc_flash_write(cmd_parameter, fastboot_buf_addr,
>image_size, response);
>  
> - if (CONFIG_IS_ENABLED(FASTBOOT_FLASH_NAND))
> + if (IS_ENABLED(CONFIG_FASTBOOT_FLASH_NAND))
>   fastboot_nand_flash_write(cmd_parameter, fastboot_buf_addr,
> image_size, response);
>  }
> @@ -318,7 +318,7 @@ static void __maybe_unused erase(char *cmd_parameter, 
> char *response)
>   if (IS_ENABLED(CONFIG_FASTBOOT_FLASH_MMC))
>   fastboot_mmc_erase(cmd_parameter, response);
>  
> - if (CONFIG_IS_ENABLED(FASTBOOT_FLASH_NAND))
> + if (IS_ENABLED(CONFIG_FASTBOOT_FLASH_NAND))
>   fastboot_nand_erase(cmd_parameter, response);
>  }
>  
> diff --git a/drivers/fastboot/fb_getvar.c b/drivers/fastboot/fb_getvar.c
> index de4879dadfb..dd3475e0a8b 100644
> --- a/drivers/fastboot/fb_getvar.c
> +++ b/drivers/fastboot/fb_getvar.c
> @@ -104,7 +104,7 @@ static int getvar_get_part_info(const char *part_name, 
> char *response,
>  response);
>   if (r >= 0 && size)
>   *size = disk_part.size * disk_part.blksz;
> - } else if (CONFIG_IS_ENABLED(FASTBOOT_FLASH_NAND)) {
> + } else if (IS_ENABLED(CONFIG_FASTBOOT_FLASH_NAND)) {
>   r = fastboot_nand_get_part_info(part_name, _info, 
> response);
>   if (r >= 0 && size)
>   *size = part_info->size;
> -- 
> 2.39.1.456.gfc5497dd1b-goog


Re: [PATCH 087/171] Correct SPL uses of FASTBOOT_FLASH_MMC

2023-01-31 Thread Mattijs Korpershoek
On Mon, Jan 30, 2023 at 07:42, Simon Glass  wrote:

> This converts 5 usages of this option to the non-SPL form, since there is
> no SPL_FASTBOOT_FLASH_MMC defined in Kconfig
>
> Signed-off-by: Simon Glass 

Reviewed-by: Mattijs Korpershoek 

> ---
>
>  drivers/fastboot/fb_command.c | 4 ++--
>  drivers/fastboot/fb_common.c  | 2 +-
>  drivers/fastboot/fb_getvar.c  | 4 ++--
>  3 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c
> index 67a94798287..5a3fb69b3f7 100644
> --- a/drivers/fastboot/fb_command.c
> +++ b/drivers/fastboot/fb_command.c
> @@ -295,7 +295,7 @@ void fastboot_data_complete(char *response)
>   */
>  static void __maybe_unused flash(char *cmd_parameter, char *response)
>  {
> - if (CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC))
> + if (IS_ENABLED(CONFIG_FASTBOOT_FLASH_MMC))
>   fastboot_mmc_flash_write(cmd_parameter, fastboot_buf_addr,
>image_size, response);
>  
> @@ -315,7 +315,7 @@ static void __maybe_unused flash(char *cmd_parameter, 
> char *response)
>   */
>  static void __maybe_unused erase(char *cmd_parameter, char *response)
>  {
> - if (CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC))
> + if (IS_ENABLED(CONFIG_FASTBOOT_FLASH_MMC))
>   fastboot_mmc_erase(cmd_parameter, response);
>  
>   if (CONFIG_IS_ENABLED(FASTBOOT_FLASH_NAND))
> diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c
> index 7563650d07d..57b6182c46a 100644
> --- a/drivers/fastboot/fb_common.c
> +++ b/drivers/fastboot/fb_common.c
> @@ -99,7 +99,7 @@ int __weak fastboot_set_reboot_flag(enum 
> fastboot_reboot_reason reason)
>   const int mmc_dev = config_opt_enabled(CONFIG_FASTBOOT_FLASH_MMC,
>  CONFIG_FASTBOOT_FLASH_MMC_DEV, 
> -1);
>  
> - if (!CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC))
> + if (!IS_ENABLED(CONFIG_FASTBOOT_FLASH_MMC))
>   return -EINVAL;
>  
>   if (reason >= FASTBOOT_REBOOT_REASONS_COUNT)
> diff --git a/drivers/fastboot/fb_getvar.c b/drivers/fastboot/fb_getvar.c
> index bcef8f866f3..de4879dadfb 100644
> --- a/drivers/fastboot/fb_getvar.c
> +++ b/drivers/fastboot/fb_getvar.c
> @@ -62,7 +62,7 @@ static const struct {
>   .variable = "has-slot",
>   .dispatch = getvar_has_slot
>  #endif
> -#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
> +#if IS_ENABLED(CONFIG_FASTBOOT_FLASH_MMC)
>   }, {
>   .variable = "partition-type",
>   .dispatch = getvar_partition_type
> @@ -99,7 +99,7 @@ static int getvar_get_part_info(const char *part_name, char 
> *response,
>   struct disk_partition disk_part;
>   struct part_info *part_info;
>  
> - if (CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)) {
> + if (IS_ENABLED(CONFIG_FASTBOOT_FLASH_MMC)) {
>   r = fastboot_mmc_get_part_info(part_name, _desc, _part,
>  response);
>   if (r >= 0 && size)
> -- 
> 2.39.1.456.gfc5497dd1b-goog


Re: [PATCH 086/171] Correct SPL uses of FASTBOOT_FLASH

2023-01-31 Thread Mattijs Korpershoek
On Mon, Jan 30, 2023 at 07:41, Simon Glass  wrote:

> This converts 3 usages of this option to the non-SPL form, since there is
> no SPL_FASTBOOT_FLASH defined in Kconfig
>
> Signed-off-by: Simon Glass 

Reviewed-by: Mattijs Korpershoek 

> ---
>
>  drivers/fastboot/fb_getvar.c | 4 ++--
>  net/fastboot.c   | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/fastboot/fb_getvar.c b/drivers/fastboot/fb_getvar.c
> index 2fbd285db38..bcef8f866f3 100644
> --- a/drivers/fastboot/fb_getvar.c
> +++ b/drivers/fastboot/fb_getvar.c
> @@ -57,7 +57,7 @@ static const struct {
>   }, {
>   .variable = "current-slot",
>   .dispatch = getvar_current_slot
> -#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
> +#if IS_ENABLED(CONFIG_FASTBOOT_FLASH)
>   }, {
>   .variable = "has-slot",
>   .dispatch = getvar_has_slot
> @@ -67,7 +67,7 @@ static const struct {
>   .variable = "partition-type",
>   .dispatch = getvar_partition_type
>  #endif
> -#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
> +#if IS_ENABLED(CONFIG_FASTBOOT_FLASH)
>   }, {
>   .variable = "partition-size",
>   .dispatch = getvar_partition_size
> diff --git a/net/fastboot.c b/net/fastboot.c
> index 96bdf5486fa..e9569d88d2a 100644
> --- a/net/fastboot.c
> +++ b/net/fastboot.c
> @@ -307,7 +307,7 @@ void fastboot_start_server(void)
>  
>   fastboot_our_port = CONFIG_UDP_FUNCTION_FASTBOOT_PORT;
>  
> - if (CONFIG_IS_ENABLED(FASTBOOT_FLASH))
> + if (IS_ENABLED(CONFIG_FASTBOOT_FLASH))
>   fastboot_set_progress_callback(fastboot_timed_send_info);
>  
>   net_set_udp_handler(fastboot_handler);
> -- 
> 2.39.1.456.gfc5497dd1b-goog


[PATCH] imx: Suggest the NXP ATF github repo

2023-01-31 Thread sbabic
> As explained in the text at the bottom of the page 
> https://source.codeaurora.org/external/imx/imx-atf:
> "QUIC repositories on this site will not receive any updates after
> March 31, 2022, and will be deleted on March 31, 2023."
> Point to the NXP ATF github repo instead.
> Signed-off-by: Fabio Estevam 
> Reviewed-by: Oliver Graute 
> Reviewed-by: Marcel Ziswiler 
> Reviewed-by: Frieder Schrempf 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH 09/10] arm: imx: imx8m: Program CSU and TZASC if PSCI provider

2023-01-31 Thread sbabic
> In case U-Boot is the PSCI provider, it is necessary to correctly
> program CSU and TZASC registers. Those are poorly documented, so
> push in the correct values.
> Signed-off-by: Marek Vasut 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH] ARM: arm: colibri-imx6ull-emmc: fix emmc access

2023-01-31 Thread sbabic
> From: Max Krummenacher 
> Synchronizing the device tree with linux introduced a regression.
> The U-Boot specific dtsi mustn't override the alias settings for
> the eMMC/SD interfaces.
> Without this U-Boot cannot access the eMMC and boot the kernel.
> Fixes: c21b61bff15 ("colibri-imx6ull/-emmc: synchronise device tree with 
> linux")
> Signed-off-by: Max Krummenacher 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH 08/10] arm: imx: imx8m: Define trampoline location if PSCI provider

2023-01-31 Thread sbabic
> The common code used to bring up secondary cores requires a final
> jump location to be stored in some sort of memory location, define
> this memory location to be the start of OCRAM, since it is available.
> Signed-off-by: Marek Vasut 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH] imx: imx6ul: kontron-sl-mx6ul: Disable CONFIG_FSL_QSPI_AHB_FULL_MAP to fix SPI NAND read access

2023-01-31 Thread sbabic
> From: Frieder Schrempf 
> The introduction of CONFIG_FSL_QSPI_AHB_FULL_MAP as default in:
> def88bce094e ("spi: fsl_qspi: Support to use full AHB space on i.MX")
> broke the SPI NAND read access on the Kontron SL i.MX6UL/ULL boards.
> Reading data from the flash returns garbage instead of the actual
> content. Fix this for now by disabling the introduced option.
> In the long run this should be fixed globally.
> Fixes: def88bce094e ("spi: fsl_qspi: Support to use full AHB space on i.MX")
> Signed-off-by: Frieder Schrempf 
> Reviewed-by: Fabio Estevam 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH 06/10] arm: imx: imx8m: Enable GICv3 support if PSCI provider

2023-01-31 Thread sbabic
> In case U-Boot is a PSCI provider, enable GICv3 support as this
> is necessary to bring up secondary cores.
> Signed-off-by: Marek Vasut 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH 03/10] arm: imx: Drop custom lowlevel_init

2023-01-31 Thread sbabic
> The custom lowlevel_init implementation is no longer necessary, since
> it is responsible for routing and trapping SErrors in U-Boot in EL2,
> which is implemented in common code since commit:
> 6c7691edd55 ("armv8: Always unmask SErrors")
> Signed-off-by: Marek Vasut 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH 05/10] arm: imx: imx8m: Only use ROM pointers if not PSCI provider

2023-01-31 Thread sbabic
> The ROM pointers are in fact populated by the ATF BL31 blob, in case
> U-Boot itself if the PSCI provider, there is no ATF BL31 blob, hence
> ignore the ROM pointers.
> Signed-off-by: Marek Vasut 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH 02/10] arm: psci: Fix RESET2 hook

2023-01-31 Thread sbabic
> The RESET2 hook is a PSCI v1.1 functionality, rename the macro accordinly.
> Add missing handler for the RESET2 hook, so it can be implemented by U-Boot.
> Signed-off-by: Marek Vasut 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH 10/10] arm: imx: imx8m: Add basic PSCI provider implementation

2023-01-31 Thread sbabic
> Implement basic PSCI provider to let OS turn CPU cores off and on,
> power off and restart the system and determine PSCI version. This
> is sufficient to remove the need for the ATF BL31 blob altogether.
> To make use of this functionality, active the following Kconfig options:
>   # CONFIG_PSCI_RESET is not set
>   CONFIG_ARMV8_MULTIENTRY=y
>   CONFIG_ARMV8_SET_SMPEN=y
>   CONFIG_ARMV8_SPL_EXCEPTION_VECTORS=y
>   CONFIG_ARMV8_EA_EL3_FIRST=y
>   CONFIG_ARMV8_PSCI=y
>   CONFIG_ARMV8_PSCI_CPUS_PER_CLUSTER=4
>   CONFIG_ARMV8_SECURE_BASE=0x97
>   CONFIG_ARM_SMCCC=y
>   CONFIG_SYS_HAS_ARMV8_SECURE_BASE=y
> Signed-off-by: Marek Vasut 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH v1] board: apalis-imx8: add 2nd ethernet address

2023-01-31 Thread sbabic
> From: Andrejs Cainikovs 
> All Apalis iMX8 variants have 2nd RGMII on SoC, so add the address
> for 2nd ethernet.
> Signed-off-by: Andrejs Cainikovs 
> Signed-off-by: Francesco Dolcini 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH v3] imx6q-sabrelite: Re-add mmc aliases

2023-01-31 Thread sbabic
> In commit d0399a46e7cda63c07e3eb8558bef84cfb068028, the device tree was
> synchronized from linux and the aliases were dropped.
> They need to be kept so that the mmc cards are in the right order.
> Without the aliases, u-boot reports:
> MMC:   FSL_SDHC: 2, FSL_SDHC: 3
> With the aliases, u-boot reports:
> MMC:   FSL_SDHC: 0, FSL_SDHC: 1
> The upstream linux device tree does not contain the same aliases than
> u-boot (It keeps the devices order with /dev/mmcblk2 and /dev/mmcblk3).
> Because this board has been using different aliases in u-boot
> and linux, a imx6q-sabrelite-u-boot.dtsi file is added to be
> automatically included in imx6q-sabrelite.dts.
> This way, linux and u-boot each keep their own aliases and there
> is no breakage on current installations.
> This should never be done for new boards as we want to keep linux and
> u-boot with the same aliases as much as possible.
> This patch is only necessary to avoid breaking existing setups.
> Signed-off-by: Detlev Casanova 
> Reviewed-by: Fabio Estevam 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH 04/10] arm: dts: imx8m: Require ATF BL31 blob only if not PSCI provider

2023-01-31 Thread sbabic
> In case U-Boot itself if the PSCI provider on i.MX8M, do not
> require the ATF BL31 blob, as at that point the blob is useless
> and would interfere with U-Boot operation.
> Signed-off-by: Marek Vasut 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH 07/10] arm: imx: imx8m: Map RAM as NS if PSCI provider

2023-01-31 Thread sbabic
> In case U-Boot is a PSCI provider, map RAM explicitly as NS,
> otherwise secondary cores crash with SError when attempting
> to access RAM mapped as secure in EL2.
> Signed-off-by: Marek Vasut 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH 01/10] arm: psci: Add PSCI v1.1 macro

2023-01-31 Thread sbabic
> Add macro representing the PSCI v1.1 .
> Signed-off-by: Marek Vasut 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

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


[PATCH] include/configs: mx6/mx7: drop dangling comments

2023-01-31 Thread sbabic
> Cleanup some dangling comments left by automated migration
> processes that are no longer value.
> Signed-off-by: Peter Robinson 
> Acked-by: Peng Fan 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=
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: [PATCH 000/171] Kconfig: More cleanup of CONFIG options

2023-01-31 Thread Simon Glass
Hi Tom,

On Mon, 30 Jan 2023 at 08:10, Tom Rini  wrote:
>
> On Mon, Jan 30, 2023 at 07:40:33AM -0700, Simon Glass wrote:
>
> > Quite a few CONFIG options without an SPL equivalent are used as if they
> > have one. For example, we see CONFIG_IS_ENABLED(IOMMU) when there is no
> > SPL_IOMMU Kconfig option.
> >
> > This series adds new features to moveconfig to detect and remove these
> > problems. It includes additions to the Kconfig for options which are
> > needed as well as dropping unwanted us of CONFIG_IS_ENABLED, etc.
> >
> > This follows on from the previous series[1]
> >
> > It is available at u-boot-dm/splb-working
> >
> > [1] https://patchwork.ozlabs.org/project/uboot/list/?series=339004
>
> I'm a little confused at the rush, and duplication right now. As part
> off the CONFIG_IS_ENABLED / IS_ENABLED thread, Troy did a series of
> patches to convert everyone that's using CONFIG_IS_ENABLED to use
> IS_ENABLED, got it through CI and I assumed was trying to figure out how
> to get it posted, next. Further, this series does too many things, and
> needs a bit more thought. All of the CMD_FOO ones are obviously correct,
> but then the majority of the rest of the cases should likely not be
> adding a disabled Kconfig option but instead converted as well as it's
> most likely people are just silencing the checkpatch.pl message and not
> thinking about the ramificationns.

Most of them have been disabled. The patches you refer to at the front
(which add a disabled option) are because I hit build failures just
trying to convert things away from CONFIG_IS_ENABLED(). I may have
made some errors, of course, as there is alot going on.

The rush is that I'd like to do the split config thing, but keep
hitting problems with the Kconfig:

- mention of options which don't existing in Kconfig (spla series)
- use of options in SPL context when there is no SPL_ option (this series splb)

My goal is 'splc', being a small series to split out the configs...but
it requires a pretty high level of consistency. Perhaps I should send
that out so you get the idea where it is heading?

Regards,
Simon


[PATCH 23/32] kconfig: Update CONFIG_IS_ENABLED() for split files

2023-01-31 Thread Simon Glass
Update this file to include the correct autoconf.h or autoconf_spl.h file
for each phase. This allows the macros to be simplified.

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

Signed-off-by: Simon Glass 
---

 include/linux/kconfig.h| 74 +-
 tools/binman/test/generated/autoconf.h |  4 +-
 2 files changed, 28 insertions(+), 50 deletions(-)

diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index 2bc704e1104..f00686eb3e1 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -1,7 +1,17 @@
 #ifndef __LINUX_KCONFIG_H
 #define __LINUX_KCONFIG_H
 
+#ifdef USE_HOSTCC
+#include 
+#elif defined(CONFIG_TPL_BUILD)
+#include 
+#elif defined(CONFIG_VPL_BUILD)
+#include 
+#elif defined(CONFIG_SPL_BUILD)
+#include 
+#else
 #include 
+#endif
 
 /*
  * Helper macros to use CONFIG_ options in C/CPP expressions. Note that
@@ -28,37 +38,9 @@
  */
 #define IS_ENABLED(option) config_enabled(option, 0)
 
-/*
- * U-Boot add-on: Helper macros to reference to different macros (prefixed by
- * CONFIG_, CONFIG_SPL_, CONFIG_TPL_ or CONFIG_TOOLS_), depending on the build
- * context.
- */
+#define __config_val(cfg) CONFIG_ ## cfg
 
-#ifdef USE_HOSTCC
-#define _CONFIG_PREFIX TOOLS_
-#elif defined(CONFIG_TPL_BUILD)
-#define _CONFIG_PREFIX TPL_
-#elif defined(CONFIG_VPL_BUILD)
-#define _CONFIG_PREFIX VPL_
-#elif defined(CONFIG_SPL_BUILD)
-#define _CONFIG_PREFIX SPL_
-#else
-#define _CONFIG_PREFIX
-#endif
-
-#define   config_val(cfg)   _config_val(_CONFIG_PREFIX, cfg)
-#define  _config_val(pfx, cfg) __config_val(pfx, cfg)
-#define __config_val(pfx, cfg) CONFIG_ ## pfx ## cfg
-
-/*
- * CONFIG_VAL(FOO) evaluates to the value of
- *  CONFIG_TOOLS_FOO if USE_HOSTCC is defined,
- *  CONFIG_FOO if CONFIG_SPL_BUILD is undefined,
- *  CONFIG_SPL_FOO if CONFIG_SPL_BUILD is defined.
- *  CONFIG_TPL_FOO if CONFIG_TPL_BUILD is defined.
- *  CONFIG_VPL_FOO if CONFIG_VPL_BUILD is defined.
- */
-#define CONFIG_VAL(option)  config_val(option)
+#define CONFIG_VAL(option)  __config_val(option)
 
 /*
  * This uses a similar mechanism to config_enabled() above. If cfg is enabled,
@@ -104,26 +86,17 @@ long invalid_use_of_IF_ENABLED_INT(void);
__concat(__unwrap, config_enabled(CONFIG_VAL(option), 0)) (case1, case0)
 
 /*
- * CONFIG_IS_ENABLED(FOO) expands to
- *  1 if USE_HOSTCC is defined and CONFIG_TOOLS_FOO is set to 'y',
- *  1 if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y',
- *  1 if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
- *  1 if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y',
- *  0 otherwise.
+ * CONFIG_IS_ENABLED(FOO) returns 1 if CONFIG_FOO is enabled for the phase 
being
+ * built, else 0. Note that CONFIG_FOO corresponds to CONFIG_SPL_FOO (in
+ * Kconfig) for the SPL phase, CONFIG_TPL_FOO for the TPL phase, etc.
  *
- * CONFIG_IS_ENABLED(FOO, (abc)) expands to
- *  abc if USE_HOSTCC is defined and CONFIG_TOOLS_FOO is set to 'y',
- *  abc if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y',
- *  abc if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
- *  abc if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y',
- *  nothing otherwise.
+ * The _nospl version of a CONFIG is emitted by kconfig when an option has no
+ * SPL equivalent. So in that case there is a CONFIG_xxx for example, but not a
+ * CONFIG_SPL_xxx
  *
- * CONFIG_IS_ENABLED(FOO, (abc), (def)) expands to
- *  abc if USE_HOSTCC is defined and CONFIG_TOOLS_FOO is set to 'y',
- *  abc if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y',
- *  abc if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y',
- *  abc if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y',
- *  def otherwise.
+ * This is needed as a transition measure while CONFIG_IS_ENABLED() is used on
+ * options without SPL equivalent, since in that case it should always return
+ * zero. Once we add SPL equivalents, this clause can be dropped.
  *
  * The optional second and third arguments must be parenthesized; that
  * allows one to include a trailing comma, e.g. for use in
@@ -135,7 +108,7 @@ long invalid_use_of_IF_ENABLED_INT(void);
  * set, and nothing otherwise.
  */
 
-#define CONFIG_IS_ENABLED(option, ...) \
+#define CONFIG_IS_ENABLED(option, ...) \
__concat(__CONFIG_IS_ENABLED_, __count_args(option, ##__VA_ARGS__)) 
(option, ##__VA_ARGS__)
 
 #ifndef __ASSEMBLY__
@@ -155,4 +128,7 @@ long invalid_use_of_CONFIG_IF_ENABLED_INT(void);
CONFIG_IS_ENABLED(option, (CONFIG_VAL(int_option)), \
(invalid_use_of_CONFIG_IF_ENABLED_INT()))
 
+#define CONFIG_IF_INT(option, int_option) \
+   CONFIG_IF_ENABLED_INT(option, int_option)
+
 #endif /* __LINUX_KCONFIG_H */
diff --git a/tools/binman/test/generated/autoconf.h 
b/tools/binman/test/generated/autoconf.h
index 6a23039f469..88dc762c423 100644
--- 

[PATCH 32/32] Makefile: Drop SPL_ and SPL_TPL_ macros

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

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

Signed-off-by: Simon Glass 
---

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

[PATCH 30/32] kconfig: Drop CONFIG_VAL()

2023-01-31 Thread Simon Glass
This serves no purpose now since we can write CONFIG_FOO instead of
CONFIG_VAL(FOO)

Drop it.

Signed-off-by: Simon Glass 
---

 arch/arm/lib/bdinfo.c |  4 +-
 arch/arm/mach-at91/arm926ejs/eflash.c |  4 +-
 arch/arm/mach-exynos/clock_init_exynos5.c |  8 ++--
 arch/arm/mach-exynos/exynos5_setup.h  |  6 +--
 arch/arm/mach-k3/am654_init.c |  2 +-
 .../arm/mach-uniphier/debug-uart/debug-uart.c |  4 +-
 arch/mips/cpu/start.S |  6 +--
 arch/mips/mach-mtmips/mt7621/spl/start.S  |  6 +--
 arch/powerpc/cpu/mpc83xx/start.S  |  6 +--
 arch/powerpc/cpu/mpc85xx/start.S  | 40 +--
 arch/sandbox/cpu/start.c  |  2 +-
 arch/sh/lib/start.S   |  4 +-
 arch/x86/cpu/apollolake/cpu_common.c  |  2 +-
 board/eets/pdu001/board.c |  2 +-
 board/freescale/p1010rdb/spl.c| 10 ++---
 board/freescale/p1_p2_rdb_pc/spl.c| 10 ++---
 board/samsung/common/board.c  |  2 +-
 boot/image-fit-sig.c  |  2 +-
 boot/vbe_simple_fw.c  |  2 +-
 common/board_f.c  |  4 +-
 common/board_r.c  |  2 +-
 common/bootstage.c|  2 +-
 common/console.c  | 12 +++---
 common/dlmalloc.c | 14 +++
 common/init/board_init.c  | 12 +++---
 common/malloc_simple.c|  2 +-
 common/spl/spl.c  | 16 
 common/spl/spl_mmc.c  |  2 +-
 drivers/mmc/mmc.c |  2 +-
 drivers/serial/altera_jtag_uart.c |  2 +-
 drivers/serial/altera_uart.c  |  4 +-
 drivers/serial/atmel_usart.c  |  4 +-
 drivers/serial/ns16550.c  |  4 +-
 drivers/serial/serial_ar933x.c|  4 +-
 drivers/serial/serial_arc.c   |  4 +-
 drivers/serial/serial_bcm6345.c   |  4 +-
 drivers/serial/serial_linflexuart.c   |  4 +-
 drivers/serial/serial_meson.c |  2 +-
 drivers/serial/serial_msm_geni.c  |  6 +--
 drivers/serial/serial_mt7620.c|  4 +-
 drivers/serial/serial_mtk.c   |  4 +-
 drivers/serial/serial_mvebu_a3700.c   |  4 +-
 drivers/serial/serial_mxc.c   |  4 +-
 drivers/serial/serial_omap.c  |  4 +-
 drivers/serial/serial_pic32.c |  4 +-
 drivers/serial/serial_pl01x.c |  4 +-
 drivers/serial/serial_s5p.c   |  4 +-
 drivers/serial/serial_sifive.c|  4 +-
 drivers/serial/serial_stm32.c |  4 +-
 drivers/serial/serial_xuartlite.c |  4 +-
 drivers/serial/serial_zynq.c  |  4 +-
 include/asm-generic/global_data.h |  2 +-
 include/dm/device_compat.h|  2 +-
 include/linux/kconfig.h   |  4 --
 include/log.h |  2 +-
 lib/asm-offsets.c |  2 +-
 lib/efi/efi_app.c |  2 +-
 lib/fdtdec.c  |  4 +-
 scripts/basic/fixdep.c|  2 +-
 59 files changed, 146 insertions(+), 150 deletions(-)

diff --git a/arch/arm/lib/bdinfo.c b/arch/arm/lib/bdinfo.c
index e62a13a3b96..06cce862b6b 100644
--- a/arch/arm/lib/bdinfo.c
+++ b/arch/arm/lib/bdinfo.c
@@ -57,8 +57,8 @@ void arch_print_bdinfo(void)
 #ifdef CONFIG_BOARD_TYPES
printf("Board Type  = %ld\n", gd->board_type);
 #endif
-#if CONFIG_VAL(SYS_MALLOC_F_LEN)
+#if CONFIG_SYS_MALLOC_F_LEN
printf("Early malloc usage: %lx / %x\n", gd->malloc_ptr,
-  CONFIG_VAL(SYS_MALLOC_F_LEN));
+  CONFIG_SYS_MALLOC_F_LEN);
 #endif
 }
diff --git a/arch/arm/mach-at91/arm926ejs/eflash.c 
b/arch/arm/mach-at91/arm926ejs/eflash.c
index aade13cc014..dff69f4133d 100644
--- a/arch/arm/mach-at91/arm926ejs/eflash.c
+++ b/arch/arm/mach-at91/arm926ejs/eflash.c
@@ -121,7 +121,7 @@ unsigned long flash_init(void)
if (i%32 == 0)
tmp = readl(>frr);
flash_info[0].protect[i] = (tmp >> (i%32)) & 1;
-#if CONFIG_VAL(EFLASH_PROTSECTORS)
+#if CONFIG_EFLASH_PROTSECTORS
if (i < CONFIG_EFLASH_PROTSECTORS)
flash_info[0].protect[i] = 1;
 #endif
@@ -159,7 +159,7 @@ int flash_real_protect (flash_info_t *info, long sector, 
int prot)
 
debug("protect sector=%ld prot=%d\n", sector, prot);
 
-#if CONFIG_VAL(EFLASH_PROTSECTORS)
+#if CONFIG_EFLASH_PROTSECTORS
if (sector < CONFIG_EFLASH_PROTSECTORS) {
if (!prot) {
printf("eflash: sector %lu cannot be unprotected\n",
diff --git 

[PATCH 21/32] kconfig: Support writing separate SPL files

2023-01-31 Thread Simon Glass
At present kconfig writes out several files, including:

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

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

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

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

The output of existing files is not changed in any way, This commit just
adds new ones.

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

Signed-off-by: Simon Glass 
---

 scripts/kconfig/conf.c |   6 +
 scripts/kconfig/confdata.c | 310 -
 scripts/kconfig/expr.h |  13 +-
 scripts/kconfig/lkc.h  |  10 +-
 4 files changed, 330 insertions(+), 9 deletions(-)

diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 376f796f674..40a3b8a45d0 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -684,6 +684,12 @@ int main(int ac, char **av)
break;
}
 
+   /* U-Boot: Mark symbols according to their SPL/non-SPL nature */
+   if (sync_kconfig) {
+   if (conf_mark_symbols())
+   exit(1);
+   }
+
if (sync_kconfig) {
/* syncconfig is used during the build so we shall update 
autoconf.
 * All other commands are only used to generate a config.
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 73bf43bcb95..cc1f133b0ea 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -16,6 +16,15 @@
 
 #include "lkc.h"
 
+/* Number of SPL prefixes we recognise */
+#define NUM_SPLS4
+
+/*
+ * SPL prefixes recognised. For example CONFIG_SPL_xxx is considered to be an
+ * SPL version of CONFIG_xxx
+ */
+static const char *spl_name[NUM_SPLS] = {"SPL", "TPL", "VPL", "TOOLS"};
+
 /* return true if 'path' exists, false otherwise */
 static bool is_present(const char *path)
 {
@@ -571,11 +580,88 @@ static struct conf_printer kconfig_printer_cb =
.print_comment = kconfig_print_comment,
 };
 
+/**
+ * get_spl_name() - Look up an SPL symbol
+ *
+ * This is used to get the name of a Kconfig option to write in an SPL context.
+ * If the symbol has an SPL symbol, this means it is used for U-Boot proper, so
+ * should not be written at all.
+ *
+ * Otherwise, this returns the name of the option. If the option is an SPL
+ * option, then the prefix (SPL_ or TPL_) is removed
+ *
+ * @sym: Symbol to look up
+ * @arg: Argument passed to the symbol function. This is void * but is actually
+ * an int, indicating the SPL index / type (see spl_name[])
+ * @return name to write out for this symbol xxx:
+ * NULL (don't write) if xxx has an associated SPL symbol
+ * xxx if xxx is a non-SPL symbol
+ * xxx if SPL_xxx is an SPL symbol
+ */
+static const char *get_spl_name(const struct symbol *sym, const void *arg)
+{
+   int spl = (long)arg;
+   const char *name = sym->name;
+
+   /*
+* Don't print it if this has an SPL symbol because processing of the
+* SPL symbol (e.g. SPL_FOO) will output CONFIG_FOO as well as
+* CONFIG_SPL_FOO
+*/
+   if (sym->flags & SYMBOL_HAS_SPL)
+   return NULL;
+
+   /*
+* If it is SPL, only print it if the SPL_ prefix matches
+* Drop the prefix.
+*/
+   if (sym->flags & SYMBOL_SPL) {
+   int len = strlen(spl_name[spl]);
+
+   if (!strncmp(name, spl_name[spl], len) && name[len] == '_')
+   name += len + 1;
+   }
+
+   return name;
+}
+
+/*
+ * auto.conf configuration printer for SPL
+ *
+ * This is used for creating auto.conf as well as SPL files like auto_spl.conf
+ *
+ * This printer is used when generating the resulting configuration after
+ * kconfig invocation and `defconfig' files. Unset symbol might be omitted by
+ * passing a non-NULL argument to the printer.
+ */
+static void spl_kconfig_print_symbol(FILE *fp, struct symbol *sym,
+const char *value, void *arg)
+{
+   const char *name;
+
+   name = get_spl_name(sym, arg);
+   if (!name)
+   return;
+
+   /*
+* If this is an SPL symbol, first print the symbol without the SPL
+* prefix
+*/
+   if (name != sym->name)
+   print_makefile_sym(fp, name, sym->type, value, true);
+   if (!(sym->flags & SYMBOL_NO_SPL))
+   print_makefile_sym(fp, sym->name, sym->type, value, true);
+}
+
+static struct conf_printer spl_kconfig_printer_cb = {
+   .print_symbol = spl_kconfig_print_symbol,
+   .print_comment = 

[PATCH 28/32] kconfig: Drop CONFIG_IS_ENABLED()

2023-01-31 Thread Simon Glass
We can use IS_ENABLED() now, so drop the CONFIG_IS_ENABLED() macro.

Signed-off-by: Simon Glass 
---

 include/linux/kconfig.h | 22 --
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index 77d8e6b6129..50e5a3d7606 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -61,32 +61,26 @@
 #define __unwrap1(case1, case0) __unwrap case1
 #define __unwrap0(case1, case0) __unwrap case0
 
-#define __CONFIG_IS_ENABLED_1(option)__CONFIG_IS_ENABLED_3(option, 
(1), (0))
-#define __CONFIG_IS_ENABLED_2(option, case1) __CONFIG_IS_ENABLED_3(option, 
case1, ())
-#define __CONFIG_IS_ENABLED_3(option, case1, case0) \
+#define __IS_ENABLED_1(option)__IS_ENABLED_3(option, (1), (0))
+#define __IS_ENABLED_2(option, case1) __IS_ENABLED_3(option, case1, ())
+#define __IS_ENABLED_3(option, case1, case0) \
__concat(__unwrap, config_enabled(option, 0)) (case1, case0)
 
 /*
- * CONFIG_IS_ENABLED(CONFIG_FOO) returns 1 if CONFIG_FOO is enabled for the
- * phase being built, else 0.
+ * IS_ENABLED(CONFIG_FOO) returns 1 if CONFIG_FOO is enabled for the phase 
being
+ * built, else 0.
  *
  * The optional second and third arguments must be parenthesized; that
  * allows one to include a trailing comma, e.g. for use in
  *
- * CONFIG_IS_ENABLED(CONFIG_ACME, ({.compatible = "acme,frobnozzle"},))
+ * IS_ENABLED(CONFIG_ACME, ({.compatible = "acme,frobnozzle"},))
  *
  * which adds an entry to the array being defined if CONFIG_ACME is
  * set, and nothing otherwise.
  */
 
-#define CONFIG_IS_ENABLED(option, ...) \
-   __concat(__CONFIG_IS_ENABLED_, __count_args(option, ##__VA_ARGS__)) 
(option, ##__VA_ARGS__)
-
-/*
- * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y',
- * 0 otherwise.
- */
-#define IS_ENABLED(option, ...)  CONFIG_IS_ENABLED(option, ##__VA_ARGS__)
+#define IS_ENABLED(option, ...) \
+   __concat(__IS_ENABLED_, __count_args(option, ##__VA_ARGS__)) (option, 
##__VA_ARGS__)
 
 #ifndef __ASSEMBLY__
 /*
-- 
2.39.1.456.gfc5497dd1b-goog



[PATCH 31/32] kconfig: Move closer to the Linux version

2023-01-31 Thread Simon Glass
This header file originally came from Linux and it has changed a little
upstream since. Bring in some of these changes.

Note that IS_ENABLED() in U-Boot supports a three-parameter version, so it
not equivalent to the Linux version.

Signed-off-by: Simon Glass 
---

 include/linux/kconfig.h | 26 --
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
index 0cd29cea708..162916b2d68 100644
--- a/include/linux/kconfig.h
+++ b/include/linux/kconfig.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 #ifndef __LINUX_KCONFIG_H
 #define __LINUX_KCONFIG_H
 
@@ -13,6 +14,21 @@
 #include 
 #endif
 
+#define __ARG_PLACEHOLDER_1 0,
+#define __take_second_arg(__ignored, val, ...) val
+
+/*
+ * The use of "&&" / "||" is limited in certain expressions.
+ * The following enable to calculate "and" / "or" with macro expansion only.
+ */
+#define __and(x, y)___and(x, y)
+#define ___and(x, y)   and(__ARG_PLACEHOLDER_##x, y)
+#define and(arg1_or_junk, y)   __take_second_arg(arg1_or_junk y, 0)
+
+#define __or(x, y) ___or(x, y)
+#define ___or(x, y)or(__ARG_PLACEHOLDER_##x, y)
+#define or(arg1_or_junk, y)__take_second_arg(arg1_or_junk 
1, y)
+
 /*
  * Helper macros to use CONFIG_ options in C/CPP expressions. Note that
  * these only work with boolean and tristate options.
@@ -26,11 +42,9 @@
  * When CONFIG_BOOGER is not defined, we generate a (... 1, 0) pair, and when
  * the last step cherry picks the 2nd arg, we get a zero.
  */
-#define __ARG_PLACEHOLDER_1 0,
-#define config_enabled(cfg, def_val) _config_enabled(cfg, def_val)
-#define _config_enabled(value, def_val) 
__config_enabled(__ARG_PLACEHOLDER_##value, def_val)
-#define __config_enabled(arg1_or_junk, def_val) ___config_enabled(arg1_or_junk 
1, def_val)
-#define ___config_enabled(__ignored, val, ...) val
+#define __is_defined(cfg, def_val) ___is_defined(cfg, def_val)
+#define ___is_defined(value, def_val) 
is_defined(__ARG_PLACEHOLDER_##value, def_val)
+#define is_defined(arg1_or_junk, def_val) __take_second_arg(arg1_or_junk 
1, def_val)
 
 /*
  * Count number of arguments to a variadic macro. Currently only need
@@ -49,7 +63,7 @@
 #define __IS_ENABLED_1(option)__IS_ENABLED_3(option, (1), (0))
 #define __IS_ENABLED_2(option, case1) __IS_ENABLED_3(option, case1, ())
 #define __IS_ENABLED_3(option, case1, case0) \
-   __concat(__unwrap, config_enabled(option, 0)) (case1, case0)
+   __concat(__unwrap, __is_defined(option, 0)) (case1, case0)
 
 /*
  * IS_ENABLED(CONFIG_FOO) returns 1 if CONFIG_FOO is enabled for the phase 
being
-- 
2.39.1.456.gfc5497dd1b-goog



[PATCH 29/32] kconfig: drop config_opt_enabled()

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

Signed-off-by: Simon Glass 
---

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

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



[PATCH 27/32] kconfig: Drop CONFIG_IF_ENABLED_INT()

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

Signed-off-by: Simon Glass 
---

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

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

[PATCH 26/32] kconfig: Adjust the meaning of CONFIG_IS_ENABLED()

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

   CONFIG_IS_ENABLED(FOO)

you must write:

   CONFIG_IS_ENABLED(CONFIG_FOO)

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

Signed-off-by: Simon Glass 
---

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

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

[PATCH 18/32] test: Add SPL versions of the TEST_KCONFIG options

2023-01-31 Thread Simon Glass
These are needed since we need a separate value in SPL and Proper.

Signed-off-by: Simon Glass 
---

 test/lib/Kconfig | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/test/lib/Kconfig b/test/lib/Kconfig
index dbb03e4a36f..134cbb85b83 100644
--- a/test/lib/Kconfig
+++ b/test/lib/Kconfig
@@ -18,6 +18,24 @@ config TEST_KCONFIG_VALUE
int "Value associated with the option"
depends on TEST_KCONFIG_ENABLE
help
- This is the value whgch is present if TEST_KCONFIG_ENABLE is enabled.
+ This is the value which is present if TEST_KCONFIG_ENABLE is enabled.
+
+config SPL_TEST_KCONFIG
+   bool "Enable detection of Kconfig macro errors (SPL)"
+   help
+ This is used to test that the IF_ENABLED_INT() macro causes a build 
error
+ if the value is used when the CONFIG Is not enabled.
+
+config SPL_TEST_KCONFIG_ENABLE
+   bool "Option to enable (SPL)"
+   help
+ This is the option that controls whether the value is present.
+
+config SPL_TEST_KCONFIG_VALUE
+   int "Value associated with the option (SPL"
+   depends on SPL_TEST_KCONFIG_ENABLE
+   help
+ This is the value which is present if SPL_TEST_KCONFIG_ENABLE is
+ enabled.
 
 endif # SANDBOX
-- 
2.39.1.456.gfc5497dd1b-goog



[PATCH 22/32] Makefile: Include the config for the phase being built

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

Signed-off-by: Simon Glass 
---

 Makefile   | 11 ++-
 scripts/Makefile.build | 12 +++-
 scripts/Makefile.spl   | 10 +-
 3 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 8150ca69e82..be5b2f4fe40 100644
--- a/Makefile
+++ b/Makefile
@@ -587,8 +587,17 @@ scripts: scripts_basic scripts_dtc include/config/auto.conf
$(Q)$(MAKE) $(build)=$(@)
 
 ifeq ($(dot-config),1)
-# Read in config
+
+# Read in the config for this phase
+ifdef CONFIG_TPL_BUILD
+-include include/config/auto_tpl.conf
+else ifdef CONFIG_VPL_BUILD
+-include include/config/auto_vpl.conf
+else ifdef CONFIG_SPL_BUILD
+-include include/config/auto_spl.conf
+else
 -include include/config/auto.conf
+endif
 
 # Read in dependencies to all Kconfig* files, make sure to run
 # oldconfig if changes are detected.
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 97dd4a64f6e..093392b430f 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -44,9 +44,19 @@ ldflags-y  :=
 subdir-asflags-y :=
 subdir-ccflags-y :=
 
-# Read auto.conf if it exists, otherwise ignore
+# Read appropriate auto.conf if it exists, otherwise ignore
 # Modified for U-Boot
+
+ifeq ($(SPL_NAME),tpl)
+-include include/config/auto_tpl.conf
+else ifeq ($(SPL_NAME),vpl)
+-include include/config/auto_vpl.conf
+else ifeq ($(SPL_NAME),spl)
+-include include/config/auto_spl.conf
+else
 -include include/config/auto.conf
+endif
+
 -include $(prefix)/include/autoconf.mk
 
 include scripts/Kbuild.include
diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
index 15ac87286d5..41528f32307 100644
--- a/scripts/Makefile.spl
+++ b/scripts/Makefile.spl
@@ -19,9 +19,17 @@ _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
 
 include $(srctree)/scripts/Kbuild.include
 
--include include/config/auto.conf
 -include $(obj)/include/autoconf.mk
 
+# Read in the config for this SPL phase
+ifdef CONFIG_TPL_BUILD
+-include include/config/auto_tpl.conf
+else ifdef CONFIG_VPL_BUILD
+-include include/config/auto_vpl.conf
+else
+-include include/config/auto_spl.conf
+endif
+
 UBOOTINCLUDE := -I$(obj)/include $(UBOOTINCLUDE)
 
 KBUILD_CPPFLAGS += -DCONFIG_SPL_BUILD
-- 
2.39.1.456.gfc5497dd1b-goog



[PATCH 19/32] kconfig: Add configuration files for noproper and nospl

2023-01-31 Thread Simon Glass
These files indicate which options are not for use in U-Boot proper and
which are not for use in SPL builds. This allows the kconfig tool to
correctly generate its output.

Signed-off-by: Simon Glass 
---

 scripts/conf_noproper | 175 ++
 scripts/conf_nospl|  79 +++
 2 files changed, 254 insertions(+)
 create mode 100644 scripts/conf_noproper
 create mode 100644 scripts/conf_nospl

diff --git a/scripts/conf_noproper b/scripts/conf_noproper
new file mode 100644
index 000..e6066dac41b
--- /dev/null
+++ b/scripts/conf_noproper
@@ -0,0 +1,175 @@
+# These options should not be enabled in Proper builds
+
+ALTERA_SDRAM
+AM33XX_ENABLE_RTC32K_OSC
+ARMV7_SET_CORTEX_SMPEN
+AT91_MCK_BYPASS
+ATF
+ATF_LOAD_IMAGE_V2
+ATF_NO_PLATFORM_PARAM
+BANNER_PRINT
+BINMAN_SYMBOLS
+BINMAN_UBOOT_SYMBOLS
+BOARD_INIT
+BOOTMETH_VBE_SIMPLE_FW
+BOOTROM_SUPPORT
+BSS_MAX_SIZE
+BSS_START_ADDR
+BUILD
+CRYPTO
+DEBUG
+DFU_NO_RESET
+DISPLAY_PRINT
+DRIVERS_MISC
+EARLY_BSS
+ETH_DEVICE
+FALCON_BOOT_MMCSD
+FIT_GENERATOR
+FIT_IMAGE_TINY
+FIT_SOURCE
+FLUSH_IMAGE
+FOO
+FRAMEWORK
+FRAMEWORK_BOARD_INIT_F
+FRED
+FSL_PBL
+FS_LOAD_ARGS_NAME
+FS_LOAD_KERNEL_NAME
+FS_LOAD_PAYLOAD_NAME
+GD_ADDR
+GENERATE_ATMEL_PMECC_HEADER
+IMAGE
+IMAGE_TYPE
+IMX_ROMAPI_LOADADDR
+INIT_MINIMAL
+KERNEL_BOOT
+LDSCRIPT
+LEGACY_BLOCK
+LEGACY_IMAGE_CRC_CHECK
+LIBCOMMON_SUPPORT
+LIBCRYPTO
+LIBDISK_SUPPORT
+LIBGENERIC_SUPPORT
+LOADER_SUPPORT
+LOAD_FIT
+LOAD_FIT_ADDRESS
+LOAD_FIT_APPLY_OVERLAY
+LOAD_FIT_APPLY_OVERLAY_BUF_SZ
+LOAD_FIT_FULL
+LOAD_IMX_CONTAINER
+MALTA
+MAX_FOOTPRINT
+MAX_PEB_SIZE
+MAX_SIZE
+MEMSIZE_IN_BYTES
+MKEFICAPSULE
+MMC_BOOT
+MMC_TINY
+MPC83XX_WAIT_FOR_NAND
+MPC8XXX_INIT_DDR
+MTD_SUPPORT
+MUSB_NEW
+MXS_PSWITCH_WAIT
+NAND_AM33XX_BCH
+NAND_BASE
+NAND_DRIVERS
+NAND_ECC
+NAND_IDENT
+NAND_INIT
+NAND_LOAD
+NAND_RAW_ONLY
+NAND_SIMPLE
+NAND_SOFTECC
+NAND_SUPPORT
+NEEDS_SEPARATE_STACK
+NET_VCI_STRING
+NOR_SUPPORT
+NO_CPU_SUPPORT
+NS16550_MIN_FUNCTIONS
+OF_PLATDATA
+OF_PLATDATA_DRIVER_RT
+OF_PLATDATA_INST
+OF_PLATDATA_NO_BIND
+OF_PLATDATA_PARENT
+OF_PLATDATA_RT
+OMAP3_ID_NAND
+ONENAND_SUPPORT
+OPENSBI
+OPENSBI_LOAD_ADDR
+OPENSBI_SCRATCH_OPTIONS
+OS_BOOT
+PAD_TO
+PANIC_ON_RAW_IMAGE
+PAYLOAD
+PLATDATA
+POST_MEM_SUPPORT
+POWER_TPS65910
+RAM_DEVICE
+RAM_SUPPORT
+RAW_IMAGE_SUPPORT
+READ_ONLY
+RECOVER_DATA_SECTION
+RELOC_MALLOC_ADDR
+RELOC_MALLOC_SIZE
+RELOC_STACK
+RELOC_TEXT_BASE
+ROCKCHIP_BACK_TO_BROM
+ROCKCHIP_EARLYRETURN_TO_BROM
+RTC
+RTC_DDR_SUPPORT
+SATA_RAW_U_BOOT_SECTOR
+SATA_RAW_U_BOOT_USE_SECTOR
+SDP_USB_DEV
+SEPARATE_BSS
+SHOW_ERRORS
+SIZE_LIMIT
+SIZE_LIMIT_PROVIDE_STACK
+SIZE_LIMIT_SUBTRACT_GD
+SIZE_LIMIT_SUBTRACT_MALLOC
+SKIP_RELOCATE
+SPI_FLASH_SUPPORT
+SPI_FLASH_TINY
+SPI_LOAD
+STACK
+STACK_R
+STACK_R_ADDR
+STACK_R_MALLOC_SIMPLE_LEN
+SYS_CCSR_DO_NOT_RELOCATE
+SYS_MALLOC_SIMPLE
+SYS_NO_VECTOR_TABLE
+SYS_REPORT_STACK_F_USAGE
+TARGET
+THERMAL
+TINY_MEMSET
+UART2_SPIS_PINMUX
+UART_CLOCK
+UBI
+UBI_INFO_ADDR
+UBI_LEB_START
+UBI_LOAD_ARGS_ID
+UBI_LOAD_BY_VOLNAME
+UBI_LOAD_KERNEL_ID
+UBI_LOAD_MONITOR_ID
+UBI_LOAD_MONITOR_VOLNAME
+UBI_MAX_PEBS
+UBI_MAX_PEB_SIZE
+UBI_MAX_VOL_LEBS
+UBI_PEB_OFFSET
+UBI_VID_OFFSET
+UBI_VOL_IDS
+UBI_VOL_ID_MAX
+UBOOT_KEY_HASH
+USB_HOST_SUPPORT
+USB_SDP_SUPPORT
+USE_TINY_PRINTF
+X86_TSC_TIMER_NATIVE
+XIP_SUPPORT
+YMODEM_SUPPORT
+ZYNQMP_ALT_BOOTMODE
+ZYNQMP_ALT_BOOTMODE_ENABLED
+ZYNQMP_DRAM_BANK1_BASE
+ZYNQMP_DRAM_BANK1_LEN
+ZYNQMP_DRAM_BANK2_BASE
+ZYNQMP_DRAM_BANK2_LEN
+ZYNQMP_DRAM_ECC_INIT
+ZYNQMP_RESTORE_JTAG
diff --git a/scripts/conf_nospl b/scripts/conf_nospl
new file mode 100644
index 000..88b38c636ec
--- /dev/null
+++ b/scripts/conf_nospl
@@ -0,0 +1,79 @@
+# These options should not be enabled in SPL builds
+
+ACPI_PMC_SANDBOX
+BINMAN_FDT
+CLK_INTEL
+CMD_MMC_RPMB
+CMD_MMC_SWRITE
+DFU_MMC
+DFU_MTD
+DFU_NAND
+DFU_SF
+DFU_SF_PART
+DFU_WRITE_ALT
+DMA_LEGACY
+DM_DMA
+DM_EVENT
+DM_REGULATOR_ANATOP
+DM_REGULATOR_PBIAS
+DM_REGULATOR_STM32_VREFBUF
+DM_STDIO
+DWC_AHSATA_AHCI
+EFI_DT_FIXUP
+EFI_EBBR_2_1_CONFORMANCE
+EFI_SCROLL_ON_CLEAR_SCREEN
+ENV_APPEND
+EVENT_DEBUG
+EXYNOS7870
+EXYNOS7880
+FASTBOOT_UUU_SUPPORT
+FRED
+FRU_SC
+INTEL_GENERIC_WIFI
+LOG_SYSLOG
+LS2_SFP
+MALTA
+MEMSIZE_IN_BYTES
+MIPS_BOOT_CMDLINE_LEGACY
+MIPS_BOOT_ENV_LEGACY
+MIPS_BOOT_FDT
+MMC_HW_PARTITIONING
+MMC_VERBOSE
+MSCODE_PARSER
+MUX_MMIO
+NAND_CS_INIT
+NO_FB_CLEAR
+OFNODE_MULTI_TREE
+PCF8575_GPIO
+PHY_J721E_WIZ
+PKCS7_MESSAGE_PARSER
+PKCS7_VERIFY
+PLATDATA
+PRE_CONSOLE_BUFFER
+REGULATOR_RK8XX
+RESTORE_EXCEPTION_VECTOR_BASE
+ROCKCHIP_RK8XX_DISABLE_BOOT_ON_POWERON
+SERIAL_PUTS
+SERIAL_RX_BUFFER
+SHA512_HW_ACCEL
+SILENT_CONSOLE_UPDATE_ON_RELOC
+SILENT_CONSOLE_UPDATE_ON_SET
+SIMPLE_BUS_CORRECT_RANGE
+SMC911X_32_BIT
+SPI_DIRMAP
+SPI_NOR_BOOT_SOFT_RESET_EXT_INVERT
+SPL_X86_32BIT_INIT
+STM32_ETZPC
+SYSRESET_AT91
+SYSRESET_X86
+SYS_DEVICE_NULLDEV
+SYS_WHITE_ON_BLACK
+TARGET_DENEB
+TARGET_EVB_RK3399
+TARGET_GIEDI
+TARGET_ST_STM32MP15X
+TURRIS_OMNIA_MCU
+USB_GADGET_OS_DESCRIPTORS
+X509_CERTIFICATE_PARSER

[PATCH 17/32] fixdep: Add some tests for parse_config_line()

2023-01-31 Thread Simon Glass
Add tests for this code to cover the basic cases.

Signed-off-by: Simon Glass 
---

 scripts/basic/fixdep.c | 73 ++
 1 file changed, 73 insertions(+)

diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index a49d35ba5f6..fe8180ab4e7 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -425,11 +425,84 @@ static void parse_dep_file(char *m, const char *target)
xprintf("$(deps_%s):\n", target);
 }
 
+#define CHECKP(expect, got)\
+   if (expect != got) { \
+   fprintf(stderr, "Test failed at line %d: expect %ld, got 
%ld\n", \
+   __LINE__, expect - buf, got - buf); \
+   return 1; \
+   }
+
+#define CHECK(expect, got) \
+   if (expect != got) { \
+   fprintf(stderr, "Test failed at line %d: expect %p, got %p\n", \
+   __LINE__, expect, got); \
+   return 1; \
+   }
+
+static int run_tests(void)
+{
+   const char *out, *end;
+   char buf_s[40], *buf = buf_s + 1;
+
+   /* make sure the previous char doesn't look like part of the CONFIG */
+   buf_s[0] = ' ';
+
+   strcpy(buf, "");
+   out = parse_config_line(buf, );
+   CHECK(NULL, out);
+   CHECK(NULL, end);
+
+   strcpy(buf, "nothing");
+   out = parse_config_line(buf, );
+   CHECK(NULL, out);
+   CHECK(NULL, end);
+
+   strcpy(buf, "CONFIG_OPTION_MORE");
+   out = parse_config_line(buf, );
+   CHECKP(buf + 7, out);
+   CHECKP(buf + 18, end);
+
+   strcpy(buf, "some CONFIG_OPTION_MORE");
+   out = parse_config_line(buf, );
+   CHECKP(buf + 12, out);
+   CHECKP(buf + 23, end);
+
+   strcpy(buf, "some CONFIG_OPTION_MORE here");
+   out = parse_config_line(buf, );
+   CHECKP(buf + 12, out);
+   CHECKP(buf + 23, end);
+
+   strcpy(buf, "CONFIG_OPTION_MODULE");
+   out = parse_config_line(buf, );
+   CHECKP(buf + 7, out);
+   CHECKP(buf + 13, end);
+
+   strcpy(buf, "CONFIG_IS_ENABLED(FRED)");
+   out = parse_config_line(buf, );
+   CHECKP(buf + 18, out);
+   CHECKP(buf + 22, end);
+
+   strcpy(buf, "CONFIG_VAL(MARY)");
+   out = parse_config_line(buf, );
+   CHECKP(buf + 11, out);
+   CHECKP(buf + 15, end);
+
+   return 0;
+}
+
 int main(int argc, char *argv[])
 {
const char *depfile, *target, *cmdline;
void *buf;
 
+   if (argc == 2 && !strcmp("-t", argv[1])) {
+   if (run_tests()) {
+   fprintf(stderr, "Tests failed\n");
+   return 1;
+   }
+   printf("Tests passed\n");
+   return 0;
+   }
if (argc != 4)
usage();
 
-- 
2.39.1.456.gfc5497dd1b-goog



[PATCH 20/32] kconfig: Refactor code into separate writer functions

2023-01-31 Thread Simon Glass
Separate out the code that writes the Makefile and headers so we can
reuse these functions when writing out SPL files.

This makes no functional change.

Signed-off-by: Simon Glass 
---

 scripts/kconfig/confdata.c | 65 ++
 scripts/kconfig/expr.h |  9 ++
 scripts/kconfig/lkc.h  |  9 ++
 3 files changed, 56 insertions(+), 27 deletions(-)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index d587b10d7f8..73bf43bcb95 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -509,27 +509,18 @@ int conf_read(const char *name)
return 0;
 }
 
-/*
- * Kconfig configuration printer
- *
- * This printer is used when generating the resulting configuration after
- * kconfig invocation and `defconfig' files. Unset symbol might be omitted by
- * passing a non-NULL argument to the printer.
- *
- */
-static void
-kconfig_print_symbol(FILE *fp, struct symbol *sym, const char *value, void 
*arg)
+/* Print a symbol for a Makefile */
+static void print_makefile_sym(FILE *fp, const char *name,
+  enum symbol_type type, const char *value,
+  bool skip_unset)
 {
-
-   switch (sym->type) {
+   switch (type) {
case S_BOOLEAN:
case S_TRISTATE:
if (*value == 'n') {
-   bool skip_unset = (arg != NULL);
-
if (!skip_unset)
fprintf(fp, "# %s%s is not set\n",
-   CONFIG_, sym->name);
+   CONFIG_, name);
return;
}
break;
@@ -537,7 +528,21 @@ kconfig_print_symbol(FILE *fp, struct symbol *sym, const 
char *value, void *arg)
break;
}
 
-   fprintf(fp, "%s%s=%s\n", CONFIG_, sym->name, value);
+   fprintf(fp, "%s%s=%s\n", CONFIG_, name, value);
+}
+
+/*
+ * Kconfig configuration printer
+ *
+ * This printer is used when generating the resulting configuration after
+ * kconfig invocation and `defconfig' files. Unset symbol might be omitted by
+ * passing a non-NULL argument to the printer.
+ *
+ */
+static void
+kconfig_print_symbol(FILE *fp, struct symbol *sym, const char *value, void 
*arg)
+{
+   print_makefile_sym(fp, sym->name, sym->type, value, arg != NULL);
 }
 
 static void
@@ -566,16 +571,12 @@ static struct conf_printer kconfig_printer_cb =
.print_comment = kconfig_print_comment,
 };
 
-/*
- * Header printer
- *
- * This printer is used when generating the `include/generated/autoconf.h' 
file.
- */
-static void
-header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
+/* Print a symbol for a header file */
+static void print_header_sym(FILE *fp, const char *name, enum symbol_type type,
+const char *value)
 {
 
-   switch (sym->type) {
+   switch (type) {
case S_BOOLEAN:
case S_TRISTATE: {
const char *suffix = "";
@@ -588,7 +589,7 @@ header_print_symbol(FILE *fp, struct symbol *sym, const 
char *value, void *arg)
/* fall through */
default:
fprintf(fp, "#define %s%s%s 1\n",
-   CONFIG_, sym->name, suffix);
+   CONFIG_, name, suffix);
}
break;
}
@@ -598,18 +599,28 @@ header_print_symbol(FILE *fp, struct symbol *sym, const 
char *value, void *arg)
if (value[0] != '0' || (value[1] != 'x' && value[1] != 'X'))
prefix = "0x";
fprintf(fp, "#define %s%s %s%s\n",
-   CONFIG_, sym->name, prefix, value);
+   CONFIG_, name, prefix, value);
break;
}
case S_STRING:
case S_INT:
fprintf(fp, "#define %s%s %s\n",
-   CONFIG_, sym->name, value);
+   CONFIG_, name, value);
break;
default:
break;
}
+}
 
+/*
+ * Header printer
+ *
+ * This printer is used when generating the `include/generated/autoconf.h' 
file.
+ */
+static void
+header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
+{
+   print_header_sym(fp, sym->name, sym->type, value);
 }
 
 static void
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index 7c329e17900..656c87fb4f3 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -158,6 +158,15 @@ struct symbol {
 /* Set symbol to y if allnoconfig; used for symbols that hide others */
 #define SYMBOL_ALLNOCONFIG_Y 0x20
 
+/* U-Boot: Marks an SPL symbol */
+#define SYMBOL_SPL 0x40
+
+/* U-Boot: Marks a non-SPL symbol that also has an SPL version */
+#define SYMBOL_HAS_SPL 0x80
+
+/* U-Boot: Marks an-SPL symbol that does not have a non-SPL version */
+#define 

[PATCH 24/32] Makefile: Use empty SPL_ and SPL_TPL_ vars

2023-01-31 Thread Simon Glass
Now that we include an auto.conf file specific to the phase being built
we can make these variables empty.

With this done, we can also remove them from U-Boot entirely, dropping
them from all Makefiles. That is left for a future clean-up since we
cannot apply this series until CONFIG migration is complete.

Signed-off-by: Simon Glass 
---

 scripts/Kbuild.include | 15 ++-
 scripts/Makefile.spl   | 19 +++
 2 files changed, 5 insertions(+), 29 deletions(-)

diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 62e0207f91b..b7668694101 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -320,18 +320,7 @@ endif
 # do not delete intermediate files automatically
 .SECONDARY:
 
-ifdef CONFIG_SPL_BUILD
-SPL_ := SPL_
-ifeq ($(CONFIG_VPL_BUILD),y)
-SPL_TPL_ := VPL_
-else
-ifeq ($(CONFIG_TPL_BUILD),y)
-SPL_TPL_ := TPL_
-else
-SPL_TPL_ := SPL_
-endif
-endif
-else
+# The SPL_ and SPL_TPL_ vars resolve to nothing so they can be used in
+# Makefiles
 SPL_ :=
 SPL_TPL_ :=
-endif
diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
index 41528f32307..3009a8b0d4b 100644
--- a/scripts/Makefile.spl
+++ b/scripts/Makefile.spl
@@ -35,11 +35,9 @@ UBOOTINCLUDE := -I$(obj)/include $(UBOOTINCLUDE)
 KBUILD_CPPFLAGS += -DCONFIG_SPL_BUILD
 ifeq ($(CONFIG_TPL_BUILD),y)
 KBUILD_CPPFLAGS += -DCONFIG_TPL_BUILD
-else
-ifeq ($(CONFIG_VPL_BUILD),y)
+else ifeq ($(CONFIG_VPL_BUILD),y)
 KBUILD_CPPFLAGS += -DCONFIG_VPL_BUILD
 endif
-endif
 
 ifeq ($(CONFIG_VPL_BUILD),y)
 SPL_BIN := u-boot-vpl
@@ -56,21 +54,10 @@ endif
 
 export SPL_NAME
 
-ifdef CONFIG_SPL_BUILD
-SPL_ := SPL_
-ifeq ($(CONFIG_VPL_BUILD),y)
-SPL_TPL_ := VPL_
-else
-ifeq ($(CONFIG_TPL_BUILD),y)
-SPL_TPL_ := TPL_
-else
-SPL_TPL_ := SPL_
-endif
-endif
-else
+# The SPL_ and SPL_TPL_ vars resolve to nothing so they can be used in
+# Makefiles
 SPL_ :=
 SPL_TPL_ :=
-endif
 
 ifeq ($(obj)$(CONFIG_SUPPORT_SPL),spl)
 $(error You cannot build SPL without enabling CONFIG_SUPPORT_SPL)
-- 
2.39.1.456.gfc5497dd1b-goog



  1   2   3   >