Re: [PATCH] travis-ci: Add m68k M5208EVBE machine

2023-04-01 Thread Angelo Dureghello

Hi Marek,

On 26/03/23 4:33 PM, Tom Rini wrote:


On Mon, 20 Mar 2023 20:46:47 +0100, Marek Vasut wrote:

Add m68k M5208EVBE machine configured to test U-Boot m68k support.




Applied, thanks!

[1/1] travis-ci: Add m68k M5208EVBE machine
   commit: 3f604a1b68a07e6c20f617c38fc849eb796f9af0

Best regards,


i rebased and tested the build, i see still a python error,

https://source.denx.de/u-boot/custodians/u-boot-coldfire/-/pipelines/15856

I applied

93acc7282341a294c28f50086ca1fb3d4cd66a90
travis-ci: Add m68k M5208EVBE machine

77e22d25af74c3be461b27d35805072ead63c178
CI: Add m68k target

31368868227702ad7176e4729a837e4a2183b739
arch: m68k: Add QEMU specific RAMBAR workaround

f087d8873614e5bfa1093d5e3a1b6d4cf85623d1
arch: m68k: Introduce trivial PIT based timer

d7ef34a0e1c500d4db2331fefaea688b1946a351
arch: m68k: Use existing CONFIG_MCFTMR instead of CFG_MCFTMR


Regards,
angelo


Re: [PATCH] Revert 9f62a472dfb2 ("video: Remove duplicate cursor-positioning function")

2023-04-01 Thread Simon Glass
Hi Tom,

On Thu, 16 Mar 2023 at 05:01, Tom Rini  wrote:
>
> This reverts commit 9f62a472dfb26ec14408a27938ddd2a2579d.
>
> The changes here aren't quite right, and on platforms such as Raspberry
> Pi where we can have both serial and video output, the change above
> causes output to change. This can be seen as the hush tests we have now
> fail.

I took at look at sorting this out. I gave it a crack with:

CROSS_COMPILE=/home/sglass/.buildman-toolchains/gcc-7.3.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-
./test/py/test.py --bd rpi_3_32b --build-dir /tmp/b/rpi3  --build --id
sjg-rpi_3b -k hush
 67 passed, 1 skipped, 322 deselected in 13.02s 

Do you know which rpi and which test?

Regards,
Simon
[..]


[PATCH 1/1] cmd: missing break in test_write_limit()

2023-04-01 Thread Heinrich Schuchardt
In test_write_limit() an unintended fall-through occurs.

Suggested-by: Simon Glass 
Signed-off-by: Heinrich Schuchardt 
---
 cmd/tpm_test.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/cmd/tpm_test.c b/cmd/tpm_test.c
index b35eae81dc..c4ed8e5901 100644
--- a/cmd/tpm_test.c
+++ b/cmd/tpm_test.c
@@ -471,6 +471,7 @@ static int test_write_limit(struct udevice *dev)
break;
case TPM_MAXNVWRITES:
assert(i >= TPM_MAX_NV_WRITES_NOOWNER);
+   break;
default:
pr_err("\tunexpected error code %d (0x%x)\n",
  result, result);
-- 
2.39.2



[PATCH v2 1/1] MAINTAINERS: assign include/tpm*, cmd/tpm*

2023-04-01 Thread Heinrich Schuchardt
The files include/tpm* are an integral part of the TPM drivers.
The tpm* commands are used to access TPM devices.

Both should be managed by the TPM DRIVERS maintainer.

Signed-off-by: Heinrich Schuchardt 
---
v2:
cmd/tpm.c -> cmd/tpm*
---
 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index d2e245e5e9..69e64ea342 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1478,7 +1478,9 @@ TPM DRIVERS
 M: Ilias Apalodimas 
 S: Maintained
 T: git https://source.denx.de/u-boot/custodians/u-boot-tpm.git
+F: cmd/tpm*
 F: drivers/tpm/
+F: include/tpm*
 
 TQ GROUP
 #M:Martin Krause 
-- 
2.39.2



[PATCH 1/1] MAINTAINERS: assign include/tpm*, cmd/tpm.c

2023-04-01 Thread Heinrich Schuchardt
The files include/tpm* are an integral part of the TPM drivers.
The tpm command is used to access TPM devices.

Both should be managed by the TPM DRIVERS maintainer.

Signed-off-by: Heinrich Schuchardt 
---
 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index d2e245e5e9..4961277e4f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1478,7 +1478,9 @@ TPM DRIVERS
 M: Ilias Apalodimas 
 S: Maintained
 T: git https://source.denx.de/u-boot/custodians/u-boot-tpm.git
+F: cmd/tpm.c
 F: drivers/tpm/
+F: include/tpm*
 
 TQ GROUP
 #M:Martin Krause 
-- 
2.39.2



Re: RISC-V FIT image type

2023-04-01 Thread Bin Meng
Hi Simon,

On Sat, Apr 1, 2023 at 2:31 PM Simon Glass  wrote:
>
> Hi Bin,
>
> On Fri, 31 Mar 2023 at 19:22, Bin Meng  wrote:
> >
> > On Fri, Mar 31, 2023 at 5:36 AM Simon Glass  wrote:
> > >
> > > Hi,
> > >
> > > I notice that in image.h we have IH_ARCH_RISCV but no mention of
> > > IH_ARCH_RISCV64. Should we not have two separate image types, as we do
> > > with ARM and x86? Otherwise, how would a loader know the word size of
> > > the target machine?
> >
> > I think that's because in RISC-V it is always the same bit-width
> > U-Boot to load the same bit-width kernel. There is no support of
> > 32-bit U-Boot to load 64-bit kernel and vice versa.
>
> Yes, understood, but in this case we can't be sure that it is possible
> load a FIT, e.g. if someone makes a mistake.
>
> Would it be OK to create a new "riscv64" type? This has come up in the
> universal payload discussions.
>

I think so. But I will leave this to the RISC-V maintainers to make a call.

Regards,
Bin


Re: [PATCH v6 09/11] xilinx: Disable CONFIG_BOOTSTD_DEFAULTS for some xilinx boards

2023-04-01 Thread Simon Glass
Hi Mark,

On Sun, 2 Apr 2023 at 10:31, Mark Kettenis  wrote:
>
> > From: Simon Glass 
> > Date: Sun,  2 Apr 2023 09:45:33 +1200
> >
> > Since CONFIG_BOOTSTD_DEFAULTS now selects ENV_VARS_UBOOT_CONFIG we
cannot
> > enable it for some Xilinx boards which have a very small environment.
> >
> > Disable it.
>
> Does that mean these configs lose distroboot support?  That would be a
> shame!

We use 'select' to enable things, so we don't have the ability to enable
just some of the defaults. So unfortunately this board needs to have
BOOTSTD_DEFAULTS disabled.

It certainly doesn't have anywhere near enough env space for distroboot,
although I'm not sure why it is so limited.

Regards,
Simon


Re: [PATCH v2 1/1] RFC: Move Odroid-C2 to use binman to produce the image

2023-04-01 Thread Simon Glass
Hi Steev,

On Sun, 2 Apr 2023 at 08:53, Steev Klimaszewski  wrote:
>
> Hi Simon,
>
> On Sat, Apr 1, 2023 at 1:55 PM Simon Glass  wrote:
> >
> > This shows how binman can be used to replace the long and complicated
> > instructions with an automated build. It is still complicated to read
> > but users don't have to worry about the details.
> >
> > It needs some tidying up and only supports Odroid-C2 at present.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > Changes in v2:
> > - Rebase to -next
> >
> >  arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi | 107 
> >  arch/arm/mach-meson/Kconfig  |   1 +
> >  doc/board/amlogic/odroid-c4.rst  | 127 +--
> >  tools/binman/etype/aml_encrypt.py| 124 ++
> >  tools/binman/ftest.py|   3 +
> >  tools/binman/missing-blob-help   |   6 +
> >  tools/binman/test/213_aml_encrypt.dts|  38 ++
> >  tools/binman/test/214_list_no_dtb.dts|  23 
> >  8 files changed, 337 insertions(+), 92 deletions(-)
> >  create mode 100644 tools/binman/etype/aml_encrypt.py
> >  create mode 100644 tools/binman/test/213_aml_encrypt.dts
> >  create mode 100644 tools/binman/test/214_list_no_dtb.dts
> >
> This says C2 and only supports C2, but you're modifying th C4
> documentation?  I'm just a random distro maintainer with interest in
> this and want to be clear is all.

Yes. The difference seems to be an Amlogic S905 on the C2 and an S902X3 on
the C4. I wonder if that affects the image makeup?

The patch is for testing by Christian, who I hope can help get this landed
for all the Amlogic boards.

Regards,
Simon


Re: [PATCH v2 0/1] meson: Demonstration of using binman to produce the image

2023-04-01 Thread Simon Glass
Hi Mark,

On Sun, 2 Apr 2023 at 09:28, Mark Kettenis  wrote:
>
> > From: Simon Glass 
> > Date: Sun,  2 Apr 2023 06:54:57 +1200
> >
> > The Odroid-C2 is quite a complicated image with many steps. It is an
ideal
> > example for how Binman can be used.
>
> You say Odroid-C2, but the patches seem to address the Odroid-C4...

Ah, yes. The difference seems to be an Amlogic S905 on the C2 and an S902X3
on the C4. I wonder if that affects the image makeup?

The patch is for testing by Christian, who I hope can help get this landed
for all the Amlogic boards.

>
> > Add a binman description and update the instructions accordingly.
> >
> > Changes in v2:
> > - Rebase to -next
> >
> > Simon Glass (1):
> >   RFC: Move Odroid-C2 to use binman to produce the image
> >
> >  arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi | 107 
> >  arch/arm/mach-meson/Kconfig  |   1 +
> >  doc/board/amlogic/odroid-c4.rst  | 127 +--
> >  tools/binman/etype/aml_encrypt.py| 124 ++
> >  tools/binman/ftest.py|   3 +
> >  tools/binman/missing-blob-help   |   6 +
> >  tools/binman/test/213_aml_encrypt.dts|  38 ++
> >  tools/binman/test/214_list_no_dtb.dts|  23 
> >  8 files changed, 337 insertions(+), 92 deletions(-)
> >  create mode 100644 tools/binman/etype/aml_encrypt.py
> >  create mode 100644 tools/binman/test/213_aml_encrypt.dts
> >  create mode 100644 tools/binman/test/214_list_no_dtb.dts
> >

Regards,
SImon


Re: [PATCH v10 10/10] arm_ffa: efi: corstone1000: enable MM communication

2023-04-01 Thread Simon Glass
Hi Abdellatif,

On Wed, 29 Mar 2023 at 05:12, Abdellatif El Khlifi <
abdellatif.elkhl...@arm.com> wrote:
>
> turn on EFI MM communication
>
> On corstone1000 platform MM communication between u-boot
> and the secure world (Optee) is done using the FF-A bus.
>
> Signed-off-by: Abdellatif El Khlifi 
> Cc: Tom Rini 
> Cc: Simon Glass 
> Cc: Ilias Apalodimas 
> Cc: Jens Wiklander 
>
> ---
> Changelog:
> ===
>
> v9: update copyright string
>
> v8:
>
> * drop OP-TEE configs from Corstone-1000 defconfig
>
> v7:
>
> * improve the definition of FFA_SHARED_MM_BUFFER_ADDR and
>   FFA_SHARED_MM_BUFFER_OFFSET
> * update FFA_SHARED_MM_BUFFER_ADDR value
>
> v6:
>
> * corstone-1000: enable optee driver
> * corstone-1000: remove CONFIG_ARM_FFA_EFI_RUNTIME_MODE from the defconfig
>
> v4:
>
> * corstone-1000: turn on EFI MM communication
>
>  configs/corstone1000_defconfig |  2 ++
>  include/configs/corstone1000.h | 15 +--
>  2 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/configs/corstone1000_defconfig
b/configs/corstone1000_defconfig
> index 74250c7524..a7bfcbb2b9 100644
> --- a/configs/corstone1000_defconfig
> +++ b/configs/corstone1000_defconfig
> @@ -52,3 +52,5 @@ CONFIG_DM_SERIAL=y
>  CONFIG_USB=y
>  CONFIG_USB_ISP1760=y
>  CONFIG_ERRNO_STR=y
> +CONFIG_EFI_MM_COMM_TEE=y
> +CONFIG_ARM_FFA_TRANSPORT=y
> diff --git a/include/configs/corstone1000.h
b/include/configs/corstone1000.h
> index 3347c11792..4ef1f05e40 100644
> --- a/include/configs/corstone1000.h
> +++ b/include/configs/corstone1000.h
> @@ -1,9 +1,11 @@
>  /* SPDX-License-Identifier: GPL-2.0+ */
>  /*
> - * (C) Copyright 2022 ARM Limited
>   * (C) Copyright 2022 Linaro
>   * Rui Miguel Silva 
> - * Abdellatif El Khlifi 
> + * Copyright 2022-2023 Arm Limited and/or its affiliates <
open-source-off...@arm.com>
> + *
> + * Authors:
> + *   Abdellatif El Khlifi 
>   *
>   * Configuration for Corstone1000. Parts were derived from other ARM
>   * configurations.
> @@ -14,6 +16,15 @@
>
>  #include 
>
> +#define FFA_SHARED_MM_BUFFER_SIZE  SZ_4K /* 4 KB */
> +
> +/*
> + * shared buffer physical address used for communication between
> + * u-boot and the MM SP
> + */
> +#define FFA_SHARED_MM_BUFFER_ADDR  0x0200UL
> +#define FFA_SHARED_MM_BUFFER_OFFSET0
> +
>  #define V2M_BASE   0x8000
>
>  #define CFG_PL011_CLOCK5000
> --
> 2.25.1
>

As a higher-level question, could this whole FFA implementation code be put
into Linux or fwupd?

Regards,
Simon


Re: [PATCH v10 04/10] arm_ffa: introduce Arm FF-A support

2023-04-01 Thread Simon Glass
Hi Abdellatif,

On Wed, 29 Mar 2023 at 05:12, Abdellatif El Khlifi <
abdellatif.elkhl...@arm.com> wrote:
>
> Add Arm FF-A support implementing Arm Firmware Framework for Armv8-A v1.0
>
> The Firmware Framework for Arm A-profile processors (FF-A v1.0) [1]
> describes interfaces (ABIs) that standardize communication
> between the Secure World and Normal World leveraging TrustZone
> technology.
>
> This driver uses 64-bit registers as per SMCCCv1.2 spec and comes
> on top of the SMCCC layer. The driver provides the FF-A ABIs needed for
> querying the FF-A framework from the secure world.
>
> The driver uses SMC32 calling convention which means using the first
> 32-bit data of the Xn registers.
>
> All supported ABIs come with their 32-bit version except FFA_RXTX_MAP
> which has 64-bit version supported.
>
> Both 32-bit and 64-bit direct messaging are supported which allows both
> 32-bit and 64-bit clients to use the FF-A bus.
>
> FF-A is a discoverable bus and similar to architecture features.
> FF-A bus is discovered using ARM_SMCCC_FEATURES mechanism performed
> by the PSCI driver.
>
> Clients are able to probe then use the FF-A bus by calling the DM class
> searching APIs (e.g: uclass_first_device).
>
> The Secure World is considered as one entity to communicate with
> using the FF-A bus. FF-A communication is handled by one device and
> one instance (the bus). This FF-A driver takes care of all the
> interactions between Normal world and Secure World.
>
> The driver exports its operations to be used by upper layers.
>
> Exported operations:
>
> - ffa_partition_info_get
> - ffa_sync_send_receive
> - ffa_rxtx_unmap
>
> Generic FF-A methods are implemented in the Uclass (arm-ffa-uclass.c).
> Arm specific methods are implemented in the Arm driver (arm-ffa.c).
>
> For more details please refer to the driver documentation [2].
>
> [1]: https://developer.arm.com/documentation/den0077/latest/
> [2]: doc/arch/arm64.ffa.rst
>
> Signed-off-by: Abdellatif El Khlifi 
> Cc: Tom Rini 
> Cc: Simon Glass 
> Cc: Ilias Apalodimas 
> Cc: Jens Wiklander 
> Cc: Heinrich Schuchardt 
>
> ---
> Changelog:
> ===
>
> v10:
>
> * provide the driver operations through the Uclass
> * move the generic FF-A methods to the Uclass
> * keep Arm specific methods in the Arm driver (arm-ffa.c)
> * rename core.c to arm-ffa.c
> * address nits

The functions at the bottom like ffa_do_remove() should be changed to
uclass methods.

E.g.

.pre_remove = ffa_do_remove,
.pre_probe = ffa_do_probe
.post_bind = ffa_do_unbind

You can make them static and they don't need to called from elsewhere. It
is automatic.

- no need to check for !dev since this is the caller's responsibiliy
- no need to check for !priv since this cannot happen

It looks like you are using 'priv' as per-device uclass data. So instead,
please add something like:

per_device_auto = sizeof(struct ffa_priv)

in your uclass driver, then use dev_get_uclass_priv() instead of
dev_get_priv().

You should use the var name uc_priv instead of priv, so it is clear that
this relates to the uclass (i.e. is common across all devices in that
uclass)

You should almost never need to set the priv data, since driver model
handles this.

Regards,
Simon


Re: [PATCH v10 06/10] arm_ffa: introduce sandbox FF-A support

2023-04-01 Thread Simon Glass
Hi Abdellatif,

On Wed, 29 Mar 2023 at 05:12, Abdellatif El Khlifi <
abdellatif.elkhl...@arm.com> wrote:
>
> Emulate Secure World's FF-A ABIs and allow testing U-Boot FF-A support
>
> Features of the sandbox FF-A support:
>
> - Introduce an FF-A emulator
> - Introduce an FF-A device driver for FF-A comms with emulated Secure
World
> - Provides test methods allowing to read the status of the inspected ABIs
>
> The sandbox FF-A emulator supports only 64-bit direct messaging.
>
> Signed-off-by: Abdellatif El Khlifi 
> Cc: Tom Rini 
> Cc: Simon Glass 
> Cc: Ilias Apalodimas 
> Cc: Jens Wiklander 
> Cc: Heinrich Schuchardt 
>
> ---
> Changelog:
> ===
>
> v10:
>
> * split the FF-A sandbox support into an emulator and a driver
> * read FFA_VERSION and FFA_PARTITION_INFO_GET state using
>sandbox_ffa_query_core_state()
> * drop CONFIG_SANDBOX_FFA config
> * address nits
>
> v9: align FF-A sandbox driver with FF-A discovery through DM
>
> v8: update ffa_bus_prvdata_get() to return a pointer rather than
> a pointer address
>
> v7: state that sandbox driver supports only 64-bit direct messaging
>
> v4: align sandbox driver with the new FF-A driver interfaces
> and new way of error handling
>
> v1: introduce the sandbox driver
>
>  MAINTAINERS   |   3 +-
>  arch/sandbox/dts/sandbox.dtsi |   8 +
>  arch/sandbox/dts/test.dts |   8 +
>  arch/sandbox/include/asm/sandbox_arm_ffa.h|  68 ++
>  .../include/asm/sandbox_arm_ffa_priv.h| 133 
>  configs/sandbox64_defconfig   |   1 +
>  configs/sandbox_defconfig |   1 +
>  doc/arch/arm64.ffa.rst|   7 +-
>  doc/arch/sandbox/sandbox.rst  |   1 +
>  drivers/firmware/arm-ffa/Kconfig  |  13 +-
>  drivers/firmware/arm-ffa/Makefile |  10 +-
>  drivers/firmware/arm-ffa/ffa-emul-uclass.c| 732 ++
>  .../firmware/arm-ffa/sandbox_arm_ffa_priv.h   |  14 -
>  drivers/firmware/arm-ffa/sandbox_ffa.c| 108 +++
>  include/dm/uclass-id.h|   1 +
>  15 files changed, 1087 insertions(+), 21 deletions(-)
>  create mode 100644 arch/sandbox/include/asm/sandbox_arm_ffa.h
>  create mode 100644 arch/sandbox/include/asm/sandbox_arm_ffa_priv.h
>  create mode 100644 drivers/firmware/arm-ffa/ffa-emul-uclass.c
>  delete mode 100644 drivers/firmware/arm-ffa/sandbox_arm_ffa_priv.h
>  create mode 100644 drivers/firmware/arm-ffa/sandbox_ffa.c
>

[..]

> +/**
> + * sandbox_ffa_get_fwk_version() - Return the FFA framework version
> + * @dev: The sandbox FF-A emulator device
> + * @func_data:  Pointer to the FF-A function arguments container
structure
> + *
> + * Return the FFA framework version read from the FF-A emulator data.
> + *
> + * Return:
> + *
> + * 0 on success. Otherwise, failure
> + */
> +static int sandbox_ffa_get_fwk_version(struct udevice *dev, struct
ffa_sandbox_data *func_data)
> +{
> +   struct sandbox_ffa_emul *priv = dev_get_priv(dev);
> +
> +   if (!func_data)
> +   return -EINVAL;
> +
> +   if (!func_data->data0 ||
> +   func_data->data0_size != sizeof(priv->fwk_version))
> +   return -EINVAL;
> +
> +   *((u32 *)func_data->data0) = priv->fwk_version;
> +
> +   return 0;
> +}
> +
> +/**
> + * sandbox_ffa_get_parts() - Return the address of partitions data
> + * @dev: The sandbox FF-A emulator device
> + * @func_data:  Pointer to the FF-A function arguments container
structure
> + *
> + * Return the address of partitions data read from the FF-A emulator
data.
> + *
> + * Return:
> + *
> + * 0 on success. Otherwise, failure
> + */
> +static int sandbox_ffa_get_parts(struct udevice *dev, struct
ffa_sandbox_data *func_data)
> +{
> +   struct sandbox_ffa_emul *priv = dev_get_priv(dev);
> +
> +   if (!func_data)
> +   return -EINVAL;
> +
> +   if (!func_data->data0 ||
> +   func_data->data0_size != sizeof(struct ffa_partitions *))
> +   return -EINVAL;
> +
> +   *((struct ffa_partitions **)func_data->data0) = &priv->partitions;
> +
> +   return 0;
> +}
> +
> +/**
> + * sandbox_ffa_query_core_state() - Inspect the FF-A ABIs
> + * @queried_func_id:   The FF-A function to be queried
> + * @func_data:  Pointer to the FF-A function arguments container
structure
> + *
> + * Queries the status of FF-A ABI specified in the input argument.
> + *
> + * Return:
> + *
> + * 0 on success. Otherwise, failure
> + */
> +int sandbox_ffa_query_core_state(u32 queried_func_id,
> +struct ffa_sandbox_data *func_data)
> +{
> +   struct udevice *dev;

Please can you use 'emul' for the emulator so it is separate from the
device?

> +
> +   uclass_first_device(UCLASS_FFA_EMUL, &dev);
> +   if (!dev) {
> +   log_err("[FFA][SANDBOX][Emul] Cannot find FF-A emulator
during querying state\n");
> +   return -ENOD

Re: [PATCH v10 07/10] arm_ffa: introduce sandbox test cases for UCLASS_FFA

2023-04-01 Thread Simon Glass
Hi Abdellatif,

On Wed, 29 Mar 2023 at 05:12, Abdellatif El Khlifi <
abdellatif.elkhl...@arm.com> wrote:
>
> Add functional test cases for the FF-A support
>
> These tests rely on the FF-A sandbox emulator and FF-A
> sandbox driver which help in inspecting the FF-A communication.
>
> Signed-off-by: Abdellatif El Khlifi 
> Cc: Tom Rini 
> Cc: Simon Glass 
> Cc: Ilias Apalodimas 
> Cc: Jens Wiklander 
> Cc: Heinrich Schuchardt 
>
> ---
> Changelog:
> ===
>
> v10:
>
> * use the FF-A driver Uclass operations
> * use uclass_first_device()
> * replace CONFIG_SANDBOX_FFA with CONFIG_ARM_FFA_TRANSPORT
> * address nits
>
> v9: align FF-A sandbox tests with FF-A discovery through DM
>
> v8:
>
>   * update partition_info_get() second argument to be an SP count
>   * pass NULL device pointer to the FF-A bus discovery and operations
>
> v7: set the tests to use 64-bit direct messaging
>
> v4: align sandbox tests with the new FF-A driver interfaces
>  and new way of error handling
>
> v1: introduce sandbox tests
>
>  MAINTAINERS|   1 +
>  doc/arch/arm64.ffa.rst |   1 +
>  test/dm/Makefile   |   2 +
>  test/dm/ffa.c  | 357 +
>  4 files changed, 361 insertions(+)
>  create mode 100644 test/dm/ffa.c
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index b8019517ba..8f698b3f20 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -276,6 +276,7 @@ F:  doc/arch/arm64.ffa.rst
>  F: doc/usage/cmd/armffa.rst
>  F: drivers/firmware/arm-ffa/
>  F: include/arm_ffa.h
> +F: test/dm/ffa.c
>
>  ARM FREESCALE IMX
>  M: Stefano Babic 
> diff --git a/doc/arch/arm64.ffa.rst b/doc/arch/arm64.ffa.rst
> index 457a0e112e..5b1450f579 100644
> --- a/doc/arch/arm64.ffa.rst
> +++ b/doc/arch/arm64.ffa.rst
> @@ -38,6 +38,7 @@ The U-Boot FF-A support provides the following parts:
>FF-A ABIs inspection methods.
>  - An FF-A sandbox device driver for FF-A communication with the emulated
Secure World.
>The driver leverages the FF-A Uclass to establish FF-A communication.
> +- Sandbox FF-A test cases.
>
>  FF-A and SMC specifications
>  ---
> diff --git a/test/dm/Makefile b/test/dm/Makefile
> index 7a79b6e1a2..45563bdfb4 100644
> --- a/test/dm/Makefile
> +++ b/test/dm/Makefile
> @@ -1,6 +1,7 @@
>  # SPDX-License-Identifier: GPL-2.0+
>  #
>  # Copyright (c) 2013 Google, Inc
> +# Copyright 2022-2023 Arm Limited and/or its affiliates <
open-source-off...@arm.com>
>
>  obj-$(CONFIG_UT_DM) += test-dm.o
>
> @@ -85,6 +86,7 @@ obj-$(CONFIG_POWER_DOMAIN) += power-domain.o
>  obj-$(CONFIG_ACPI_PMC) += pmc.o
>  obj-$(CONFIG_DM_PMIC) += pmic.o
>  obj-$(CONFIG_DM_PWM) += pwm.o
> +obj-$(CONFIG_ARM_FFA_TRANSPORT) += ffa.o
>  obj-$(CONFIG_QFW) += qfw.o
>  obj-$(CONFIG_RAM) += ram.o
>  obj-y += regmap.o
> diff --git a/test/dm/ffa.c b/test/dm/ffa.c
> new file mode 100644
> index 00..d493597521
> --- /dev/null
> +++ b/test/dm/ffa.c
> @@ -0,0 +1,357 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Functional tests for UCLASS_FFA  class
> + *
> + * Copyright 2022-2023 Arm Limited and/or its affiliates <
open-source-off...@arm.com>
> + *
> + * Authors:
> + *   Abdellatif El Khlifi 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/* Macros */
> +
> +#define LOG_MSG_SZ (100)
> +#define LOG_CMD_SZ (LOG_MSG_SZ * 2)
> +
> +/* Functional tests for the UCLASS_FFA */
> +
> +static int dm_test_ffa_log(struct unit_test_state *uts, char *msg)
> +{
> +   char cmd[LOG_CMD_SZ] = {0};
> +
> +   console_record_reset();
> +
> +   snprintf(cmd, LOG_CMD_SZ, "echo \"%s\"", msg);
> +   run_command(cmd, 0);
> +
> +   ut_assert_console_end();
> +
> +   return 0;
> +}
> +
> +static int check_fwk_version(struct ffa_priv *priv, struct
unit_test_state *uts)
> +{
> +   struct ffa_sandbox_data func_data;
> +   u32 fwk_version = 0;
> +
> +   func_data.data0 = &fwk_version;
> +   func_data.data0_size = sizeof(fwk_version);
> +   ut_assertok(sandbox_ffa_query_core_state(FFA_VERSION,
&func_data));
> +
> +   if (priv->dscvry_info.fwk_version != fwk_version) {
> +   char msg[LOG_MSG_SZ] = {0};
> +
> +   snprintf(msg, LOG_MSG_SZ,
> +"[%s]: Error: framework version: core = 0x%x ,
sandbox  = 0x%x", __func__,
> +priv->dscvry_info.fwk_version,
> +fwk_version);
> +
> +   dm_test_ffa_log(uts, msg);
> +   return CMD_RET_FAILURE;

This is not a command. You should use ut_assert(false) here, perhaps?
Please fix throughout.

> +   }
> +   return 0;
> +}
> +
> +static int check_endpoint_id(struct ffa_priv *priv, struct
unit_test_state *uts)
> +{
> +   if (priv->id) {
> +   char msg[LOG_MSG_SZ] = {0};
> +
> +   snprintf(msg, LOG_MSG_SZ,
> +"[%s]: Error: endpoint id: core = 0x%x

Re: [PATCH v10 05/10] arm_ffa: introduce armffa command

2023-04-01 Thread Simon Glass
Hi Abdellatif,

On Wed, 29 Mar 2023 at 05:12, Abdellatif El Khlifi <
abdellatif.elkhl...@arm.com> wrote:
>
> Provide armffa command showcasing the use of the U-Boot FF-A support
>
> armffa is a command showcasing how to invoke FF-A operations.
> This provides a guidance to the client developers on how to
> call the FF-A bus interfaces. The command also allows to gather secure
> partitions information and ping these  partitions. The command is also
> helpful in testing the communication with secure partitions.
>
> For more details please refer to the command documentation [1].
>
> [1]: doc/usage/cmd/armffa.rst
>
> Signed-off-by: Abdellatif El Khlifi 
> Cc: Tom Rini 
> Cc: Simon Glass 
> Cc: Ilias Apalodimas 
> Cc: Jens Wiklander 
> Cc: Heinrich Schuchardt 
>
> ---
> Changelog:
> ===
>
> v10:
>
> * use the FF-A driver Uclass operations
> * use uclass_first_device()
> * address nits
>
> v9:
>
> * remove manual FF-A discovery and use DM
> * use DM class APIs to probe and interact with the FF-A bus
> * add doc/usage/cmd/armffa.rst
>
> v8:
>
> * update partition_info_get() second argument to be an SP count
> * pass NULL device pointer to the FF-A bus discovery and operations
>
> v7:
>
> * adapt do_ffa_dev_list() following the recent update on
>   uclass_first_device/uclass_next_device functions (they return void now)
> * set armffa command to use 64-bit direct messaging
>
> v4:
>
> * remove pattern data in do_ffa_msg_send_direct_req
>
> v3:
>
> * use the new driver interfaces (partition_info_get, sync_send_receive)
>   in armffa command
>
> v2:
>
> * replace use of ffa_helper_init_device function by
>  ffa_helper_bus_discover
>
> v1:
>
> * introduce armffa command
>
>  MAINTAINERS  |   2 +
>  cmd/Kconfig  |  10 ++
>  cmd/Makefile |   2 +
>  cmd/armffa.c | 238 +++
>  doc/arch/arm64.ffa.rst   |   7 +
>  doc/usage/cmd/armffa.rst | 107 ++
>  doc/usage/index.rst  |   1 +
>  drivers/firmware/arm-ffa/Kconfig |   1 +
>  8 files changed, 368 insertions(+)
>  create mode 100644 cmd/armffa.c
>  create mode 100644 doc/usage/cmd/armffa.rst
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 62c30184bb..add208e4ef 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -269,7 +269,9 @@ F:  configs/cortina_presidio-asic-pnand_defconfig
>  ARM FF-A
>  M: Abdellatif El Khlifi 
>  S: Maintained
> +F: cmd/armffa.c
>  F: doc/arch/arm64.ffa.rst
> +F: doc/usage/cmd/armffa.rst
>  F: drivers/firmware/arm-ffa/
>  F: include/arm_ffa.h
>  F: include/sandbox_arm_ffa.h
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index ba5ec69293..b814a20d8a 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -934,6 +934,16 @@ endmenu
>
>  menu "Device access commands"
>
> +config CMD_ARMFFA
> +   bool "Arm FF-A test command"
> +   depends on ARM_FFA_TRANSPORT
> +   help
> + Provides a test command for the FF-A support
> + supported options:
> +   - Listing the partition(s) info
> +   - Sending a data pattern to the specified partition
> +   - Displaying the arm_ffa device info
> +
>  config CMD_ARMFLASH
> #depends on FLASH_CFI_DRIVER
> bool "armflash"
> diff --git a/cmd/Makefile b/cmd/Makefile
> index d95833b2de..a1eb45f881 100644
> --- a/cmd/Makefile
> +++ b/cmd/Makefile
> @@ -12,6 +12,8 @@ obj-y += panic.o
>  obj-y += version.o
>
>  # command
> +
> +obj-$(CONFIG_CMD_ARMFFA) += armffa.o
>  obj-$(CONFIG_CMD_ACPI) += acpi.o
>  obj-$(CONFIG_CMD_ADDRMAP) += addrmap.o
>  obj-$(CONFIG_CMD_AES) += aes.o
> diff --git a/cmd/armffa.c b/cmd/armffa.c
> new file mode 100644
> index 00..d983a23bbc
> --- /dev/null
> +++ b/cmd/armffa.c
> @@ -0,0 +1,238 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright 2022-2023 Arm Limited and/or its affiliates <
open-source-off...@arm.com>
> + *
> + * Authors:
> + *   Abdellatif El Khlifi 
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/**
> + * do_ffa_getpart() - implementation of the getpart subcommand
> + * @cmdtp: Command Table
> + * @flag:  flags
> + * @argc:  number of arguments
> + * @argv:  arguments
> + *
> + * This function queries the secure partition information which the UUID
is provided

s/This function queries/Query/

We know it is a function so try to be brief and use the imperative mood
like you do in commit messages.

> + * as an argument. The function uses the arm_ffa driver
partition_info_get operation
> + * which implements FFA_PARTITION_INFO_GET ABI to retrieve the data.
> + * The input UUID string is expected to be in big endian format.
> + *
> + * Return:
> + *
> + * CMD_RET_SUCCESS: on success, otherwise failure
> + */
> +static int do_ffa_getpart(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
> +{
> +   u

Re: BUG: cmd/tmp.c missing fallthrough or break

2023-04-01 Thread Simon Glass
Hi Heinrich,

It needs a break. It is trying to write too many times and create an error.

Regards,
Simon


On Sat, 1 Apr 2023 at 21:04, Heinrich Schuchardt <
heinrich.schucha...@canonical.com> wrote:
>
> Hello Simon,
>
> please, have a look and this error:
>
> cmd/tpm_test.c:473:25: note: in expansion of macro ‘assert’
>473 | assert(i >= TPM_MAX_NV_WRITES_NOOWNER);
>| ^~
> cmd/tpm_test.c:474:17: note: here
>474 | default:
>| ^~~
>
> I am not sure if you forgot a break or a fallthrough.
>
> Best regards
>
> Heinrich


Re: BUG: pta_scp03_invoke_func() in drivers/tee/sandbox.c

2023-04-01 Thread Simon Glass
Hi Heinrich,

On Sat, 1 Apr 2023 at 20:58, Heinrich Schuchardt <
heinrich.schucha...@canonical.com> wrote:
>
> Hello Simon,
>
> could you, please, have a look at this warning:
>
> drivers/tee/sandbox.c: In function ‘pta_scp03_invoke_func’:
> drivers/tee/sandbox.c:138:20: warning: this statement may fall through
> [-Wimplicit-fallthrough=]
>138 | if (params[0].u.value.a)
>|^
> drivers/tee/sandbox.c:141:9: note: here
>141 | default:
>| ^~~
>
> Either the return statement is incorrectly indented and a fallthrough
> macro is missing or the if statement is superfluous.
>

+Jorge Ramirez who will know.

Regards,
SImon


> Best regards
>
> Heinrich


Re: [PATCH 1/1] common: avoid NULL dereference in console_devices_set

2023-04-01 Thread Simon Glass
Hi Heinrich,

On Sat, 1 Apr 2023 at 23:14, Heinrich Schuchardt <
heinrich.schucha...@canonical.com> wrote:
>
> If CONFIG_CONSOLE_MUX=y and CONFIG_SYS_CONSOLE_IS_IN_ENV=n, a NULL
> dereference occurs in console_devices_set().
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  common/console.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/common/console.c b/common/console.c
> index e4301a4932..39e1ab0e24 100644
> --- a/common/console.c
> +++ b/common/console.c
> @@ -243,6 +243,9 @@ int cd_count[MAX_FILES];
>
>  static void console_devices_set(int file, struct stdio_dev *dev)
>  {
> +   console_devices[file] = malloc(sizeof(struct stdio_dev *));
> +   if (!console_devices[file])
> +   return;

This is strange code and desperately needs a comment. As you say, it is
only called only when:

SYS_CONSOLE_IS_IN_ENV=n
CONSOLE_MUX=y

Please add some notes about this being allocated in iomux normally, but in
this case we just need a single device so it is allocated here...

> console_devices[file][0] = dev;
> cd_count[file] = 1;
>  }
> --
> 2.39.2
>

Regards,
SImon


Re: [PATCH 1/1] cmd: consider multiplexing in coninfo

2023-04-01 Thread Simon Glass
On Sat, 1 Apr 2023 at 23:20, Heinrich Schuchardt <
heinrich.schucha...@canonical.com> wrote:
>
> If console multiplexing in enabled (CONFIG_CONSOLE_MUX=y), the output of
> the coninfo command should show the file association (stdin, stderr,
> stdout) for all devices not only the default ones.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  cmd/console.c | 11 +--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>

Reviewed-by: Simon Glass 

Could add a test for this.


Re: [PATCH 1/1] doc: coninfo man-page

2023-04-01 Thread Simon Glass
On Sat, 1 Apr 2023 at 23:35, Heinrich Schuchardt <
heinrich.schucha...@canonical.com> wrote:
>
> Provide a man-page for the coninfo command.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  doc/usage/cmd/coninfo.rst | 55 +++
>  doc/usage/index.rst   |  1 +
>  2 files changed, 56 insertions(+)
>  create mode 100644 doc/usage/cmd/coninfo.rst
>

Reviewed-by: Simon Glass 


Re: [PATCH 2/3] starqltechn: use button keyboard driver

2023-04-01 Thread Simon Glass
On Sat, 1 Apr 2023 at 22:28, Dzmitry Sankouski  wrote:
>
> Button keyboard driver used to navigate bootmenu entries.
>
> Add gpio buttons, button keyboard driver.
> Add gpio keys dts bindings.
>
> Signed-off-by: Dzmitry Sankouski 
> ---
>
>  arch/arm/dts/starqltechn.dts  | 18 ++
>  configs/starqltechn_defconfig |  3 +++
>  include/configs/sdm845.h  |  2 +-
>  3 files changed, 22 insertions(+), 1 deletion(-)
>

Reviewed-by: Simon Glass 


Re: [PATCH 1/3] starqltechn: use 16x32 font

2023-04-01 Thread Simon Glass
On Sat, 1 Apr 2023 at 22:29, Dzmitry Sankouski  wrote:
>
> This font is more readable on high ppi display
>
> Signed-off-by: Dzmitry Sankouski 
> ---
>
>  configs/starqltechn_defconfig | 2 ++
>  1 file changed, 2 insertions(+)
>

Reviewed-by: Simon Glass 


Re: [PATCH 1/1] cmd/regulator: missing fallthrough in do_dev()

2023-04-01 Thread Simon Glass
On Sat, 1 Apr 2023 at 21:07, Heinrich Schuchardt <
heinrich.schucha...@canonical.com> wrote:
>
> Add missing fallthrough macro.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  cmd/regulator.c | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Simon Glass 


Re: [PATCH 1/1] sandbox: mark sandbox_exit() as no return.

2023-04-01 Thread Simon Glass
On Sat, 1 Apr 2023 at 20:54, Heinrich Schuchardt <
heinrich.schucha...@canonical.com> wrote:
>
> Fix a -Wimplicit-fallthrough warning in sandbox_sysreset_request().
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  arch/sandbox/cpu/cpu.c| 2 +-
>  arch/sandbox/include/asm/u-boot-sandbox.h | 2 +-
>  drivers/sysreset/sysreset_sandbox.c   | 1 -
>  3 files changed, 2 insertions(+), 3 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH 1/1] cmd: missing fallthrough macro in do_pci()

2023-04-01 Thread Simon Glass
On Sat, 1 Apr 2023 at 20:43, Heinrich Schuchardt <
heinrich.schucha...@canonical.com> wrote:
>
> Add a missing fallthrough macro to avoid a -Wimplicit-fallthrough warning.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  cmd/pci.c | 1 +
>  1 file changed, 1 insertion(+)
>

Reviewed-by: Simon Glass 


Re: [PATCH 1/1] sandbox: spi: sandbox_sf_process_cmd() missing fallthrough

2023-04-01 Thread Simon Glass
On Sat, 1 Apr 2023 at 20:38, Heinrich Schuchardt <
heinrich.schucha...@canonical.com> wrote:
>
> Add a missing fallthrough macro to avoid a -Wimplicit-fallthrough warning.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  drivers/mtd/spi/sandbox.c | 1 +
>  1 file changed, 1 insertion(+)
>

Reviewed-by: Simon Glass 


Re: [PATCH 1/1] sandbox: fix sandbox_hub_submit_control_msg()

2023-04-01 Thread Simon Glass
On Sat, 1 Apr 2023 at 19:57, Heinrich Schuchardt <
heinrich.schucha...@canonical.com> wrote:
>
> Avoid incorrect fall through:
> A USB_RT_HUB request should not be treated as USB_RT_PORT.
>
> Simplify the coding:
> Avoid duplicate debug() statements.
>
> This fixes all -Wimplicit-fallthrough warnings.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  drivers/usb/emul/sandbox_hub.c | 30 +-
>  1 file changed, 9 insertions(+), 21 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH 1/1] efi_loader: remove duplicate assignment

2023-04-01 Thread Simon Glass
On Sat, 1 Apr 2023 at 18:31, Heinrich Schuchardt <
heinrich.schucha...@canonical.com> wrote:
>
> Assigning the value of a variable to itself should be avoided.
>
> Addresses-Coverity-ID: 451089 ("Evaluation order violation")
> Fixes: 180b7118bed8 ("efi_loader: fix device-path for USB devices")
> Signed-off-by: Heinrich Schuchardt 
> ---
>  lib/efi_loader/efi_device_path.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

Reviewed-by: Simon Glass 


Re: [PATCH 1/1] tools: avoid implicit fallthrough in fdt_add_pubkey

2023-04-01 Thread Simon Glass
On Sat, 1 Apr 2023 at 19:10, Heinrich Schuchardt <
heinrich.schucha...@canonical.com> wrote:
>
> When building with -Wimplicit-fallthrough we get a warning
>
> tools/fdt_add_pubkey.c:52:25: warning:
> this statement may fall through [-Wimplicit-fallthrough=]
>52 | print_help();
>   |
>
> Explicitly declare which functions don't return.
>
> Fixes: 30238e99619c ("tools: add fdt_add_pubkey")
> Signed-off-by: Heinrich Schuchardt 
> ---
>  tools/fdt_add_pubkey.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass 


Re: [PATCH 1/1] lib: missing fallthrough comment in vsnprintf_internal()

2023-04-01 Thread Simon Glass
Hi Heinrich,

On Sat, 1 Apr 2023 at 19:13, Heinrich Schuchardt <
heinrich.schucha...@canonical.com> wrote:
>
> When a case statement intentionally falls through we should add a comment.
> Cf. -Wimplicit-fallthrough
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  lib/vsprintf.c | 4 
>  1 file changed, 4 insertions(+)

Why not use the fallthrough macro here?

>
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 2d13e68b57..8af6310651 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -674,6 +674,7 @@ repeat:
>
> case 'x':
> flags |= SMALL;
> +   /* fallthrough */
> case 'X':
> base = 16;
> break;
> @@ -681,8 +682,10 @@ repeat:
> case 'd':
> if (fmt[1] == 'E')
> flags |= ERRSTR;
> +   /* fallthrough */
> case 'i':
> flags |= SIGN;
> +   /* fallthrough */
> case 'u':
> break;
>
> --
> 2.39.2
>

Regards,
Simon


Re: [PATCH 1/1] sandbox: fix fall through in sandbox_flash_bulk()

2023-04-01 Thread Simon Glass
On Sat, 1 Apr 2023 at 19:25, Heinrich Schuchardt <
heinrich.schucha...@canonical.com> wrote:
>
> Handling of SANDBOX_FLASH_EP_OUT should never fall through to
> SANDBOX_FLASH_EP_IN.
>
> This addresses a warning shown when compiling with
> -Wimplicit-fallthrough.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  drivers/usb/emul/sandbox_flash.c | 1 +
>  1 file changed, 1 insertion(+)
>

Reviewed-by: Simon Glass 


Re: [PATCH 1/1] net: replace /* Fall through */

2023-04-01 Thread Simon Glass
On Sat, 1 Apr 2023 at 20:30, Heinrich Schuchardt <
heinrich.schucha...@canonical.com> wrote:
>
> gcc 12 does not understand /* Fall through */.
> Use the fallthrough macro instead.
>
> Fallthrough at the start of a switch statement makes no sense.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  net/net.c | 9 -
>  1 file changed, 4 insertions(+), 5 deletions(-)
>

Reviewed-by: Simon Glass 


Re: [PATCH 1/1] cmd: convert fallthrough comment.

2023-04-01 Thread Simon Glass
On Sat, 1 Apr 2023 at 20:14, Heinrich Schuchardt <
heinrich.schucha...@canonical.com> wrote:
>
> gcc does not understand /* FALL TROUGH */ and emits a warning:
>
> cmd/date.c: In function ‘do_date’:
> cmd/date.c:62:20: warning:
> this statement may fall through [-Wimplicit-fallthrough=]
>62 | if (strcmp(argv[1],"reset") == 0) {
>   |^
> cmd/date.c:102:9: note: here
>   102 | case 1: /* get date & time */
>   | ^~~~
>
> Use the fallthrough macro instead.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  cmd/date.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

Reviewed-by: Simon Glass 


Re: [PATCH v2 1/1] RFC: Move Odroid-C2 to use binman to produce the image

2023-04-01 Thread Steev Klimaszewski
Hi Simon,

On Sat, Apr 1, 2023 at 1:55 PM Simon Glass  wrote:
>
> This shows how binman can be used to replace the long and complicated
> instructions with an automated build. It is still complicated to read
> but users don't have to worry about the details.
>
> It needs some tidying up and only supports Odroid-C2 at present.
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v2:
> - Rebase to -next
>
>  arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi | 107 
>  arch/arm/mach-meson/Kconfig  |   1 +
>  doc/board/amlogic/odroid-c4.rst  | 127 +--
>  tools/binman/etype/aml_encrypt.py| 124 ++
>  tools/binman/ftest.py|   3 +
>  tools/binman/missing-blob-help   |   6 +
>  tools/binman/test/213_aml_encrypt.dts|  38 ++
>  tools/binman/test/214_list_no_dtb.dts|  23 
>  8 files changed, 337 insertions(+), 92 deletions(-)
>  create mode 100644 tools/binman/etype/aml_encrypt.py
>  create mode 100644 tools/binman/test/213_aml_encrypt.dts
>  create mode 100644 tools/binman/test/214_list_no_dtb.dts
>
This says C2 and only supports C2, but you're modifying th C4
documentation?  I'm just a random distro maintainer with interest in
this and want to be clear is all.


[PATCH v7 11/11] bootstd: Enable BOOTSTD_DEFAULTS by default

2023-04-01 Thread Simon Glass
This is needed to enable the boot command used to start standard boot.
Enable it by default for boards which use BOOTSTD.

This br
ings in quite a few features, mostly in common with
DISTRO_DEFAULTS

Signed-off-by: Simon Glass 
---

Changes in v7:
- Don't resync after defconfig changes

Changes in v6:
- Redo patch for the new approach

 boot/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/boot/Kconfig b/boot/Kconfig
index d95a2a702665..61ebc2750154 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -435,6 +435,7 @@ if BOOTSTD
 config BOOTSTD_DEFAULTS
bool "Select some common defaults for standard boot"
depends on BOOTSTD
+   default y
imply USE_BOOTCOMMAND
select BOOT_DEFAULTS
help
-- 
2.40.0.348.gf938b09366-goog



[PATCH v7 10/11] atmel: Disable SPL_EFI_PARTITION for sama5d27_som1_ek_qspiflash

2023-04-01 Thread Simon Glass
This is enabled by BOOT_DEFAULT but makes SPL too large. Disable it.

Signed-off-by: Simon Glass 
---

(no changes since v6)

Changes in v6:
- Add new patch to disable SPL_EFI_PARTITION for sama5d27 board

 configs/sama5d27_som1_ek_qspiflash_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/sama5d27_som1_ek_qspiflash_defconfig 
b/configs/sama5d27_som1_ek_qspiflash_defconfig
index 1c8adfbb7a31..94f070b87ef2 100644
--- a/configs/sama5d27_som1_ek_qspiflash_defconfig
+++ b/configs/sama5d27_som1_ek_qspiflash_defconfig
@@ -119,3 +119,4 @@ CONFIG_W1_GPIO=y
 CONFIG_W1_EEPROM=y
 CONFIG_W1_EEPROM_DS24XXX=y
 CONFIG_OF_LIBFDT_OVERLAY=y
+# CONFIG_SPL_EFI_PARTITION is not set
-- 
2.40.0.348.gf938b09366-goog



[PATCH v7 06/11] rockchip: Move to standard boot

2023-04-01 Thread Simon Glass
Drop the distro-boot scripts and use standard boot instead.

Signed-off-by: Simon Glass 
---

(no changes since v4)

Changes in v4:
- Add back BOOT_TARGETS

Changes in v3:
- Update rk3588 boards too

Changes in v2:
- Add new patch to move rockchip to standard boot

 include/configs/px30_common.h |  3 +-
 include/configs/rk3036_common.h   |  4 +--
 include/configs/rk3066_common.h   |  4 +--
 include/configs/rk3128_common.h   |  3 +-
 include/configs/rk3188_common.h   |  4 +--
 include/configs/rk322x_common.h   |  4 +--
 include/configs/rk3288_common.h   |  4 +--
 include/configs/rk3308_common.h   |  3 +-
 include/configs/rk3328_common.h   |  3 +-
 include/configs/rk3368_common.h   |  6 ++--
 include/configs/rk3568_common.h   |  5 ++-
 include/configs/rk3588_common.h   |  5 ++-
 include/configs/rockchip-common.h | 58 ---
 include/configs/rv1108_common.h   |  2 +-
 14 files changed, 16 insertions(+), 92 deletions(-)

diff --git a/include/configs/px30_common.h b/include/configs/px30_common.h
index 8df481b09788..6fbd2679f099 100644
--- a/include/configs/px30_common.h
+++ b/include/configs/px30_common.h
@@ -24,12 +24,11 @@
"kernel_addr_c=0x03e8\0" \
"ramdisk_addr_r=0x0a20\0"
 
-#include 
 #define CFG_EXTRA_ENV_SETTINGS \
ENV_MEM_LAYOUT_SETTINGS \
"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
"partitions=" PARTS_DEFAULT \
ROCKCHIP_DEVICE_SETTINGS \
-   BOOTENV
+   "boot_targets=" BOOT_TARGETS "\0"
 
 #endif
diff --git a/include/configs/rk3036_common.h b/include/configs/rk3036_common.h
index ea6073f29446..c2abd14e114b 100644
--- a/include/configs/rk3036_common.h
+++ b/include/configs/rk3036_common.h
@@ -21,8 +21,6 @@
"kernel_addr_r=0x6200\0" \
"ramdisk_addr_r=0x6400\0"
 
-#include 
-
 /* Linux fails to load the fdt if it's loaded above 512M on a evb-rk3036 board,
  * so limit the fdt reallocation to that */
 #define CFG_EXTRA_ENV_SETTINGS \
@@ -30,6 +28,6 @@
"fdt_high=0x7fff\0" \
"partitions=" PARTS_DEFAULT \
ENV_MEM_LAYOUT_SETTINGS \
-   BOOTENV
+   "boot_targets=" BOOT_TARGETS "\0"
 
 #endif
diff --git a/include/configs/rk3066_common.h b/include/configs/rk3066_common.h
index 1a6d3678df3e..d70c8f77d487 100644
--- a/include/configs/rk3066_common.h
+++ b/include/configs/rk3066_common.h
@@ -22,14 +22,12 @@
"kernel_addr_r=0x6200\0" \
"ramdisk_addr_r=0x6400\0"
 
-#include 
-
 #define CFG_EXTRA_ENV_SETTINGS \
"fdt_high=0x6fff\0" \
"initrd_high=0x6fff\0" \
"partitions=" PARTS_DEFAULT \
ENV_MEM_LAYOUT_SETTINGS \
ROCKCHIP_DEVICE_SETTINGS \
-   BOOTENV
+   "boot_targets=" BOOT_TARGETS "\0"
 
 #endif
diff --git a/include/configs/rk3128_common.h b/include/configs/rk3128_common.h
index 8736b14d1015..d8269b0ec96f 100644
--- a/include/configs/rk3128_common.h
+++ b/include/configs/rk3128_common.h
@@ -22,11 +22,10 @@
"kernel_addr_r=0x6200\0" \
"ramdisk_addr_r=0x6400\0"
 
-#include 
 #define CFG_EXTRA_ENV_SETTINGS \
ENV_MEM_LAYOUT_SETTINGS \
"fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \
"partitions=" PARTS_DEFAULT \
-   BOOTENV
+   "boot_targets=" BOOT_TARGETS "\0"
 
 #endif
diff --git a/include/configs/rk3188_common.h b/include/configs/rk3188_common.h
index fcb274565e9e..a8cee1e44d4d 100644
--- a/include/configs/rk3188_common.h
+++ b/include/configs/rk3188_common.h
@@ -21,8 +21,6 @@
"kernel_addr_r=0x6200\0" \
"ramdisk_addr_r=0x6400\0"
 
-#include 
-
 /* Linux fails to load the fdt if it's loaded above 256M on a Rock board,
  * so limit the fdt reallocation to that */
 #define CFG_EXTRA_ENV_SETTINGS \
@@ -32,6 +30,6 @@
"partitions=" PARTS_DEFAULT \
ENV_MEM_LAYOUT_SETTINGS \
ROCKCHIP_DEVICE_SETTINGS \
-   BOOTENV
+   "boot_targets=" BOOT_TARGETS "\0"
 
 #endif
diff --git a/include/configs/rk322x_common.h b/include/configs/rk322x_common.h
index 39a40f4e2d10..15f77df3e17e 100644
--- a/include/configs/rk322x_common.h
+++ b/include/configs/rk322x_common.h
@@ -22,8 +22,6 @@
"kernel_addr_r=0x6200\0" \
"ramdisk_addr_r=0x6400\0"
 
-#include 
-
 /* Linux fails to load the fdt if it's loaded above 512M on a evb-rk3036 board,
  * so limit the fdt reallocation to that */
 #define CFG_EXTRA_ENV_SETTINGS \
@@ -31,6 +29,6 @@
"fdt_high=0x7fff\0" \
"partitions=" PARTS_DEFAULT \
ENV_MEM_LAYOUT_SETTINGS \
-   BOOTENV
+   "boot_targets=" BOOT_TARGETS "\0"
 
 #endif
diff --git a/include/configs/rk3288_common.h b/include/configs/rk3288_common.h
index 71d2426d72a4..3063076a97af 100644
--- a/include/configs/rk3288_common.h
+++ b/include/configs/rk3288_common.h
@@ -23,8 +23,6 @@
"kernel_addr_r=0x0200\0" \
"ramdisk_addr_r=0x0400\0"
 
-#include 
-
 /* Linux fails to load the fdt if it's loaded above 256M on a Rock 2 board, so
  * limit the f

[PATCH v7 09/11] xilinx: Disable CONFIG_BOOTSTD_DEFAULTS for some xilinx boards

2023-04-01 Thread Simon Glass
Since CONFIG_BOOTSTD_DEFAULTS now selects ENV_VARS_UBOOT_CONFIG we cannot
enable it for some Xilinx boards which have a very small environment.

Disable it.

Signed-off-by: Simon Glass 
---

(no changes since v6)

Changes in v6:
- Add new patch to disable CONFIG_BOOTSTD_DEFAULTS for some xilinx boards

 configs/xilinx_versal_mini_emmc0_defconfig | 1 +
 configs/xilinx_versal_mini_emmc1_defconfig | 1 +
 configs/xilinx_zynqmp_mini_emmc0_defconfig | 1 +
 configs/xilinx_zynqmp_mini_emmc1_defconfig | 1 +
 4 files changed, 4 insertions(+)

diff --git a/configs/xilinx_versal_mini_emmc0_defconfig 
b/configs/xilinx_versal_mini_emmc0_defconfig
index 31b3c02f7389..8aadc7f6805b 100644
--- a/configs/xilinx_versal_mini_emmc0_defconfig
+++ b/configs/xilinx_versal_mini_emmc0_defconfig
@@ -16,6 +16,7 @@ CONFIG_SYS_PROMPT="Versal> "
 CONFIG_SYS_LOAD_ADDR=0x800
 # CONFIG_EXPERT is not set
 CONFIG_REMAKE_ELF=y
+# CONFIG_BOOTSTD_DEFAULTS is not set
 # CONFIG_AUTOBOOT is not set
 CONFIG_USE_BOOTCOMMAND=y
 CONFIG_BOOTCOMMAND="run distro_bootcmd"
diff --git a/configs/xilinx_versal_mini_emmc1_defconfig 
b/configs/xilinx_versal_mini_emmc1_defconfig
index 5480cf1d9cc4..5ccc20048212 100644
--- a/configs/xilinx_versal_mini_emmc1_defconfig
+++ b/configs/xilinx_versal_mini_emmc1_defconfig
@@ -16,6 +16,7 @@ CONFIG_SYS_PROMPT="Versal> "
 CONFIG_SYS_LOAD_ADDR=0x800
 # CONFIG_EXPERT is not set
 CONFIG_REMAKE_ELF=y
+# CONFIG_BOOTSTD_DEFAULTS is not set
 # CONFIG_AUTOBOOT is not set
 CONFIG_USE_BOOTCOMMAND=y
 CONFIG_BOOTCOMMAND="run distro_bootcmd"
diff --git a/configs/xilinx_zynqmp_mini_emmc0_defconfig 
b/configs/xilinx_zynqmp_mini_emmc0_defconfig
index 54b22aefa1d9..44deabaaff52 100644
--- a/configs/xilinx_zynqmp_mini_emmc0_defconfig
+++ b/configs/xilinx_zynqmp_mini_emmc0_defconfig
@@ -18,6 +18,7 @@ CONFIG_SYS_LOAD_ADDR=0x800
 CONFIG_REMAKE_ELF=y
 # CONFIG_MP is not set
 CONFIG_FIT=y
+# CONFIG_BOOTSTD_DEFAULTS is not set
 CONFIG_SUPPORT_RAW_INITRD=y
 # CONFIG_AUTOBOOT is not set
 # CONFIG_DISPLAY_CPUINFO is not set
diff --git a/configs/xilinx_zynqmp_mini_emmc1_defconfig 
b/configs/xilinx_zynqmp_mini_emmc1_defconfig
index eb78e0a39f3c..b9b003c03134 100644
--- a/configs/xilinx_zynqmp_mini_emmc1_defconfig
+++ b/configs/xilinx_zynqmp_mini_emmc1_defconfig
@@ -19,6 +19,7 @@ CONFIG_REMAKE_ELF=y
 # CONFIG_MP is not set
 CONFIG_FIT=y
 CONFIG_SUPPORT_RAW_INITRD=y
+# CONFIG_BOOTSTD_DEFAULTS is not set
 # CONFIG_AUTOBOOT is not set
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_BOARD_EARLY_INIT_R=y
-- 
2.40.0.348.gf938b09366-goog



[PATCH v7 07/11] rockchip: Use the same boot_targets for all boards

2023-04-01 Thread Simon Glass
It doesn't really matter if we mention things which are not present. For
example, if 'nvme' is included but the board does not support it, it just
continues with the next item in the list.

It is simpler to use the same target list for all boards, so drop the
different one for rk3399.

Signed-off-by: Simon Glass 
---

(no changes since v5)

Changes in v5:
- Drop patch to relax the argument requirements for bootflow scan

Changes in v4:
- Rebase to -next
- Add new patch to use the same boot_targets for all boards

 include/configs/rockchip-common.h | 4 
 1 file changed, 4 deletions(-)

diff --git a/include/configs/rockchip-common.h 
b/include/configs/rockchip-common.h
index e9f4072b7e78..9121bba37384 100644
--- a/include/configs/rockchip-common.h
+++ b/include/configs/rockchip-common.h
@@ -13,11 +13,7 @@
 
 #ifndef CONFIG_SPL_BUILD
 
-#ifdef CONFIG_ROCKCHIP_RK3399
 #define BOOT_TARGETS   "mmc1 mmc0 nvme scsi usb pxe dhcp spi"
-#else
-#define BOOT_TARGETS   "mmc1 mmc0 usb pxe dhcp"
-#endif
 
 #ifdef CONFIG_ARM64
 #define ROOT_UUID "B921B045-1DF0-41C3-AF44-4C6F280D3FAE;\0"
-- 
2.40.0.348.gf938b09366-goog



[PATCH v7 04/11] bootstd: Report missing labels only when asked

2023-04-01 Thread Simon Glass
Use the -l flag to indicate whether to report missing uclasses.

Also try to be more helpful when no devices are found. For example, when
we see something 'scsi0' requested and nothing was found, this indicates
that there are no SCSI devices, so show a suitable message.

Move messages out of the low-level functions so that silent operation
is possible.

This means they are never reported unless BOOTSTD_FULL is enabled, since
the -l flag cannot otherwise be set.

Suggested-by: Tom Rini 

Signed-off-by: Simon Glass 
---

(no changes since v6)

Changes in v6:
- Add new patch to report missing labels only when asked

 boot/bootdev-uclass.c | 32 +---
 include/bootdev.h |  2 +-
 test/boot/bootdev.c   | 12 +---
 3 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
index d34b7e37cf79..91087981d213 100644
--- a/boot/bootdev-uclass.c
+++ b/boot/bootdev-uclass.c
@@ -364,7 +364,8 @@ int bootdev_unbind_dev(struct udevice *parent)
  * @seqp: Returns the sequence number, or -1 if none
  * @method_flagsp: If non-NULL, returns any flags implied by the label
  * (enum bootflow_meth_flags_t), 0 if none
- * Returns: sequence number on success, else -ve error code
+ * Returns: sequence number on success, -EPFNOSUPPORT is the uclass is not
+ * known, other -ve error code on other error
  */
 static int label_to_uclass(const char *label, int *seqp, int *method_flagsp)
 {
@@ -394,8 +395,7 @@ static int label_to_uclass(const char *label, int *seqp, 
int *method_flagsp)
id = UCLASS_ETH;
method_flags |= BOOTFLOW_METHF_DHCP_ONLY;
} else {
-   log_warning("Unknown uclass '%s' in label\n", label);
-   return -EINVAL;
+   return -EPFNOSUPPORT;
}
}
if (id == UCLASS_USB)
@@ -458,7 +458,6 @@ int bootdev_find_by_label(const char *label, struct udevice 
**devp,
}
log_debug("- no device in %s\n", media->name);
}
-   log_warning("Unknown seq %d for label '%s'\n", seq, label);
 
return -ENOENT;
 }
@@ -577,9 +576,28 @@ int bootdev_next_label(struct bootflow_iter *iter, struct 
udevice **devp,
 
log_debug("next\n");
for (dev = NULL; !dev && iter->labels[++iter->cur_label];) {
-   log_debug("Scanning: %s\n", iter->labels[iter->cur_label]);
-   bootdev_hunt_and_find_by_label(iter->labels[iter->cur_label],
-  &dev, method_flagsp);
+   const char *label = iter->labels[iter->cur_label];
+   int ret;
+
+   log_debug("Scanning: %s\n", label);
+   ret = bootdev_hunt_and_find_by_label(label, &dev,
+method_flagsp);
+   if (iter->flags & BOOTFLOWIF_SHOW) {
+   if (ret == -EPFNOSUPPORT) {
+   log_warning("Unknown uclass '%s' in label\n",
+   label);
+   } else if (ret == -ENOENT) {
+   /*
+* looking for, e.g. 'scsi0' should find
+* something if SCSI is present
+*/
+   if (!trailing_strtol(label)) {
+   log_warning("No bootdevs for '%s'\n",
+   label);
+   }
+   }
+   }
+
}
 
if (!dev)
diff --git a/include/bootdev.h b/include/bootdev.h
index b92ff4d4f154..e72ef3650f7c 100644
--- a/include/bootdev.h
+++ b/include/bootdev.h
@@ -258,7 +258,7 @@ int bootdev_find_by_label(const char *label, struct udevice 
**devp,
  * @devp: returns the device found, on success
  * @method_flagsp: If non-NULL, returns any flags implied by the label
  * (enum bootflow_meth_flags_t), 0 if none. Unset if function fails
- * Return: 0 if OK, -EINVAL if the uclass is not supported by this board,
+ * Return: 0 if OK, -EPFNOSUPPORT if the uclass is not supported by this board,
  * -ENOENT if there is no device with that number
  */
 int bootdev_find_by_any(const char *name, struct udevice **devp,
diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c
index 4fe9fd722084..0899c78c2c4a 100644
--- a/test/boot/bootdev.c
+++ b/test/boot/bootdev.c
@@ -124,7 +124,8 @@ static int bootdev_test_labels(struct unit_test_state *uts)
mflags);
 
/* Check invalid uclass */
-   ut_asserteq(-EINVAL, bootdev_find_by_label("fred0", &dev, &mflags));
+   ut_asserteq(-EPFNOSUPPORT,
+   bootdev_find_by_label("fred0", &dev, &mflags));
 
/* Check unknown sequence number */
ut_asserteq(-ENOENT, bootdev_find_by_label("mmc6", &dev, &mflags));
@@ -

[PATCH v7 05/11] bootstd: Show a message sometimes if no bootflows are found

2023-04-01 Thread Simon Glass
Enable some messages that might provide hints, but only for
CMD_BOOTFLOW_FULL since otherwise the -l flag is not available.

Signed-off-by: Simon Glass 
Suggested-by: Tom Rini 
---

(no changes since v6)

Changes in v6:
- Add new patch to show a message sometimes if no bootflows are found

 cmd/bootflow.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index 42f6e14a4370..aa06999e3db3 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -181,6 +181,9 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int 
flag, int argc,
if (list)
show_footer(i, num_valid);
 
+   if (IS_ENABLED(CONFIG_CMD_BOOTFLOW_FULL) && !num_valid && !list)
+   printf("No bootflows found; try again with -l\n");
+
return 0;
 }
 
-- 
2.40.0.348.gf938b09366-goog



[PATCH v7 03/11] bootstd: Support booting EFI where multiple options exist

2023-04-01 Thread Simon Glass
The current EFI implementation has a strange quirk where it watches
loaded files and uses the last-loaded file to determine the device that
is being booted from.

This is confusing with bootstd, where multiple options may exist. Even
loading a device tree will cause it to go wrong. There is no API for
passing this information, since the only entry into booting an EFI image
is the 'bootefi' command.

To work around this, call efi_set_bootdev() for EFI images, if possible,
just before booting.

Signed-off-by: Simon Glass 
---

(no changes since v5)

Changes in v5:
- Add new patch to support booting EFI where multiple options exist

 boot/bootmeth_efi.c | 26 +++---
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
index d7e042cf01ee..d8bc7fafd127 100644
--- a/boot/bootmeth_efi.c
+++ b/boot/bootmeth_efi.c
@@ -94,7 +94,7 @@ static int get_efi_pxe_vci(char *str, int max_len)
return 0;
 }
 
-static int efiload_read_file(struct blk_desc *desc, struct bootflow *bflow)
+static void set_efi_bootdev(struct blk_desc *desc, struct bootflow *bflow)
 {
const struct udevice *media_dev;
int size = bflow->size;
@@ -102,11 +102,6 @@ static int efiload_read_file(struct blk_desc *desc, struct 
bootflow *bflow)
char devnum_str[9];
char dirname[200];
char *last_slash;
-   int ret;
-
-   ret = bootmeth_alloc_file(bflow, 0x200, 0x1);
-   if (ret)
-   return log_msg_ret("read", ret);
 
/*
 * This is a horrible hack to tell EFI about this boot device. Once we
@@ -117,7 +112,8 @@ static int efiload_read_file(struct blk_desc *desc, struct 
bootflow *bflow)
 * this can go away.
 */
media_dev = dev_get_parent(bflow->dev);
-   snprintf(devnum_str, sizeof(devnum_str), "%x", dev_seq(media_dev));
+   snprintf(devnum_str, sizeof(devnum_str), "%x:%x", dev_seq(media_dev),
+bflow->part);
 
strlcpy(dirname, bflow->fname, sizeof(dirname));
last_slash = strrchr(dirname, '/');
@@ -130,6 +126,15 @@ static int efiload_read_file(struct blk_desc *desc, struct 
bootflow *bflow)
dev_name = device_get_uclass_id(media_dev) == UCLASS_MASS_STORAGE ?
 "usb" : dev_get_uclass_name(media_dev);
efi_set_bootdev(dev_name, devnum_str, bflow->fname, bflow->buf, size);
+}
+
+static int efiload_read_file(struct blk_desc *desc, struct bootflow *bflow)
+{
+   int ret;
+
+   ret = bootmeth_alloc_file(bflow, 0x200, 0x1);
+   if (ret)
+   return log_msg_ret("read", ret);
 
return 0;
 }
@@ -373,6 +378,13 @@ int distro_efi_boot(struct udevice *dev, struct bootflow 
*bflow)
 
/* A non-zero buffer indicates the kernel is there */
if (bflow->buf) {
+   /* Set the EFI bootdev again, since reading an FDT loses it! */
+   if (bflow->blk) {
+   struct blk_desc *desc = dev_get_uclass_plat(bflow->blk);
+
+   set_efi_bootdev(desc, bflow);
+   }
+
kernel = (ulong)map_to_sysmem(bflow->buf);
 
/*
-- 
2.40.0.348.gf938b09366-goog



[PATCH v7 02/11] virtio: Ensure PCI is set up first

2023-04-01 Thread Simon Glass
Sometimes virtio may rely on PCI, or at least that is what the
distro_bootcmd script suggests. Add this in.

Signed-off-by: Simon Glass 
---

(no changes since v5)

Changes in v5:
Add new patch to ensure PCI is set up first

 drivers/virtio/virtio-uclass.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/virtio/virtio-uclass.c b/drivers/virtio/virtio-uclass.c
index de9bc90359ca..918cc15b019f 100644
--- a/drivers/virtio/virtio-uclass.c
+++ b/drivers/virtio/virtio-uclass.c
@@ -373,6 +373,12 @@ static int virtio_bootdev_hunt(struct bootdev_hunter 
*info, bool show)
 {
int ret;
 
+   if (IS_ENABLED(CONFIG_PCI)) {
+   ret = uclass_probe_all(UCLASS_PCI);
+   if (ret && ret != -ENOENT)
+   return log_msg_ret("pci", ret);
+   }
+
ret = uclass_probe_all(UCLASS_VIRTIO);
if (ret && ret != -ENOENT)
return log_msg_ret("vir", ret);
-- 
2.40.0.348.gf938b09366-goog



[PATCH v7 01/11] bootstd: Tweak bootflow logic for device tree

2023-04-01 Thread Simon Glass
We should only store the FDT filename if we were able to determine one.
Adjust the logic for this.

This corrects the case where no FDT is needed to boot, such as with EFI
using ACPI.

Signed-off-by: Simon Glass 
---

(no changes since v6)

Changes in v6:
- Fix 'unable' typo

Changes in v5:
- Add new patch to tweak bootflow logic for device tree

 boot/bootmeth_efi.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
index 6a97ac02ff5c..d7e042cf01ee 100644
--- a/boot/bootmeth_efi.c
+++ b/boot/bootmeth_efi.c
@@ -235,21 +235,21 @@ static int distro_efi_read_bootflow_file(struct udevice 
*dev,
 
/* try the various available names */
ret = -ENOENT;
-   for (seq = 0; ret; seq++) {
+   *fname = '\0';
+   for (seq = 0; ret == -ENOENT; seq++) {
ret = distro_efi_get_fdt_name(fname, sizeof(fname), seq);
-   if (ret == -EALREADY) {
+   if (ret == -EALREADY)
bflow->flags = BOOTFLOWF_USE_PRIOR_FDT;
-   break;
-   }
-   if (ret)
-   return log_msg_ret("nam", ret);
-   ret = bootmeth_common_read_file(dev, bflow, fname, fdt_addr,
-   &size);
+   if (!ret)
+   ret = bootmeth_common_read_file(dev, bflow, fname,
+   fdt_addr, &size);
}
 
-   bflow->fdt_fname = strdup(fname);
-   if (!bflow->fdt_fname)
-   return log_msg_ret("fil", -ENOMEM);
+   if (*fname) {
+   bflow->fdt_fname = strdup(fname);
+   if (!bflow->fdt_fname)
+   return log_msg_ret("fil", -ENOMEM);
+   }
 
if (!ret) {
bflow->fdt_size = size;
-- 
2.40.0.348.gf938b09366-goog



[PATCH v2 4/4] test: Run the VPL tests with 'make check'

2023-04-01 Thread Simon Glass
Update the script to run VPL tests as well as the others.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 test/run | 5 +
 1 file changed, 5 insertions(+)

diff --git a/test/run b/test/run
index 93b556f6cffc..768b22577c49 100755
--- a/test/run
+++ b/test/run
@@ -56,6 +56,11 @@ echo "${prompt}"
 run_test "sandbox_noinst" ./test/py/test.py --bd sandbox_noinst --build 
${para} \
-k 'test_ofplatdata or test_handoff or test_spl'
 
+# Run tests which require sandbox_vpl
+echo "${prompt}"
+run_test "sandbox_vpl" ./test/py/test.py --bd sandbox_vpl --build ${para} \
+   -k 'vpl or test_spl'
+
 if [ -z "$tools_only" ]; then
# Run tests for the flat-device-tree version of sandbox. This is a 
special
# build which does not enable CONFIG_OF_LIVE for the live device tree, 
so we can
-- 
2.40.0.348.gf938b09366-goog



[PATCH v2 3/4] CI: Ensure that vpl test is run

2023-04-01 Thread Simon Glass
This is actually skipped at present due to the condition in the file.
Fix this by running all vpl tests.

Signed-off-by: Simon Glass 
---

(no changes since v1)

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

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 5594a67d6b52..64da11e87f51 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -263,7 +263,7 @@ stages:
   TEST_PY_TEST_SPEC: "test_ofplatdata or test_handoff or test_spl"
 sandbox_vpl:
   TEST_PY_BD: "sandbox_vpl"
-  TEST_PY_TEST_SPEC: "test_vpl_help or test_spl"
+  TEST_PY_TEST_SPEC: "vpl or test_spl"
 sandbox_noinst:
   TEST_PY_BD: "sandbox_noinst"
   TEST_PY_TEST_SPEC: "test_ofplatdata or test_handoff or test_spl"
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 5431bf6011a6..2a423744c504 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -301,7 +301,7 @@ sandbox_noinst_test.py:
 sandbox_vpl test.py:
   variables:
 TEST_PY_BD: "sandbox_vpl"
-TEST_PY_TEST_SPEC: "test_vpl_help or test_spl"
+TEST_PY_TEST_SPEC: "vpl or test_spl"
   <<: *buildman_and_testpy_dfn
 
 # Enable tracing and disable LTO, to ensure functions are not elided
-- 
2.40.0.348.gf938b09366-goog



[PATCH v2 2/4] vbe: Use the correct image filename in the test

2023-04-01 Thread Simon Glass
At present this inadvertently relies on having a symlink to the correct
file from the current directory. Use the correct path to fix this.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 test/py/tests/test_vbe_vpl.py | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/test/py/tests/test_vbe_vpl.py b/test/py/tests/test_vbe_vpl.py
index d1c9d0548ae0..ed12d3a46186 100644
--- a/test/py/tests/test_vbe_vpl.py
+++ b/test/py/tests/test_vbe_vpl.py
@@ -15,6 +15,7 @@ def test_vbe_vpl(u_boot_console):
 #cmd = [cons.config.build_dir + fname, '-v']
 ram = os.path.join(cons.config.build_dir, 'ram.bin')
 fdt = os.path.join(cons.config.build_dir, 'arch/sandbox/dts/test.dtb')
+image_fname = os.path.join(cons.config.build_dir, 'image.bin')
 
 # Enable firmware1 and the mmc that it uses. These are needed for the full
 # VBE flow.
@@ -24,12 +25,13 @@ def test_vbe_vpl(u_boot_console):
 cons, f'fdtput -t s {fdt} /bootstd/firmware1 status okay')
 u_boot_utils.run_and_log(
 cons, f'fdtput -t s {fdt} /mmc3 status okay')
+u_boot_utils.run_and_log(
+cons, f'fdtput -t s {fdt} /mmc3 filename {image_fname}')
 
 # Remove any existing RAM file, so we don't have old data present
 if os.path.exists(ram):
 os.remove(ram)
-flags = ['-p', os.path.join(cons.config.build_dir, 'image.bin'), '-w',
- '-s', 'state.dtb']
+flags = ['-p', image_fname, '-w', '-s', 'state.dtb']
 cons.restart_uboot_with_flags(flags)
 
 # Make sure that VBE was used in both VPL (to load SPL) and SPL (to load
-- 
2.40.0.348.gf938b09366-goog



[PATCH v2 1/4] sandbox: Update the VBE firmware location

2023-04-01 Thread Simon Glass
The image size was increased but the firmware-update part was not
updated. Correct this so that VBE firmware update can succeed with
sandbox_vpl.

Signed-off-by: Simon Glass 
Fixes: 85c66dc95c2 ("sandbox: Expand size for VPL image")
---

Changes in v2:
- Add new patch to update the VBE firmware location

 arch/sandbox/dts/test.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index d72d7a567a71..7c1ee71cb7c2 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -129,7 +129,7 @@
status = "disabled";
compatible = "fwupd,vbe-simple";
storage = "mmc3";
-   skip-offset = <0x40>;
+   skip-offset = <0x80>;
area-start = <0>;
area-size = <0xe0>;
state-offset = <0xdffc00>;
-- 
2.40.0.348.gf938b09366-goog



[PATCH v2 0/4] vpl: Correct some tests

2023-04-01 Thread Simon Glass
It was reported that one of the VPL tests does not work. The problem
turned out to be a leftover symlink that I had which made things work
locally. This was not noticed in CI since the tests did not run there
either.

This little series fixes these problems.

Changes in v2:
- Add new patch to update the VBE firmware location

Simon Glass (4):
  sandbox: Update the VBE firmware location
  vbe: Use the correct image filename in the test
  CI: Ensure that vpl test is run
  test: Run the VPL tests with 'make check'

 .azure-pipelines.yml  | 2 +-
 .gitlab-ci.yml| 2 +-
 arch/sandbox/dts/test.dts | 2 +-
 test/py/tests/test_vbe_vpl.py | 6 --
 test/run  | 5 +
 5 files changed, 12 insertions(+), 5 deletions(-)

-- 
2.40.0.348.gf938b09366-goog



Re: [PATCH v6 11/11] bootstd: Enable BOOTSTD_DEFAULTS by default

2023-04-01 Thread Tom Rini
On Sun, Apr 02, 2023 at 09:45:35AM +1200, Simon Glass wrote:

> This is needed to enable the boot command used to start standard boot.
> Enable it by default for boards which use BOOTSTD.
> 
> This brings in quite a few features, mostly in common with
> DISTRO_DEFAULTS
> 
> Signed-off-by: Simon Glass 
> ---
> 
> Changes in v6:
> - Redo patch for the new approach

So, if the preceding patch to disable BOOTSTD is right, this patch
should result in no size changes, since we're enabling these defaults on
platforms that already had everything, but they're using distro_bootcmd
and not bootstd itself.

And please don't resync the defconfigs too, that makes review much
harder and likely won't apply when merged anyhow.

-- 
Tom


signature.asc
Description: PGP signature


Re: Pull request for efi-2023-04-rc6

2023-04-01 Thread Tom Rini
On Sat, Apr 01, 2023 at 01:32:55PM +0200, Heinrich Schuchardt wrote:

> Dear Tom,
> 
> The following changes since commit 897d634a9861feedbccf63fad5383670dd973276:
> 
>   Merge tag 'dm-pull-31mar23' of
> https://source.denx.de/u-boot/custodians/u-boot-dm (2023-03-31 12:02:41
> -0400)
> 
> are available in the Git repository at:
> 
>   https://source.denx.de/u-boot/custodians/u-boot-efi.git
> tags/efi-2023-04-rc6
> 
> for you to fetch changes up to dfd4288173245f0ea03df3e73cf62848c0212d98:
> 
>   efi_loader: remove duplicate assignment (2023-04-01 10:11:50 +0200)
> 
> Gitlab CI showed no issues:
> https://source.denx.de/u-boot/custodians/u-boot-efi/-/pipelines/15840
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [RFC PATCH v7 11/23] cmd: Add new parser command

2023-04-01 Thread Francis Laniel
Hi.


Le samedi 1 avril 2023, 07:32:14 WEST Simon Glass a écrit :
> Hi Francis,
> 
> On Fri, 31 Mar 2023 at 08:49, Francis Laniel
> 
>  wrote:
> > This command can be used to print the current parser with 'parser print'.
> > It can also be used to set the current parser with 'parser set'.
> > For the moment, only one value is valid for set: old.
> > 
> > Signed-off-by: Francis Laniel 
> > ---
> > 
> >  cmd/Makefile |   2 +
> >  cmd/parser.c | 120 +++
> >  common/cli.c |   3 +-
> >  3 files changed, 124 insertions(+), 1 deletion(-)
> >  create mode 100644 cmd/parser.c
> 
> Reviewed-by: Simon Glass 

Thank you for the reviews!

> 
> But I wonder whether 'cli' might be a better name for this command? We
> use cli everywhere else.

"Naming thing is hard" [1].
Thank you for the suggestion! I changed it to cli which I think is a better 
name as it is less abstract than parser.

> Also can you add doc/usage for this?

Done! I was not aware of doc/usage/cmd before.

> Regards,
> Simon

By the way, I also addressed your other comments on patches 4 and 9.


Best regards.
---
[1] https://www.karlton.org/2017/12/naming-things-hard/




Re: [PATCH v6 09/11] xilinx: Disable CONFIG_BOOTSTD_DEFAULTS for some xilinx boards

2023-04-01 Thread Mark Kettenis
> From: Simon Glass 
> Date: Sun,  2 Apr 2023 09:45:33 +1200
> 
> Since CONFIG_BOOTSTD_DEFAULTS now selects ENV_VARS_UBOOT_CONFIG we cannot
> enable it for some Xilinx boards which have a very small environment.
> 
> Disable it.

Does that mean these configs lose distroboot support?  That would be a
shame!

> Signed-off-by: Simon Glass 
> ---
> 
> Changes in v6:
> - Add new patch to disable CONFIG_BOOTSTD_DEFAULTS for some xilinx boards
> 
>  configs/xilinx_versal_mini_emmc0_defconfig | 1 +
>  configs/xilinx_versal_mini_emmc1_defconfig | 1 +
>  configs/xilinx_zynqmp_mini_emmc0_defconfig | 1 +
>  configs/xilinx_zynqmp_mini_emmc1_defconfig | 1 +
>  4 files changed, 4 insertions(+)
> 
> diff --git a/configs/xilinx_versal_mini_emmc0_defconfig 
> b/configs/xilinx_versal_mini_emmc0_defconfig
> index 31b3c02f7389..8aadc7f6805b 100644
> --- a/configs/xilinx_versal_mini_emmc0_defconfig
> +++ b/configs/xilinx_versal_mini_emmc0_defconfig
> @@ -16,6 +16,7 @@ CONFIG_SYS_PROMPT="Versal> "
>  CONFIG_SYS_LOAD_ADDR=0x800
>  # CONFIG_EXPERT is not set
>  CONFIG_REMAKE_ELF=y
> +# CONFIG_BOOTSTD_DEFAULTS is not set
>  # CONFIG_AUTOBOOT is not set
>  CONFIG_USE_BOOTCOMMAND=y
>  CONFIG_BOOTCOMMAND="run distro_bootcmd"
> diff --git a/configs/xilinx_versal_mini_emmc1_defconfig 
> b/configs/xilinx_versal_mini_emmc1_defconfig
> index 5480cf1d9cc4..5ccc20048212 100644
> --- a/configs/xilinx_versal_mini_emmc1_defconfig
> +++ b/configs/xilinx_versal_mini_emmc1_defconfig
> @@ -16,6 +16,7 @@ CONFIG_SYS_PROMPT="Versal> "
>  CONFIG_SYS_LOAD_ADDR=0x800
>  # CONFIG_EXPERT is not set
>  CONFIG_REMAKE_ELF=y
> +# CONFIG_BOOTSTD_DEFAULTS is not set
>  # CONFIG_AUTOBOOT is not set
>  CONFIG_USE_BOOTCOMMAND=y
>  CONFIG_BOOTCOMMAND="run distro_bootcmd"
> diff --git a/configs/xilinx_zynqmp_mini_emmc0_defconfig 
> b/configs/xilinx_zynqmp_mini_emmc0_defconfig
> index cf7c7eda8c94..47eab450c90a 100644
> --- a/configs/xilinx_zynqmp_mini_emmc0_defconfig
> +++ b/configs/xilinx_zynqmp_mini_emmc0_defconfig
> @@ -17,6 +17,7 @@ CONFIG_SYS_LOAD_ADDR=0x800
>  CONFIG_REMAKE_ELF=y
>  # CONFIG_MP is not set
>  CONFIG_FIT=y
> +# CONFIG_BOOTSTD_DEFAULTS is not set
>  CONFIG_SUPPORT_RAW_INITRD=y
>  # CONFIG_AUTOBOOT is not set
>  # CONFIG_DISPLAY_CPUINFO is not set
> diff --git a/configs/xilinx_zynqmp_mini_emmc1_defconfig 
> b/configs/xilinx_zynqmp_mini_emmc1_defconfig
> index a4a43b58a85e..da1e2d699caa 100644
> --- a/configs/xilinx_zynqmp_mini_emmc1_defconfig
> +++ b/configs/xilinx_zynqmp_mini_emmc1_defconfig
> @@ -18,6 +18,7 @@ CONFIG_REMAKE_ELF=y
>  # CONFIG_MP is not set
>  CONFIG_FIT=y
>  CONFIG_SUPPORT_RAW_INITRD=y
> +# CONFIG_BOOTSTD_DEFAULTS is not set
>  # CONFIG_AUTOBOOT is not set
>  # CONFIG_DISPLAY_CPUINFO is not set
>  CONFIG_BOARD_EARLY_INIT_R=y
> -- 
> 2.40.0.348.gf938b09366-goog
> 
> 


Re: [PATCH v6 01/11] bootstd: Tweak bootflow logic for device tree

2023-04-01 Thread Mark Kettenis
> From: Simon Glass 
> Date: Sun,  2 Apr 2023 09:45:25 +1200
> 
> We should only store the FDT filename if we were unable to determine one.
> Adjust the logic for this.

This explanation makes no sense.  How can we store the FDT filename if
we were unable to determine one?

> This corrects the case where no FDT is needed to boot, such as with EFI
> using ACPI.
> 
> Signed-off-by: Simon Glass 
> ---
> 
> (no changes since v5)
> 
> Changes in v5:
> - Add new patch to tweak bootflow logic for device tree
> 
>  boot/bootmeth_efi.c | 22 +++---
>  1 file changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
> index 6a97ac02ff5c..d7e042cf01ee 100644
> --- a/boot/bootmeth_efi.c
> +++ b/boot/bootmeth_efi.c
> @@ -235,21 +235,21 @@ static int distro_efi_read_bootflow_file(struct udevice 
> *dev,
>  
>   /* try the various available names */
>   ret = -ENOENT;
> - for (seq = 0; ret; seq++) {
> + *fname = '\0';
> + for (seq = 0; ret == -ENOENT; seq++) {
>   ret = distro_efi_get_fdt_name(fname, sizeof(fname), seq);
> - if (ret == -EALREADY) {
> + if (ret == -EALREADY)
>   bflow->flags = BOOTFLOWF_USE_PRIOR_FDT;
> - break;
> - }
> - if (ret)
> - return log_msg_ret("nam", ret);
> - ret = bootmeth_common_read_file(dev, bflow, fname, fdt_addr,
> - &size);
> + if (!ret)
> + ret = bootmeth_common_read_file(dev, bflow, fname,
> + fdt_addr, &size);
>   }
>  
> - bflow->fdt_fname = strdup(fname);
> - if (!bflow->fdt_fname)
> - return log_msg_ret("fil", -ENOMEM);
> + if (*fname) {
> + bflow->fdt_fname = strdup(fname);
> + if (!bflow->fdt_fname)
> + return log_msg_ret("fil", -ENOMEM);
> + }
>  
>   if (!ret) {
>   bflow->fdt_size = size;
> -- 
> 2.40.0.348.gf938b09366-goog
> 
> 


Re: [RFC PATCH v1] arm: lib: add __gnu_thumb1_case_si

2023-04-01 Thread Tony Dinh
Hi Francis,

On Sat, Apr 1, 2023 at 2:55 PM Francis Laniel
 wrote:
>
> The assembly for __gnu_thumb1_case_si was taken from upstream gcc and adapted
> as width suffix was removed for the add instruction [1].
>
> Signed-off-by: Francis Laniel 
> Tested-by: Tony Dinh 
> [1] 
> https://github.com/gcc-mirror/gcc/blob/4f181f9c7ee3efc509d185fdfda33be9018f1611/libgcc/config/arm/lib1funcs.S#L2156

Thanks for the patch! I've added Tom, Pali, and Stefan.

I think we need to do some more testing for other boards that have
CONFIG_HAS_THUMB2 and CONFIG_SPL_SYS_THUMB_BUILD. My test target
(Marvell Armada 385 SoC) is somewhat broken right now. So it will take
some time for me to get that back running to run this test.

All the best,
Tony

> ---
>  arch/arm/lib/lib1funcs.S | 17 +
>  1 file changed, 17 insertions(+)
>
> diff --git a/arch/arm/lib/lib1funcs.S b/arch/arm/lib/lib1funcs.S
> index 7ff4446dd6..79cedc0aad 100644
> --- a/arch/arm/lib/lib1funcs.S
> +++ b/arch/arm/lib/lib1funcs.S
> @@ -424,4 +424,21 @@ ENTRY(__gnu_thumb1_case_uhi)
> ret lr
>  ENDPROC(__gnu_thumb1_case_uhi)
>  .popsection
> +
> +/* Taken and adapted from: 
> https://github.com/gcc-mirror/gcc/blob/4f181f9c7ee3efc509d185fdfda33be9018f1611/libgcc/config/arm/lib1funcs.S#L2156
>  */
> +.pushsection .text.__gnu_thumb1_case_si, "ax"
> +ENTRY(__gnu_thumb1_case_si)
> +   push{r0, r1}
> +   mov r1, lr
> +   addsr1, r1, #2  /* Align to word.  */
> +   lsrsr1, r1, #2
> +   lslsr0, r0, #2
> +   lslsr1, r1, #2
> +   ldr r0, [r1, r0]
> +   addsr0, r0, r1
> +   mov lr, r0
> +   pop {r0, r1}
> +   mov pc, lr  /* We know we were called from thumb code.  */
> +ENDPROC(__gnu_thumb1_case_si)
> +.popsection
>  #endif
> --
> 2.34.1
>


[PATCH v6 09/11] xilinx: Disable CONFIG_BOOTSTD_DEFAULTS for some xilinx boards

2023-04-01 Thread Simon Glass
Since CONFIG_BOOTSTD_DEFAULTS now selects ENV_VARS_UBOOT_CONFIG we cannot
enable it for some Xilinx boards which have a very small environment.

Disable it.

Signed-off-by: Simon Glass 
---

Changes in v6:
- Add new patch to disable CONFIG_BOOTSTD_DEFAULTS for some xilinx boards

 configs/xilinx_versal_mini_emmc0_defconfig | 1 +
 configs/xilinx_versal_mini_emmc1_defconfig | 1 +
 configs/xilinx_zynqmp_mini_emmc0_defconfig | 1 +
 configs/xilinx_zynqmp_mini_emmc1_defconfig | 1 +
 4 files changed, 4 insertions(+)

diff --git a/configs/xilinx_versal_mini_emmc0_defconfig 
b/configs/xilinx_versal_mini_emmc0_defconfig
index 31b3c02f7389..8aadc7f6805b 100644
--- a/configs/xilinx_versal_mini_emmc0_defconfig
+++ b/configs/xilinx_versal_mini_emmc0_defconfig
@@ -16,6 +16,7 @@ CONFIG_SYS_PROMPT="Versal> "
 CONFIG_SYS_LOAD_ADDR=0x800
 # CONFIG_EXPERT is not set
 CONFIG_REMAKE_ELF=y
+# CONFIG_BOOTSTD_DEFAULTS is not set
 # CONFIG_AUTOBOOT is not set
 CONFIG_USE_BOOTCOMMAND=y
 CONFIG_BOOTCOMMAND="run distro_bootcmd"
diff --git a/configs/xilinx_versal_mini_emmc1_defconfig 
b/configs/xilinx_versal_mini_emmc1_defconfig
index 5480cf1d9cc4..5ccc20048212 100644
--- a/configs/xilinx_versal_mini_emmc1_defconfig
+++ b/configs/xilinx_versal_mini_emmc1_defconfig
@@ -16,6 +16,7 @@ CONFIG_SYS_PROMPT="Versal> "
 CONFIG_SYS_LOAD_ADDR=0x800
 # CONFIG_EXPERT is not set
 CONFIG_REMAKE_ELF=y
+# CONFIG_BOOTSTD_DEFAULTS is not set
 # CONFIG_AUTOBOOT is not set
 CONFIG_USE_BOOTCOMMAND=y
 CONFIG_BOOTCOMMAND="run distro_bootcmd"
diff --git a/configs/xilinx_zynqmp_mini_emmc0_defconfig 
b/configs/xilinx_zynqmp_mini_emmc0_defconfig
index cf7c7eda8c94..47eab450c90a 100644
--- a/configs/xilinx_zynqmp_mini_emmc0_defconfig
+++ b/configs/xilinx_zynqmp_mini_emmc0_defconfig
@@ -17,6 +17,7 @@ CONFIG_SYS_LOAD_ADDR=0x800
 CONFIG_REMAKE_ELF=y
 # CONFIG_MP is not set
 CONFIG_FIT=y
+# CONFIG_BOOTSTD_DEFAULTS is not set
 CONFIG_SUPPORT_RAW_INITRD=y
 # CONFIG_AUTOBOOT is not set
 # CONFIG_DISPLAY_CPUINFO is not set
diff --git a/configs/xilinx_zynqmp_mini_emmc1_defconfig 
b/configs/xilinx_zynqmp_mini_emmc1_defconfig
index a4a43b58a85e..da1e2d699caa 100644
--- a/configs/xilinx_zynqmp_mini_emmc1_defconfig
+++ b/configs/xilinx_zynqmp_mini_emmc1_defconfig
@@ -18,6 +18,7 @@ CONFIG_REMAKE_ELF=y
 # CONFIG_MP is not set
 CONFIG_FIT=y
 CONFIG_SUPPORT_RAW_INITRD=y
+# CONFIG_BOOTSTD_DEFAULTS is not set
 # CONFIG_AUTOBOOT is not set
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_BOARD_EARLY_INIT_R=y
-- 
2.40.0.348.gf938b09366-goog



[RFC PATCH v1] arm: lib: add __gnu_thumb1_case_si

2023-04-01 Thread Francis Laniel
The assembly for __gnu_thumb1_case_si was taken from upstream gcc and adapted
as width suffix was removed for the add instruction [1].

Signed-off-by: Francis Laniel 
Tested-by: Tony Dinh 
[1] 
https://github.com/gcc-mirror/gcc/blob/4f181f9c7ee3efc509d185fdfda33be9018f1611/libgcc/config/arm/lib1funcs.S#L2156
---
 arch/arm/lib/lib1funcs.S | 17 +
 1 file changed, 17 insertions(+)

diff --git a/arch/arm/lib/lib1funcs.S b/arch/arm/lib/lib1funcs.S
index 7ff4446dd6..79cedc0aad 100644
--- a/arch/arm/lib/lib1funcs.S
+++ b/arch/arm/lib/lib1funcs.S
@@ -424,4 +424,21 @@ ENTRY(__gnu_thumb1_case_uhi)
ret lr
 ENDPROC(__gnu_thumb1_case_uhi)
 .popsection
+
+/* Taken and adapted from: 
https://github.com/gcc-mirror/gcc/blob/4f181f9c7ee3efc509d185fdfda33be9018f1611/libgcc/config/arm/lib1funcs.S#L2156
 */
+.pushsection .text.__gnu_thumb1_case_si, "ax"
+ENTRY(__gnu_thumb1_case_si)
+   push{r0, r1}
+   mov r1, lr
+   addsr1, r1, #2  /* Align to word.  */
+   lsrsr1, r1, #2
+   lslsr0, r0, #2
+   lslsr1, r1, #2
+   ldr r0, [r1, r0]
+   addsr0, r0, r1
+   mov lr, r0
+   pop {r0, r1}
+   mov pc, lr  /* We know we were called from thumb code.  */
+ENDPROC(__gnu_thumb1_case_si)
+.popsection
 #endif
--
2.34.1



[PATCH v6 05/11] bootstd: Show a message sometimes if no bootflows are found

2023-04-01 Thread Simon Glass
Enable some messages that might provide hints, but only for
CMD_BOOTFLOW_FULL since otherwise the -l flag is not available.

Signed-off-by: Simon Glass 
Suggested-by: Tom Rini 
---

Changes in v6:
- Add new patch to show a message sometimes if no bootflows are found

 cmd/bootflow.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index 42f6e14a4370..aa06999e3db3 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -181,6 +181,9 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int 
flag, int argc,
if (list)
show_footer(i, num_valid);
 
+   if (IS_ENABLED(CONFIG_CMD_BOOTFLOW_FULL) && !num_valid && !list)
+   printf("No bootflows found; try again with -l\n");
+
return 0;
 }
 
-- 
2.40.0.348.gf938b09366-goog



[PATCH v6 07/11] rockchip: Use the same boot_targets for all boards

2023-04-01 Thread Simon Glass
It doesn't really matter if we mention things which are not present. For
example, if 'nvme' is included but the board does not support it, it just
continues with the next item in the list.

It is simpler to use the same target list for all boards, so drop the
different one for rk3399.

Signed-off-by: Simon Glass 
---

(no changes since v5)

Changes in v5:
- Drop patch to relax the argument requirements for bootflow scan

Changes in v4:
- Rebase to -next
- Add new patch to use the same boot_targets for all boards

 include/configs/rockchip-common.h | 4 
 1 file changed, 4 deletions(-)

diff --git a/include/configs/rockchip-common.h 
b/include/configs/rockchip-common.h
index e9f4072b7e78..9121bba37384 100644
--- a/include/configs/rockchip-common.h
+++ b/include/configs/rockchip-common.h
@@ -13,11 +13,7 @@
 
 #ifndef CONFIG_SPL_BUILD
 
-#ifdef CONFIG_ROCKCHIP_RK3399
 #define BOOT_TARGETS   "mmc1 mmc0 nvme scsi usb pxe dhcp spi"
-#else
-#define BOOT_TARGETS   "mmc1 mmc0 usb pxe dhcp"
-#endif
 
 #ifdef CONFIG_ARM64
 #define ROOT_UUID "B921B045-1DF0-41C3-AF44-4C6F280D3FAE;\0"
-- 
2.40.0.348.gf938b09366-goog



[PATCH v6 06/11] rockchip: Move to standard boot

2023-04-01 Thread Simon Glass
Drop the distro-boot scripts and use standard boot instead.

Signed-off-by: Simon Glass 
---

(no changes since v4)

Changes in v4:
- Add back BOOT_TARGETS

Changes in v3:
- Update rk3588 boards too

Changes in v2:
- Add new patch to move rockchip to standard boot

 include/configs/px30_common.h |  3 +-
 include/configs/rk3036_common.h   |  4 +--
 include/configs/rk3066_common.h   |  4 +--
 include/configs/rk3128_common.h   |  3 +-
 include/configs/rk3188_common.h   |  4 +--
 include/configs/rk322x_common.h   |  4 +--
 include/configs/rk3288_common.h   |  4 +--
 include/configs/rk3308_common.h   |  3 +-
 include/configs/rk3328_common.h   |  3 +-
 include/configs/rk3368_common.h   |  6 ++--
 include/configs/rk3568_common.h   |  5 ++-
 include/configs/rk3588_common.h   |  5 ++-
 include/configs/rockchip-common.h | 58 ---
 include/configs/rv1108_common.h   |  2 +-
 14 files changed, 16 insertions(+), 92 deletions(-)

diff --git a/include/configs/px30_common.h b/include/configs/px30_common.h
index 8df481b09788..6fbd2679f099 100644
--- a/include/configs/px30_common.h
+++ b/include/configs/px30_common.h
@@ -24,12 +24,11 @@
"kernel_addr_c=0x03e8\0" \
"ramdisk_addr_r=0x0a20\0"
 
-#include 
 #define CFG_EXTRA_ENV_SETTINGS \
ENV_MEM_LAYOUT_SETTINGS \
"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
"partitions=" PARTS_DEFAULT \
ROCKCHIP_DEVICE_SETTINGS \
-   BOOTENV
+   "boot_targets=" BOOT_TARGETS "\0"
 
 #endif
diff --git a/include/configs/rk3036_common.h b/include/configs/rk3036_common.h
index ea6073f29446..c2abd14e114b 100644
--- a/include/configs/rk3036_common.h
+++ b/include/configs/rk3036_common.h
@@ -21,8 +21,6 @@
"kernel_addr_r=0x6200\0" \
"ramdisk_addr_r=0x6400\0"
 
-#include 
-
 /* Linux fails to load the fdt if it's loaded above 512M on a evb-rk3036 board,
  * so limit the fdt reallocation to that */
 #define CFG_EXTRA_ENV_SETTINGS \
@@ -30,6 +28,6 @@
"fdt_high=0x7fff\0" \
"partitions=" PARTS_DEFAULT \
ENV_MEM_LAYOUT_SETTINGS \
-   BOOTENV
+   "boot_targets=" BOOT_TARGETS "\0"
 
 #endif
diff --git a/include/configs/rk3066_common.h b/include/configs/rk3066_common.h
index 1a6d3678df3e..d70c8f77d487 100644
--- a/include/configs/rk3066_common.h
+++ b/include/configs/rk3066_common.h
@@ -22,14 +22,12 @@
"kernel_addr_r=0x6200\0" \
"ramdisk_addr_r=0x6400\0"
 
-#include 
-
 #define CFG_EXTRA_ENV_SETTINGS \
"fdt_high=0x6fff\0" \
"initrd_high=0x6fff\0" \
"partitions=" PARTS_DEFAULT \
ENV_MEM_LAYOUT_SETTINGS \
ROCKCHIP_DEVICE_SETTINGS \
-   BOOTENV
+   "boot_targets=" BOOT_TARGETS "\0"
 
 #endif
diff --git a/include/configs/rk3128_common.h b/include/configs/rk3128_common.h
index 8736b14d1015..d8269b0ec96f 100644
--- a/include/configs/rk3128_common.h
+++ b/include/configs/rk3128_common.h
@@ -22,11 +22,10 @@
"kernel_addr_r=0x6200\0" \
"ramdisk_addr_r=0x6400\0"
 
-#include 
 #define CFG_EXTRA_ENV_SETTINGS \
ENV_MEM_LAYOUT_SETTINGS \
"fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \
"partitions=" PARTS_DEFAULT \
-   BOOTENV
+   "boot_targets=" BOOT_TARGETS "\0"
 
 #endif
diff --git a/include/configs/rk3188_common.h b/include/configs/rk3188_common.h
index fcb274565e9e..a8cee1e44d4d 100644
--- a/include/configs/rk3188_common.h
+++ b/include/configs/rk3188_common.h
@@ -21,8 +21,6 @@
"kernel_addr_r=0x6200\0" \
"ramdisk_addr_r=0x6400\0"
 
-#include 
-
 /* Linux fails to load the fdt if it's loaded above 256M on a Rock board,
  * so limit the fdt reallocation to that */
 #define CFG_EXTRA_ENV_SETTINGS \
@@ -32,6 +30,6 @@
"partitions=" PARTS_DEFAULT \
ENV_MEM_LAYOUT_SETTINGS \
ROCKCHIP_DEVICE_SETTINGS \
-   BOOTENV
+   "boot_targets=" BOOT_TARGETS "\0"
 
 #endif
diff --git a/include/configs/rk322x_common.h b/include/configs/rk322x_common.h
index 39a40f4e2d10..15f77df3e17e 100644
--- a/include/configs/rk322x_common.h
+++ b/include/configs/rk322x_common.h
@@ -22,8 +22,6 @@
"kernel_addr_r=0x6200\0" \
"ramdisk_addr_r=0x6400\0"
 
-#include 
-
 /* Linux fails to load the fdt if it's loaded above 512M on a evb-rk3036 board,
  * so limit the fdt reallocation to that */
 #define CFG_EXTRA_ENV_SETTINGS \
@@ -31,6 +29,6 @@
"fdt_high=0x7fff\0" \
"partitions=" PARTS_DEFAULT \
ENV_MEM_LAYOUT_SETTINGS \
-   BOOTENV
+   "boot_targets=" BOOT_TARGETS "\0"
 
 #endif
diff --git a/include/configs/rk3288_common.h b/include/configs/rk3288_common.h
index 71d2426d72a4..3063076a97af 100644
--- a/include/configs/rk3288_common.h
+++ b/include/configs/rk3288_common.h
@@ -23,8 +23,6 @@
"kernel_addr_r=0x0200\0" \
"ramdisk_addr_r=0x0400\0"
 
-#include 
-
 /* Linux fails to load the fdt if it's loaded above 256M on a Rock 2 board, so
  * limit the f

[PATCH v6 04/11] bootstd: Report missing labels only when asked

2023-04-01 Thread Simon Glass
Use the -l flag to indicate whether to report missing uclasses.

Also try to be more helpful when no devices are found. For example, when
we see something 'scsi0' requested and nothing was found, this indicates
that there are no SCSI devices, so show a suitable message.

Move messages out of the low-level functions so that silent operation
is possible.

This means they are never reported unless BOOTSTD_FULL is enabled, since
the -l flag cannot otherwise be set.

Suggested-by: Tom Rini 

Signed-off-by: Simon Glass 
---

Changes in v6:
- Add new patch to report missing labels only when asked

 boot/bootdev-uclass.c | 32 +---
 include/bootdev.h |  2 +-
 test/boot/bootdev.c   | 12 +---
 3 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
index d34b7e37cf79..91087981d213 100644
--- a/boot/bootdev-uclass.c
+++ b/boot/bootdev-uclass.c
@@ -364,7 +364,8 @@ int bootdev_unbind_dev(struct udevice *parent)
  * @seqp: Returns the sequence number, or -1 if none
  * @method_flagsp: If non-NULL, returns any flags implied by the label
  * (enum bootflow_meth_flags_t), 0 if none
- * Returns: sequence number on success, else -ve error code
+ * Returns: sequence number on success, -EPFNOSUPPORT is the uclass is not
+ * known, other -ve error code on other error
  */
 static int label_to_uclass(const char *label, int *seqp, int *method_flagsp)
 {
@@ -394,8 +395,7 @@ static int label_to_uclass(const char *label, int *seqp, 
int *method_flagsp)
id = UCLASS_ETH;
method_flags |= BOOTFLOW_METHF_DHCP_ONLY;
} else {
-   log_warning("Unknown uclass '%s' in label\n", label);
-   return -EINVAL;
+   return -EPFNOSUPPORT;
}
}
if (id == UCLASS_USB)
@@ -458,7 +458,6 @@ int bootdev_find_by_label(const char *label, struct udevice 
**devp,
}
log_debug("- no device in %s\n", media->name);
}
-   log_warning("Unknown seq %d for label '%s'\n", seq, label);
 
return -ENOENT;
 }
@@ -577,9 +576,28 @@ int bootdev_next_label(struct bootflow_iter *iter, struct 
udevice **devp,
 
log_debug("next\n");
for (dev = NULL; !dev && iter->labels[++iter->cur_label];) {
-   log_debug("Scanning: %s\n", iter->labels[iter->cur_label]);
-   bootdev_hunt_and_find_by_label(iter->labels[iter->cur_label],
-  &dev, method_flagsp);
+   const char *label = iter->labels[iter->cur_label];
+   int ret;
+
+   log_debug("Scanning: %s\n", label);
+   ret = bootdev_hunt_and_find_by_label(label, &dev,
+method_flagsp);
+   if (iter->flags & BOOTFLOWIF_SHOW) {
+   if (ret == -EPFNOSUPPORT) {
+   log_warning("Unknown uclass '%s' in label\n",
+   label);
+   } else if (ret == -ENOENT) {
+   /*
+* looking for, e.g. 'scsi0' should find
+* something if SCSI is present
+*/
+   if (!trailing_strtol(label)) {
+   log_warning("No bootdevs for '%s'\n",
+   label);
+   }
+   }
+   }
+
}
 
if (!dev)
diff --git a/include/bootdev.h b/include/bootdev.h
index b92ff4d4f154..e72ef3650f7c 100644
--- a/include/bootdev.h
+++ b/include/bootdev.h
@@ -258,7 +258,7 @@ int bootdev_find_by_label(const char *label, struct udevice 
**devp,
  * @devp: returns the device found, on success
  * @method_flagsp: If non-NULL, returns any flags implied by the label
  * (enum bootflow_meth_flags_t), 0 if none. Unset if function fails
- * Return: 0 if OK, -EINVAL if the uclass is not supported by this board,
+ * Return: 0 if OK, -EPFNOSUPPORT if the uclass is not supported by this board,
  * -ENOENT if there is no device with that number
  */
 int bootdev_find_by_any(const char *name, struct udevice **devp,
diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c
index 4fe9fd722084..0899c78c2c4a 100644
--- a/test/boot/bootdev.c
+++ b/test/boot/bootdev.c
@@ -124,7 +124,8 @@ static int bootdev_test_labels(struct unit_test_state *uts)
mflags);
 
/* Check invalid uclass */
-   ut_asserteq(-EINVAL, bootdev_find_by_label("fred0", &dev, &mflags));
+   ut_asserteq(-EPFNOSUPPORT,
+   bootdev_find_by_label("fred0", &dev, &mflags));
 
/* Check unknown sequence number */
ut_asserteq(-ENOENT, bootdev_find_by_label("mmc6", &dev, &mflags));
@@ -179,9 +180,8 @@ static 

[PATCH v6 03/11] bootstd: Support booting EFI where multiple options exist

2023-04-01 Thread Simon Glass
The current EFI implementation has a strange quirk where it watches
loaded files and uses the last-loaded file to determine the device that
is being booted from.

This is confusing with bootstd, where multiple options may exist. Even
loading a device tree will cause it to go wrong. There is no API for
passing this information, since the only entry into booting an EFI image
is the 'bootefi' command.

To work around this, call efi_set_bootdev() for EFI images, if possible,
just before booting.

Signed-off-by: Simon Glass 
---

(no changes since v5)

Changes in v5:
- Add new patch to support booting EFI where multiple options exist

 boot/bootmeth_efi.c | 26 +++---
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
index d7e042cf01ee..d8bc7fafd127 100644
--- a/boot/bootmeth_efi.c
+++ b/boot/bootmeth_efi.c
@@ -94,7 +94,7 @@ static int get_efi_pxe_vci(char *str, int max_len)
return 0;
 }
 
-static int efiload_read_file(struct blk_desc *desc, struct bootflow *bflow)
+static void set_efi_bootdev(struct blk_desc *desc, struct bootflow *bflow)
 {
const struct udevice *media_dev;
int size = bflow->size;
@@ -102,11 +102,6 @@ static int efiload_read_file(struct blk_desc *desc, struct 
bootflow *bflow)
char devnum_str[9];
char dirname[200];
char *last_slash;
-   int ret;
-
-   ret = bootmeth_alloc_file(bflow, 0x200, 0x1);
-   if (ret)
-   return log_msg_ret("read", ret);
 
/*
 * This is a horrible hack to tell EFI about this boot device. Once we
@@ -117,7 +112,8 @@ static int efiload_read_file(struct blk_desc *desc, struct 
bootflow *bflow)
 * this can go away.
 */
media_dev = dev_get_parent(bflow->dev);
-   snprintf(devnum_str, sizeof(devnum_str), "%x", dev_seq(media_dev));
+   snprintf(devnum_str, sizeof(devnum_str), "%x:%x", dev_seq(media_dev),
+bflow->part);
 
strlcpy(dirname, bflow->fname, sizeof(dirname));
last_slash = strrchr(dirname, '/');
@@ -130,6 +126,15 @@ static int efiload_read_file(struct blk_desc *desc, struct 
bootflow *bflow)
dev_name = device_get_uclass_id(media_dev) == UCLASS_MASS_STORAGE ?
 "usb" : dev_get_uclass_name(media_dev);
efi_set_bootdev(dev_name, devnum_str, bflow->fname, bflow->buf, size);
+}
+
+static int efiload_read_file(struct blk_desc *desc, struct bootflow *bflow)
+{
+   int ret;
+
+   ret = bootmeth_alloc_file(bflow, 0x200, 0x1);
+   if (ret)
+   return log_msg_ret("read", ret);
 
return 0;
 }
@@ -373,6 +378,13 @@ int distro_efi_boot(struct udevice *dev, struct bootflow 
*bflow)
 
/* A non-zero buffer indicates the kernel is there */
if (bflow->buf) {
+   /* Set the EFI bootdev again, since reading an FDT loses it! */
+   if (bflow->blk) {
+   struct blk_desc *desc = dev_get_uclass_plat(bflow->blk);
+
+   set_efi_bootdev(desc, bflow);
+   }
+
kernel = (ulong)map_to_sysmem(bflow->buf);
 
/*
-- 
2.40.0.348.gf938b09366-goog



[PATCH v6 02/11] virtio: Ensure PCI is set up first

2023-04-01 Thread Simon Glass
Sometimes virtio may rely on PCI, or at least that is what the
distro_bootcmd script suggests. Add this in.

Signed-off-by: Simon Glass 
---

(no changes since v5)

Changes in v5:
Add new patch to ensure PCI is set up first

 drivers/virtio/virtio-uclass.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/virtio/virtio-uclass.c b/drivers/virtio/virtio-uclass.c
index de9bc90359ca..918cc15b019f 100644
--- a/drivers/virtio/virtio-uclass.c
+++ b/drivers/virtio/virtio-uclass.c
@@ -373,6 +373,12 @@ static int virtio_bootdev_hunt(struct bootdev_hunter 
*info, bool show)
 {
int ret;
 
+   if (IS_ENABLED(CONFIG_PCI)) {
+   ret = uclass_probe_all(UCLASS_PCI);
+   if (ret && ret != -ENOENT)
+   return log_msg_ret("pci", ret);
+   }
+
ret = uclass_probe_all(UCLASS_VIRTIO);
if (ret && ret != -ENOENT)
return log_msg_ret("vir", ret);
-- 
2.40.0.348.gf938b09366-goog



[PATCH v6 01/11] bootstd: Tweak bootflow logic for device tree

2023-04-01 Thread Simon Glass
We should only store the FDT filename if we were unable to determine one.
Adjust the logic for this.

This corrects the case where no FDT is needed to boot, such as with EFI
using ACPI.

Signed-off-by: Simon Glass 
---

(no changes since v5)

Changes in v5:
- Add new patch to tweak bootflow logic for device tree

 boot/bootmeth_efi.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
index 6a97ac02ff5c..d7e042cf01ee 100644
--- a/boot/bootmeth_efi.c
+++ b/boot/bootmeth_efi.c
@@ -235,21 +235,21 @@ static int distro_efi_read_bootflow_file(struct udevice 
*dev,
 
/* try the various available names */
ret = -ENOENT;
-   for (seq = 0; ret; seq++) {
+   *fname = '\0';
+   for (seq = 0; ret == -ENOENT; seq++) {
ret = distro_efi_get_fdt_name(fname, sizeof(fname), seq);
-   if (ret == -EALREADY) {
+   if (ret == -EALREADY)
bflow->flags = BOOTFLOWF_USE_PRIOR_FDT;
-   break;
-   }
-   if (ret)
-   return log_msg_ret("nam", ret);
-   ret = bootmeth_common_read_file(dev, bflow, fname, fdt_addr,
-   &size);
+   if (!ret)
+   ret = bootmeth_common_read_file(dev, bflow, fname,
+   fdt_addr, &size);
}
 
-   bflow->fdt_fname = strdup(fname);
-   if (!bflow->fdt_fname)
-   return log_msg_ret("fil", -ENOMEM);
+   if (*fname) {
+   bflow->fdt_fname = strdup(fname);
+   if (!bflow->fdt_fname)
+   return log_msg_ret("fil", -ENOMEM);
+   }
 
if (!ret) {
bflow->fdt_size = size;
-- 
2.40.0.348.gf938b09366-goog



Re: [PATCH v2 0/1] meson: Demonstration of using binman to produce the image

2023-04-01 Thread Mark Kettenis
> From: Simon Glass 
> Date: Sun,  2 Apr 2023 06:54:57 +1200
> 
> The Odroid-C2 is quite a complicated image with many steps. It is an ideal
> example for how Binman can be used.

You say Odroid-C2, but the patches seem to address the Odroid-C4...

> Add a binman description and update the instructions accordingly.
> 
> Changes in v2:
> - Rebase to -next
> 
> Simon Glass (1):
>   RFC: Move Odroid-C2 to use binman to produce the image
> 
>  arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi | 107 
>  arch/arm/mach-meson/Kconfig  |   1 +
>  doc/board/amlogic/odroid-c4.rst  | 127 +--
>  tools/binman/etype/aml_encrypt.py| 124 ++
>  tools/binman/ftest.py|   3 +
>  tools/binman/missing-blob-help   |   6 +
>  tools/binman/test/213_aml_encrypt.dts|  38 ++
>  tools/binman/test/214_list_no_dtb.dts|  23 
>  8 files changed, 337 insertions(+), 92 deletions(-)
>  create mode 100644 tools/binman/etype/aml_encrypt.py
>  create mode 100644 tools/binman/test/213_aml_encrypt.dts
>  create mode 100644 tools/binman/test/214_list_no_dtb.dts
> 
> -- 
> 2.40.0.348.gf938b09366-goog
> 
> 


Re: [PATCH] net: ipv6: Add support for default gateway discovery.

2023-04-01 Thread Ramon Fried
On Thu, Mar 2, 2023 at 6:58 PM  wrote:
>
> From: Ehsan Mohandesi 
>
> In IPv6, the default gateway and prefix length are determined by receiving
> a router advertisement as defined in -
> https://www.rfc-editor.org/rfc/rfc4861.
>
> Add support for sending router solicitation (RS) and processing router
> advertisements (RA).
>
> If the RA has prefix info option and following conditions are met, then
> gatewayip6 and net_prefix_length of ip6addr env variables are initialized.
> These are later consumed by IPv6 code for non-local destination IP.
>
> - "Router Lifetime" != 0
> - Prefix is NOT link-local prefix (0xfe80::/10)
> - L flag is 1
> - "Valid Lifetime" != 0
>
> Timing Parameters:
> - MAX_RTR_SOLICITATION_DELAY (0-1s)
> - RTR_SOLICITATION_INTERVAL (4s) (min retransmit delay)
> - MAX_RTR_SOLICITATIONS (3 RS transmissions)
>
> The functionality is enabled by CONFIG_IPV6_ROUTER_DISCOVERY and invoked
> automatically from net_init_loop().
>
> Signed-off-by: Ehsan Mohandesi 
>
> Conflicts:
> cmd/Kconfig
> include/net.h
> net/net.c
> ---
>  cmd/Kconfig |   7 ++
>  include/ndisc.h |  23 ++
>  include/net.h   |   2 +-
>  include/net6.h  |  40 ++
>  net/ndisc.c | 243 
> +---
>  net/net.c   |  23 +-
>  net/net6.c  |   1 +
>  7 files changed, 327 insertions(+), 12 deletions(-)
>
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index 2caa4af..c46613e 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -1894,6 +1894,13 @@ config CMD_NCSI
>   Normally this happens automatically before other network
>   operations.
>
> +config IPV6_ROUTER_DISCOVERY
> +   bool "Do router discovery"
> +   depends on IPV6
> +   help
> + Will automatically perform router solicitation on first IPv6
> + network operation
> +
>  endif
>
>  config CMD_ETHSW
> diff --git a/include/ndisc.h b/include/ndisc.h
> index f6f8eb6..362d707 100644
> --- a/include/ndisc.h
> +++ b/include/ndisc.h
> @@ -19,6 +19,20 @@ struct nd_msg {
> __u8opt[0];
>  };
>
> +/* struct rs_msg - ICMPv6 Router Solicitation message format */
> +struct rs_msg {
> +   struct icmp6hdr icmph;
> +   __u8opt[0];
> +};
> +
> +/* struct ra_msg - ICMPv6 Router Advertisement message format */
> +struct ra_msg {
> +   struct icmp6hdr icmph;
> +   __u32   reachable_time;
> +   __u32   retransmission_timer;
> +   __u8opt[0];
> +};
> +
>  /* struct echo_msg - ICMPv6 echo request/reply message format */
>  struct echo_msg {
> struct icmp6hdr icmph;
> @@ -57,6 +71,11 @@ extern int net_nd_try;
>   */
>  void ndisc_init(void);
>
> +/*
> + * ip6_send_rs() - Send IPv6 Router Solicitation Message
> + */
> +void ip6_send_rs(void);
> +
>  /**
>   * ndisc_receive() - Handle ND packet
>   *
> @@ -97,6 +116,10 @@ static inline int ndisc_timeout_check(void)
>  {
> return 0;
>  }
> +
> +void ip6_send_rs(void)
> +{
> +}
>  #endif
>
>  #endif /* __NDISC_H__ */
> diff --git a/include/net.h b/include/net.h
> index 399af5e..25c43b3 100644
> --- a/include/net.h
> +++ b/include/net.h
> @@ -505,7 +505,7 @@ extern int  net_restart_wrap;   /* Tried all 
> network devices */
>
>  enum proto_t {
> BOOTP, RARP, ARP, TFTPGET, DHCP, PING, PING6, DNS, NFS, CDP, NETCONS,
> -   SNTP, TFTPSRV, TFTPPUT, LINKLOCAL, FASTBOOT, WOL, UDP, NCSI, WGET
> +   SNTP, TFTPSRV, TFTPPUT, LINKLOCAL, FASTBOOT, WOL, UDP, NCSI, WGET, RS
>  };
>
>  extern charnet_boot_file_name[1024];/* Boot File name */
> diff --git a/include/net6.h b/include/net6.h
> index 2d7c5a0..beafc05 100644
> --- a/include/net6.h
> +++ b/include/net6.h
> @@ -81,8 +81,17 @@ struct udp_hdr {
>   0x00, 0x00, 0x00, 0x00, \
>   0x00, 0x00, 0x00, 0x00, \
>   0x00, 0x00, 0x00, 0x00 } } }
> +/*
> + * All-routers multicast address is the link-local scope address to reach all
> + * routers.
> + */
> +#define ALL_ROUTERS_MULT_ADDR { { { 0xFF, 0x02, 0x00, 0x00, \
> + 0x00, 0x00, 0x00, 0x00, \
> + 0x00, 0x00, 0x00, 0x00, \
> + 0x00, 0x00, 0x00, 0x02 } } }
>
>  #define IPV6_LINK_LOCAL_PREFIX 0xfe80
> +#define IPV6_LINK_LOCAL_MASK   0xffb0 /* The first 10-bit of address mask. */
>
>  /* hop limit for neighbour discovery packets */
>  #define IPV6_NDISC_HOPLIMIT 255
> @@ -166,6 +175,37 @@ struct icmp6hdr {
>  #define icmp6_rt_lifetime  icmp6_dataun.u_nd_ra.rt_lifetime
>  } __packed;
>
> +/*
> + * struct icmp6_ra_prefix_info - Prefix Information option of the ICMPv6 
> message
> + * The Prefix Information option provides hosts with on-link prefixes and
> + * prefixes for Address Autoconfiguration. Refer to RFC 4861 for more info.
> + */
> +struct icmp6_ra_prefix_info {
> +   u8  type;   /* Type is 3 for Prefix Information. */
> +   u8  

Re: [PATCH 1/4] net: e1000: add and make use of NUM_RX_DESC macro

2023-04-01 Thread Ramon Fried
On Fri, Mar 3, 2023 at 10:49 PM Christian Gmeiner
 wrote:
>
> The call to DEFINE_ALIGN_BUFFER for the rx_desc array
> conained an icnonsistency as 16 receive descriptors
> were allocated when the remaining code would only use
> 8 of them.
>
> Signed-off-by: Christian Gmeiner 
> ---
>  drivers/net/e1000.c | 6 +++---
>  drivers/net/e1000.h | 2 ++
>  2 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c
> index 41e6ba760e..8dccf29c7e 100644
> --- a/drivers/net/e1000.c
> +++ b/drivers/net/e1000.c
> @@ -60,7 +60,7 @@ tested on both gig copper and gig fiber boards
>   * move these buffers and the tx/rx pointers to struct e1000_hw.
>   */
>  DEFINE_ALIGN_BUFFER(struct e1000_tx_desc, tx_base, 16, E1000_BUFFER_ALIGN);
> -DEFINE_ALIGN_BUFFER(struct e1000_rx_desc, rx_base, 16, E1000_BUFFER_ALIGN);
> +DEFINE_ALIGN_BUFFER(struct e1000_rx_desc, rx_base, NUM_RX_DESC, 
> E1000_BUFFER_ALIGN);
>  DEFINE_ALIGN_BUFFER(unsigned char, packet, 4096, E1000_BUFFER_ALIGN);
>
>  static int tx_tail;
> @@ -5095,7 +5095,7 @@ fill_rx(struct e1000_hw *hw)
>
> rx_last = rx_tail;
> rd = rx_base + rx_tail;
> -   rx_tail = (rx_tail + 1) % 8;
> +   rx_tail = (rx_tail + 1) % NUM_RX_DESC;
> memset(rd, 0, 16);
> rd->buffer_addr = cpu_to_le64(virt_to_phys(packet));
>
> @@ -5272,7 +5272,7 @@ e1000_configure_rx(struct e1000_hw *hw)
> E1000_WRITE_REG(hw, RDBAL, lower_32_bits(virt_to_phys(rx_base)));
> E1000_WRITE_REG(hw, RDBAH, upper_32_bits(virt_to_phys(rx_base)));
>
> -   E1000_WRITE_REG(hw, RDLEN, 128);
> +   E1000_WRITE_REG(hw, RDLEN, NUM_RX_DESC * sizeof(struct 
> e1000_rx_desc));
>
> /* Setup the HW Rx Head and Tail Descriptor Pointers */
> E1000_WRITE_REG(hw, RDH, 0);
> diff --git a/drivers/net/e1000.h b/drivers/net/e1000.h
> index f788394da8..69882ba66f 100644
> --- a/drivers/net/e1000.h
> +++ b/drivers/net/e1000.h
> @@ -42,6 +42,8 @@
>  #define DEBUGOUT(fmt, args...) do { } while (0)
>  #endif
>
> +#define NUM_RX_DESC8
> +
>  /* I/O wrapper functions */
>  #define E1000_WRITE_REG(a, reg, value) \
> writel((value), ((a)->hw_addr + E1000_##reg))
> --
> 2.39.2
>
Reviewed-by: Ramon Fried 


Re: [PATCH 01/41] net: phy: aquantia: Staticize PHY driver entries

2023-04-01 Thread Ramon Fried
On Sun, Mar 19, 2023 at 7:03 PM Marek Vasut
 wrote:
>
> These struct phy_driver ... instances are local to this source code
> file, staticize them. No functional change.
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: "Ariel D'Alessandro" 
> Cc: "Cédric Le Goater" 
> Cc: "Marek Behún" 
> Cc: Alex Nemirovsky 
> Cc: Haolin Li 
> Cc: Heinrich Schuchardt 
> Cc: Joe Hershberger 
> Cc: Joel Stanley 
> Cc: Josua Mayer 
> Cc: Marek Vasut 
> Cc: Michael Trimarchi 
> Cc: Michal Simek 
> Cc: Nate Drude 
> Cc: Neil Armstrong 
> Cc: Radu Pirea 
> Cc: Ramon Fried 
> Cc: Samuel Mendoza-Jonas 
> Cc: Stefan Roese 
> Cc: T Karthik Reddy 
> Cc: Tim Harvey 
> Cc: Vladimir Oltean 
> Cc: u-boot-amlo...@groups.io
> ---
>  drivers/net/phy/aquantia.c | 18 +-
>  1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/phy/aquantia.c b/drivers/net/phy/aquantia.c
> index 8eb6024829d..fa887ade0c2 100644
> --- a/drivers/net/phy/aquantia.c
> +++ b/drivers/net/phy/aquantia.c
> @@ -598,7 +598,7 @@ int aquantia_startup(struct phy_device *phydev)
> return 0;
>  }
>
> -struct phy_driver aq1202_driver = {
> +static struct phy_driver aq1202_driver = {
> .name = "Aquantia AQ1202",
> .uid = 0x3a1b445,
> .mask = 0xfff0,
> @@ -611,7 +611,7 @@ struct phy_driver aq1202_driver = {
> .shutdown = &gen10g_shutdown,
>  };
>
> -struct phy_driver aq2104_driver = {
> +static struct phy_driver aq2104_driver = {
> .name = "Aquantia AQ2104",
> .uid = 0x3a1b460,
> .mask = 0xfff0,
> @@ -624,7 +624,7 @@ struct phy_driver aq2104_driver = {
> .shutdown = &gen10g_shutdown,
>  };
>
> -struct phy_driver aqr105_driver = {
> +static struct phy_driver aqr105_driver = {
> .name = "Aquantia AQR105",
> .uid = 0x3a1b4a2,
> .mask = 0xfff0,
> @@ -638,7 +638,7 @@ struct phy_driver aqr105_driver = {
> .data = AQUANTIA_GEN1,
>  };
>
> -struct phy_driver aqr106_driver = {
> +static struct phy_driver aqr106_driver = {
> .name = "Aquantia AQR106",
> .uid = 0x3a1b4d0,
> .mask = 0xfff0,
> @@ -651,7 +651,7 @@ struct phy_driver aqr106_driver = {
> .shutdown = &gen10g_shutdown,
>  };
>
> -struct phy_driver aqr107_driver = {
> +static struct phy_driver aqr107_driver = {
> .name = "Aquantia AQR107",
> .uid = 0x3a1b4e0,
> .mask = 0xfff0,
> @@ -665,7 +665,7 @@ struct phy_driver aqr107_driver = {
> .data = AQUANTIA_GEN2,
>  };
>
> -struct phy_driver aqr112_driver = {
> +static struct phy_driver aqr112_driver = {
> .name = "Aquantia AQR112",
> .uid = 0x3a1b660,
> .mask = 0xfff0,
> @@ -679,7 +679,7 @@ struct phy_driver aqr112_driver = {
> .data = AQUANTIA_GEN3,
>  };
>
> -struct phy_driver aqr113c_driver = {
> +static struct phy_driver aqr113c_driver = {
> .name = "Aquantia AQR113C",
> .uid = 0x31c31c12,
> .mask = 0xfff0,
> @@ -693,7 +693,7 @@ struct phy_driver aqr113c_driver = {
> .data = AQUANTIA_GEN3,
>  };
>
> -struct phy_driver aqr405_driver = {
> +static struct phy_driver aqr405_driver = {
> .name = "Aquantia AQR405",
> .uid = 0x3a1b4b2,
> .mask = 0xfff0,
> @@ -707,7 +707,7 @@ struct phy_driver aqr405_driver = {
> .data = AQUANTIA_GEN1,
>  };
>
> -struct phy_driver aqr412_driver = {
> +static struct phy_driver aqr412_driver = {
> .name = "Aquantia AQR412",
> .uid = 0x3a1b710,
> .mask = 0xfff0,
> --
> 2.39.2
>
Reviewed-by: Ramon Fried 


Re: [PATCH v2 3/3] net: phy: Synchronize PHY interface modes with Linux

2023-04-01 Thread Ramon Fried
On Tue, Mar 21, 2023 at 7:26 PM Marek Vasut
 wrote:
>
> Synchronize PHY interface modes with Linux next 6.2.y commit:
> 0194b64578e90 ("net: phy: improve phy_read_poll_timeout")
>
> Retain LX2160A/LX2162A PHY modes as those are not yet supported
> by the Linux kernel, but isolate those with ifdeffery.
>
> Isolate NCSI which are also not supported by Linux kernel. Note
> that the ifdeffery cannot be avoided with IS_ENABLED() here due
> to compilation of the entire conditional, which would fail in
> case NCSI symbols are not available.
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: "Ariel D'Alessandro" 
> Cc: "Marek Behún" 
> Cc: Joe Hershberger 
> Cc: Marek Vasut 
> Cc: Ramon Fried 
> Cc: Stefan Roese 
> Cc: Tim Harvey 
> Cc: Vladimir Oltean 
> ---
> V2: No change
> ---
>  drivers/net/phy/phy.c   |  4 +++
>  include/phy_interface.h | 68 +
>  2 files changed, 53 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 9b0e497f223..f720d0a7920 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -1160,7 +1160,11 @@ int phy_clear_bits_mmd(struct phy_device *phydev, int 
> devad, u32 regnum, u16 val
>
>  bool phy_interface_is_ncsi(void)
>  {
> +#ifdef CONFIG_PHY_NCSI
> struct eth_pdata *pdata = dev_get_plat(eth_get_dev());
>
> return pdata->phy_interface == PHY_INTERFACE_MODE_NCSI;
> +#else
> +   return 0;
> +#endif
>  }
> diff --git a/include/phy_interface.h b/include/phy_interface.h
> index 52af7e612b6..31be3228c7c 100644
> --- a/include/phy_interface.h
> +++ b/include/phy_interface.h
> @@ -14,65 +14,95 @@
>
>  typedef enum {
> PHY_INTERFACE_MODE_NA, /* don't touch */
> +   PHY_INTERFACE_MODE_INTERNAL,
> PHY_INTERFACE_MODE_MII,
> PHY_INTERFACE_MODE_GMII,
> PHY_INTERFACE_MODE_SGMII,
> -   PHY_INTERFACE_MODE_SGMII_2500,
> -   PHY_INTERFACE_MODE_QSGMII,
> PHY_INTERFACE_MODE_TBI,
> +   PHY_INTERFACE_MODE_REVMII,
> PHY_INTERFACE_MODE_RMII,
> +   PHY_INTERFACE_MODE_REVRMII,
> PHY_INTERFACE_MODE_RGMII,
> PHY_INTERFACE_MODE_RGMII_ID,
> PHY_INTERFACE_MODE_RGMII_RXID,
> PHY_INTERFACE_MODE_RGMII_TXID,
> PHY_INTERFACE_MODE_RTBI,
> +   PHY_INTERFACE_MODE_SMII,
> +   PHY_INTERFACE_MODE_XGMII,
> +   PHY_INTERFACE_MODE_XLGMII,
> +   PHY_INTERFACE_MODE_MOCA,
> +   PHY_INTERFACE_MODE_QSGMII,
> +   PHY_INTERFACE_MODE_TRGMII,
> +   PHY_INTERFACE_MODE_100BASEX,
> PHY_INTERFACE_MODE_1000BASEX,
> PHY_INTERFACE_MODE_2500BASEX,
> -   PHY_INTERFACE_MODE_XGMII,
> -   PHY_INTERFACE_MODE_XAUI,
> -   PHY_INTERFACE_MODE_RXAUI,
> PHY_INTERFACE_MODE_5GBASER,
> -   PHY_INTERFACE_MODE_SFI,
> -   PHY_INTERFACE_MODE_INTERNAL,
> +   PHY_INTERFACE_MODE_RXAUI,
> +   PHY_INTERFACE_MODE_XAUI,
> +   /* 10GBASE-R, XFI, SFI - single lane 10G Serdes */
> +   PHY_INTERFACE_MODE_10GBASER,
> +   PHY_INTERFACE_MODE_25GBASER,
> +   PHY_INTERFACE_MODE_USXGMII,
> +   /* 10GBASE-KR - with Clause 73 AN */
> +   PHY_INTERFACE_MODE_10GKR,
> +   PHY_INTERFACE_MODE_QUSGMII,
> +   PHY_INTERFACE_MODE_1000BASEKX,
> +#if defined(CONFIG_ARCH_LX2160A) || defined(CONFIG_ARCH_LX2162A)
> +   /* LX2160A SERDES modes */
> PHY_INTERFACE_MODE_25G_AUI,
> PHY_INTERFACE_MODE_XLAUI,
> PHY_INTERFACE_MODE_CAUI2,
> PHY_INTERFACE_MODE_CAUI4,
> +#endif
> +#if defined(CONFIG_PHY_NCSI)
> PHY_INTERFACE_MODE_NCSI,
> -   PHY_INTERFACE_MODE_10GBASER,
> -   PHY_INTERFACE_MODE_USXGMII,
> +#endif
> PHY_INTERFACE_MODE_MAX,
>  } phy_interface_t;
>
>  static const char * const phy_interface_strings[] = {
> -   [PHY_INTERFACE_MODE_NA] = "",
> +   [PHY_INTERFACE_MODE_NA] = "",
> +   [PHY_INTERFACE_MODE_INTERNAL]   = "internal",
> [PHY_INTERFACE_MODE_MII]= "mii",
> [PHY_INTERFACE_MODE_GMII]   = "gmii",
> [PHY_INTERFACE_MODE_SGMII]  = "sgmii",
> -   [PHY_INTERFACE_MODE_SGMII_2500] = "sgmii-2500",
> -   [PHY_INTERFACE_MODE_QSGMII] = "qsgmii",
> [PHY_INTERFACE_MODE_TBI]= "tbi",
> +   [PHY_INTERFACE_MODE_REVMII] = "rev-mii",
> [PHY_INTERFACE_MODE_RMII]   = "rmii",
> +   [PHY_INTERFACE_MODE_REVRMII]= "rev-rmii",
> [PHY_INTERFACE_MODE_RGMII]  = "rgmii",
> [PHY_INTERFACE_MODE_RGMII_ID]   = "rgmii-id",
> [PHY_INTERFACE_MODE_RGMII_RXID] = "rgmii-rxid",
> [PHY_INTERFACE_MODE_RGMII_TXID] = "rgmii-txid",
> [PHY_INTERFACE_MODE_RTBI]   = "rtbi",
> +   [PHY_INTERFACE_MODE_SMII]   = "smii",
> +   [PHY_INTERFACE_MODE_XGMII]  = "xgmii",
> +   [PHY_INTERFACE_MODE_XLGMII] = "xlgmii",
> + 

Re: [PATCH v2 2/3] net: mvpp2: Replace PHY_INTERFACE_MODE_SFI with 5GBASER/10GBASER/XAUI

2023-04-01 Thread Ramon Fried
On Tue, Mar 21, 2023 at 7:26 PM Marek Vasut
 wrote:
>
> Replace PHY_INTERFACE_MODE_SFI with PHY_INTERFACE_MODE_5GBASER,
> PHY_INTERFACE_MODE_10GBASER and PHY_INTERFACE_MODE_XAUI to match
> Linux PHY interface modes.
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: "Ariel D'Alessandro" 
> Cc: "Marek Behún" 
> Cc: Joe Hershberger 
> Cc: Marek Vasut 
> Cc: Ramon Fried 
> Cc: Stefan Roese 
> Cc: Tim Harvey 
> Cc: Vladimir Oltean 
> ---
> V2: No change
> ---
>  drivers/net/mvpp2.c | 8 ++--
>  include/phy_interface.h | 2 ++
>  2 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
> index c99d52c85d7..f407d8f6a81 100644
> --- a/drivers/net/mvpp2.c
> +++ b/drivers/net/mvpp2.c
> @@ -3391,7 +3391,9 @@ static int gop_port_init(struct mvpp2_port *port)
> gop_gmac_reset(port, 0);
> break;
>
> -   case PHY_INTERFACE_MODE_SFI:
> +   case PHY_INTERFACE_MODE_10GBASER:
> +   case PHY_INTERFACE_MODE_5GBASER:
> +   case PHY_INTERFACE_MODE_XAUI:
> num_of_act_lanes = 2;
> mac_num = 0;
> /* configure PCS */
> @@ -3442,7 +3444,9 @@ static void gop_port_enable(struct mvpp2_port *port, 
> int enable)
> mvpp2_port_disable(port);
> break;
>
> -   case PHY_INTERFACE_MODE_SFI:
> +   case PHY_INTERFACE_MODE_10GBASER:
> +   case PHY_INTERFACE_MODE_5GBASER:
> +   case PHY_INTERFACE_MODE_XAUI:
> gop_xlg_mac_port_enable(port, enable);
>
> break;
> diff --git a/include/phy_interface.h b/include/phy_interface.h
> index fed3357b9a2..52af7e612b6 100644
> --- a/include/phy_interface.h
> +++ b/include/phy_interface.h
> @@ -31,6 +31,7 @@ typedef enum {
> PHY_INTERFACE_MODE_XGMII,
> PHY_INTERFACE_MODE_XAUI,
> PHY_INTERFACE_MODE_RXAUI,
> +   PHY_INTERFACE_MODE_5GBASER,
> PHY_INTERFACE_MODE_SFI,
> PHY_INTERFACE_MODE_INTERNAL,
> PHY_INTERFACE_MODE_25G_AUI,
> @@ -62,6 +63,7 @@ static const char * const phy_interface_strings[] = {
> [PHY_INTERFACE_MODE_XGMII]  = "xgmii",
> [PHY_INTERFACE_MODE_XAUI]   = "xaui",
> [PHY_INTERFACE_MODE_RXAUI]  = "rxaui",
> +   [PHY_INTERFACE_MODE_5GBASER]= "5gbase-r",
> [PHY_INTERFACE_MODE_SFI]= "sfi",
> [PHY_INTERFACE_MODE_INTERNAL]   = "internal",
> [PHY_INTERFACE_MODE_25G_AUI]= "25g-aui",
> --
> 2.39.2
>
Reviewed-by: Ramon Fried 


Re: [PATCH] net: rswitch: Add Renesas Ethernet Switch

2023-04-01 Thread Ramon Fried
On Mon, Mar 20, 2023 at 10:05 PM Marek Vasut
 wrote:
>
> From: Phong Hoang 
>
> This patch adds Ethernet Switch support that found on R-Car S4
> (r8a779f0) SoC. This is extracted from multiple patches from
> downstream BSP, with additional rework of the network device
> registration.
>
> Signed-off-by: Hai Pham 
> Signed-off-by: Marek Vasut 
> Signed-off-by: Phong Hoang 
> Signed-off-by: Takeshi Kihara 
> [Marek: Rework the driver to support all ports via subdrivers.
> Split the driver up, add generic PHY framework support.
> Generic code clean ups.]
> ---
> Cc: Hai Pham 
> Cc: Joe Hershberger 
> Cc: Marek Vasut 
> Cc: Peng Fan 
> Cc: Ramon Fried 
> Cc: Simon Glass 
> ---
>  drivers/net/Kconfig   |8 +
>  drivers/net/Makefile  |1 +
>  drivers/net/rswitch.c | 1139 +
>  3 files changed, 1148 insertions(+)
>  create mode 100644 drivers/net/rswitch.c
>
> diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
> index 5c29e63d0be..09039a283eb 100644
> --- a/drivers/net/Kconfig
> +++ b/drivers/net/Kconfig
> @@ -752,6 +752,14 @@ config GMAC_ROCKCHIP
>   This driver provides Rockchip SoCs network support based on the
>   Synopsys Designware driver.
>
> +config RENESAS_ETHER_SWITCH
> +   bool "Renesas Ethernet Switch support"
> +   depends on DM_ETH && R8A779F0
> +   select PHYLIB
> +   help
> + This driver implements support for the Renesas Ethernet Switch
> + which is available on R-Car S4 SoC (r8a779f0).
> +
>  config RENESAS_RAVB
> bool "Renesas Ethernet AVB MAC"
> depends on RCAR_64
> diff --git a/drivers/net/Makefile b/drivers/net/Makefile
> index 75daa5e694c..46a40e2ed9f 100644
> --- a/drivers/net/Makefile
> +++ b/drivers/net/Makefile
> @@ -76,6 +76,7 @@ obj-$(CONFIG_OCTEONTX_SMI) += octeontx/smi.o
>  obj-$(CONFIG_PCH_GBE) += pch_gbe.o
>  obj-$(CONFIG_PCNET) += pcnet.o
>  obj-$(CONFIG_PIC32_ETH) += pic32_mdio.o pic32_eth.o
> +obj-$(CONFIG_RENESAS_ETHER_SWITCH) += rswitch.o
>  obj-$(CONFIG_RENESAS_RAVB) += ravb.o
>  obj-$(CONFIG_RTL8139) += rtl8139.o
>  obj-$(CONFIG_RTL8169) += rtl8169.o
> diff --git a/drivers/net/rswitch.c b/drivers/net/rswitch.c
> new file mode 100644
> index 000..5a69ca1a0f9
> --- /dev/null
> +++ b/drivers/net/rswitch.c
> @@ -0,0 +1,1139 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Driver for Renesas Ethernet RSwitch2 (Ethernet-TSN).
> + *
> + * Copyright (C) 2021 Renesas Electronics Corporation
> + *
> + * Based on the Renesas Ethernet AVB driver.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define RSWITCH_SLEEP_US   1000
> +#define RSWITCH_TIMEOUT_US 100
> +
> +#define RSWITCH_NUM_HW 5
> +
> +#define ETHA_TO_GWCA(i)((i) % 2)
> +#define GWCA_TO_HW_INDEX(i)((i) + 3)
> +#define HW_INDEX_TO_GWCA(i)((i) - 3)
> +
> +#define RSWITCH_MAX_CTAG_PCP   7
> +
> +/* Registers */
> +#define RSWITCH_COMA_OFFSET 0x9000
> +#define RSWITCH_ETHA_OFFSET 0xa000  /* with RMAC */
> +#define RSWITCH_ETHA_SIZE   0x2000  /* with RMAC */
> +#define RSWITCH_GWCA_OFFSET0x0001
> +#define RSWITCH_GWCA_SIZE  0x2000
> +
> +#define FWRO0
> +#define CARORSWITCH_COMA_OFFSET
> +#define GWRO0
> +#define TARO0
> +#define RMRO0x1000
> +
> +enum rswitch_reg {
> +   EAMC= TARO + 0x,
> +   EAMS= TARO + 0x0004,
> +   EATDQDC = TARO + 0x0060,
> +   EATTFC  = TARO + 0x0138,
> +   EATASRIRM   = TARO + 0x03E4,
> +
> +   GWMC= GWRO + 0x,
> +   GWMS= GWRO + 0x0004,
> +   GWMTIRM = GWRO + 0x0100,
> +   GWVCC   = GWRO + 0x0130,
> +   GWTTFC  = GWRO + 0x0138,
> +   GWDCBAC0= GWRO + 0x0194,
> +   GWDCBAC1= GWRO + 0x0198,
> +   GWTRC   = GWRO + 0x0200,
> +   GWARIRM = GWRO + 0x0380,
> +   GWDCC   = GWRO + 0x0400,
> +
> +   RRC = CARO + 0x0004,
> +   RCEC= CARO + 0x0008,
> +   RCDC= CARO + 0x000C,
> +   CABPIRM = CARO + 0x0140,
> +
> +   FWPC0   = FWRO + 0x0100,
> +   FWPBFC  = FWRO + 0x4A00,
> +   FWPBFCSDC   = FWRO + 0x4A04,
> +
> +   MPSM= RMRO + 0x,
> +   MPIC= RMRO + 0x0004,
> +   MRMAC0  = RMRO + 0x0084,
> +   MRMAC1  = RMRO + 0x0088,
> +   MRAFC   = RMRO + 0x008C,
> +   MRSCE   = RMRO + 0x0090,
> +   MRSCP   = RMRO + 0x0094,
> +   MLVC= RMRO + 0x0180,
> +   MLBC= RMRO + 0x0188,
> +   MXGMIIC = RMRO + 0x0190,
> +   MPCH= RMRO + 0x0194,
> +   MANM  

Re: [PATCH v2 1/3] net: mvpp2: Drop PHY_INTERFACE_MODE_SGMII_2500 support

2023-04-01 Thread Ramon Fried
On Tue, Mar 21, 2023 at 7:26 PM Marek Vasut
 wrote:
>
> This mode does not seem to be well defined and used anywhere, remove support 
> for it.
> Based on discussion:
> - 1000baseX does c37 AN of duplex+pause
> - SGMII does AN of duplex+pause+speed, at lower speed bytes are repeated 
> 10x/100x
> - 2500baseX does not do AN, or does very different c73 AN
> - SGMII 2500 behavior is unclear
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: "Ariel D'Alessandro" 
> Cc: "Marek Behún" 
> Cc: Joe Hershberger 
> Cc: Marek Vasut 
> Cc: Ramon Fried 
> Cc: Stefan Roese 
> Cc: Tim Harvey 
> Cc: Vladimir Oltean 
> ---
> V2: Drop SGMII 2500 support, if it becomes required and/or standardized,
> this patch can be reverted
> ---
>  drivers/net/mvpp2.c | 53 -
>  1 file changed, 53 deletions(-)
>
> diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
> index 1bad50d344c..c99d52c85d7 100644
> --- a/drivers/net/mvpp2.c
> +++ b/drivers/net/mvpp2.c
> @@ -2871,7 +2871,6 @@ static void mvpp2_port_mii_set(struct mvpp2_port *port)
>
> switch (port->phy_interface) {
> case PHY_INTERFACE_MODE_SGMII:
> -   case PHY_INTERFACE_MODE_SGMII_2500:
> val |= MVPP2_GMAC_INBAND_AN_MASK;
> break;
> case PHY_INTERFACE_MODE_1000BASEX:
> @@ -2939,7 +2938,6 @@ static void mvpp2_port_loopback_set(struct mvpp2_port 
> *port)
> val &= ~MVPP2_GMAC_GMII_LB_EN_MASK;
>
> if (port->phy_interface == PHY_INTERFACE_MODE_SGMII ||
> -   port->phy_interface == PHY_INTERFACE_MODE_SGMII_2500 ||
> port->phy_interface == PHY_INTERFACE_MODE_1000BASEX ||
> port->phy_interface == PHY_INTERFACE_MODE_2500BASEX)
> val |= MVPP2_GMAC_PCS_LB_EN_MASK;
> @@ -3027,48 +3025,6 @@ static int gop_bypass_clk_cfg(struct mvpp2_port *port, 
> int en)
> return 0;
>  }
>
> -static void gop_gmac_sgmii2_5_cfg(struct mvpp2_port *port)
> -{
> -   u32 val, thresh;
> -
> -   /*
> -* Configure minimal level of the Tx FIFO before the lower part
> -* starts to read a packet
> -*/
> -   thresh = MVPP2_SGMII2_5_TX_FIFO_MIN_TH;
> -   val = readl(port->base + MVPP2_GMAC_PORT_FIFO_CFG_1_REG);
> -   val &= ~MVPP2_GMAC_TX_FIFO_MIN_TH_ALL_MASK;
> -   val |= MVPP2_GMAC_TX_FIFO_MIN_TH_MASK(thresh);
> -   writel(val, port->base + MVPP2_GMAC_PORT_FIFO_CFG_1_REG);
> -
> -   /* Disable bypass of sync module */
> -   val = readl(port->base + MVPP2_GMAC_CTRL_4_REG);
> -   val |= MVPP2_GMAC_CTRL4_SYNC_BYPASS_MASK;
> -   /* configure DP clock select according to mode */
> -   val |= MVPP2_GMAC_CTRL4_DP_CLK_SEL_MASK;
> -   /* configure QSGMII bypass according to mode */
> -   val |= MVPP2_GMAC_CTRL4_QSGMII_BYPASS_ACTIVE_MASK;
> -   writel(val, port->base + MVPP2_GMAC_CTRL_4_REG);
> -
> -   val = readl(port->base + MVPP2_GMAC_CTRL_0_REG);
> -   /*
> -* Configure GIG MAC to SGMII mode connected to a fiber
> -* transceiver
> -*/
> -   val &= ~MVPP2_GMAC_PORT_TYPE_MASK;
> -   writel(val, port->base + MVPP2_GMAC_CTRL_0_REG);
> -
> -   /* configure AN 0x9268 */
> -   val = MVPP2_GMAC_EN_PCS_AN |
> -   MVPP2_GMAC_AN_BYPASS_EN |
> -   MVPP2_GMAC_CONFIG_MII_SPEED  |
> -   MVPP2_GMAC_CONFIG_GMII_SPEED |
> -   MVPP2_GMAC_FC_ADV_EN|
> -   MVPP2_GMAC_CONFIG_FULL_DUPLEX |
> -   MVPP2_GMAC_CHOOSE_SAMPLE_TX_CONFIG;
> -   writel(val, port->base + MVPP2_GMAC_AUTONEG_CONFIG);
> -}
> -
>  static void gop_gmac_sgmii_cfg(struct mvpp2_port *port)
>  {
> u32 val, thresh;
> @@ -3239,9 +3195,6 @@ static int gop_gmac_mode_cfg(struct mvpp2_port *port)
> case PHY_INTERFACE_MODE_SGMII:
> gop_gmac_sgmii_cfg(port);
> break;
> -   case PHY_INTERFACE_MODE_SGMII_2500:
> -   gop_gmac_sgmii2_5_cfg(port);
> -   break;
> case PHY_INTERFACE_MODE_1000BASEX:
> gop_gmac_1000basex_cfg(port);
> break;
> @@ -3422,7 +3375,6 @@ static int gop_port_init(struct mvpp2_port *port)
> break;
>
> case PHY_INTERFACE_MODE_SGMII:
> -   case PHY_INTERFACE_MODE_SGMII_2500:
> case PHY_INTERFACE_MODE_1000BASEX:
> case PHY_INTERFACE_MODE_2500BASEX:
> /* configure PCS */
> @@ -3482,7 +3434,6 @@ static void gop_port_enable(struct mvpp2_port *port, 
> int enable)
> case PHY_INTERFACE_MODE_RGMII:
> case PHY_INTERFACE_MODE_RGMII_ID:
> case PHY_INTERFACE_MODE_SGMII:
> -   case PHY_INTERFACE_MODE_SGMII_2500:
> case PHY_INTERFACE_MODE_1000BASEX:
> case PHY_INTERFACE_MODE_2500BASEX:
> if (enable)
> @@ -3519,7 +3470,6 @@ static u32 mvpp2_netc_cfg_create(int gop_id, 
> phy_interface_t phy_type)
>
> if (gop_id == 2) {
> if (phy_type == PHY_INT

[PATCH v2 1/1] RFC: Move Odroid-C2 to use binman to produce the image

2023-04-01 Thread Simon Glass
This shows how binman can be used to replace the long and complicated
instructions with an automated build. It is still complicated to read
but users don't have to worry about the details.

It needs some tidying up and only supports Odroid-C2 at present.

Signed-off-by: Simon Glass 
---

Changes in v2:
- Rebase to -next

 arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi | 107 
 arch/arm/mach-meson/Kconfig  |   1 +
 doc/board/amlogic/odroid-c4.rst  | 127 +--
 tools/binman/etype/aml_encrypt.py| 124 ++
 tools/binman/ftest.py|   3 +
 tools/binman/missing-blob-help   |   6 +
 tools/binman/test/213_aml_encrypt.dts|  38 ++
 tools/binman/test/214_list_no_dtb.dts|  23 
 8 files changed, 337 insertions(+), 92 deletions(-)
 create mode 100644 tools/binman/etype/aml_encrypt.py
 create mode 100644 tools/binman/test/213_aml_encrypt.dts
 create mode 100644 tools/binman/test/214_list_no_dtb.dts

diff --git a/arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi 
b/arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi
index 963bf96b2567..b221ce6920b0 100644
--- a/arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi
+++ b/arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi
@@ -6,6 +6,113 @@
 
 #include "meson-sm1-u-boot.dtsi"
 
+/{
+   binman {
+   /* run --bootmk on all the included inputs */
+   aml-encrypt {
+   missing-msg = "aml-encrypt";
+   aml-algo = "g12a";
+   aml-op = "bootmk";
+   aml-level = "v3";
+
+   /* produce a bl2, containing signed bl2 binaries */
+   bl2 {
+   type = "aml-encrypt";
+   aml-algo = "g12a";
+   aml-op = "bl2sig";
+
+   /* sign the binary contaiing bl2 and acs */
+   aml-input {
+   type = "section";
+   bl2 {
+   type = "blob-ext";
+   size = <0xe000>;
+   filename = "bl2.bin";
+   };
+   acs {
+   type = "blob-ext";
+   size = <0x1000>;
+   filename = "acs.bin";
+   };
+   };
+   };
+
+   /* produce a bl30, containing signed bl30 binaries */
+   bl30 {
+   type = "aml-encrypt";
+   aml-algo = "g12a";
+   aml-op = "bl3sig";
+   aml-level = "v3";
+   aml-type = "bl30";
+
+   /* sign the binary contaiing bl30 and bl301 */
+   aml-input {
+   type = "aml-encrypt";
+   aml-algo = "g12a";
+   aml-op = "bl30sig";
+   aml-level = "v3";
+
+   /*
+* put bl30 and bl301 together, with
+* the necessary paddiung
+*/
+   aml-input {
+   type = "section";
+   bl30 {
+   type = "blob-ext";
+   size = <0xa000>;
+   filename = "bl30.bin";
+   };
+   bl301 {
+   type = "blob-ext";
+   size = <0x3400>;
+   filename = "bl301.bin";
+   };
+   };
+   };
+   };
+
+   /* sign the bl31 binary */
+   bl31 {
+   type = "aml-encrypt";
+   aml-algo = "g12a";
+   aml-op = "bl3sig";
+   aml-input = "bl31.img";
+   aml-level = "v3";
+   aml-type = "bl31";
+   

[PATCH v2 0/1] meson: Demonstration of using binman to produce the image

2023-04-01 Thread Simon Glass
The Odroid-C2 is quite a complicated image with many steps. It is an ideal
example for how Binman can be used.

Add a binman description and update the instructions accordingly.

Changes in v2:
- Rebase to -next

Simon Glass (1):
  RFC: Move Odroid-C2 to use binman to produce the image

 arch/arm/dts/meson-sm1-odroid-c4-u-boot.dtsi | 107 
 arch/arm/mach-meson/Kconfig  |   1 +
 doc/board/amlogic/odroid-c4.rst  | 127 +--
 tools/binman/etype/aml_encrypt.py| 124 ++
 tools/binman/ftest.py|   3 +
 tools/binman/missing-blob-help   |   6 +
 tools/binman/test/213_aml_encrypt.dts|  38 ++
 tools/binman/test/214_list_no_dtb.dts|  23 
 8 files changed, 337 insertions(+), 92 deletions(-)
 create mode 100644 tools/binman/etype/aml_encrypt.py
 create mode 100644 tools/binman/test/213_aml_encrypt.dts
 create mode 100644 tools/binman/test/214_list_no_dtb.dts

-- 
2.40.0.348.gf938b09366-goog



Re: [PATCH 3/3] net: share fastboot boot handle logic between transports

2023-04-01 Thread Ramon Fried
On Sat, Apr 1, 2023 at 9:36 AM Simon Glass  wrote:
>
> On Wed, 29 Mar 2023 at 09:31, Dmitrii Merkurev  wrote:
> >
> > Introduce reboot, boot and continue commands support to
> > TCP fastboot by moving existing UDP logic into the common module.
> >
> > Cc: Ying-Chun Liu (PaulLiu) 
> > Cc: Simon Glass 
> > Сс: Joe Hershberger 
> > Сс: Ramon Fried 
> > Signed-off-by: Dmitrii Merkurev 
> > ---
> >
> >  drivers/fastboot/fb_common.c | 32 
> >  include/fastboot.h   |  9 +
> >  net/fastboot_tcp.c   |  5 -
> >  net/fastboot_udp.c   | 29 +
> >  4 files changed, 46 insertions(+), 29 deletions(-)
>
> Reviewed-by: Simon Glass 
Reviewed-by: Ramon Fried 


Re: [PATCH 1/3] net: support being a TCP server to unblock TCP fastboot

2023-04-01 Thread Ramon Fried
On Sat, Apr 1, 2023 at 9:36 AM Simon Glass  wrote:
>
> On Wed, 29 Mar 2023 at 09:31, Dmitrii Merkurev  wrote:
> >
> > Make following changes to unblock TCP fastboot support:
> >
> > 1. Implement being a TCP server support
> > 2. Introduce dedicated TCP traffic handler (get rid of UDP signature)
> > 3. Ensure seq_num and ack_num are respected in net_send_tcp_packet
> > function (make sure existing wget_cmd code is reflected with the fix)
> >
> > Signed-off-by: Dmitrii Merkurev 
> > Cc: Ying-Chun Liu (PaulLiu) 
> > Cc: Simon Glass 
> > Сс: Joe Hershberger 
> > Сс: Ramon Fried 
> > ---
> >
> >  include/net/tcp.h |  16 +--
> >  net/tcp.c | 115 +++---
> >  net/wget.c|  43 -
> >  3 files changed, 90 insertions(+), 84 deletions(-)
> >
> Reviewed-by: Simon Glass 
Reviewed-by: Ramon Fried 


Re: [PATCH 1/1] net: replace /* Fall through */

2023-04-01 Thread Ramon Fried
On Sat, Apr 1, 2023 at 10:30 AM Heinrich Schuchardt
 wrote:
>
> gcc 12 does not understand /* Fall through */.
> Use the fallthrough macro instead.
>
> Fallthrough at the start of a switch statement makes no sense.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  net/net.c | 9 -
>  1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/net/net.c b/net/net.c
> index c9a749f6cc..b3199572b7 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -1435,7 +1435,6 @@ void net_process_received_packet(uchar *in_packet, int 
> len)
>  static int net_check_prereq(enum proto_t protocol)
>  {
> switch (protocol) {
> -   /* Fall through */
>  #if defined(CONFIG_CMD_PING)
> case PING:
> if (net_ping_ip.s_addr == 0) {
> @@ -1470,7 +1469,7 @@ static int net_check_prereq(enum proto_t protocol)
>  #if defined(CONFIG_CMD_NFS)
> case NFS:
>  #endif
> -   /* Fall through */
> +   fallthrough;
> case TFTPGET:
> case TFTPPUT:
> if (IS_ENABLED(CONFIG_IPV6) && use_ip6) {
> @@ -1484,11 +1483,11 @@ static int net_check_prereq(enum proto_t protocol)
> puts("*** ERROR: `serverip' not set\n");
> return 1;
> }
> +   fallthrough;
>  #ifdefined(CONFIG_CMD_PING) || \
> defined(CONFIG_CMD_DNS) || defined(CONFIG_PROT_UDP)
>  common:
>  #endif
> -   /* Fall through */
>
> case NETCONS:
> case FASTBOOT:
> @@ -1503,7 +1502,7 @@ common:
> puts("*** ERROR: `ipaddr' not set\n");
> return 1;
> }
> -   /* Fall through */
> +   fallthrough;
>
>  #ifdef CONFIG_CMD_RARP
> case RARP:
> @@ -1534,7 +1533,7 @@ common:
> net_start_again();
> return 2;
> }
> -   /* Fall through */
> +   fallthrough;
> default:
> return 0;
> }
> --
> 2.39.2
>
Reviewed-by: Ramon Fried 
BTW, where is the fallthrough macro defined ?


Re: [PATCH 5/5] net: phy: marvell10g: Adapt Marvell 10G PHY driver from Linux

2023-04-01 Thread Ramon Fried
On Sun, Mar 19, 2023 at 7:08 PM Marek Vasut
 wrote:
>
> Pull Marvell 10G PHY driver from Linux 6.1.y as of commit
> d6d29292640d3 ("net: phy: marvell10g: select host interface configuration")
> and heavily adapt to match U-Boot PHY framework. Support for
> hwmon is removed as is much other functionality which could
> not be tested, this results in much simpler driver which can
> only bring the PHY up and set MAC type.
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: "Ariel D'Alessandro" 
> Cc: "Marek Behún" 
> Cc: Joe Hershberger 
> Cc: Marek Vasut 
> Cc: Michael Trimarchi 
> Cc: Nate Drude 
> Cc: Ramon Fried 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: Tim Harvey 
> Cc: Vladimir Oltean 
> ---
>  drivers/net/phy/Kconfig  |   5 +
>  drivers/net/phy/Makefile |   1 +
>  drivers/net/phy/marvell10g.c | 605 +++
>  3 files changed, 611 insertions(+)
>  create mode 100644 drivers/net/phy/marvell10g.c
>
> diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
> index 6806e3c0903..24158776f52 100644
> --- a/drivers/net/phy/Kconfig
> +++ b/drivers/net/phy/Kconfig
> @@ -174,6 +174,11 @@ config PHY_LXT
>  config PHY_MARVELL
> bool "Marvell Ethernet PHYs support"
>
> +config PHY_MARVELL_10G
> +   bool "Marvell Alaska 10Gbit PHYs"
> +   help
> + Support for the Marvell Alaska MV88X3310 and compatible PHYs.
> +
>  config PHY_MESON_GXL
> bool "Amlogic Meson GXL Internal PHY support"
>
> diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
> index 963d96e2bcb..85d17f109cd 100644
> --- a/drivers/net/phy/Makefile
> +++ b/drivers/net/phy/Makefile
> @@ -20,6 +20,7 @@ obj-$(CONFIG_PHY_DAVICOM) += davicom.o
>  obj-$(CONFIG_PHY_ET1011C) += et1011c.o
>  obj-$(CONFIG_PHY_LXT) += lxt.o
>  obj-$(CONFIG_PHY_MARVELL) += marvell.o
> +obj-$(CONFIG_PHY_MARVELL_10G) += marvell10g.o
>  obj-$(CONFIG_PHY_MICREL_KSZ8XXX) += micrel_ksz8xxx.o
>  obj-$(CONFIG_PHY_MICREL_KSZ90X1) += micrel_ksz90x1.o
>  obj-$(CONFIG_PHY_MESON_GXL) += meson-gxl.o
> diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c
> new file mode 100644
> index 000..9e64672f5ca
> --- /dev/null
> +++ b/drivers/net/phy/marvell10g.c
> @@ -0,0 +1,605 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Marvell 10G 88x3310 PHY driver
> + *
> + * Based upon the ID registers, this PHY appears to be a mixture of IPs
> + * from two different companies.
> + *
> + * There appears to be several different data paths through the PHY which
> + * are automatically managed by the PHY.  The following has been determined
> + * via observation and experimentation for a setup using single-lane Serdes:
> + *
> + *   SGMII PHYXS -- BASE-T PCS -- 10G PMA -- AN -- Copper (for <= 1G)
> + *  10GBASE-KR PHYXS -- BASE-T PCS -- 10G PMA -- AN -- Copper (for 10G)
> + *  10GBASE-KR PHYXS -- BASE-R PCS -- Fiber
> + *
> + * With XAUI, observation shows:
> + *
> + *XAUI PHYXS -- 
> + *
> + * and no switching of the host interface mode occurs.
> + *
> + * If both the fiber and copper ports are connected, the first to gain
> + * link takes priority and the other port is completely locked out.
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define MV_PHY_ALASKA_NBT_QUIRK_MASK   0xfffe
> +#define MV_PHY_ALASKA_NBT_QUIRK_REV(MARVELL_PHY_ID_88X3310 | 0xa)
> +
> +#define MV_VERSION(a, b, c, d) ((a) << 24 | (b) << 16 | (c) << 8 | (d))
> +
> +enum {
> +   MV_PMA_FW_VER0  = 0xc011,
> +   MV_PMA_FW_VER1  = 0xc012,
> +   MV_PMA_21X0_PORT_CTRL   = 0xc04a,
> +   MV_PMA_21X0_PORT_CTRL_SWRST = BIT(15),
> +   MV_PMA_21X0_PORT_CTRL_MACTYPE_MASK  = 0x7,
> +   MV_PMA_21X0_PORT_CTRL_MACTYPE_USXGMII   = 0x0,
> +   MV_PMA_2180_PORT_CTRL_MACTYPE_DXGMII= 0x1,
> +   MV_PMA_2180_PORT_CTRL_MACTYPE_QXGMII= 0x2,
> +   MV_PMA_21X0_PORT_CTRL_MACTYPE_5GBASER   = 0x4,
> +   MV_PMA_21X0_PORT_CTRL_MACTYPE_5GBASER_NO_SGMII_AN   = 0x5,
> +   MV_PMA_21X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH   = 0x6,
> +   MV_PMA_BOOT = 0xc050,
> +   MV_PMA_BOOT_FATAL   = BIT(0),
> +
> +   MV_PCS_BASE_T   = 0x,
> +   MV_PCS_BASE_R   = 0x1000,
> +   MV_PCS_1000BASEX= 0x2000,
> +
> +   MV_PCS_CSCR1= 0x8000,
> +   MV_PCS_CSCR1_ED_MASK= 0x0300,
> +   MV_PCS_CSCR1_ED_OFF = 0x,
> +   MV_PCS_CSCR1_ED_RX  = 0x0200,
> +   MV_PCS_CSCR1_ED_NLP = 0x0300,
> +   MV_PCS_CSCR1_MDIX_MASK  = 0x0060,
> +   MV_PCS_CSCR1_MDIX_MDI   = 0x,
> +   MV_PCS_CSCR1_MDIX_MDIX  = 0x0020,
> +   MV_PCS_CSCR1_MDIX_AUTO  = 0x0060,
> +
> +   MV_PCS_DSC1 = 0x8003,
> +   MV_PCS_DSC1_ENABLE  = BIT(9),
> +   M

Re: [PATCH 4/5] net: phy: Add MDIO PCS 2.5G and 5G speed macros from Linux

2023-04-01 Thread Ramon Fried
On Sun, Mar 19, 2023 at 7:08 PM Marek Vasut
 wrote:
>
> Add MDIO PCS 2.5G and 5G speed macros from Linux 5.1.y as of commit
> 7fd8afa8933a0 ("net: phy: Add generic support for 2.5GBaseT and 5GBaseT")
> This is used by the upcoming Marvell 10G PHY driver.
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: "Ariel D'Alessandro" 
> Cc: "Marek Behún" 
> Cc: Joe Hershberger 
> Cc: Marek Vasut 
> Cc: Michael Trimarchi 
> Cc: Nate Drude 
> Cc: Ramon Fried 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: Tim Harvey 
> Cc: Vladimir Oltean 
> ---
>  include/linux/mdio.h | 18 ++
>  1 file changed, 18 insertions(+)
>
> diff --git a/include/linux/mdio.h b/include/linux/mdio.h
> index 6e821d906fb..b7c845155e4 100644
> --- a/include/linux/mdio.h
> +++ b/include/linux/mdio.h
> @@ -44,6 +44,7 @@
>  #define MDIO_AN_ADVERTISE  16  /* AN advertising (base page) */
>  #define MDIO_AN_LPA19  /* AN LP abilities (base page) */
>  #define MDIO_PCS_EEE_ABLE  20  /* EEE Capability register */
> +#define MDIO_PMA_NG_EXTABLE21  /* 2.5G/5G PMA/PMD extended ability */
>  #define MDIO_PCS_EEE_WK_ERR22  /* EEE wake error counter */
>  #define MDIO_PHYXS_LNSTAT  24  /* PHY XGXS lane state */
>  #define MDIO_AN_EEE_ADV60  /* EEE advertisement */
> @@ -91,6 +92,10 @@
>  #define MDIO_CTRL1_SPEED10G(MDIO_CTRL1_SPEEDSELEXT | 0x00)
>  /* 10PASS-TS/2BASE-TL */
>  #define MDIO_CTRL1_SPEED10P2B  (MDIO_CTRL1_SPEEDSELEXT | 0x04)
> +/* 2.5 Gb/s */
> +#define MDIO_CTRL1_SPEED2_5G   (MDIO_CTRL1_SPEEDSELEXT | 0x18)
> +/* 5 Gb/s */
> +#define MDIO_CTRL1_SPEED5G (MDIO_CTRL1_SPEEDSELEXT | 0x1c)
>
>  /* Status register 1. */
>  #define MDIO_STAT1_LPOWERABLE  0x0002  /* Low-power ability */
> @@ -111,6 +116,8 @@
>  #define MDIO_PMA_SPEED_100 0x0020  /* 100M capable */
>  #define MDIO_PMA_SPEED_10  0x0040  /* 10M capable */
>  #define MDIO_PCS_SPEED_10P2B   0x0002  /* 10PASS-TS/2BASE-TL capable 
> */
> +#define MDIO_PCS_SPEED_2_5G0x0040  /* 2.5G capable */
> +#define MDIO_PCS_SPEED_5G  0x0080  /* 5G capable */
>
>  /* Device present registers. */
>  #define MDIO_DEVS_PRESENT(devad)   (1 << (devad))
> @@ -150,6 +157,8 @@
>  #define MDIO_PMA_CTRL2_1000BKX 0x000d  /* 1000BASE-KX type */
>  #define MDIO_PMA_CTRL2_100BTX  0x000e  /* 100BASE-TX type */
>  #define MDIO_PMA_CTRL2_10BT0x000f  /* 10BASE-T type */
> +#define MDIO_PMA_CTRL2_2_5GBT  0x0030  /* 2.5GBaseT type */
> +#define MDIO_PMA_CTRL2_5GBT0x0031  /* 5GBaseT type */
>  #define MDIO_PCS_CTRL2_TYPE0x0003  /* PCS type selection */
>  #define MDIO_PCS_CTRL2_10GBR   0x  /* 10GBASE-R type */
>  #define MDIO_PCS_CTRL2_10GBX   0x0001  /* 10GBASE-X type */
> @@ -203,6 +212,7 @@
>  #define MDIO_PMA_EXTABLE_1000BKX   0x0040  /* 1000BASE-KX ability */
>  #define MDIO_PMA_EXTABLE_100BTX0x0080  /* 100BASE-TX ability 
> */
>  #define MDIO_PMA_EXTABLE_10BT  0x0100  /* 10BASE-T ability */
> +#define MDIO_PMA_EXTABLE_NBT   0x4000  /* 2.5/5GBASE-T ability */
>
>  /* PHY XGXS lane state register. */
>  #define MDIO_PHYXS_LNSTAT_SYNC00x0001
> @@ -239,9 +249,13 @@
>  #define MDIO_PCS_10GBRT_STAT2_BER  0x3f00
>
>  /* AN 10GBASE-T control register. */
> +#define MDIO_AN_10GBT_CTRL_ADV2_5G 0x0080  /* Advertise 2.5GBASE-T */
> +#define MDIO_AN_10GBT_CTRL_ADV5G   0x0100  /* Advertise 5GBASE-T */
>  #define MDIO_AN_10GBT_CTRL_ADV10G  0x1000  /* Advertise 10GBASE-T */
>
>  /* AN 10GBASE-T status register. */
> +#define MDIO_AN_10GBT_STAT_LP2_5G  0x0020  /* LP is 2.5GBT capable */
> +#define MDIO_AN_10GBT_STAT_LP5G0x0040  /* LP is 5GBT capable 
> */
>  #define MDIO_AN_10GBT_STAT_LPTRR   0x0200  /* LP training reset req. */
>  #define MDIO_AN_10GBT_STAT_LPLTABLE0x0400  /* LP loop timing ability */
>  #define MDIO_AN_10GBT_STAT_LP10G   0x0800  /* LP is 10GBT capable */
> @@ -270,6 +284,10 @@
>  #define MDIO_EEE_10GKX40x0020  /* 10G KX4 EEE cap */
>  #define MDIO_EEE_10GKR 0x0040  /* 10G KR EEE cap */
>
> +/* 2.5G/5G Extended abilities register. */
> +#define MDIO_PMA_NG_EXTABLE_2_5GBT 0x0001  /* 2.5GBASET ability */
> +#define MDIO_PMA_NG_EXTABLE_5GBT   0x0002  /* 5GBASET ability */
> +
>  /* LASI RX_ALARM control/status registers. */
>  #define MDIO_PMA_LASI_RX_PHYXSLFLT 0x0001  /* PHY XS RX local fault */
>  #define MDIO_PMA_LASI_RX_PCSLFLT   0x0008  /* PCS RX local fault */
> --
> 2.39.2
>
Reviewed-by: Ramon Fried 


Re: [PATCH 3/5] net: phy: Add phy_read_mmd_poll_timeout() from Linux

2023-04-01 Thread Ramon Fried
On Sun, Mar 19, 2023 at 7:08 PM Marek Vasut
 wrote:
>
> Add phy_read_mmd_poll_timeout() from Linux 5.7.y as of commit
> bd971ff0b7392 ("net: phy: introduce phy_read_mmd_poll_timeout macro")
> This is used by the upcoming Marvell 10G PHY driver.
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: "Ariel D'Alessandro" 
> Cc: "Marek Behún" 
> Cc: Joe Hershberger 
> Cc: Marek Vasut 
> Cc: Michael Trimarchi 
> Cc: Nate Drude 
> Cc: Ramon Fried 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: Tim Harvey 
> Cc: Vladimir Oltean 
> ---
>  include/phy.h | 31 +++
>  1 file changed, 31 insertions(+)
>
> diff --git a/include/phy.h b/include/phy.h
> index 34675b2c9c0..a837fed7235 100644
> --- a/include/phy.h
> +++ b/include/phy.h
> @@ -282,6 +282,37 @@ static inline ofnode phy_get_ofnode(struct phy_device 
> *phydev)
> return dev_ofnode(phydev->dev);
>  }
>
> +/**
> + * phy_read_mmd_poll_timeout - Periodically poll a PHY register until a
> + * condition is met or a timeout occurs
> + *
> + * @phydev: The phy_device struct
> + * @devaddr: The MMD to read from
> + * @regnum: The register on the MMD to read
> + * @val: Variable to read the register into
> + * @cond: Break condition (usually involving @val)
> + * @sleep_us: Maximum time to sleep between reads in us (0
> + *tight-loops).  Should be less than ~20ms since usleep_range
> + *is used (see Documentation/timers/timers-howto.rst).
> + * @timeout_us: Timeout in us, 0 means never timeout
> + * @sleep_before_read: if it is true, sleep @sleep_us before read.
> + * Returns 0 on success and -ETIMEDOUT upon a timeout. In either
> + * case, the last read value at @args is stored in @val. Must not
> + * be called from atomic context if sleep_us or timeout_us are used.
> + */
> +#define phy_read_mmd_poll_timeout(phydev, devaddr, regnum, val, cond, \
> + sleep_us, timeout_us, sleep_before_read) \
> +({ \
> +   int __ret = read_poll_timeout(phy_read_mmd, val, (cond) || val < 0, \
> + sleep_us, timeout_us, \
> + phydev, devaddr, regnum); \
> +   if (val <  0) \
> +   __ret = val; \
> +   if (__ret) \
> +   dev_err(phydev->dev, "%s failed: %d\n", __func__, __ret); \
> +   __ret; \
> +})
> +
>  int phy_read(struct phy_device *phydev, int devad, int regnum);
>  int phy_write(struct phy_device *phydev, int devad, int regnum, u16 val);
>  void phy_mmd_start_indirect(struct phy_device *phydev, int devad, int 
> regnum);
> --
> 2.39.2
>
Reviewed-by: Ramon Fried 


Re: [PATCH 2/5] net: phy: Add phy_modify_mmd() and phy_modify_mmd_changed() from Linux

2023-04-01 Thread Ramon Fried
On Sun, Mar 19, 2023 at 7:08 PM Marek Vasut
 wrote:
>
> Add phy_modify_mmd()/phy_modify_mmd_changed() from Linux 5.1.y as of commit
> b8554d4f7288f ("net: phy: add register modifying helpers returning 1 on 
> change")
> This is used by the upcoming Marvell 10G PHY driver.
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: "Ariel D'Alessandro" 
> Cc: "Marek Behún" 
> Cc: Joe Hershberger 
> Cc: Marek Vasut 
> Cc: Michael Trimarchi 
> Cc: Nate Drude 
> Cc: Ramon Fried 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: Tim Harvey 
> Cc: Vladimir Oltean 
> ---
>  drivers/net/phy/phy.c | 54 +++
>  include/phy.h |  4 
>  2 files changed, 58 insertions(+)
>
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index f720d0a7920..0eeb0cb3a85 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -1158,6 +1158,60 @@ int phy_clear_bits_mmd(struct phy_device *phydev, int 
> devad, u32 regnum, u16 val
> return 0;
>  }
>
> +/**
> + * phy_modify_mmd_changed - Function for modifying a register on MMD
> + * @phydev: the phy_device struct
> + * @devad: the MMD containing register to modify
> + * @regnum: register number to modify
> + * @mask: bit mask of bits to clear
> + * @set: new value of bits set in mask to write to @regnum
> + *
> + * NOTE: MUST NOT be called from interrupt context,
> + * because the bus read/write functions may wait for an interrupt
> + * to conclude the operation.
> + *
> + * Returns negative errno, 0 if there was no change, and 1 in case of change
> + */
> +int phy_modify_mmd_changed(struct phy_device *phydev, int devad, u32 regnum,
> +  u16 mask, u16 set)
> +{
> +   int new, ret;
> +
> +   ret = phy_read_mmd(phydev, devad, regnum);
> +   if (ret < 0)
> +   return ret;
> +
> +   new = (ret & ~mask) | set;
> +   if (new == ret)
> +   return 0;
> +
> +   ret = phy_write_mmd(phydev, devad, regnum, new);
> +
> +   return ret < 0 ? ret : 1;
> +}
> +
> +/**
> + * phy_modify_mmd - Convenience function for modifying a register on MMD
> + * @phydev: the phy_device struct
> + * @devad: the MMD containing register to modify
> + * @regnum: register number to modify
> + * @mask: bit mask of bits to clear
> + * @set: new value of bits set in mask to write to @regnum
> + *
> + * NOTE: MUST NOT be called from interrupt context,
> + * because the bus read/write functions may wait for an interrupt
> + * to conclude the operation.
> + */
> +int phy_modify_mmd(struct phy_device *phydev, int devad, u32 regnum,
> +  u16 mask, u16 set)
> +{
> +   int ret;
> +
> +   ret = phy_modify_mmd_changed(phydev, devad, regnum, mask, set);
> +
> +   return ret < 0 ? ret : 0;
> +}
> +
>  bool phy_interface_is_ncsi(void)
>  {
>  #ifdef CONFIG_PHY_NCSI
> diff --git a/include/phy.h b/include/phy.h
> index 4a9de461152..34675b2c9c0 100644
> --- a/include/phy.h
> +++ b/include/phy.h
> @@ -289,6 +289,10 @@ int phy_read_mmd(struct phy_device *phydev, int devad, 
> int regnum);
>  int phy_write_mmd(struct phy_device *phydev, int devad, int regnum, u16 val);
>  int phy_set_bits_mmd(struct phy_device *phydev, int devad, u32 regnum, u16 
> val);
>  int phy_clear_bits_mmd(struct phy_device *phydev, int devad, u32 regnum, u16 
> val);
> +int phy_modify_mmd_changed(struct phy_device *phydev, int devad, u32 regnum,
> +  u16 mask, u16 set);
> +int phy_modify_mmd(struct phy_device *phydev, int devad, u32 regnum,
> +  u16 mask, u16 set);
>
>  int phy_startup(struct phy_device *phydev);
>  int phy_config(struct phy_device *phydev);
> --
> 2.39.2
>
Reviewed-by: Ramon Fried 


Re: [PATCH 1/5] net: phy: marvell: Import and use marvell_phy.h from Linux

2023-04-01 Thread Ramon Fried
On Sun, Mar 19, 2023 at 7:08 PM Marek Vasut
 wrote:
>
> Import marvell_phy.h from Linux 5.14.y as of commit
> a5de4be06 ("net: phy: marvell10g: fix differentiation of 88X3310 from 
> 88X3340")
> and use it in marvell PHY driver instead of current ad-hoc macros.
> Two of the PHY IDs are unknown to Linux, 88E1149S and 88E1680, for
> those two, only sync the length of the hexadecimal number to 8 digits.
>
> No functional change.
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: "Ariel D'Alessandro" 
> Cc: "Marek Behún" 
> Cc: Joe Hershberger 
> Cc: Marek Vasut 
> Cc: Michael Trimarchi 
> Cc: Nate Drude 
> Cc: Ramon Fried 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: Tim Harvey 
> Cc: Vladimir Oltean 
> ---
>  drivers/net/phy/marvell.c | 45 +++--
>  include/marvell_phy.h | 47 +++
>  2 files changed, 70 insertions(+), 22 deletions(-)
>  create mode 100644 include/marvell_phy.h
>
> diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
> index 8992be6e89e..0a90f710dfe 100644
> --- a/drivers/net/phy/marvell.c
> +++ b/drivers/net/phy/marvell.c
> @@ -7,6 +7,7 @@
>   */
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -695,8 +696,8 @@ static int m88e1680_config(struct phy_device *phydev)
>
>  U_BOOT_PHY_DRIVER(m88e1011s) = {
> .name = "Marvell 88E1011S",
> -   .uid = 0x1410c60,
> -   .mask = 0xff0,
> +   .uid = MARVELL_PHY_ID_88E1101,
> +   .mask = MARVELL_PHY_ID_MASK,
> .features = PHY_GBIT_FEATURES,
> .config = &m88e1011s_config,
> .startup = &m88e1011s_startup,
> @@ -705,8 +706,8 @@ U_BOOT_PHY_DRIVER(m88e1011s) = {
>
>  U_BOOT_PHY_DRIVER(m88es) = {
> .name = "Marvell 88ES",
> -   .uid = 0x1410cc0,
> -   .mask = 0xff0,
> +   .uid = MARVELL_PHY_ID_88E,
> +   .mask = MARVELL_PHY_ID_MASK,
> .features = PHY_GBIT_FEATURES,
> .config = &m88es_config,
> .startup = &m88e1011s_startup,
> @@ -715,8 +716,8 @@ U_BOOT_PHY_DRIVER(m88es) = {
>
>  U_BOOT_PHY_DRIVER(m88e1118) = {
> .name = "Marvell 88E1118",
> -   .uid = 0x1410e10,
> -   .mask = 0xff0,
> +   .uid = MARVELL_PHY_ID_88E1118,
> +   .mask = MARVELL_PHY_ID_MASK,
> .features = PHY_GBIT_FEATURES,
> .config = &m88e1118_config,
> .startup = &m88e1118_startup,
> @@ -725,8 +726,8 @@ U_BOOT_PHY_DRIVER(m88e1118) = {
>
>  U_BOOT_PHY_DRIVER(m88e1118r) = {
> .name = "Marvell 88E1118R",
> -   .uid = 0x1410e40,
> -   .mask = 0xff0,
> +   .uid = MARVELL_PHY_ID_88E1116R,
> +   .mask = MARVELL_PHY_ID_MASK,
> .features = PHY_GBIT_FEATURES,
> .config = &m88e1118_config,
> .startup = &m88e1118_startup,
> @@ -735,8 +736,8 @@ U_BOOT_PHY_DRIVER(m88e1118r) = {
>
>  U_BOOT_PHY_DRIVER(m88e1121r) = {
> .name = "Marvell 88E1121R",
> -   .uid = 0x1410cb0,
> -   .mask = 0xff0,
> +   .uid = MARVELL_PHY_ID_88E1121R,
> +   .mask = MARVELL_PHY_ID_MASK,
> .features = PHY_GBIT_FEATURES,
> .config = &m88e1121_config,
> .startup = &genphy_startup,
> @@ -745,8 +746,8 @@ U_BOOT_PHY_DRIVER(m88e1121r) = {
>
>  U_BOOT_PHY_DRIVER(m88e1145) = {
> .name = "Marvell 88E1145",
> -   .uid = 0x1410cd0,
> -   .mask = 0xff0,
> +   .uid = MARVELL_PHY_ID_88E1145,
> +   .mask = MARVELL_PHY_ID_MASK,
> .features = PHY_GBIT_FEATURES,
> .config = &m88e1145_config,
> .startup = &m88e1145_startup,
> @@ -755,8 +756,8 @@ U_BOOT_PHY_DRIVER(m88e1145) = {
>
>  U_BOOT_PHY_DRIVER(m88e1149s) = {
> .name = "Marvell 88E1149S",
> -   .uid = 0x1410ca0,
> -   .mask = 0xff0,
> +   .uid = 0x01410ca0,
> +   .mask = MARVELL_PHY_ID_MASK,
> .features = PHY_GBIT_FEATURES,
> .config = &m88e1149_config,
> .startup = &m88e1011s_startup,
> @@ -765,8 +766,8 @@ U_BOOT_PHY_DRIVER(m88e1149s) = {
>
>  U_BOOT_PHY_DRIVER(m88e1240) = {
> .name = "Marvell 88E1240",
> -   .uid = 0x1410e30,
> -   .mask = 0xff0,
> +   .uid = MARVELL_PHY_ID_88E1240,
> +   .mask = MARVELL_PHY_ID_MASK,
> .features = PHY_GBIT_FEATURES,
> .config = &m88e1240_config,
> .startup = &m88e1011s_startup,
> @@ -775,8 +776,8 @@ U_BOOT_PHY_DRIVER(m88e1240) = {
>
>  U_BOOT_PHY_DRIVER(m88e151x) = {
> .name = "Marvell 88E151x",
> -   .uid = 0x1410dd0,
> -   .mask = 0xff0,
> +   .uid = MARVELL_PHY_ID_88E1510,
> +   .mask = MARVELL_PHY_ID_MASK,
> .features = PHY_GBIT_FEATURES,
> .config = &m88e151x_config,
> .startup = &m88e1011s_startup,
> @@ -787,8 +788,8 @@ U_BOOT_PHY_DRIVER(m88e151x) = {
>
>  U_BOOT_PHY_DRIVER(m88e1310) = {
> .name = "Marvell 88E1310",
> -   .uid = 0x01410e90,
> -   .mask = 0xff0,
> +   .uid = MARVELL_PHY_ID_88E1318S,
> +   .mask = MARVELL_PHY_ID_MASK,
>  

Re: [PATCH 3/3] net: phy: Synchronize PHY interface modes with Linux

2023-04-01 Thread Ramon Fried
On Sun, Mar 19, 2023 at 7:07 PM Marek Vasut
 wrote:
>
> Synchronize PHY interface modes with Linux next 6.2.y commit:
> 0194b64578e90 ("net: phy: improve phy_read_poll_timeout")
>
> Retain LX2160A/LX2162A PHY modes as those are not yet supported
> by the Linux kernel, but isolate those with ifdeffery.
>
> Isolate NCSI which are also not supported by Linux kernel. Note
> that the ifdeffery cannot be avoided with IS_ENABLED() here due
> to compilation of the entire conditional, which would fail in
> case NCSI symbols are not available.
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: "Ariel D'Alessandro" 
> Cc: "Marek Behún" 
> Cc: Joe Hershberger 
> Cc: Marek Vasut 
> Cc: Ramon Fried 
> Cc: Stefan Roese 
> Cc: Tim Harvey 
> Cc: Vladimir Oltean 
> ---
>  drivers/net/phy/phy.c   |  4 +++
>  include/phy_interface.h | 68 +
>  2 files changed, 53 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 9b0e497f223..f720d0a7920 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -1160,7 +1160,11 @@ int phy_clear_bits_mmd(struct phy_device *phydev, int 
> devad, u32 regnum, u16 val
>
>  bool phy_interface_is_ncsi(void)
>  {
> +#ifdef CONFIG_PHY_NCSI
> struct eth_pdata *pdata = dev_get_plat(eth_get_dev());
>
> return pdata->phy_interface == PHY_INTERFACE_MODE_NCSI;
> +#else
> +   return 0;
> +#endif
>  }
> diff --git a/include/phy_interface.h b/include/phy_interface.h
> index 52af7e612b6..31be3228c7c 100644
> --- a/include/phy_interface.h
> +++ b/include/phy_interface.h
> @@ -14,65 +14,95 @@
>
>  typedef enum {
> PHY_INTERFACE_MODE_NA, /* don't touch */
> +   PHY_INTERFACE_MODE_INTERNAL,
> PHY_INTERFACE_MODE_MII,
> PHY_INTERFACE_MODE_GMII,
> PHY_INTERFACE_MODE_SGMII,
> -   PHY_INTERFACE_MODE_SGMII_2500,
> -   PHY_INTERFACE_MODE_QSGMII,
> PHY_INTERFACE_MODE_TBI,
> +   PHY_INTERFACE_MODE_REVMII,
> PHY_INTERFACE_MODE_RMII,
> +   PHY_INTERFACE_MODE_REVRMII,
> PHY_INTERFACE_MODE_RGMII,
> PHY_INTERFACE_MODE_RGMII_ID,
> PHY_INTERFACE_MODE_RGMII_RXID,
> PHY_INTERFACE_MODE_RGMII_TXID,
> PHY_INTERFACE_MODE_RTBI,
> +   PHY_INTERFACE_MODE_SMII,
> +   PHY_INTERFACE_MODE_XGMII,
> +   PHY_INTERFACE_MODE_XLGMII,
> +   PHY_INTERFACE_MODE_MOCA,
> +   PHY_INTERFACE_MODE_QSGMII,
> +   PHY_INTERFACE_MODE_TRGMII,
> +   PHY_INTERFACE_MODE_100BASEX,
> PHY_INTERFACE_MODE_1000BASEX,
> PHY_INTERFACE_MODE_2500BASEX,
> -   PHY_INTERFACE_MODE_XGMII,
> -   PHY_INTERFACE_MODE_XAUI,
> -   PHY_INTERFACE_MODE_RXAUI,
> PHY_INTERFACE_MODE_5GBASER,
> -   PHY_INTERFACE_MODE_SFI,
> -   PHY_INTERFACE_MODE_INTERNAL,
> +   PHY_INTERFACE_MODE_RXAUI,
> +   PHY_INTERFACE_MODE_XAUI,
> +   /* 10GBASE-R, XFI, SFI - single lane 10G Serdes */
> +   PHY_INTERFACE_MODE_10GBASER,
> +   PHY_INTERFACE_MODE_25GBASER,
> +   PHY_INTERFACE_MODE_USXGMII,
> +   /* 10GBASE-KR - with Clause 73 AN */
> +   PHY_INTERFACE_MODE_10GKR,
> +   PHY_INTERFACE_MODE_QUSGMII,
> +   PHY_INTERFACE_MODE_1000BASEKX,
> +#if defined(CONFIG_ARCH_LX2160A) || defined(CONFIG_ARCH_LX2162A)
> +   /* LX2160A SERDES modes */
> PHY_INTERFACE_MODE_25G_AUI,
> PHY_INTERFACE_MODE_XLAUI,
> PHY_INTERFACE_MODE_CAUI2,
> PHY_INTERFACE_MODE_CAUI4,
> +#endif
> +#if defined(CONFIG_PHY_NCSI)
> PHY_INTERFACE_MODE_NCSI,
> -   PHY_INTERFACE_MODE_10GBASER,
> -   PHY_INTERFACE_MODE_USXGMII,
> +#endif
> PHY_INTERFACE_MODE_MAX,
>  } phy_interface_t;
>
>  static const char * const phy_interface_strings[] = {
> -   [PHY_INTERFACE_MODE_NA] = "",
> +   [PHY_INTERFACE_MODE_NA] = "",
> +   [PHY_INTERFACE_MODE_INTERNAL]   = "internal",
> [PHY_INTERFACE_MODE_MII]= "mii",
> [PHY_INTERFACE_MODE_GMII]   = "gmii",
> [PHY_INTERFACE_MODE_SGMII]  = "sgmii",
> -   [PHY_INTERFACE_MODE_SGMII_2500] = "sgmii-2500",
> -   [PHY_INTERFACE_MODE_QSGMII] = "qsgmii",
> [PHY_INTERFACE_MODE_TBI]= "tbi",
> +   [PHY_INTERFACE_MODE_REVMII] = "rev-mii",
> [PHY_INTERFACE_MODE_RMII]   = "rmii",
> +   [PHY_INTERFACE_MODE_REVRMII]= "rev-rmii",
> [PHY_INTERFACE_MODE_RGMII]  = "rgmii",
> [PHY_INTERFACE_MODE_RGMII_ID]   = "rgmii-id",
> [PHY_INTERFACE_MODE_RGMII_RXID] = "rgmii-rxid",
> [PHY_INTERFACE_MODE_RGMII_TXID] = "rgmii-txid",
> [PHY_INTERFACE_MODE_RTBI]   = "rtbi",
> +   [PHY_INTERFACE_MODE_SMII]   = "smii",
> +   [PHY_INTERFACE_MODE_XGMII]  = "xgmii",
> +   [PHY_INTERFACE_MODE_XLGMII] = "xlgmii",
> +   [PHY_INTERFACE_M

Re: [PATCH 2/3] net: mvpp2: Replace PHY_INTERFACE_MODE_SFI with 5GBASER/10GBASER/XAUI

2023-04-01 Thread Ramon Fried
On Sun, Mar 19, 2023 at 7:07 PM Marek Vasut
 wrote:
>
> Replace PHY_INTERFACE_MODE_SFI with PHY_INTERFACE_MODE_5GBASER,
> PHY_INTERFACE_MODE_10GBASER and PHY_INTERFACE_MODE_XAUI to match
> Linux PHY interface modes.
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: "Ariel D'Alessandro" 
> Cc: "Marek Behún" 
> Cc: Joe Hershberger 
> Cc: Marek Vasut 
> Cc: Ramon Fried 
> Cc: Stefan Roese 
> Cc: Tim Harvey 
> Cc: Vladimir Oltean 
> ---
>  drivers/net/mvpp2.c | 8 ++--
>  include/phy_interface.h | 2 ++
>  2 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
> index 71347b7e69c..096b8a35853 100644
> --- a/drivers/net/mvpp2.c
> +++ b/drivers/net/mvpp2.c
> @@ -3438,7 +3438,9 @@ static int gop_port_init(struct mvpp2_port *port)
> gop_gmac_reset(port, 0);
> break;
>
> -   case PHY_INTERFACE_MODE_SFI:
> +   case PHY_INTERFACE_MODE_10GBASER:
> +   case PHY_INTERFACE_MODE_5GBASER:
> +   case PHY_INTERFACE_MODE_XAUI:
> num_of_act_lanes = 2;
> mac_num = 0;
> /* configure PCS */
> @@ -3489,7 +3491,9 @@ static void gop_port_enable(struct mvpp2_port *port, 
> int enable)
> mvpp2_port_disable(port);
> break;
>
> -   case PHY_INTERFACE_MODE_SFI:
> +   case PHY_INTERFACE_MODE_10GBASER:
> +   case PHY_INTERFACE_MODE_5GBASER:
> +   case PHY_INTERFACE_MODE_XAUI:
> gop_xlg_mac_port_enable(port, enable);
>
> break;
> diff --git a/include/phy_interface.h b/include/phy_interface.h
> index fed3357b9a2..52af7e612b6 100644
> --- a/include/phy_interface.h
> +++ b/include/phy_interface.h
> @@ -31,6 +31,7 @@ typedef enum {
> PHY_INTERFACE_MODE_XGMII,
> PHY_INTERFACE_MODE_XAUI,
> PHY_INTERFACE_MODE_RXAUI,
> +   PHY_INTERFACE_MODE_5GBASER,
> PHY_INTERFACE_MODE_SFI,
> PHY_INTERFACE_MODE_INTERNAL,
> PHY_INTERFACE_MODE_25G_AUI,
> @@ -62,6 +63,7 @@ static const char * const phy_interface_strings[] = {
> [PHY_INTERFACE_MODE_XGMII]  = "xgmii",
> [PHY_INTERFACE_MODE_XAUI]   = "xaui",
> [PHY_INTERFACE_MODE_RXAUI]  = "rxaui",
> +   [PHY_INTERFACE_MODE_5GBASER]= "5gbase-r",
> [PHY_INTERFACE_MODE_SFI]= "sfi",
> [PHY_INTERFACE_MODE_INTERNAL]   = "internal",
> [PHY_INTERFACE_MODE_25G_AUI]= "25g-aui",
> --
> 2.39.2
>
Reviewed-by: Ramon Fried 


Re: [PATCH 41/41] net: phy: Only call phy_init() on systems needing manual relocation

2023-04-01 Thread Ramon Fried
On Sun, Mar 19, 2023 at 7:05 PM Marek Vasut
 wrote:
>
> The phy_init() is now used only to perform manual relocation of PHY
> driver callbacks. Wrap it in ifdeffery and only call it on systems
> which still require manual relocation, i.e. m68k .
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: "Ariel D'Alessandro" 
> Cc: "Cédric Le Goater" 
> Cc: "Marek Behún" 
> Cc: Alex Nemirovsky 
> Cc: Haolin Li 
> Cc: Heinrich Schuchardt 
> Cc: Joe Hershberger 
> Cc: Joel Stanley 
> Cc: Josua Mayer 
> Cc: Marek Vasut 
> Cc: Michael Trimarchi 
> Cc: Michal Simek 
> Cc: Nate Drude 
> Cc: Neil Armstrong 
> Cc: Radu Pirea 
> Cc: Ramon Fried 
> Cc: Samuel Mendoza-Jonas 
> Cc: Stefan Roese 
> Cc: T Karthik Reddy 
> Cc: Tim Harvey 
> Cc: Vladimir Oltean 
> Cc: u-boot-amlo...@groups.io
> ---
>  drivers/net/phy/phy.c | 4 ++--
>  net/eth_common.c  | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 61603f28179..9b0e497f223 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -463,9 +463,9 @@ U_BOOT_PHY_DRIVER(genphy) = {
> .shutdown   = genphy_shutdown,
>  };
>
> +#ifdef CONFIG_NEEDS_MANUAL_RELOC
>  int phy_init(void)
>  {
> -#ifdef CONFIG_NEEDS_MANUAL_RELOC
> const int ll_n_ents = ll_entry_count(struct phy_driver, phy_driver);
> struct phy_driver *drv, *ll_entry;
>
> @@ -489,10 +489,10 @@ int phy_init(void)
> if (drv->write_mmd)
> drv->write_mmd += gd->reloc_off;
> }
> -#endif
>
> return 0;
>  }
> +#endif
>
>  int phy_set_supported(struct phy_device *phydev, u32 max_speed)
>  {
> diff --git a/net/eth_common.c b/net/eth_common.c
> index 82d527abba6..c94a7ba6ae7 100644
> --- a/net/eth_common.c
> +++ b/net/eth_common.c
> @@ -37,7 +37,7 @@ void eth_common_init(void)
> miiphy_init();
>  #endif
>
> -#ifdef CONFIG_PHYLIB
> +#if defined(CONFIG_NEEDS_MANUAL_RELOC) && defined(CONFIG_PHYLIB)
> phy_init();
>  #endif
>  #endif
> --
> 2.39.2
>
Reviewed-by: Ramon Fried 


Re: [PATCH 40/41] net: phy: Re-inline phy_drv_reloc()

2023-04-01 Thread Ramon Fried
On Sun, Mar 19, 2023 at 7:05 PM Marek Vasut
 wrote:
>
> Wrap phy_drv_reloc() back into phy_init() to reduce ifdeffery,
> since phy_drv_reloc() is now called only from one call site.
> No functional change.
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: "Ariel D'Alessandro" 
> Cc: "Cédric Le Goater" 
> Cc: "Marek Behún" 
> Cc: Alex Nemirovsky 
> Cc: Haolin Li 
> Cc: Heinrich Schuchardt 
> Cc: Joe Hershberger 
> Cc: Joel Stanley 
> Cc: Josua Mayer 
> Cc: Marek Vasut 
> Cc: Michael Trimarchi 
> Cc: Michal Simek 
> Cc: Nate Drude 
> Cc: Neil Armstrong 
> Cc: Radu Pirea 
> Cc: Ramon Fried 
> Cc: Samuel Mendoza-Jonas 
> Cc: Stefan Roese 
> Cc: T Karthik Reddy 
> Cc: Tim Harvey 
> Cc: Vladimir Oltean 
> Cc: u-boot-amlo...@groups.io
> ---
>  drivers/net/phy/phy.c | 42 ++
>  1 file changed, 18 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 15da9a80de2..61603f28179 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -463,28 +463,6 @@ U_BOOT_PHY_DRIVER(genphy) = {
> .shutdown   = genphy_shutdown,
>  };
>
> -#ifdef CONFIG_NEEDS_MANUAL_RELOC
> -static void phy_drv_reloc(struct phy_driver *drv)
> -{
> -   if (drv->probe)
> -   drv->probe += gd->reloc_off;
> -   if (drv->config)
> -   drv->config += gd->reloc_off;
> -   if (drv->startup)
> -   drv->startup += gd->reloc_off;
> -   if (drv->shutdown)
> -   drv->shutdown += gd->reloc_off;
> -   if (drv->readext)
> -   drv->readext += gd->reloc_off;
> -   if (drv->writeext)
> -   drv->writeext += gd->reloc_off;
> -   if (drv->read_mmd)
> -   drv->read_mmd += gd->reloc_off;
> -   if (drv->write_mmd)
> -   drv->write_mmd += gd->reloc_off;
> -}
> -#endif
> -
>  int phy_init(void)
>  {
>  #ifdef CONFIG_NEEDS_MANUAL_RELOC
> @@ -493,8 +471,24 @@ int phy_init(void)
>
> /* Perform manual relocation on linker list based PHY drivers */
> ll_entry = ll_entry_start(struct phy_driver, phy_driver);
> -   for (drv = ll_entry; drv != ll_entry + ll_n_ents; drv++)
> -   phy_drv_reloc(drv);
> +   for (drv = ll_entry; drv != ll_entry + ll_n_ents; drv++) {
> +   if (drv->probe)
> +   drv->probe += gd->reloc_off;
> +   if (drv->config)
> +   drv->config += gd->reloc_off;
> +   if (drv->startup)
> +   drv->startup += gd->reloc_off;
> +   if (drv->shutdown)
> +   drv->shutdown += gd->reloc_off;
> +   if (drv->readext)
> +   drv->readext += gd->reloc_off;
> +   if (drv->writeext)
> +   drv->writeext += gd->reloc_off;
> +   if (drv->read_mmd)
> +   drv->read_mmd += gd->reloc_off;
> +   if (drv->write_mmd)
> +   drv->write_mmd += gd->reloc_off;
> +   }
>  #endif
>
> return 0;
> --
> 2.39.2
>
Reviewed-by: Ramon Fried 


Re: [PATCH 39/41] net: phy: Drop unused phy_register()

2023-04-01 Thread Ramon Fried
On Sun, Mar 19, 2023 at 7:05 PM Marek Vasut
 wrote:
>
> This function is no longer used, drop it.
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: "Ariel D'Alessandro" 
> Cc: "Cédric Le Goater" 
> Cc: "Marek Behún" 
> Cc: Alex Nemirovsky 
> Cc: Haolin Li 
> Cc: Heinrich Schuchardt 
> Cc: Joe Hershberger 
> Cc: Joel Stanley 
> Cc: Josua Mayer 
> Cc: Marek Vasut 
> Cc: Michael Trimarchi 
> Cc: Michal Simek 
> Cc: Nate Drude 
> Cc: Neil Armstrong 
> Cc: Radu Pirea 
> Cc: Ramon Fried 
> Cc: Samuel Mendoza-Jonas 
> Cc: Stefan Roese 
> Cc: T Karthik Reddy 
> Cc: Tim Harvey 
> Cc: Vladimir Oltean 
> Cc: u-boot-amlo...@groups.io
> ---
>  drivers/net/phy/phy.c | 8 
>  include/phy.h | 1 -
>  2 files changed, 9 deletions(-)
>
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index f4aa1f664cb..15da9a80de2 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -500,14 +500,6 @@ int phy_init(void)
> return 0;
>  }
>
> -int phy_register(struct phy_driver *drv)
> -{
> -#ifdef CONFIG_NEEDS_MANUAL_RELOC
> -   phy_drv_reloc(drv);
> -#endif
> -   return 0;
> -}
> -
>  int phy_set_supported(struct phy_device *phydev, u32 max_speed)
>  {
> /* The default values for phydev->supported are provided by the PHY
> diff --git a/include/phy.h b/include/phy.h
> index 5e8ae5e29aa..4a9de461152 100644
> --- a/include/phy.h
> +++ b/include/phy.h
> @@ -293,7 +293,6 @@ int phy_clear_bits_mmd(struct phy_device *phydev, int 
> devad, u32 regnum, u16 val
>  int phy_startup(struct phy_device *phydev);
>  int phy_config(struct phy_device *phydev);
>  int phy_shutdown(struct phy_device *phydev);
> -int phy_register(struct phy_driver *drv);
>  int phy_set_supported(struct phy_device *phydev, u32 max_speed);
>  int phy_modify(struct phy_device *phydev, int devad, int regnum, u16 mask,
>u16 set);
> --
> 2.39.2
>
Reviewed-by: Ramon Fried 


Re: [PATCH 38/41] net: phy: Drop static phy_drivers list

2023-04-01 Thread Ramon Fried
On Sun, Mar 19, 2023 at 7:05 PM Marek Vasut
 wrote:
>
> The static phy_drivers list is superseded by linker list of struct phy_drivers
> now that all drivers have been converted to the later. Drop the phy_drivers
> list as well as list_head from struct phy_driver.
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: "Ariel D'Alessandro" 
> Cc: "Cédric Le Goater" 
> Cc: "Marek Behún" 
> Cc: Alex Nemirovsky 
> Cc: Haolin Li 
> Cc: Heinrich Schuchardt 
> Cc: Joe Hershberger 
> Cc: Joel Stanley 
> Cc: Josua Mayer 
> Cc: Marek Vasut 
> Cc: Michael Trimarchi 
> Cc: Michal Simek 
> Cc: Nate Drude 
> Cc: Neil Armstrong 
> Cc: Radu Pirea 
> Cc: Ramon Fried 
> Cc: Samuel Mendoza-Jonas 
> Cc: Stefan Roese 
> Cc: T Karthik Reddy 
> Cc: Tim Harvey 
> Cc: Vladimir Oltean 
> Cc: u-boot-amlo...@groups.io
> ---
>  drivers/net/phy/phy.c | 26 ++
>  include/phy.h |  2 --
>  2 files changed, 2 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index bd9c576f459..f4aa1f664cb 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -463,8 +463,6 @@ U_BOOT_PHY_DRIVER(genphy) = {
> .shutdown   = genphy_shutdown,
>  };
>
> -static LIST_HEAD(phy_drivers);
> -
>  #ifdef CONFIG_NEEDS_MANUAL_RELOC
>  static void phy_drv_reloc(struct phy_driver *drv)
>  {
> @@ -493,16 +491,6 @@ int phy_init(void)
> const int ll_n_ents = ll_entry_count(struct phy_driver, phy_driver);
> struct phy_driver *drv, *ll_entry;
>
> -   /*
> -* The pointers inside phy_drivers also needs to be updated incase of
> -* manual reloc, without which these points to some invalid
> -* pre reloc address and leads to invalid accesses, hangs.
> -*/
> -   struct list_head *head = &phy_drivers;
> -
> -   head->next = (void *)head->next + gd->reloc_off;
> -   head->prev = (void *)head->prev + gd->reloc_off;
> -
> /* Perform manual relocation on linker list based PHY drivers */
> ll_entry = ll_entry_start(struct phy_driver, phy_driver);
> for (drv = ll_entry; drv != ll_entry + ll_n_ents; drv++)
> @@ -514,9 +502,6 @@ int phy_init(void)
>
>  int phy_register(struct phy_driver *drv)
>  {
> -   INIT_LIST_HEAD(&drv->list);
> -   list_add_tail(&drv->list, &phy_drivers);
> -
>  #ifdef CONFIG_NEEDS_MANUAL_RELOC
> phy_drv_reloc(drv);
>  #endif
> @@ -575,16 +560,9 @@ static struct phy_driver *generic_for_phy(struct 
> phy_device *phydev)
>  static struct phy_driver *get_phy_driver(struct phy_device *phydev)
>  {
> const int ll_n_ents = ll_entry_count(struct phy_driver, phy_driver);
> -   struct phy_driver *ll_entry;
> -   struct list_head *entry;
> int phy_id = phydev->phy_id;
> -   struct phy_driver *drv = NULL;
> -
> -   list_for_each(entry, &phy_drivers) {
> -   drv = list_entry(entry, struct phy_driver, list);
> -   if ((drv->uid & drv->mask) == (phy_id & drv->mask))
> -   return drv;
> -   }
> +   struct phy_driver *ll_entry;
> +   struct phy_driver *drv;
>
> ll_entry = ll_entry_start(struct phy_driver, phy_driver);
> for (drv = ll_entry; drv != ll_entry + ll_n_ents; drv++)
> diff --git a/include/phy.h b/include/phy.h
> index 5f4967cb150..5e8ae5e29aa 100644
> --- a/include/phy.h
> +++ b/include/phy.h
> @@ -125,8 +125,6 @@ struct phy_driver {
> int (*write_mmd)(struct phy_device *phydev, int devad, int reg,
>  u16 val);
>
> -   struct list_head list;
> -
> /* driver private data */
> ulong data;
>  };
> --
> 2.39.2
>
Reviewed-by: Ramon Fried 


Re: [PATCH 37/41] net: phy: gen10g: Convert to U_BOOT_PHY_DRIVER()

2023-04-01 Thread Ramon Fried
On Sun, Mar 19, 2023 at 7:05 PM Marek Vasut
 wrote:
>
> Convert PHY driver to U_BOOT_PHY_DRIVER() macro and drop phy_register() init 
> call.
>
> Converted using sed
> "s@^static struct phy_driver \(.*\)_driver = \+{@U_BOOT_PHY_DRIVER(\L\1) = {"
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: "Ariel D'Alessandro" 
> Cc: "Cédric Le Goater" 
> Cc: "Marek Behún" 
> Cc: Alex Nemirovsky 
> Cc: Haolin Li 
> Cc: Heinrich Schuchardt 
> Cc: Joe Hershberger 
> Cc: Joel Stanley 
> Cc: Josua Mayer 
> Cc: Marek Vasut 
> Cc: Michael Trimarchi 
> Cc: Michal Simek 
> Cc: Nate Drude 
> Cc: Neil Armstrong 
> Cc: Radu Pirea 
> Cc: Ramon Fried 
> Cc: Samuel Mendoza-Jonas 
> Cc: Stefan Roese 
> Cc: T Karthik Reddy 
> Cc: Tim Harvey 
> Cc: Vladimir Oltean 
> Cc: u-boot-amlo...@groups.io
> ---
>  drivers/net/phy/generic_10g.c | 2 +-
>  drivers/net/phy/phy.c | 2 +-
>  include/phy.h | 4 
>  3 files changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/phy/generic_10g.c b/drivers/net/phy/generic_10g.c
> index b4384e1f781..34ac51ea070 100644
> --- a/drivers/net/phy/generic_10g.c
> +++ b/drivers/net/phy/generic_10g.c
> @@ -80,7 +80,7 @@ int gen10g_config(struct phy_device *phydev)
> return gen10g_discover_mmds(phydev);
>  }
>
> -struct phy_driver gen10g_driver = {
> +U_BOOT_PHY_DRIVER(gen10g) = {
> .uid= 0x,
> .mask   = 0x,
> .name   = "Generic 10G PHY",
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index b1e9861c6f3..bd9c576f459 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -566,7 +566,7 @@ static struct phy_driver *generic_for_phy(struct 
> phy_device *phydev)
>  {
>  #ifdef CONFIG_PHYLIB_10G
> if (phydev->is_c45)
> -   return &gen10g_driver;
> +   return ll_entry_get(struct phy_driver, gen10g, phy_driver);
>  #endif
>
> return ll_entry_get(struct phy_driver, genphy, phy_driver);
> diff --git a/include/phy.h b/include/phy.h
> index df2586f89ea..5f4967cb150 100644
> --- a/include/phy.h
> +++ b/include/phy.h
> @@ -173,10 +173,6 @@ struct fixed_link {
> int asym_pause;
>  };
>
> -#ifdef CONFIG_PHYLIB_10G
> -extern struct phy_driver gen10g_driver;
> -#endif
> -
>  /**
>   * phy_init() - Initializes the PHY drivers
>   * This function registers all available PHY drivers
> --
> 2.39.2
>
Reviewed-by: Ramon Fried 


Re: [PATCH 35/41] net: phy: xilinx-gmii2rgmii: Convert to U_BOOT_PHY_DRIVER()

2023-04-01 Thread Ramon Fried
On Sun, Mar 19, 2023 at 7:05 PM Marek Vasut
 wrote:
>
> Convert PHY driver to U_BOOT_PHY_DRIVER() macro and drop phy_register() init 
> call.
>
> Converted using sed
> "s@^static struct phy_driver \(.*\)_driver = \+{@U_BOOT_PHY_DRIVER(\L\1) = {"
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: "Ariel D'Alessandro" 
> Cc: "Cédric Le Goater" 
> Cc: "Marek Behún" 
> Cc: Alex Nemirovsky 
> Cc: Haolin Li 
> Cc: Heinrich Schuchardt 
> Cc: Joe Hershberger 
> Cc: Joel Stanley 
> Cc: Josua Mayer 
> Cc: Marek Vasut 
> Cc: Michael Trimarchi 
> Cc: Michal Simek 
> Cc: Nate Drude 
> Cc: Neil Armstrong 
> Cc: Radu Pirea 
> Cc: Ramon Fried 
> Cc: Samuel Mendoza-Jonas 
> Cc: Stefan Roese 
> Cc: T Karthik Reddy 
> Cc: Tim Harvey 
> Cc: Vladimir Oltean 
> Cc: u-boot-amlo...@groups.io
> ---
>  drivers/net/phy/phy.c   | 3 ---
>  drivers/net/phy/xilinx_gmii2rgmii.c | 9 +
>  include/phy.h   | 2 --
>  3 files changed, 1 insertion(+), 13 deletions(-)
>
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 69db79f79e0..9d5d1494616 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -514,9 +514,6 @@ int phy_init(void)
> phy_drv_reloc(drv);
>  #endif
>
> -#ifdef CONFIG_PHY_XILINX_GMII2RGMII
> -   phy_xilinx_gmii2rgmii_init();
> -#endif
> genphy_init();
>
> return 0;
> diff --git a/drivers/net/phy/xilinx_gmii2rgmii.c 
> b/drivers/net/phy/xilinx_gmii2rgmii.c
> index 73762839565..0b7436a7e1e 100644
> --- a/drivers/net/phy/xilinx_gmii2rgmii.c
> +++ b/drivers/net/phy/xilinx_gmii2rgmii.c
> @@ -124,7 +124,7 @@ static int xilinxgmiitorgmii_probe(struct phy_device 
> *phydev)
> return 0;
>  }
>
> -static struct phy_driver gmii2rgmii_driver = {
> +U_BOOT_PHY_DRIVER(gmii2rgmii) = {
> .name = "XILINX GMII2RGMII",
> .uid = PHY_GMII2RGMII_ID,
> .mask = 0x,
> @@ -135,10 +135,3 @@ static struct phy_driver gmii2rgmii_driver = {
> .writeext = xilinxgmiitorgmii_extwrite,
> .readext = xilinxgmiitorgmii_extread,
>  };
> -
> -int phy_xilinx_gmii2rgmii_init(void)
> -{
> -   phy_register(&gmii2rgmii_driver);
> -
> -   return 0;
> -}
> diff --git a/include/phy.h b/include/phy.h
> index 001c998db47..df2586f89ea 100644
> --- a/include/phy.h
> +++ b/include/phy.h
> @@ -315,8 +315,6 @@ int gen10g_startup(struct phy_device *phydev);
>  int gen10g_shutdown(struct phy_device *phydev);
>  int gen10g_discover_mmds(struct phy_device *phydev);
>
> -int phy_xilinx_gmii2rgmii_init(void);
> -
>  /**
>   * U_BOOT_PHY_DRIVER() - Declare a new U-Boot driver
>   * @__name: name of the driver
> --
> 2.39.2
>
Reviewed-by: Ramon Fried 


Re: [PATCH 34/41] net: phy: ncsi: Convert to U_BOOT_PHY_DRIVER()

2023-04-01 Thread Ramon Fried
On Sun, Mar 19, 2023 at 7:05 PM Marek Vasut
 wrote:
>
> Convert PHY driver to U_BOOT_PHY_DRIVER() macro and drop phy_register() init 
> call.
>
> Converted using sed
> "s@^static struct phy_driver \(.*\)_driver = \+{@U_BOOT_PHY_DRIVER(\L\1) = {"
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: "Ariel D'Alessandro" 
> Cc: "Cédric Le Goater" 
> Cc: "Marek Behún" 
> Cc: Alex Nemirovsky 
> Cc: Haolin Li 
> Cc: Heinrich Schuchardt 
> Cc: Joe Hershberger 
> Cc: Joel Stanley 
> Cc: Josua Mayer 
> Cc: Marek Vasut 
> Cc: Michael Trimarchi 
> Cc: Michal Simek 
> Cc: Nate Drude 
> Cc: Neil Armstrong 
> Cc: Radu Pirea 
> Cc: Ramon Fried 
> Cc: Samuel Mendoza-Jonas 
> Cc: Stefan Roese 
> Cc: T Karthik Reddy 
> Cc: Tim Harvey 
> Cc: Vladimir Oltean 
> Cc: u-boot-amlo...@groups.io
> ---
>  drivers/net/phy/ncsi.c | 8 +---
>  drivers/net/phy/phy.c  | 3 ---
>  include/phy.h  | 1 -
>  3 files changed, 1 insertion(+), 11 deletions(-)
>
> diff --git a/drivers/net/phy/ncsi.c b/drivers/net/phy/ncsi.c
> index bb7ecebed38..eb3fd65bb47 100644
> --- a/drivers/net/phy/ncsi.c
> +++ b/drivers/net/phy/ncsi.c
> @@ -881,7 +881,7 @@ int ncsi_shutdown(struct phy_device *phydev)
> return 0;
>  }
>
> -static struct phy_driver ncsi_driver = {
> +U_BOOT_PHY_DRIVER(ncsi) = {
> .uid= PHY_NCSI_ID,
> .mask   = 0x,
> .name   = "NC-SI",
> @@ -891,9 +891,3 @@ static struct phy_driver ncsi_driver = {
> .startup= ncsi_startup,
> .shutdown   = ncsi_shutdown,
>  };
> -
> -int phy_ncsi_init(void)
> -{
> -   phy_register(&ncsi_driver);
> -   return 0;
> -}
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 245357c31dc..69db79f79e0 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -514,9 +514,6 @@ int phy_init(void)
> phy_drv_reloc(drv);
>  #endif
>
> -#ifdef CONFIG_PHY_NCSI
> -   phy_ncsi_init();
> -#endif
>  #ifdef CONFIG_PHY_XILINX_GMII2RGMII
> phy_xilinx_gmii2rgmii_init();
>  #endif
> diff --git a/include/phy.h b/include/phy.h
> index 9cabfeedec8..001c998db47 100644
> --- a/include/phy.h
> +++ b/include/phy.h
> @@ -315,7 +315,6 @@ int gen10g_startup(struct phy_device *phydev);
>  int gen10g_shutdown(struct phy_device *phydev);
>  int gen10g_discover_mmds(struct phy_device *phydev);
>
> -int phy_ncsi_init(void);
>  int phy_xilinx_gmii2rgmii_init(void);
>
>  /**
> --
> 2.39.2
>
Reviewed-by: Ramon Fried 


Re: [PATCH 33/41] net: phy: fixed: Convert to U_BOOT_PHY_DRIVER()

2023-04-01 Thread Ramon Fried
On Sun, Mar 19, 2023 at 7:05 PM Marek Vasut
 wrote:
>
> Convert PHY driver to U_BOOT_PHY_DRIVER() macro and drop phy_register() init 
> call.
>
> Converted using sed
> "s@^static struct phy_driver \(.*\)_driver = \+{@U_BOOT_PHY_DRIVER(\L\1) = {"
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: "Ariel D'Alessandro" 
> Cc: "Cédric Le Goater" 
> Cc: "Marek Behún" 
> Cc: Alex Nemirovsky 
> Cc: Haolin Li 
> Cc: Heinrich Schuchardt 
> Cc: Joe Hershberger 
> Cc: Joel Stanley 
> Cc: Josua Mayer 
> Cc: Marek Vasut 
> Cc: Michael Trimarchi 
> Cc: Michal Simek 
> Cc: Nate Drude 
> Cc: Neil Armstrong 
> Cc: Radu Pirea 
> Cc: Ramon Fried 
> Cc: Samuel Mendoza-Jonas 
> Cc: Stefan Roese 
> Cc: T Karthik Reddy 
> Cc: Tim Harvey 
> Cc: Vladimir Oltean 
> Cc: u-boot-amlo...@groups.io
> ---
>  drivers/net/phy/fixed.c | 8 +---
>  drivers/net/phy/phy.c   | 3 ---
>  include/phy.h   | 1 -
>  3 files changed, 1 insertion(+), 11 deletions(-)
>
> diff --git a/drivers/net/phy/fixed.c b/drivers/net/phy/fixed.c
> index 1192915ee52..2f0823b8365 100644
> --- a/drivers/net/phy/fixed.c
> +++ b/drivers/net/phy/fixed.c
> @@ -93,7 +93,7 @@ static int fixedphy_shutdown(struct phy_device *phydev)
> return 0;
>  }
>
> -static struct phy_driver fixedphy_driver = {
> +U_BOOT_PHY_DRIVER(fixedphy) = {
> .uid= PHY_FIXED_ID,
> .mask   = 0x,
> .name   = "Fixed PHY",
> @@ -103,9 +103,3 @@ static struct phy_driver fixedphy_driver = {
> .startup= fixedphy_startup,
> .shutdown   = fixedphy_shutdown,
>  };
> -
> -int phy_fixed_init(void)
> -{
> -   phy_register(&fixedphy_driver);
> -   return 0;
> -}
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index c20e750aa16..245357c31dc 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -514,9 +514,6 @@ int phy_init(void)
> phy_drv_reloc(drv);
>  #endif
>
> -#ifdef CONFIG_PHY_FIXED
> -   phy_fixed_init();
> -#endif
>  #ifdef CONFIG_PHY_NCSI
> phy_ncsi_init();
>  #endif
> diff --git a/include/phy.h b/include/phy.h
> index e4a3e10c48b..9cabfeedec8 100644
> --- a/include/phy.h
> +++ b/include/phy.h
> @@ -315,7 +315,6 @@ int gen10g_startup(struct phy_device *phydev);
>  int gen10g_shutdown(struct phy_device *phydev);
>  int gen10g_discover_mmds(struct phy_device *phydev);
>
> -int phy_fixed_init(void);
>  int phy_ncsi_init(void);
>  int phy_xilinx_gmii2rgmii_init(void);
>
> --
> 2.39.2
>
Reviewed-by: Ramon Fried 


Re: [PATCH 32/41] net: phy: mscc: Convert to U_BOOT_PHY_DRIVER()

2023-04-01 Thread Ramon Fried
On Sun, Mar 19, 2023 at 7:05 PM Marek Vasut
 wrote:
>
> Convert PHY driver to U_BOOT_PHY_DRIVER() macro and drop phy_register() init 
> call.
>
> Converted using sed
> "s@^static struct phy_driver \(.*\)_driver = \+{@U_BOOT_PHY_DRIVER(\L\1) = {"
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: "Ariel D'Alessandro" 
> Cc: "Cédric Le Goater" 
> Cc: "Marek Behún" 
> Cc: Alex Nemirovsky 
> Cc: Haolin Li 
> Cc: Heinrich Schuchardt 
> Cc: Joe Hershberger 
> Cc: Joel Stanley 
> Cc: Josua Mayer 
> Cc: Marek Vasut 
> Cc: Michael Trimarchi 
> Cc: Michal Simek 
> Cc: Nate Drude 
> Cc: Neil Armstrong 
> Cc: Radu Pirea 
> Cc: Ramon Fried 
> Cc: Samuel Mendoza-Jonas 
> Cc: Stefan Roese 
> Cc: T Karthik Reddy 
> Cc: Tim Harvey 
> Cc: Vladimir Oltean 
> Cc: u-boot-amlo...@groups.io
> ---
>  drivers/net/phy/mscc.c | 27 +++
>  drivers/net/phy/phy.c  |  3 ---
>  include/phy.h  |  1 -
>  3 files changed, 7 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/net/phy/mscc.c b/drivers/net/phy/mscc.c
> index f9482b21a01..ef1761a8bda 100644
> --- a/drivers/net/phy/mscc.c
> +++ b/drivers/net/phy/mscc.c
> @@ -1558,7 +1558,7 @@ static int vsc8502_config(struct phy_device *phydev)
> return 0;
>  }
>
> -static struct phy_driver VSC8530_driver = {
> +U_BOOT_PHY_DRIVER(vsc8530) = {
> .name = "Microsemi VSC8530",
> .uid = PHY_ID_VSC8530,
> .mask = 0x0000,
> @@ -1568,7 +1568,7 @@ static struct phy_driver VSC8530_driver = {
> .shutdown = &genphy_shutdown,
>  };
>
> -static struct phy_driver VSC8531_driver = {
> +U_BOOT_PHY_DRIVER(vsc8531) = {
> .name = "Microsemi VSC8531",
> .uid = PHY_ID_VSC8531,
> .mask = 0x0000,
> @@ -1578,7 +1578,7 @@ static struct phy_driver VSC8531_driver = {
> .shutdown = &genphy_shutdown,
>  };
>
> -static struct phy_driver VSC8502_driver = {
> +U_BOOT_PHY_DRIVER(vsc8502) = {
> .name = "Microsemi VSC8502",
> .uid = PHY_ID_VSC8502,
> .mask = 0x0000,
> @@ -1588,7 +1588,7 @@ static struct phy_driver VSC8502_driver = {
> .shutdown = &genphy_shutdown,
>  };
>
> -static struct phy_driver VSC8540_driver = {
> +U_BOOT_PHY_DRIVER(vsc8540) = {
> .name = "Microsemi VSC8540",
> .uid = PHY_ID_VSC8540,
> .mask = 0x0000,
> @@ -1598,7 +1598,7 @@ static struct phy_driver VSC8540_driver = {
> .shutdown = &genphy_shutdown,
>  };
>
> -static struct phy_driver VSC8541_driver = {
> +U_BOOT_PHY_DRIVER(vsc8541) = {
> .name = "Microsemi VSC8541",
> .uid = PHY_ID_VSC8541,
> .mask = 0x0000,
> @@ -1608,7 +1608,7 @@ static struct phy_driver VSC8541_driver = {
> .shutdown = &genphy_shutdown,
>  };
>
> -static struct phy_driver VSC8574_driver = {
> +U_BOOT_PHY_DRIVER(vsc8574) = {
> .name = "Microsemi VSC8574",
> .uid = PHY_ID_VSC8574,
> .mask = 0x0000,
> @@ -1618,7 +1618,7 @@ static struct phy_driver VSC8574_driver = {
> .shutdown = &genphy_shutdown,
>  };
>
> -static struct phy_driver VSC8584_driver = {
> +U_BOOT_PHY_DRIVER(vsc8584) = {
> .name = "Microsemi VSC8584",
> .uid = PHY_ID_VSC8584,
> .mask = 0x0000,
> @@ -1627,16 +1627,3 @@ static struct phy_driver VSC8584_driver = {
> .startup = &mscc_startup,
> .shutdown = &genphy_shutdown,
>  };
> -
> -int phy_mscc_init(void)
> -{
> -   phy_register(&VSC8530_driver);
> -   phy_register(&VSC8531_driver);
> -   phy_register(&VSC8502_driver);
> -   phy_register(&VSC8540_driver);
> -   phy_register(&VSC8541_driver);
> -   phy_register(&VSC8574_driver);
> -   phy_register(&VSC8584_driver);
> -
> -   return 0;
> -}
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 1542fe89252..c20e750aa16 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -514,9 +514,6 @@ int phy_init(void)
> phy_drv_reloc(drv);
>  #endif
>
> -#ifdef CONFIG_PHY_MSCC
> -   phy_mscc_init();
> -#endif
>  #ifdef CONFIG_PHY_FIXED
> phy_fixed_init();
>  #endif
> diff --git a/include/phy.h b/include/phy.h
> index fc8300d5d97..e4a3e10c48b 100644
> --- a/include/phy.h
> +++ b/include/phy.h
> @@ -315,7 +315,6 @@ int gen10g_startup(struct phy_device *phydev);
>  int gen10g_shutdown(struct phy_device *phydev);
>  int gen10g_discover_mmds(struct phy_device *phydev);
>
> -int phy_mscc_init(void);
>  int phy_fixed_init(void);
>  int phy_ncsi_init(void);
>  int phy_xilinx_gmii2rgmii_init(void);
> --
> 2.39.2
>
Reviewed-by: Ramon Fried 


Re: [PATCH 31/41] net: phy: intel-xway: Convert to U_BOOT_PHY_DRIVER()

2023-04-01 Thread Ramon Fried
On Sun, Mar 19, 2023 at 7:05 PM Marek Vasut
 wrote:
>
> Convert PHY driver to U_BOOT_PHY_DRIVER() macro and drop phy_register() init 
> call.
>
> Converted using sed
> "s@^static struct phy_driver \(.*\)_driver = \+{@U_BOOT_PHY_DRIVER(\L\1) = {"
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: "Ariel D'Alessandro" 
> Cc: "Cédric Le Goater" 
> Cc: "Marek Behún" 
> Cc: Alex Nemirovsky 
> Cc: Haolin Li 
> Cc: Heinrich Schuchardt 
> Cc: Joe Hershberger 
> Cc: Joel Stanley 
> Cc: Josua Mayer 
> Cc: Marek Vasut 
> Cc: Michael Trimarchi 
> Cc: Michal Simek 
> Cc: Nate Drude 
> Cc: Neil Armstrong 
> Cc: Radu Pirea 
> Cc: Ramon Fried 
> Cc: Samuel Mendoza-Jonas 
> Cc: Stefan Roese 
> Cc: T Karthik Reddy 
> Cc: Tim Harvey 
> Cc: Vladimir Oltean 
> Cc: u-boot-amlo...@groups.io
> ---
>  drivers/net/phy/intel_xway.c | 9 +
>  drivers/net/phy/phy.c| 3 ---
>  include/phy.h| 1 -
>  3 files changed, 1 insertion(+), 12 deletions(-)
>
> diff --git a/drivers/net/phy/intel_xway.c b/drivers/net/phy/intel_xway.c
> index dfce3f8332e..9d1b97d349f 100644
> --- a/drivers/net/phy/intel_xway.c
> +++ b/drivers/net/phy/intel_xway.c
> @@ -30,7 +30,7 @@ static int xway_config(struct phy_device *phydev)
> return 0;
>  }
>
> -static struct phy_driver XWAY_driver = {
> +U_BOOT_PHY_DRIVER(xway) = {
> .name = "XWAY",
> .uid = 0xD565A400,
> .mask = 0xff00,
> @@ -39,10 +39,3 @@ static struct phy_driver XWAY_driver = {
> .startup = genphy_startup,
> .shutdown = genphy_shutdown,
>  };
> -
> -int phy_xway_init(void)
> -{
> -   phy_register(&XWAY_driver);
> -
> -   return 0;
> -}
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index b85d5c4566d..1542fe89252 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -514,9 +514,6 @@ int phy_init(void)
> phy_drv_reloc(drv);
>  #endif
>
> -#ifdef CONFIG_PHY_XWAY
> -   phy_xway_init();
> -#endif
>  #ifdef CONFIG_PHY_MSCC
> phy_mscc_init();
>  #endif
> diff --git a/include/phy.h b/include/phy.h
> index e128ddf0037..fc8300d5d97 100644
> --- a/include/phy.h
> +++ b/include/phy.h
> @@ -315,7 +315,6 @@ int gen10g_startup(struct phy_device *phydev);
>  int gen10g_shutdown(struct phy_device *phydev);
>  int gen10g_discover_mmds(struct phy_device *phydev);
>
> -int phy_xway_init(void);
>  int phy_mscc_init(void);
>  int phy_fixed_init(void);
>  int phy_ncsi_init(void);
> --
> 2.39.2
>
Reviewed-by: Ramon Fried 


Re: [PATCH 30/41] net: phy: xilinx: Convert to U_BOOT_PHY_DRIVER()

2023-04-01 Thread Ramon Fried
On Sun, Mar 19, 2023 at 7:05 PM Marek Vasut
 wrote:
>
> Convert PHY driver to U_BOOT_PHY_DRIVER() macro and drop phy_register() init 
> call.
>
> Converted using sed
> "s@^static struct phy_driver \(.*\)_driver = \+{@U_BOOT_PHY_DRIVER(\L\1) = {"
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: "Ariel D'Alessandro" 
> Cc: "Cédric Le Goater" 
> Cc: "Marek Behún" 
> Cc: Alex Nemirovsky 
> Cc: Haolin Li 
> Cc: Heinrich Schuchardt 
> Cc: Joe Hershberger 
> Cc: Joel Stanley 
> Cc: Josua Mayer 
> Cc: Marek Vasut 
> Cc: Michael Trimarchi 
> Cc: Michal Simek 
> Cc: Nate Drude 
> Cc: Neil Armstrong 
> Cc: Radu Pirea 
> Cc: Ramon Fried 
> Cc: Samuel Mendoza-Jonas 
> Cc: Stefan Roese 
> Cc: T Karthik Reddy 
> Cc: Tim Harvey 
> Cc: Vladimir Oltean 
> Cc: u-boot-amlo...@groups.io
> ---
>  drivers/net/phy/phy.c|  3 ---
>  drivers/net/phy/xilinx_phy.c | 10 +-
>  include/phy.h|  1 -
>  3 files changed, 1 insertion(+), 13 deletions(-)
>
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index fff1d669fcd..b85d5c4566d 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -514,9 +514,6 @@ int phy_init(void)
> phy_drv_reloc(drv);
>  #endif
>
> -#ifdef CONFIG_PHY_XILINX
> -   phy_xilinx_init();
> -#endif
>  #ifdef CONFIG_PHY_XWAY
> phy_xway_init();
>  #endif
> diff --git a/drivers/net/phy/xilinx_phy.c b/drivers/net/phy/xilinx_phy.c
> index 39dbfdb7da8..1df639d6f44 100644
> --- a/drivers/net/phy/xilinx_phy.c
> +++ b/drivers/net/phy/xilinx_phy.c
> @@ -127,7 +127,7 @@ static int xilinxphy_config(struct phy_device *phydev)
> return 0;
>  }
>
> -static struct phy_driver xilinxphy_driver = {
> +U_BOOT_PHY_DRIVER(xilinxphy) = {
> .uid = XILINX_PHY_ID,
> .mask = XILINX_PHY_ID_MASK,
> .name = "Xilinx PCS/PMA PHY",
> @@ -136,11 +136,3 @@ static struct phy_driver xilinxphy_driver = {
> .startup = &xilinxphy_startup,
> .shutdown = &genphy_shutdown,
>  };
> -
> -int phy_xilinx_init(void)
> -{
> -   debug("%s\n", __func__);
> -   phy_register(&xilinxphy_driver);
> -
> -   return 0;
> -}
> diff --git a/include/phy.h b/include/phy.h
> index 74f3ada2491..e128ddf0037 100644
> --- a/include/phy.h
> +++ b/include/phy.h
> @@ -315,7 +315,6 @@ int gen10g_startup(struct phy_device *phydev);
>  int gen10g_shutdown(struct phy_device *phydev);
>  int gen10g_discover_mmds(struct phy_device *phydev);
>
> -int phy_xilinx_init(void);
>  int phy_xway_init(void);
>  int phy_mscc_init(void);
>  int phy_fixed_init(void);
> --
> 2.39.2
>
Reviewed-by: Ramon Fried 


Re: [PATCH 29/41] net: phy: vitesse: Convert to U_BOOT_PHY_DRIVER()

2023-04-01 Thread Ramon Fried
On Sun, Mar 19, 2023 at 7:05 PM Marek Vasut
 wrote:
>
> Convert PHY driver to U_BOOT_PHY_DRIVER() macro and drop phy_register() init 
> call.
>
> Converted using sed
> "s@^static struct phy_driver \(.*\)_driver = \+{@U_BOOT_PHY_DRIVER(\L\1) = {"
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: "Ariel D'Alessandro" 
> Cc: "Cédric Le Goater" 
> Cc: "Marek Behún" 
> Cc: Alex Nemirovsky 
> Cc: Haolin Li 
> Cc: Heinrich Schuchardt 
> Cc: Joe Hershberger 
> Cc: Joel Stanley 
> Cc: Josua Mayer 
> Cc: Marek Vasut 
> Cc: Michael Trimarchi 
> Cc: Michal Simek 
> Cc: Nate Drude 
> Cc: Neil Armstrong 
> Cc: Radu Pirea 
> Cc: Ramon Fried 
> Cc: Samuel Mendoza-Jonas 
> Cc: Stefan Roese 
> Cc: T Karthik Reddy 
> Cc: Tim Harvey 
> Cc: Vladimir Oltean 
> Cc: u-boot-amlo...@groups.io
> ---
>  drivers/net/phy/phy.c |  3 ---
>  drivers/net/phy/vitesse.c | 45 +++
>  include/phy.h |  1 -
>  3 files changed, 13 insertions(+), 36 deletions(-)
>
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 404d61c5ab3..fff1d669fcd 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -514,9 +514,6 @@ int phy_init(void)
> phy_drv_reloc(drv);
>  #endif
>
> -#ifdef CONFIG_PHY_VITESSE
> -   phy_vitesse_init();
> -#endif
>  #ifdef CONFIG_PHY_XILINX
> phy_xilinx_init();
>  #endif
> diff --git a/drivers/net/phy/vitesse.c b/drivers/net/phy/vitesse.c
> index eca26c98938..c5cf0d7dfbd 100644
> --- a/drivers/net/phy/vitesse.c
> +++ b/drivers/net/phy/vitesse.c
> @@ -293,7 +293,7 @@ static int vsc8664_config(struct phy_device *phydev)
> return 0;
>  }
>
> -static struct phy_driver VSC8211_driver = {
> +U_BOOT_PHY_DRIVER(vsc8211) = {
> .name   = "Vitesse VSC8211",
> .uid= 0xfc4b0,
> .mask   = 0x0,
> @@ -303,7 +303,7 @@ static struct phy_driver VSC8211_driver = {
> .shutdown = &genphy_shutdown,
>  };
>
> -static struct phy_driver VSC8221_driver = {
> +U_BOOT_PHY_DRIVER(vsc8221) = {
> .name = "Vitesse VSC8221",
> .uid = 0xfc550,
> .mask = 0x0,
> @@ -313,7 +313,7 @@ static struct phy_driver VSC8221_driver = {
> .shutdown = &genphy_shutdown,
>  };
>
> -static struct phy_driver VSC8244_driver = {
> +U_BOOT_PHY_DRIVER(vsc8244) = {
> .name = "Vitesse VSC8244",
> .uid = 0xfc6c0,
> .mask = 0x0,
> @@ -323,7 +323,7 @@ static struct phy_driver VSC8244_driver = {
> .shutdown = &genphy_shutdown,
>  };
>
> -static struct phy_driver VSC8234_driver = {
> +U_BOOT_PHY_DRIVER(vsc8234) = {
> .name = "Vitesse VSC8234",
> .uid = 0xfc620,
> .mask = 0x0,
> @@ -333,7 +333,7 @@ static struct phy_driver VSC8234_driver = {
> .shutdown = &genphy_shutdown,
>  };
>
> -static struct phy_driver VSC8574_driver = {
> +U_BOOT_PHY_DRIVER(vsc8574) = {
> .name = "Vitesse VSC8574",
> .uid = 0x704a0,
> .mask = 0x0,
> @@ -343,7 +343,7 @@ static struct phy_driver VSC8574_driver = {
> .shutdown = &genphy_shutdown,
>  };
>
> -static struct phy_driver VSC8514_driver = {
> +U_BOOT_PHY_DRIVER(vsc8514) = {
> .name = "Vitesse VSC8514",
> .uid = 0x70670,
> .mask = 0x0,
> @@ -353,7 +353,7 @@ static struct phy_driver VSC8514_driver = {
> .shutdown = &genphy_shutdown,
>  };
>
> -static struct phy_driver VSC8584_driver = {
> +U_BOOT_PHY_DRIVER(vsc8584) = {
> .name = "Vitesse VSC8584",
> .uid = 0x707c0,
> .mask = 0x0,
> @@ -363,7 +363,7 @@ static struct phy_driver VSC8584_driver = {
> .shutdown = &genphy_shutdown,
>  };
>
> -static struct phy_driver VSC8601_driver = {
> +U_BOOT_PHY_DRIVER(vsc8601) = {
> .name = "Vitesse VSC8601",
> .uid = 0x70420,
> .mask = 0x0,
> @@ -373,7 +373,7 @@ static struct phy_driver VSC8601_driver = {
> .shutdown = &genphy_shutdown,
>  };
>
> -static struct phy_driver VSC8641_driver = {
> +U_BOOT_PHY_DRIVER(vsc8641) = {
> .name = "Vitesse VSC8641",
> .uid = 0x70430,
> .mask = 0x0,
> @@ -383,7 +383,7 @@ static struct phy_driver VSC8641_driver = {
> .shutdown = &genphy_shutdown,
>  };
>
> -static struct phy_driver VSC8662_driver = {
> +U_BOOT_PHY_DRIVER(vsc8662) = {
> .name = "Vitesse VSC8662",
> .uid = 0x70660,
> .mask = 0x0,
> @@ -393,7 +393,7 @@ static struct phy_driver VSC8662_driver = {
> .shutdown = &genphy_shutdown,
>  };
>
> -static struct phy_driver VSC8664_driver = {
> +U_BOOT_PHY_DRIVER(vsc8664) = {
> .name = "Vitesse VSC8664",
> .uid = 0x70660,
> .mask = 0x0,
> @@ -404,7 +404,7 @@ static struct phy_driver VSC8664_driver = {
>  };
>
>  /* Vitesse bought Cicada, so we'll put these here */
> -static struct phy_driver cis8201_driver = {
> +U_BOOT_PHY_DRIVER(cis8201) = {
> .name = "CIS8201",
> .uid = 0xfc410,
> .mask = 0x0,
> @@ -414,7 +414,7 @@ static 

Re: A38x BootROM MMC_CMD_SEND_STATUS timeouts

2023-04-01 Thread Pali Rohár
Can anybody help with this?

On Saturday 25 March 2023 13:25:06 Pali Rohár wrote:
> CCing MMC maintainers (Peng Fan & Jaehoon Chung). Could you help us with
> this issue? Expected usage is following: BootROM reads and execute SPL
> from eMMC (BootROM has its own code for reading eMMC), SPL initialize
> mmc driver and after SPL finish its work it returns control back to
> BootROM and BootROM reads and execute proper U-Boot from eMMC. And issue
> is that after SPL returns control back to BootROM it looks like that
> BootROM is sending MMC_CMD_SEND_STATUS command to eMMC but it timeouts
> (timeout takes 5 minutes!) and after it correctly reads proper U-Boot
> from eMMC and continues booting proper U-Boot. I guess that there is an
> issue that SPL's mmc driver changes eMMC state into something which
> BootROM does not expect.
> 
> On Friday 24 March 2023 02:55:55 Martin Rowe wrote:
> > On Thu, 23 Mar 2023 at 19:01, Pali Rohár  wrote:
> > > There is issue with that 5 minutes delay. But I think it should be fixed
> > > by the patch which I sent earlier, which restore partition config based
> > > on mmc->part_config in board_return_to_bootrom(). Could you test it?
> > > https://lore.kernel.org/u-boot/20230305160416.xc7wlzmkaociwcf7@pali/
> > > Now when mmc->part_config is correctly initialized it should restore
> > > configuration and BootROM does not have to get that "Timeout waiting
> > > card ready" error.
> > 
> > Still takes about 5 minutes. The output is below with MMC tracing. I
> > confirmed the value of mmc->part_config used for
> > restore_emmc_boot_part_config is the same as what is initially
> > detected early in SPL (both are 10 with mmc partconf 0 0 1 1 and
> > zeroed boot0).
> > 
> > ERROR: Invalid kwbimage v1
> > mmc_load_image_raw_sector: mmc block read error
> > spl: mmc: wrong boot mode
> > Trying to boot from BOOTROM
> > CMD_SEND:6
> > ARG 0x03b30a00
> > MMC_RSP_R1b 0x0900
> > CMD_SEND:13
> > ARG 0x0001
> > MMC_RSP_R1,5,6,7  0x0900
> > CURR STATE:4
> > Returning to BootROM (return address 0x05c4)...
> 
> I looked at the BootROM disassembled code and error message
> "Timeout waiting card ready" is printed when following mmc command
> cmdidx=0xd, resptype=0x15, cmdarg=(something)<<0x10 timeouts.
> 
> 0xd is in U-Boot MMC_CMD_SEND_STATUS
> 
> 0x15 is in U-Boot MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC|MMC_RSP_BUSY
> which looks like U-Boot's MMC_RSP_R2 with BUSY bit set
> 
> It looks like U-Boot function mmc_send_status() where that "something"
> in cmdarg is mmc->rca.
> 
> If command does not timeout then BootROM next checks if response has
> BIT(8) set and if response mask 0x1e00 matches value 0xe00. If both are
> truth then BootROM mark call as successful.
> 
> If response ANDed with mask 0xfdf94080 is non-zero then BootROM prints
> "Status Error: " with hex response value and mark call as unsuccessful.
> 
> I'm looking at the U-Boot code and this BootROM logic looks very similar
> to U-Boot function mmc_poll_for_busy(), just without first call
> mmc_wait_dat0().
> 
> BIT(8) is MMC_STATUS_RDY_FOR_DATA
> 0x1e00 is MMC_STATUS_CURR_STATE
> 0xe00 is MMC_STATE_PRG
> 0xfdf94080 is MMC_STATUS_MASK
> 
> I'm not mmc expert, but this looks like MMC_CMD_SEND_STATUS is failing
> in BootROM after U-Boot returns control back to the BootROM.


[PATCH 4/4] arm: histb: hi3798mv200: add initial support for Hi3798MV200 HC2910-2AGHD05 board

2023-04-01 Thread Yang Xiwen
A board with Hi3798MV200 SoC and various peripherals. Details are in the
board README.md.

Signed-off-by: Yang Xiwen 
---
 .../hi3798mv200-hc2910-2aghd05-u-boot.dtsi|   8 +
 arch/arm/dts/hi3798mv200-hc2910-2aghd05.dts   |  71 ++
 arch/arm/dts/hi3798mv200-u-boot.dtsi  |  22 ++
 arch/arm/dts/hi3798mv200.dtsi | 225 ++
 arch/arm/mach-histb/Kconfig   |  25 ++
 board/skyworth/hc2910-2aghd05/Kconfig |  15 ++
 board/skyworth/hc2910-2aghd05/MAINTAINERS |   6 +
 board/skyworth/hc2910-2aghd05/Makefile|   1 +
 board/skyworth/hc2910-2aghd05/README  |  25 ++
 .../skyworth/hc2910-2aghd05/hc2910-2aghd05.c  |  26 ++
 configs/hc2910_2aghd05_defconfig  |  50 
 include/configs/hc2910-2aghd05.h  |   6 +
 12 files changed, 480 insertions(+)
 create mode 100644 arch/arm/dts/hi3798mv200-hc2910-2aghd05-u-boot.dtsi
 create mode 100644 arch/arm/dts/hi3798mv200-hc2910-2aghd05.dts
 create mode 100644 arch/arm/dts/hi3798mv200-u-boot.dtsi
 create mode 100644 arch/arm/dts/hi3798mv200.dtsi
 create mode 100644 board/skyworth/hc2910-2aghd05/Kconfig
 create mode 100644 board/skyworth/hc2910-2aghd05/MAINTAINERS
 create mode 100644 board/skyworth/hc2910-2aghd05/Makefile
 create mode 100644 board/skyworth/hc2910-2aghd05/README
 create mode 100644 board/skyworth/hc2910-2aghd05/hc2910-2aghd05.c
 create mode 100644 configs/hc2910_2aghd05_defconfig
 create mode 100644 include/configs/hc2910-2aghd05.h

diff --git a/arch/arm/dts/hi3798mv200-hc2910-2aghd05-u-boot.dtsi 
b/arch/arm/dts/hi3798mv200-hc2910-2aghd05-u-boot.dtsi
new file mode 100644
index 00..eb320761f2
--- /dev/null
+++ b/arch/arm/dts/hi3798mv200-hc2910-2aghd05-u-boot.dtsi
@@ -0,0 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include "hi3798mv200-u-boot.dtsi"
+
+/* The clock driver is missing */
+&sd0 {
+   status = "disabled";
+};
diff --git a/arch/arm/dts/hi3798mv200-hc2910-2aghd05.dts 
b/arch/arm/dts/hi3798mv200-hc2910-2aghd05.dts
new file mode 100644
index 00..c4ca5ed235
--- /dev/null
+++ b/arch/arm/dts/hi3798mv200-hc2910-2aghd05.dts
@@ -0,0 +1,71 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * DTS File for Skyworth HC2910 with board label 2AGHD05 set-top box.
+ *
+ * Released under the GPLv2 only.
+ */
+
+/dts-v1/;
+
+#include "hi3798mv200.dtsi"
+
+/ {
+   // Usually known as Henan Guangdian HC2910
+   model = "Skyworth HC2910 with board label 2AGHD05";
+   compatible = "skyworth,hc2910-2aghd05", "hisilicon,hi3798mv200";
+
+   aliases {
+   serial0 = &uart0;
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   memory@0 {
+   device_type = "memory";
+   reg = <0x0 0x0 0x0 0x8000>;
+   };
+};
+
+&ehci {
+   status = "okay";
+};
+
+&emmc {
+   fifo-depth = <256>;
+   clock-frequency = <2>;
+   cap-mmc-highspeed;
+   mmc-ddr-1_8v;
+   mmc-hs200-1_8v;
+   non-removable;
+   bus-width = <8>;
+   status = "okay";
+};
+
+&gmac {
+   status = "okay";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   phy-handle = <ð_phy1>;
+   phy-mode = "rgmii";
+   hisilicon,phy-reset-delays-us = <1 1 3>;
+
+   eth_phy1: phy@3 {
+   reg = <3>;
+   };
+};
+
+&ohci {
+   status = "okay";
+};
+
+&sd0 {
+   bus-width = <4>;
+   cap-sd-highspeed;
+   status = "okay";
+};
+
+&uart0 {
+   status = "okay";
+};
diff --git a/arch/arm/dts/hi3798mv200-u-boot.dtsi 
b/arch/arm/dts/hi3798mv200-u-boot.dtsi
new file mode 100644
index 00..8917bcf33d
--- /dev/null
+++ b/arch/arm/dts/hi3798mv200-u-boot.dtsi
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * U-Boot addition to:
+ *  1) use platform data for the console
+ *
+ */
+
+#include 
+
+/* The driver in U-Boot does not support "snps,dw-mshc" compatible. */
+&sd0 {
+   compatible = "hisilicon,hi3798mv200-dw-mshc";
+};
+
+&sd1 {
+   compatible = "hisilicon,hi3798mv200-dw-mshc";
+};
+
+/* The clock driver is missing */
+&uart0 {
+   clock = <7500>;
+};
diff --git a/arch/arm/dts/hi3798mv200.dtsi b/arch/arm/dts/hi3798mv200.dtsi
new file mode 100644
index 00..fedf87ac67
--- /dev/null
+++ b/arch/arm/dts/hi3798mv200.dtsi
@@ -0,0 +1,225 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * DTS File for HiSilicon Hi3798mv200 SoC.
+ *
+ * Released under the GPLv2 only.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+/ {
+   compatible = "hisilicon,hi3798mv200";
+   interrupt-parent = <&gic>;
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   psci {
+   compatible = "arm,psci-0.2";
+   method = "smc";
+   };
+
+   cpus {
+   #address-cells = <2>;
+   #size-cells = <0>;
+
+   cpu@0 {
+   compatible = "arm,cortex-a53";
+   device_type = "cpu";
+  

[PATCH 3/4] dt-binding: histb-clock: add clocks definition for Hi3798MV200

2023-04-01 Thread Yang Xiwen
These clocks are found on Hi3798MV200

Signed-off-by: Yang Xiwen 
---
 include/dt-bindings/clock/histb-clock.h | 12 
 1 file changed, 12 insertions(+)

diff --git a/include/dt-bindings/clock/histb-clock.h 
b/include/dt-bindings/clock/histb-clock.h
index 136de24733..8a05790d1a 100644
--- a/include/dt-bindings/clock/histb-clock.h
+++ b/include/dt-bindings/clock/histb-clock.h
@@ -70,6 +70,18 @@
 #define HISTB_USB3_UTMI_CLK1   48
 #define HISTB_USB3_PIPE_CLK1   49
 #define HISTB_USB3_SUSPEND_CLK150
+#define HISTB_SDIO1_BIU_CLK51
+#define HISTB_SDIO1_CIU_CLK52
+#define HISTB_SDIO1_DRV_CLK53
+#define HISTB_SDIO1_SAMPLE_CLK 54
+
+/* Hi3798MV200 specific clocks */
+
+// reuse clocks of histb
+#define HI3798MV200_GMAC_CLK   HISTB_ETH0_MAC_CLK
+#define HI3798MV200_GMACIF_CLK HISTB_ETH0_MACIF_CLK
+#define HI3798MV200_FEMAC_CLK  HISTB_ETH1_MAC_CLK
+#define HI3798MV200_FEMACIF_CLKHISTB_ETH1_MACIF_CLK
 
 /* clocks provided by mcu CRG */
 #define HISTB_MCE_CLK  1
-- 
2.39.1



[PATCH 2/4] mmc: hi6220_dw_mmc: add compatible for HC2910 support

2023-04-01 Thread Yang Xiwen
It adds compatible "hisilicon,hi3798mv200-dw-mshc" for HC2910 SoC
Hi3798MV200 to probe this mmc driver.

Signed-off-by: Yang Xiwen 
---
 drivers/mmc/hi6220_dw_mmc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mmc/hi6220_dw_mmc.c b/drivers/mmc/hi6220_dw_mmc.c
index 2cec5b9ae3..71962cd47e 100644
--- a/drivers/mmc/hi6220_dw_mmc.c
+++ b/drivers/mmc/hi6220_dw_mmc.c
@@ -100,6 +100,8 @@ static const struct udevice_id hi6220_dwmmc_ids[] = {
  .data = (ulong)&hi6220_mmc_data },
{ .compatible = "hisilicon,hi3798cv200-dw-mshc",
  .data = (ulong)&hi6220_mmc_data },
+   { .compatible = "hisilicon,hi3798mv200-dw-mshc",
+ .data = (ulong)&hi6220_mmc_data },
{ .compatible = "hisilicon,hi3660-dw-mshc",
  .data = (ulong)&hi3660_mmc_data },
{ }
-- 
2.39.1



[PATCH 1/4] arm: add support for Hisilicon HiSTB family SoCs

2023-04-01 Thread Yang Xiwen
First supported chip is hi3798mv200 (which is similar to Hi3798cv200
used by poplar).

Signed-off-by: Yang Xiwen 
---
 MAINTAINERS|  1 +
 arch/arm/Kconfig   | 12 
 arch/arm/Makefile  |  1 +
 arch/arm/mach-histb/Kconfig| 14 ++
 arch/arm/mach-histb/Makefile   |  4 
 arch/arm/mach-histb/board_common.c | 31 ++
 arch/arm/mach-histb/sysmap-histb.c | 31 ++
 7 files changed, 94 insertions(+)
 create mode 100644 arch/arm/mach-histb/Kconfig
 create mode 100644 arch/arm/mach-histb/Makefile
 create mode 100644 arch/arm/mach-histb/board_common.c
 create mode 100644 arch/arm/mach-histb/sysmap-histb.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 91d40ea4b6..ea7bf5e04c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -291,6 +291,7 @@ S:  Maintained
 F: arch/arm/cpu/armv8/hisilicon
 F: arch/arm/include/asm/arch-hi6220/
 F: arch/arm/include/asm/arch-hi3660/
+F: arch/arm/mach-histb
 
 ARM HPE GXP ARCHITECTURE
 M: Jean-Marie Verdun 
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 8a1e223422..a80322a48a 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -578,6 +578,16 @@ config ARCH_DAVINCI
help
  Support for TI's DaVinci platform.
 
+config ARCH_HISTB
+   bool "Hisilicon HiSTB SoCs"
+   select DM
+   select DM_SERIAL
+   select OF_CONTROL
+   select PL01X_SERIAL
+   imply CMD_DM
+   help
+ Support for HiSTB SoCs.
+
 config ARCH_KIRKWOOD
bool "Marvell Kirkwood"
select ARCH_MISC_INIT
@@ -2156,6 +2166,8 @@ source "arch/arm/mach-hpe/gxp/Kconfig"
 
 source "arch/arm/mach-highbank/Kconfig"
 
+source "arch/arm/mach-histb/Kconfig"
+
 source "arch/arm/mach-integrator/Kconfig"
 
 source "arch/arm/mach-ipq40xx/Kconfig"
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index ac602aed9c..5ebe0619d3 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -61,6 +61,7 @@ machine-$(CONFIG_ARCH_DAVINCI)+= davinci
 machine-$(CONFIG_ARCH_EXYNOS)  += exynos
 machine-$(CONFIG_ARCH_GXP) += hpe
 machine-$(CONFIG_ARCH_HIGHBANK)+= highbank
+machine-$(CONFIG_ARCH_HISTB)   += histb
 machine-$(CONFIG_ARCH_IPQ40XX) += ipq40xx
 machine-$(CONFIG_ARCH_K3)  += k3
 machine-$(CONFIG_ARCH_KEYSTONE)+= keystone
diff --git a/arch/arm/mach-histb/Kconfig b/arch/arm/mach-histb/Kconfig
new file mode 100644
index 00..78d40859a3
--- /dev/null
+++ b/arch/arm/mach-histb/Kconfig
@@ -0,0 +1,14 @@
+if ARCH_HISTB
+
+choice
+   prompt "Select a HiSTB SoC"
+
+config ARCH_HI3798MV2X
+   bool "Hi3798M V2XX series SoC"
+   select ARM64
+   help
+ Support for Hi3798MV2XX series SoCs.
+
+endchoice
+
+endif
diff --git a/arch/arm/mach-histb/Makefile b/arch/arm/mach-histb/Makefile
new file mode 100644
index 00..7975c0f2a0
--- /dev/null
+++ b/arch/arm/mach-histb/Makefile
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-y += sysmap-histb.o
+obj-y += board_common.o
diff --git a/arch/arm/mach-histb/board_common.c 
b/arch/arm/mach-histb/board_common.c
new file mode 100644
index 00..a26c2066e0
--- /dev/null
+++ b/arch/arm/mach-histb/board_common.c
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Board init file for all histb boards
+ *
+ * (C) Copyright 2023 Yang Xiwen 
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+int __weak board_init(void)
+{
+   return 0;
+}
+
+int __weak dram_init_banksize(void)
+{
+   return fdtdec_setup_memory_banksize();
+}
+
+int __weak dram_init(void)
+{
+   return fdtdec_setup_mem_size_base();
+}
+
+void __weak reset_cpu(void)
+{
+   psci_system_reset();
+}
diff --git a/arch/arm/mach-histb/sysmap-histb.c 
b/arch/arm/mach-histb/sysmap-histb.c
new file mode 100644
index 00..83a2bb9417
--- /dev/null
+++ b/arch/arm/mach-histb/sysmap-histb.c
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Hisilicon HiSTB memory map
+ *
+ * (C) Copyright 2023 Yang Xiwen 
+ */
+
+#include 
+#include 
+
+static struct mm_region histb_mem_map[] = {
+   {
+   .virt = 0x0UL, /* DRAM */
+   .phys = 0x0UL,
+   .size = 0x8000UL,
+   .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+PTE_BLOCK_INNER_SHARE
+   }, {
+   .virt = 0x8000UL, /* Peripheral block */
+   .phys = 0x8000UL,
+   .size = 0x8000UL,
+   .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+PTE_BLOCK_NON_SHARE |
+PTE_BLOCK_PXN | PTE_BLOCK_UXN
+   }, {
+   /* Terminator */
+   0,
+   }
+};
+
+struct mm_region *mem_map = histb_mem_map;
-- 
2.39.1



  1   2   >