Re: [RFC PATCH 0/5] Allow for removal of DT nodes and properties

2023-09-06 Thread Ilias Apalodimas
Hi Rob,

[...]

> > > > > >
> > > > > > What is the point of removing them? Instead, we should make sure 
> > > > > > that
> > > > > > we upstream the bindings and encourage SoC vendors to sync them. If 
> > > > > > we
> > > > > > remove them, no one will bother and U-Boot just becomes a dumping
> > > > > > ground.
> > > > >
> > > > > Well things like the binman entries in DT are U-Boot specific and not
> > > > > useful for HW related descriptions or for Linux or another OS being
> > > > > able to deal with HW so arguably we're already a dumping ground to
> > > > > some degree for not defining hardware.
> > > >
> > > > I have started the process to upstream the binman bindings.
> > >
> > > I don't think they should be in DT at all, they don't describe
> > > anything to do with hardware, or generally even the runtime of a
> > > device, they don't even describe the boot/runtime state of the
> > > firmware, they describe build time, so I don't see what that has to do
> > > with device tree? Can you explain that? To me those sorts of things
> > > should live in a build time style config file.
>
> For the record, I tend to agree.
>

+1

> > I beg to differ. Devicetree is more than just hardware and always has
> > been. See, for example the /chosen and /options nodes.
>
> There are exceptions...
>

We've been this over and over again and frankly it gets a bit annoying.
It's called *DEVICE* tree for a reason.  As Rob pointed out there are
exceptions, but those made a lot of sense.  Having arbitrary internal ABI
stuff of various projects in the schema just defeats the definition of a
spec.

> > We need run-time configuration here, since we cannot know at build
> > time what we will be asked to do by a previous firmware phase.
>
> Really, I don't want to have to care about the binman binding. If it is
> u-boot specific, then it should stay in u-boot. I took /options/u-boot/,
> but now I'm starting to have second thoughts on that being in dtschema
> if it is going to be continually and frequently extended. Validating it
> in SR does little. If a vendor is abusing /options/u-boot/ in some way
> they could just as easily remove the node in their u-boot fork to pass.
> SR is certainly not going to require the node be there.
>
> On A/B updates, that really doesn't seem like a u-boot specific problem
> to me. No one wants A/B updates in EDK2 or anything else?

A/B updates might be implemented in EDK2 or any other bootloader that
chooses to implement it.  The metadata information a bootloader needs
to implement it are documented here [0].  Those metadata are not part of
the DT.  If they were it would make sense to add them on the schema.  The
DT entry we are using though serves a different purpose.  It tells the
bootloader the location of the metadata (iow where can I read them from the
disk).  Since bootloaders have a different way of storing their
configuration, I don't think this needs to be in the spec.  EDK2 for
example doesn't always use a DT and I don't think they'll ever use it to
store configuration information.

[0] https://developer.arm.com/documentation/den0118/b/?lang=en

Thanks
/Ilias
>
> Rob


Re: [PATCH 3/3] arm: dts: j7200: dtb sync with Linux 6.5-rc1

2023-09-06 Thread Manorit Chawdhry
Hi Reid,

On 13:13-20230905, Reid Tonking wrote:
> Sync j7200 device tree files with Linux 6.5-rc1
> 
> - k3-j7200-r5-common-proc-board.dts now inherits from
>   k3-j7200-common-proc-board.dts instead of k3-j7200-som-p0.dtsi. This
>   allows us to trim down the r5 file considerably by using existing
>   properties.
> 
> - remove pimux nodes from r5 file
> 
> - remove duplicate nodes & node properties from r5/u-boot files
> 
> - mcu_timer0 now used instead of timer1
> 
>   mcu_timer0 device id added to dev-data.c file in order to work
> 
> - remove cpsw node
> 
>   This node is no longer required since the compatible is now fixed
> 
> - remove dummy_clock_19_2_mhz
> 
>   This node wasn't being used anyhere, so it was removed.
> 
> - remove dummy_clock_200mhz
> 
>   main_sdhci0 & main_sdhci1 no longer need dummy clock for eMMC/SD
> 
> - fix secure proxy node
> 
>   mcu_secproxy changed to used secure_prxy_mcu which is already
>   defined in k3-j7200-mcu-wakeup.dtsi
> 
> Signed-off-by: Reid Tonking 
> ---
>  .../k3-j7200-common-proc-board-u-boot.dtsi| 160 +++---
>  arch/arm/dts/k3-j7200-common-proc-board.dts   | 170 --
>  arch/arm/dts/k3-j7200-main.dtsi   | 512 +-
>  arch/arm/dts/k3-j7200-mcu-wakeup.dtsi | 265 -
>  .../arm/dts/k3-j7200-r5-common-proc-board.dts | 301 +-
>  arch/arm/dts/k3-j7200-som-p0.dtsi | 153 --
>  arch/arm/dts/k3-j7200-thermal.dtsi|  47 ++
>  arch/arm/dts/k3-j7200.dtsi|  30 +-
>  8 files changed, 1150 insertions(+), 488 deletions(-)
>  create mode 100644 arch/arm/dts/k3-j7200-thermal.dtsi
> 
> diff --git a/arch/arm/dts/k3-j7200-common-proc-board-u-boot.dtsi 
> b/arch/arm/dts/k3-j7200-common-proc-board-u-boot.dtsi
> index f25c7136c9..c32df00e9c 100644
> --- a/arch/arm/dts/k3-j7200-common-proc-board-u-boot.dtsi
> +++ b/arch/arm/dts/k3-j7200-common-proc-board-u-boot.dtsi
> @@ -1,22 +1,13 @@
>  // SPDX-License-Identifier: GPL-2.0
>  /*
> - * Copyright (C) 2020 Texas Instruments Incorporated - https://www.ti.com/
> + * Copyright (C) 2020-2023 Texas Instruments Incorporated - 
> https://www.ti.com/
>   */
>  
>  #include "k3-j7200-binman.dtsi"
>  
>  / {
>   chosen {
> - stdout-path = "serial2:115200n8";
> - tick-timer = 
> - };
> -
> - aliases {
> - ethernet0 = _port1;
> - i2c0 = _i2c0;
> - i2c1 = _i2c0;
> - i2c2 = _i2c1;
> - i2c3 = _i2c0;
> + tick-timer = _timer0;
>   };
>  };
>  
> @@ -28,48 +19,42 @@
>   bootph-pre-ram;
>  };
>  
> -_mcu_wakeup {
> +_esm {
>   bootph-pre-ram;
> +};
>  
> - timer1: timer@4040 {
> - compatible = "ti,omap5430-timer";
> - reg = <0x0 0x4040 0x0 0x80>;
> - ti,timer-alwon;
> - clock-frequency = <25000>;
> - bootph-pre-ram;
> - };
> +_mcu_wakeup {
> + bootph-pre-ram;
>  
>   chipid@4314 {
>   bootph-pre-ram;
>   };
> +};
>  
> - mcu_navss: bus@2838 {
> - bootph-pre-ram;
> - #address-cells = <2>;
> - #size-cells = <2>;
> -
> - ringacc@2b80 {
> - reg =   <0x0 0x2b80 0x0 0x40>,
> - <0x0 0x2b00 0x0 0x40>,
> - <0x0 0x2859 0x0 0x100>,
> - <0x0 0x2a50 0x0 0x4>,
> - <0x0 0x2844 0x0 0x4>;
> - reg-names = "rt", "fifos", "proxy_gcfg", 
> "proxy_target", "cfg";
> - bootph-pre-ram;
> - };
> -
> - dma-controller@285c {
> - reg =   <0x0 0x285c 0x0 0x100>,
> - <0x0 0x284c 0x0 0x4000>,
> - <0x0 0x2a80 0x0 0x4>,
> - <0x0 0x284a 0x0 0x4000>,
> - <0x0 0x2aa0 0x0 0x4>,
> - <0x0 0x2840 0x0 0x2000>;
> - reg-names = "gcfg", "rchan", "rchanrt", "tchan",
> - "tchanrt", "rflow";
> - bootph-pre-ram;
> - };
> - };
> +_navss {
> + bootph-pre-ram;
> +};
> +
> +_ringacc {
> + reg = <0x0 0x2b80 0x0 0x40>,
> + <0x0 0x2b00 0x0 0x40>,
> + <0x0 0x2859 0x0 0x100>,
> + <0x0 0x2a50 0x0 0x4>,
> + <0x0 0x2844 0x0 0x4>;
> + reg-names = "rt", "fifos", "proxy_gcfg", "proxy_target", "cfg";
> + bootph-pre-ram;
> +};
> +
> +_udmap {
> + reg = <0x0 0x285c 0x0 0x100>,
> + <0x0 0x284c 0x0 0x4000>,
> + <0x0 0x2a80 0x0 0x4>,
> + <0x0 0x284a 0x0 0x4000>,
> + <0x0 0x2aa0 0x0 0x4>,
> + <0x0 0x2840 0x0 0x2000>;
> + 

Re: [PATCH 1/3] drivers: misc: k3_avs: Add Linux compatible to enable avs in u-boot

2023-09-06 Thread Kumar, Udit



On 9/7/2023 12:58 AM, reidt wrote:

On 13:06-20230906, Nishanth Menon wrote:

On 13:13-20230905, Reid Tonking wrote:

The ti,j7200-vtm compatible is used for voltage and thermal monitoring
(VTM) by (drivers/thermal/k3_j72xx_bandgap.c) in Linux, but the same
hardware is used for adaptive voltage scaling (AVS) in u-boot, This brings
both drivers in line with the same compatible. Since the j7200 uses the
config as the j721e, the data is inherited from j721e vs creating a
duplicate in all but name.

Signed-off-by: Reid Tonking 
---
  drivers/misc/k3_avs.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/k3_avs.c b/drivers/misc/k3_avs.c
index 840148d090..f7936017ba 100644
--- a/drivers/misc/k3_avs.c
+++ b/drivers/misc/k3_avs.c
@@ -382,7 +382,7 @@ static struct vd_config am654_vd_config = {
  static const struct udevice_id k3_avs_ids[] = {
{ .compatible = "ti,am654-avs", .data = (ulong)_vd_config },
{ .compatible = "ti,j721e-avs", .data = (ulong)_vd_config },
-   {}
+   { .compatible = "ti,j7200-vtm", .data = (ulong)_vd_config }

you don't need the null terminator?


Ah, I wasn't aware of its purpose until now, but searched it up.
I'll add it back in for v3.


  };
  
  U_BOOT_DRIVER(k3_avs) = {

--
2.34.1


https://lore.kernel.org/all/1fed9388-dfc4-0b9c-4502-b5020b2ae...@ti.com/

Will let Udit and you sort this out.

Udit and I talked a bit about this yesterday. It's something to explore
implementing down the road, after this sync - nothing immediate


Integration of TSHUT or porting of bandgap driver into this driver is 
incremental work.


So change of name is compatible for this series is ok.

Thanks



--
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 
849D 1736 249D

Thanks,
Reid Tonking


Re: [RFC PATCH 0/5] Allow for removal of DT nodes and properties

2023-09-06 Thread Tom Rini
On Thu, Sep 07, 2023 at 01:30:01AM +0200, Heinrich Schuchardt wrote:

[snip]
> The missing piece is validation of the U-Boot internal device-trees
> against a schema in the U-Boot CI. This should be possible even if some
> of the schema yaml files are maintained inside the U-Boot repo.

Dropping Rob since I don't think he cares about this part.  Yes, what we
need is some help in re-syncing our Kbuild (and Kconfig, but..) logic
with the kernel as it's stuck at v4.20 still and all of the parts that
make running the validation targets would be much easier (free) if we
were in sync or much closer at least. It would be much appreciated if
Linaro or Canonical or one of the other companies doing U-Boot work
could get someone to focus on this task.  It would help with a number of
things, this included.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 3/3] Azure: Add sandbox64 to CI

2023-09-06 Thread Tom Rini
On Fri, Sep 01, 2023 at 04:41:43PM -0400, Tom Rini wrote:

> Now that sandbox64 can run and pass the regular test.py suite, add it
> here as well.
> 
> Signed-off-by: Tom Rini 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 2/3] Azure: Split sandbox and qemu test.py runs

2023-09-06 Thread Tom Rini
On Fri, Sep 01, 2023 at 04:41:42PM -0400, Tom Rini wrote:

> Currently, most sandbox runs take a long time (due to running so many
> tests) while QEMu based test.py runs are fairly short.  Split the
> pipeline here so that we get more consistent average run times.
> 
> Signed-off-by: Tom Rini 
> Reviewed-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/3] Azure: Rework test_py job to publish its wrapper script

2023-09-06 Thread Tom Rini
On Fri, Sep 01, 2023 at 04:41:41PM -0400, Tom Rini wrote:

> Both to aide in debugging of any test.py issues as well as to make it
> easier to split the current matrix in two, have a new job that creates
> and publishes the current wrapper script we use for test.py jobs.
> 
> Signed-off-by: Tom Rini 
> Reviewed-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] .gitlab-ci: Test sandbox64 board in addition to sandbox

2023-09-06 Thread Tom Rini
On Fri, Sep 01, 2023 at 10:48:10AM +0200, Marek Vasut wrote:

> Test both 32bit and 64bit sandbox boards in CI.
> 
> Signed-off-by: Marek Vasut 
> Reviewed-by: Tom Rini 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v2] test: print: Fix hexdump test on 64bit systems

2023-09-06 Thread Tom Rini
On Fri, Aug 25, 2023 at 10:19:40AM +0200, Marek Vasut wrote:

> Use the following regex to make this test compatible with
> both 32bit and 64bit systems. The trick is to use %0*lx
> format string for the address prefix in the test.
> 
> "
> s@\(ut_assert_nextline("\)0\+\([^:]\+\)\(:.*"\)\();\)@\1%0*lx\3, 
> IS_ENABLED(CONFIG_PHYS_64BIT) ? 16 : 8, 0x\2UL\4
> "
> 
> Signed-off-by: Marek Vasut 
> Reviewed-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] test: dm: test-fdt: Use fdtdec_get_int() in dm_check_devices()

2023-09-06 Thread Tom Rini
On Wed, Aug 23, 2023 at 09:37:44PM +0200, Marek Vasut wrote:

> The current fdtdec_get_addr() takes into consideration #address-cells
> and #size-cells for "ping-expect" property which is clearly neither.
> Use fdtdec_get_int() instead and return negative one in case the
> property is not in DT or the platform under test is not DT based,
> i.e. mimic the current fdtdec_get_addr() behavior.
> 
> This fixes ut dm dm_test_bus_children test.
> 
> Signed-off-by: Marek Vasut 
> Reviewed-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] configs: sandbox64: Enable legacy image format support

2023-09-06 Thread Tom Rini
On Wed, Aug 23, 2023 at 02:17:12AM +0200, Marek Vasut wrote:

> Align the sandbox64 defconfig with sandbox defconfig. Enable missing
> legacy image format support. This fixes ut_bootstd_bootflow_cmd_menu
> test.
> 
> Suggested-by: Jonas Karlman 
> Signed-off-by: Marek Vasut 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 4/4] CI: Drop some jobs we didn't really utilize

2023-09-06 Thread Tom Rini
On Sun, Aug 20, 2023 at 01:31:29PM -0400, Tom Rini wrote:

> - We have added more TODO/etc comments since this task was created and
>   never focused on removing them.
> - The output of sloccount isn't preserved or looked at, and if desired
>   should be in the release stats pages instead somehow.
> - The results of cppcheck aren't investigated and require modeling work
>   to be useful to start with.
> 
> Signed-off-by: Tom Rini 
> Reviewed-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 3/4] CI: Combine tools-only and envtools jobs

2023-09-06 Thread Tom Rini
On Sun, Aug 20, 2023 at 01:31:28PM -0400, Tom Rini wrote:

> These jobs are to confirm specific build targets, on a Linux host.  We
> can safely combine these two build tests, with a make mrproper in
> between.
> 
> Signed-off-by: Tom Rini 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 2/4] Azure: Rework build the world jobs

2023-09-06 Thread Tom Rini
On Sun, Aug 20, 2023 at 01:31:27PM -0400, Tom Rini wrote:

> Now that we have 3600 minutes per build job, condense and rework things
> such that our overall time largely doesn't change, but we can also
> largely avoid having to re-tweak this job to avoid timeouts.  Given that
> we have 10 threads, we also move a few of the specific sandbox test
> builds to a prior stage.
> 
> Note that while sandbox builds with address sanitization enabled (ASAN)
> not all tests pass, so we limit ourselves to just checking that the
> version test passes for now.
> 
> Link: 
> https://learn.microsoft.com/en-us/azure/devops/pipelines/process/phases?view=azure-devops=yaml#timeouts
> Signed-off-by: Tom Rini 
> Reviewed-by: Simon Glass 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH 3/3] imx: hab: Explain that ivt_offset is optional

2023-09-06 Thread Fabio Estevam
From: Fabio Estevam 

The ivt_offset parameter is optional for both hab_auth_img_or_fail
and hab_auth_img commands.

Document it in their usage texts to make it clearer.

Signed-off-by: Fabio Estevam 
---
 arch/arm/mach-imx/hab.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c
index ea9c5d3c9fd4..41121d575734 100644
--- a/arch/arm/mach-imx/hab.c
+++ b/arch/arm/mach-imx/hab.c
@@ -700,7 +700,7 @@ U_BOOT_CMD(
"addr length ivt_offset\n"
"addr - image hex address\n"
"length - image hex length\n"
-   "ivt_offset - hex offset of IVT in the image"
+   "ivt_offset - hex offset of IVT in the image (optional)"
  );
 
 U_BOOT_CMD(
@@ -716,7 +716,7 @@ U_BOOT_CMD(
"addr length ivt_offset\n"
"addr - image hex address\n"
"length - image hex length\n"
-   "ivt_offset - hex offset of IVT in the image"
+   "ivt_offset - hex offset of IVT in the image (optional)"
  );
 
 U_BOOT_CMD(
-- 
2.34.1



[PATCH 2/3] imx: hab: Improve the hab_auth_img_or_fail usage text

2023-09-06 Thread Fabio Estevam
From: Fabio Estevam 

Split the hab_auth_img_or_fail usage text in two sentences to make it
clearer.

Signed-off-by: Fabio Estevam 
---
 arch/arm/mach-imx/hab.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c
index 6cacca069d9f..ea9c5d3c9fd4 100644
--- a/arch/arm/mach-imx/hab.c
+++ b/arch/arm/mach-imx/hab.c
@@ -712,7 +712,7 @@ U_BOOT_CMD(
 U_BOOT_CMD(
hab_auth_img_or_fail, 4, 0,
do_authenticate_image_or_failover,
-   "authenticate image via HAB on failure drop to USB BootROM 
mode",
+   "authenticate image via HAB. Switch to USB BootROM mode on 
failure",
"addr length ivt_offset\n"
"addr - image hex address\n"
"length - image hex length\n"
-- 
2.34.1



[PATCH 1/3] imx: hab: Allow hab_auth_img_or_fail to be called without ivt_offset

2023-09-06 Thread Fabio Estevam
From: Eduard Strehlau 

Since commit ea91031b2232 ("imx: hab: extend hab_auth_img to calculate
ivt_offset"), it is possible to call the hab_auth_img command without the 
last ivt_offset argument.

Currently, calling hab_auth_img_or_fail without the last
ivt_offset parameter causes a failure and the command usage text is shown.

Fix this problem by adjusting the argc logic to allow
calling hab_auth_img_or_fail with only the address and size parameters.

This way, both hab_auth_img and hab_auth_img_or_fail have the same
behavior with respect to the allowed number of command parameters.
 
Signed-off-by: Eduard Strehlau 
Signed-off-by: Fabio Estevam 
---
 arch/arm/mach-imx/hab.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c
index 439cdaf07a7c..6cacca069d9f 100644
--- a/arch/arm/mach-imx/hab.c
+++ b/arch/arm/mach-imx/hab.c
@@ -659,7 +659,7 @@ static int do_authenticate_image_or_failover(struct cmd_tbl 
*cmdtp, int flag,
 {
int ret = CMD_RET_FAILURE;
 
-   if (argc != 4) {
+   if (argc < 3) {
ret = CMD_RET_USAGE;
goto error;
}
-- 
2.34.1




Re: [RFC PATCH 0/5] Allow for removal of DT nodes and properties

2023-09-06 Thread Heinrich Schuchardt

On 9/7/23 00:04, Tom Rini wrote:

On Wed, Sep 06, 2023 at 09:21:39AM -0500, Rob Herring wrote:

On Mon, Aug 28, 2023 at 04:09:29PM -0600, Simon Glass wrote:

Hi Peter,

On Mon, 28 Aug 2023 at 14:29, Peter Robinson  wrote:


On Mon, Aug 28, 2023 at 6:54 PM Simon Glass  wrote:


Hi Peter,

On Mon, 28 Aug 2023 at 10:37, Peter Robinson  wrote:


On Mon, Aug 28, 2023 at 5:20 PM Simon Glass  wrote:


Hi,

On Sat, 26 Aug 2023 at 03:07, Sughosh Ganu  wrote:



Provide a way for removing certain devicetree nodes and/or properties
from the devicetree. This is needed to purge certain nodes and
properties which may be relevant only in U-Boot. Such nodes and
properties are then removed from the devicetree before it is passed to
the kernel. This ensures that the devicetree passed to the OS does not
contain any non-compliant nodes and properties.

The removal of the nodes and properties is being done through an
EVT_FT_FIXUP handler. I am not sure if the removal code needs to be
behind any Kconfig symbol.

I have only build tested this on sandbox, and tested on qemu arm64
virt platform. This being a RFC, I have not put this through a CI run.

Sughosh Ganu (5):
   dt: Provide a way to remove non-compliant nodes and properties
   fwu: Add the fwu-mdata node for removal from devicetree
   capsule: Add the capsule-key property for removal from devicetree
   bootefi: Call the EVT_FT_FIXUP event handler
   doc: Add a document for non-compliant DT node/property removal

  cmd/bootefi.c | 18 +
  .../devicetree/dt_non_compliant_purge.rst | 64 
  drivers/fwu-mdata/fwu-mdata-uclass.c  |  5 ++
  include/dt-structs.h  | 11 +++
  lib/Makefile  |  1 +
  lib/dt_purge.c| 73 +++
  lib/efi_loader/efi_capsule.c  |  7 ++
  7 files changed, 179 insertions(+)
  create mode 100644 doc/develop/devicetree/dt_non_compliant_purge.rst
  create mode 100644 lib/dt_purge.c


What is the point of removing them? Instead, we should make sure that
we upstream the bindings and encourage SoC vendors to sync them. If we
remove them, no one will bother and U-Boot just becomes a dumping
ground.


Well things like the binman entries in DT are U-Boot specific and not
useful for HW related descriptions or for Linux or another OS being
able to deal with HW so arguably we're already a dumping ground to
some degree for not defining hardware.


I have started the process to upstream the binman bindings.


I don't think they should be in DT at all, they don't describe
anything to do with hardware, or generally even the runtime of a
device, they don't even describe the boot/runtime state of the
firmware, they describe build time, so I don't see what that has to do
with device tree? Can you explain that? To me those sorts of things
should live in a build time style config file.


For the record, I tend to agree.


I beg to differ. Devicetree is more than just hardware and always has
been. See, for example the /chosen and /options nodes.


There are exceptions...


We need run-time configuration here, since we cannot know at build
time what we will be asked to do by a previous firmware phase.


Really, I don't want to have to care about the binman binding. If it is
u-boot specific, then it should stay in u-boot. I took /options/u-boot/,
but now I'm starting to have second thoughts on that being in dtschema
if it is going to be continually and frequently extended. Validating it
in SR does little. If a vendor is abusing /options/u-boot/ in some way
they could just as easily remove the node in their u-boot fork to pass.
SR is certainly not going to require the node be there.


The missing piece is validation of the U-Boot internal device-trees
against a schema in the U-Boot CI. This should be possible even if some
of the schema yaml files are maintained inside the U-Boot repo.

Best regards

Heinrich



It's going to continue to be a "fun" tight-rope to walk. No one wants an
easy way for vendors to cheat the requirements which is why in some
other parts of this thread (you may or may not have been on, I don't
recall, sorry) I've been trying to make it clear that the removal
mechanism should be both a slight pain to add to, and at least wrt
upstream, clear that effort was made to upstream things.  Cheaters are
going to cheat and they could just chain a bunch of "fdt rm" together to
do it today.





Re: [RFC 4/6] gpio: add scmi driver based on pinctrl

2023-09-06 Thread AKASHI Takahiro
On Wed, Sep 06, 2023 at 04:56:56PM +0200, Michal Simek wrote:
> 
> 
> On 9/6/23 04:40, AKASHI Takahiro wrote:
> > This DM-compliant driver deals with SCMI pinctrl protocol and presents
> > gpio devices exposed by SCMI firmware (server).
> > 
> > Signed-off-by: AKASHI Takahiro 
> > ---
> >   drivers/pinctrl/pinctrl-scmi.c | 544 -
> >   1 file changed, 539 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c
> > index 3ebdad57b86c..73d385bdbfcc 100644
> > --- a/drivers/pinctrl/pinctrl-scmi.c
> > +++ b/drivers/pinctrl/pinctrl-scmi.c
> > @@ -11,21 +11,20 @@
> >   #include 
> >   #include 
> >   #include 
> > +#include 
> >   #include 
> > +#include 
> > +#include 
> >   #include 
> >   /**
> >* struct scmi_pin - attributes for a pin
> >* @name: Name of pin
> > - * @value: Value of pin
> > - * @flags: A set of flags
> >* @function: Function selected
> >* @status:   An array of status of configuration types
> >*/
> >   struct scmi_pin {
> > char*name;
> > -   u32 value;
> > -   u32 flags;
> 
> 
> You have added this in 3/6 then there is no reason to remove it in this 
> version.

Right.
It was my mistake in a last-minute cleanup.
The hunk should be merged in 3/6.

BTW, this part of code, holding status of every pin's pinconf properties
locally, is a bit clumsy. I'd remove the whole code if possible.

-Takahiro Akashi


> M


Re: [RFC PATCH 0/5] Allow for removal of DT nodes and properties

2023-09-06 Thread Tom Rini
On Wed, Sep 06, 2023 at 09:21:39AM -0500, Rob Herring wrote:
> On Mon, Aug 28, 2023 at 04:09:29PM -0600, Simon Glass wrote:
> > Hi Peter,
> > 
> > On Mon, 28 Aug 2023 at 14:29, Peter Robinson  wrote:
> > >
> > > On Mon, Aug 28, 2023 at 6:54 PM Simon Glass  wrote:
> > > >
> > > > Hi Peter,
> > > >
> > > > On Mon, 28 Aug 2023 at 10:37, Peter Robinson  
> > > > wrote:
> > > > >
> > > > > On Mon, Aug 28, 2023 at 5:20 PM Simon Glass  wrote:
> > > > > >
> > > > > > Hi,
> > > > > >
> > > > > > On Sat, 26 Aug 2023 at 03:07, Sughosh Ganu 
> > > > > >  wrote:
> > > > > > >
> > > > > > >
> > > > > > > Provide a way for removing certain devicetree nodes and/or 
> > > > > > > properties
> > > > > > > from the devicetree. This is needed to purge certain nodes and
> > > > > > > properties which may be relevant only in U-Boot. Such nodes and
> > > > > > > properties are then removed from the devicetree before it is 
> > > > > > > passed to
> > > > > > > the kernel. This ensures that the devicetree passed to the OS 
> > > > > > > does not
> > > > > > > contain any non-compliant nodes and properties.
> > > > > > >
> > > > > > > The removal of the nodes and properties is being done through an
> > > > > > > EVT_FT_FIXUP handler. I am not sure if the removal code needs to 
> > > > > > > be
> > > > > > > behind any Kconfig symbol.
> > > > > > >
> > > > > > > I have only build tested this on sandbox, and tested on qemu arm64
> > > > > > > virt platform. This being a RFC, I have not put this through a CI 
> > > > > > > run.
> > > > > > >
> > > > > > > Sughosh Ganu (5):
> > > > > > >   dt: Provide a way to remove non-compliant nodes and properties
> > > > > > >   fwu: Add the fwu-mdata node for removal from devicetree
> > > > > > >   capsule: Add the capsule-key property for removal from 
> > > > > > > devicetree
> > > > > > >   bootefi: Call the EVT_FT_FIXUP event handler
> > > > > > >   doc: Add a document for non-compliant DT node/property removal
> > > > > > >
> > > > > > >  cmd/bootefi.c | 18 +
> > > > > > >  .../devicetree/dt_non_compliant_purge.rst | 64 
> > > > > > > 
> > > > > > >  drivers/fwu-mdata/fwu-mdata-uclass.c  |  5 ++
> > > > > > >  include/dt-structs.h  | 11 +++
> > > > > > >  lib/Makefile  |  1 +
> > > > > > >  lib/dt_purge.c| 73 
> > > > > > > +++
> > > > > > >  lib/efi_loader/efi_capsule.c  |  7 ++
> > > > > > >  7 files changed, 179 insertions(+)
> > > > > > >  create mode 100644 
> > > > > > > doc/develop/devicetree/dt_non_compliant_purge.rst
> > > > > > >  create mode 100644 lib/dt_purge.c
> > > > > >
> > > > > > What is the point of removing them? Instead, we should make sure 
> > > > > > that
> > > > > > we upstream the bindings and encourage SoC vendors to sync them. If 
> > > > > > we
> > > > > > remove them, no one will bother and U-Boot just becomes a dumping
> > > > > > ground.
> > > > >
> > > > > Well things like the binman entries in DT are U-Boot specific and not
> > > > > useful for HW related descriptions or for Linux or another OS being
> > > > > able to deal with HW so arguably we're already a dumping ground to
> > > > > some degree for not defining hardware.
> > > >
> > > > I have started the process to upstream the binman bindings.
> > >
> > > I don't think they should be in DT at all, they don't describe
> > > anything to do with hardware, or generally even the runtime of a
> > > device, they don't even describe the boot/runtime state of the
> > > firmware, they describe build time, so I don't see what that has to do
> > > with device tree? Can you explain that? To me those sorts of things
> > > should live in a build time style config file.
> 
> For the record, I tend to agree.
> 
> > I beg to differ. Devicetree is more than just hardware and always has
> > been. See, for example the /chosen and /options nodes.
> 
> There are exceptions...
> 
> > We need run-time configuration here, since we cannot know at build
> > time what we will be asked to do by a previous firmware phase.
> 
> Really, I don't want to have to care about the binman binding. If it is 
> u-boot specific, then it should stay in u-boot. I took /options/u-boot/, 
> but now I'm starting to have second thoughts on that being in dtschema 
> if it is going to be continually and frequently extended. Validating it 
> in SR does little. If a vendor is abusing /options/u-boot/ in some way 
> they could just as easily remove the node in their u-boot fork to pass. 
> SR is certainly not going to require the node be there.

It's going to continue to be a "fun" tight-rope to walk. No one wants an
easy way for vendors to cheat the requirements which is why in some
other parts of this thread (you may or may not have been on, I don't
recall, sorry) I've been trying to make it clear that the removal
mechanism should be both a slight pain to add to, and at 

Re: [RFC PATCH 0/5] Allow for removal of DT nodes and properties

2023-09-06 Thread Tom Rini
On Wed, Sep 06, 2023 at 09:21:39AM -0500, Rob Herring wrote:

[snip]
> On A/B updates, that really doesn't seem like a u-boot specific problem 
> to me. No one wants A/B updates in EDK2 or anything else?

This specific case goes back to:
https://lore.kernel.org/u-boot/20230410232112.72778-1-jaswinder.si...@linaro.org/

But I believe Sughosh and Ilias are basically the people who are in
charge of the code at this point?  So perhaps a step here is some advice
on whatever they need to redo/rethink to get something that is
acceptable.

-- 
Tom


signature.asc
Description: PGP signature


[PATCH] arm: apple: Add initial Apple M2 Ultra support

2023-09-06 Thread Janne Grunau
 | PTE_BLOCK_UXN
+   }, {
+   /* PCIE */
+   .virt = 0x25a000,
+   .phys = 0x25a000,
+   .size = SZ_512M,
+   .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRE) |
+PTE_BLOCK_INNER_SHARE |
+PTE_BLOCK_PXN | PTE_BLOCK_UXN
+   }, {
+   /* PCIE */
+   .virt = 0x25c000,
+   .phys = 0x25c000,
+   .size = SZ_1G,
+   .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRE) |
+PTE_BLOCK_INNER_SHARE |
+PTE_BLOCK_PXN | PTE_BLOCK_UXN
+   }, {
+   /* I/O */
+   .virt = 0x27,
+   .phys = 0x27,
+   .size = SZ_1G,
+   .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+PTE_BLOCK_NON_SHARE |
+PTE_BLOCK_PXN | PTE_BLOCK_UXN
+   }, {
+   /* I/O */
+   .virt = 0x2b,
+   .phys = 0x2b,
+   .size = SZ_1G,
+   .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+PTE_BLOCK_NON_SHARE |
+PTE_BLOCK_PXN | PTE_BLOCK_UXN
+   }, {
+   /* I/O */
+   .virt = 0x2f,
+   .phys = 0x2f,
+   .size = SZ_1G,
+   .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+PTE_BLOCK_NON_SHARE |
+PTE_BLOCK_PXN | PTE_BLOCK_UXN
+   }, {
+   /* I/O */
+   .virt = 0x33,
+   .phys = 0x33,
+   .size = SZ_1G,
+   .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+PTE_BLOCK_NON_SHARE |
+PTE_BLOCK_PXN | PTE_BLOCK_UXN
+   }, {
+   /* RAM */
+   .virt = 0x100,
+   .phys = 0x100,
+   .size = 16UL * SZ_1G,
+   .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+PTE_BLOCK_INNER_SHARE
+   }, {
+   /* Framebuffer */
+   .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL_NC) |
+PTE_BLOCK_INNER_SHARE |
+PTE_BLOCK_PXN | PTE_BLOCK_UXN
+   }, {
+   /* List terminator */
+   0,
+   }
+};
+
 struct mm_region *mem_map;
 
 int board_init(void)
@@ -488,6 +669,8 @@ void build_mem_map(void)
else if (of_machine_is_compatible("apple,t6020") ||
 of_machine_is_compatible("apple,t6021"))
mem_map = t6020_mem_map;
+   else if (of_machine_is_compatible("apple,t6022"))
+   mem_map = t6022_mem_map;
else
panic("Unsupported SoC\n");
 

---
base-commit: c0c08be5468cb26db597932bc69c4eda1129841d
change-id: 20230906-apple_t6022_m2_ultra-9146e34619e6

Best regards,
-- 
Janne Grunau 



[PATCH 35/35] post: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 doc/README.POST |  5 -
 include/post.h  |  3 ---
 post/post.c | 48 
 3 files changed, 56 deletions(-)

diff --git a/doc/README.POST b/doc/README.POST
index 1366f95c662..c614ea44a28 100644
--- a/doc/README.POST
+++ b/doc/README.POST
@@ -138,11 +138,6 @@ The POST layer will export the following interface 
routines:
  mode the test is executed in (power-on, normal, power-fail,
  manual).
 
-  o) void post_reloc(ulong offset);
-
- This routine will be called from board_init_r() and will
- relocate the POST test table.
-
   o) int post_info(char *name);
 
  This routine will print the list of all POST tests that can be
diff --git a/include/post.h b/include/post.h
index 41120695064..6e88d550722 100644
--- a/include/post.h
+++ b/include/post.h
@@ -105,9 +105,6 @@ void post_bootmode_clear (void);
 int post_run (char *name, int flags);
 int post_info (char *name);
 int post_log (char *format, ...);
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-void post_reloc (void);
-#endif
 unsigned long post_time_ms (unsigned long base);
 
 /**
diff --git a/post/post.c b/post/post.c
index 4db862c0dbb..946d9094d45 100644
--- a/post/post.c
+++ b/post/post.c
@@ -416,54 +416,6 @@ int post_log(char *format, ...)
return 0;
 }
 
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-void post_reloc(void)
-{
-   unsigned int i;
-
-   /*
-* We have to relocate the test table manually
-*/
-   for (i = 0; i < post_list_size; i++) {
-   ulong addr;
-   struct post_test *test = post_list + i;
-
-   if (test->name) {
-   addr = (ulong)(test->name) + gd->reloc_off;
-   test->name = (char *)addr;
-   }
-
-   if (test->cmd) {
-   addr = (ulong)(test->cmd) + gd->reloc_off;
-   test->cmd = (char *)addr;
-   }
-
-   if (test->desc) {
-   addr = (ulong)(test->desc) + gd->reloc_off;
-   test->desc = (char *)addr;
-   }
-
-   if (test->test) {
-   addr = (ulong)(test->test) + gd->reloc_off;
-   test->test = (int (*)(int flags)) addr;
-   }
-
-   if (test->init_f) {
-   addr = (ulong)(test->init_f) + gd->reloc_off;
-   test->init_f = (int (*)(void)) addr;
-   }
-
-   if (test->reloc) {
-   addr = (ulong)(test->reloc) + gd->reloc_off;
-   test->reloc = (void (*)(void)) addr;
-
-   test->reloc();
-   }
-   }
-}
-#endif
-
-
 /*
  * Some tests (e.g. SYSMON) need the time when post_init_f started,
  * but we cannot use get_timer() at this point.
-- 
2.40.1



[PATCH 34/35] wdt: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 drivers/watchdog/wdt-uclass.c | 23 ---
 1 file changed, 23 deletions(-)

diff --git a/drivers/watchdog/wdt-uclass.c b/drivers/watchdog/wdt-uclass.c
index 509896a1b80..ed329284dec 100644
--- a/drivers/watchdog/wdt-uclass.c
+++ b/drivers/watchdog/wdt-uclass.c
@@ -236,28 +236,6 @@ void watchdog_reset(void)
 }
 #endif
 
-static int wdt_post_bind(struct udevice *dev)
-{
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
-   struct wdt_ops *ops = (struct wdt_ops *)device_get_ops(dev);
-   static int reloc_done;
-
-   if (!reloc_done) {
-   if (ops->start)
-   ops->start += gd->reloc_off;
-   if (ops->stop)
-   ops->stop += gd->reloc_off;
-   if (ops->reset)
-   ops->reset += gd->reloc_off;
-   if (ops->expire_now)
-   ops->expire_now += gd->reloc_off;
-
-   reloc_done++;
-   }
-#endif
-   return 0;
-}
-
 static int wdt_pre_probe(struct udevice *dev)
 {
u32 timeout = WATCHDOG_TIMEOUT_SECS;
@@ -295,7 +273,6 @@ UCLASS_DRIVER(wdt) = {
.id = UCLASS_WDT,
.name   = "watchdog",
.flags  = DM_UC_FLAG_SEQ_ALIAS,
-   .post_bind  = wdt_post_bind,
.pre_probe  = wdt_pre_probe,
.per_device_auto= sizeof(struct wdt_priv),
 };
-- 
2.40.1



[PATCH 33/35] timer: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 drivers/timer/timer-uclass.c | 13 -
 1 file changed, 13 deletions(-)

diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
index f4b871ac23a..0c2018bfe3b 100644
--- a/drivers/timer/timer-uclass.c
+++ b/drivers/timer/timer-uclass.c
@@ -51,19 +51,6 @@ unsigned long notrace timer_get_rate(struct udevice *dev)
 
 static int timer_pre_probe(struct udevice *dev)
 {
-   if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC) &&
-   (gd->flags & GD_FLG_RELOC)) {
-   struct timer_ops *ops = timer_get_ops(dev);
-   static int reloc_done;
-
-   if (!reloc_done) {
-   if (ops->get_count)
-   MANUAL_RELOC(ops->get_count);
-
-   reloc_done++;
-   }
-   }
-
if (CONFIG_IS_ENABLED(OF_REAL)) {
struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev);
struct clk timer_clk;
-- 
2.40.1



[PATCH 32/35] sysreset: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 drivers/sysreset/sysreset-uclass.c | 16 
 1 file changed, 16 deletions(-)

diff --git a/drivers/sysreset/sysreset-uclass.c 
b/drivers/sysreset/sysreset-uclass.c
index 279b087d16d..6151b5fe03e 100644
--- a/drivers/sysreset/sysreset-uclass.c
+++ b/drivers/sysreset/sysreset-uclass.c
@@ -158,23 +158,7 @@ int do_poweroff(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
 }
 #endif
 
-static int sysreset_post_bind(struct udevice *dev)
-{
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
-   struct sysreset_ops *ops = sysreset_get_ops(dev);
-   static int reloc_done;
-
-   if (!reloc_done) {
-   if (ops->request)
-   ops->request += gd->reloc_off;
-   reloc_done++;
-   }
-#endif
-   return 0;
-}
-
 UCLASS_DRIVER(sysreset) = {
.id = UCLASS_SYSRESET,
.name   = "sysreset",
-   .post_bind  = sysreset_post_bind,
 };
-- 
2.40.1



[PATCH 28/35] net: miiphybb: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 drivers/net/phy/miiphybb.c | 20 ++--
 1 file changed, 2 insertions(+), 18 deletions(-)

diff --git a/drivers/net/phy/miiphybb.c b/drivers/net/phy/miiphybb.c
index 24d617553e7..cf71f7d4e7e 100644
--- a/drivers/net/phy/miiphybb.c
+++ b/drivers/net/phy/miiphybb.c
@@ -18,10 +18,6 @@
 #include 
 #include 
 
-#define BB_MII_RELOCATE(v,off) (v += (v?off:0))
-
-DECLARE_GLOBAL_DATA_PTR;
-
 #ifndef CONFIG_BITBANGMII_MULTI
 
 /*
@@ -110,21 +106,9 @@ int bb_miiphy_init(void)
 {
int i;
 
-   for (i = 0; i < bb_miiphy_buses_num; i++) {
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
-   /* Relocate the hook pointers*/
-   BB_MII_RELOCATE(bb_miiphy_buses[i].init, gd->reloc_off);
-   BB_MII_RELOCATE(bb_miiphy_buses[i].mdio_active, gd->reloc_off);
-   BB_MII_RELOCATE(bb_miiphy_buses[i].mdio_tristate, 
gd->reloc_off);
-   BB_MII_RELOCATE(bb_miiphy_buses[i].set_mdio, gd->reloc_off);
-   BB_MII_RELOCATE(bb_miiphy_buses[i].get_mdio, gd->reloc_off);
-   BB_MII_RELOCATE(bb_miiphy_buses[i].set_mdc, gd->reloc_off);
-   BB_MII_RELOCATE(bb_miiphy_buses[i].delay, gd->reloc_off);
-#endif
-   if (bb_miiphy_buses[i].init != NULL) {
+   for (i = 0; i < bb_miiphy_buses_num; i++)
+   if (bb_miiphy_buses[i].init != NULL)
bb_miiphy_buses[i].init(_miiphy_buses[i]);
-   }
-   }
 
return 0;
 }
-- 
2.40.1



[PATCH 29/35] net: phy: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 drivers/net/phy/phy.c | 31 ---
 include/phy.h |  8 
 net/eth_common.c  |  4 
 3 files changed, 43 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index ae21acb059b..d50fd505e51 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -463,37 +463,6 @@ U_BOOT_PHY_DRIVER(genphy) = {
.shutdown   = genphy_shutdown,
 };
 
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-int phy_init(void)
-{
-   const int ll_n_ents = ll_entry_count(struct phy_driver, phy_driver);
-   struct phy_driver *drv, *ll_entry;
-
-   /* 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++) {
-   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;
-   }
-
-   return 0;
-}
-#endif
-
 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 f023a3c2685..27effdb5763 100644
--- a/include/phy.h
+++ b/include/phy.h
@@ -171,14 +171,6 @@ struct fixed_link {
int asym_pause;
 };
 
-/**
- * phy_init() - Initializes the PHY drivers
- * This function registers all available PHY drivers
- *
- * @return: 0 if OK, -ve on error
- */
-int phy_init(void);
-
 /**
  * phy_reset() - Resets the specified PHY
  * Issues a reset of the PHY and waits for it to complete
diff --git a/net/eth_common.c b/net/eth_common.c
index c94a7ba6ae7..14d4c07b695 100644
--- a/net/eth_common.c
+++ b/net/eth_common.c
@@ -36,10 +36,6 @@ void eth_common_init(void)
 #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) || defined(CONFIG_PHYLIB)
miiphy_init();
 #endif
-
-#if defined(CONFIG_NEEDS_MANUAL_RELOC) && defined(CONFIG_PHYLIB)
-   phy_init();
-#endif
 #endif
 }
 
-- 
2.40.1



[PATCH 27/35] net: eth: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 net/eth-uclass.c | 26 --
 1 file changed, 26 deletions(-)

diff --git a/net/eth-uclass.c b/net/eth-uclass.c
index c393600fabc..4311f3fe6e8 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -556,32 +556,6 @@ static int eth_post_probe(struct udevice *dev)
unsigned char env_enetaddr[ARP_HLEN];
char *source = "DT";
 
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
-   struct eth_ops *ops = eth_get_ops(dev);
-   static int reloc_done;
-
-   if (!reloc_done) {
-   if (ops->start)
-   ops->start += gd->reloc_off;
-   if (ops->send)
-   ops->send += gd->reloc_off;
-   if (ops->recv)
-   ops->recv += gd->reloc_off;
-   if (ops->free_pkt)
-   ops->free_pkt += gd->reloc_off;
-   if (ops->stop)
-   ops->stop += gd->reloc_off;
-   if (ops->mcast)
-   ops->mcast += gd->reloc_off;
-   if (ops->write_hwaddr)
-   ops->write_hwaddr += gd->reloc_off;
-   if (ops->read_rom_hwaddr)
-   ops->read_rom_hwaddr += gd->reloc_off;
-
-   reloc_done++;
-   }
-#endif
-
priv->state = ETH_STATE_INIT;
priv->running = false;
 
-- 
2.40.1



[PATCH 31/35] spi: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 drivers/spi/spi-uclass.c | 32 
 1 file changed, 32 deletions(-)

diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c
index c929e7c1d0e..f4795e68672 100644
--- a/drivers/spi/spi-uclass.c
+++ b/drivers/spi/spi-uclass.c
@@ -196,38 +196,6 @@ static int spi_post_probe(struct udevice *bus)
 
spi->max_hz = dev_read_u32_default(bus, "spi-max-frequency", 0);
}
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
-   struct dm_spi_ops *ops = spi_get_ops(bus);
-   static int reloc_done;
-
-   if (!reloc_done) {
-   if (ops->claim_bus)
-   ops->claim_bus += gd->reloc_off;
-   if (ops->release_bus)
-   ops->release_bus += gd->reloc_off;
-   if (ops->set_wordlen)
-   ops->set_wordlen += gd->reloc_off;
-   if (ops->xfer)
-   ops->xfer += gd->reloc_off;
-   if (ops->set_speed)
-   ops->set_speed += gd->reloc_off;
-   if (ops->set_mode)
-   ops->set_mode += gd->reloc_off;
-   if (ops->cs_info)
-   ops->cs_info += gd->reloc_off;
-   if (ops->mem_ops) {
-   struct spi_controller_mem_ops *mem_ops =
-   (struct spi_controller_mem_ops *)ops->mem_ops;
-   if (mem_ops->adjust_op_size)
-   mem_ops->adjust_op_size += gd->reloc_off;
-   if (mem_ops->supports_op)
-   mem_ops->supports_op += gd->reloc_off;
-   if (mem_ops->exec_op)
-   mem_ops->exec_op += gd->reloc_off;
-   }
-   reloc_done++;
-   }
-#endif
 
return 0;
 }
-- 
2.40.1



[PATCH 30/35] serial: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 drivers/serial/serial-uclass.c | 22 --
 drivers/serial/serial.c| 17 -
 2 files changed, 39 deletions(-)

diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index e954f0189bb..5e2e7dfbcb3 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -508,28 +508,6 @@ static int serial_post_probe(struct udevice *dev)
 #endif
int ret;
 
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
-   if (ops->setbrg)
-   ops->setbrg += gd->reloc_off;
-   if (ops->getc)
-   ops->getc += gd->reloc_off;
-   if (ops->putc)
-   ops->putc += gd->reloc_off;
-   if (ops->pending)
-   ops->pending += gd->reloc_off;
-   if (ops->clear)
-   ops->clear += gd->reloc_off;
-   if (ops->getconfig)
-   ops->getconfig += gd->reloc_off;
-   if (ops->setconfig)
-   ops->setconfig += gd->reloc_off;
-#if CFG_POST & CFG_SYS_POST_UART
-   if (ops->loop)
-   ops->loop += gd->reloc_off;
-#endif
-   if (ops->getinfo)
-   ops->getinfo += gd->reloc_off;
-#endif
/* Set the baud rate */
if (ops->setbrg) {
ret = ops->setbrg(dev, gd->baudrate);
diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c
index 9a380d7c5e7..787edd53602 100644
--- a/drivers/serial/serial.c
+++ b/drivers/serial/serial.c
@@ -142,23 +142,6 @@ serial_initfunc(mtk_serial_initialize);
  */
 void serial_register(struct serial_device *dev)
 {
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-   if (dev->start)
-   dev->start += gd->reloc_off;
-   if (dev->stop)
-   dev->stop += gd->reloc_off;
-   if (dev->setbrg)
-   dev->setbrg += gd->reloc_off;
-   if (dev->getc)
-   dev->getc += gd->reloc_off;
-   if (dev->tstc)
-   dev->tstc += gd->reloc_off;
-   if (dev->putc)
-   dev->putc += gd->reloc_off;
-   if (dev->puts)
-   dev->puts += gd->reloc_off;
-#endif
-
dev->next = serial_devices;
serial_devices = dev;
 }
-- 
2.40.1



[PATCH 26/35] mtd: ubifs: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 fs/ubifs/ubifs.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 609bdbf6037..a509584e5d7 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -201,12 +201,6 @@ static int __init compr_init(struct ubifs_compressor 
*compr)
 {
ubifs_compressors[compr->compr_type] = compr;
 
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-   ubifs_compressors[compr->compr_type]->name += gd->reloc_off;
-   ubifs_compressors[compr->compr_type]->capi_name += gd->reloc_off;
-   ubifs_compressors[compr->compr_type]->decompress += gd->reloc_off;
-#endif
-
if (compr->capi_name) {
compr->cc = crypto_alloc_comp(compr->capi_name, 0, 0);
if (IS_ERR(compr->cc)) {
-- 
2.40.1



[PATCH 25/35] sf: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 drivers/mtd/spi/sf-uclass.c | 16 
 1 file changed, 16 deletions(-)

diff --git a/drivers/mtd/spi/sf-uclass.c b/drivers/mtd/spi/sf-uclass.c
index df1f75390c4..2da0cf0dcf9 100644
--- a/drivers/mtd/spi/sf-uclass.c
+++ b/drivers/mtd/spi/sf-uclass.c
@@ -96,22 +96,6 @@ static int spi_flash_post_bind(struct udevice *dev)
return log_msg_ret("bd", ret);
}
 
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
-   struct dm_spi_flash_ops *ops = sf_get_ops(dev);
-   static int reloc_done;
-
-   if (!reloc_done) {
-   if (ops->read)
-   ops->read += gd->reloc_off;
-   if (ops->write)
-   ops->write += gd->reloc_off;
-   if (ops->erase)
-   ops->erase += gd->reloc_off;
-
-   reloc_done++;
-   }
-#endif
-
return 0;
 }
 
-- 
2.40.1



[PATCH 24/35] hwspinlock: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 drivers/hwspinlock/hwspinlock-uclass.c | 21 -
 1 file changed, 21 deletions(-)

diff --git a/drivers/hwspinlock/hwspinlock-uclass.c 
b/drivers/hwspinlock/hwspinlock-uclass.c
index e012d5a4c93..e9a4d7f9fbb 100644
--- a/drivers/hwspinlock/hwspinlock-uclass.c
+++ b/drivers/hwspinlock/hwspinlock-uclass.c
@@ -123,28 +123,7 @@ int hwspinlock_unlock(struct hwspinlock *hws)
return ops->unlock(hws->dev, hws->id);
 }
 
-static int hwspinlock_post_bind(struct udevice *dev)
-{
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
-   struct hwspinlock_ops *ops = device_get_ops(dev);
-   static int reloc_done;
-
-   if (!reloc_done) {
-   if (ops->lock)
-   ops->lock += gd->reloc_off;
-   if (ops->unlock)
-   ops->unlock += gd->reloc_off;
-   if (ops->relax)
-   ops->relax += gd->reloc_off;
-
-   reloc_done++;
-   }
-#endif
-   return 0;
-}
-
 UCLASS_DRIVER(hwspinlock) = {
.id = UCLASS_HWSPINLOCK,
.name   = "hwspinlock",
-   .post_bind  = hwspinlock_post_bind,
 };
-- 
2.40.1



[PATCH 23/35] gpio: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 drivers/gpio/gpio-uclass.c | 30 --
 1 file changed, 30 deletions(-)

diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index fc395c97a28..7aece85a70a 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -1498,36 +1498,6 @@ void devm_gpiod_put(struct udevice *dev, struct 
gpio_desc *desc)
 
 static int gpio_post_bind(struct udevice *dev)
 {
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
-   struct dm_gpio_ops *ops = (struct dm_gpio_ops *)device_get_ops(dev);
-   static int reloc_done;
-
-   if (!reloc_done) {
-   if (ops->request)
-   ops->request += gd->reloc_off;
-   if (ops->rfree)
-   ops->rfree += gd->reloc_off;
-   if (ops->direction_input)
-   ops->direction_input += gd->reloc_off;
-   if (ops->direction_output)
-   ops->direction_output += gd->reloc_off;
-   if (ops->get_value)
-   ops->get_value += gd->reloc_off;
-   if (ops->set_value)
-   ops->set_value += gd->reloc_off;
-   if (ops->get_function)
-   ops->get_function += gd->reloc_off;
-   if (ops->xlate)
-   ops->xlate += gd->reloc_off;
-   if (ops->set_flags)
-   ops->set_flags += gd->reloc_off;
-   if (ops->get_flags)
-   ops->get_flags += gd->reloc_off;
-
-   reloc_done++;
-   }
-#endif
-
if (CONFIG_IS_ENABLED(GPIO_HOG) && dev_has_ofnode(dev)) {
struct udevice *child;
ofnode node;
-- 
2.40.1



[PATCH 22/35] crypto: rsa: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 drivers/crypto/rsa_mod_exp/mod_exp_uclass.c | 13 -
 1 file changed, 13 deletions(-)

diff --git a/drivers/crypto/rsa_mod_exp/mod_exp_uclass.c 
b/drivers/crypto/rsa_mod_exp/mod_exp_uclass.c
index 6a4d235d57b..057cc74b10b 100644
--- a/drivers/crypto/rsa_mod_exp/mod_exp_uclass.c
+++ b/drivers/crypto/rsa_mod_exp/mod_exp_uclass.c
@@ -16,24 +16,11 @@
 #include 
 #include 
 
-#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
-DECLARE_GLOBAL_DATA_PTR;
-#endif
-
 int rsa_mod_exp(struct udevice *dev, const uint8_t *sig, uint32_t sig_len,
struct key_prop *node, uint8_t *out)
 {
struct mod_exp_ops *ops = (struct mod_exp_ops *)device_get_ops(dev);
 
-#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
-   static bool done;
-
-   if (!done) {
-   done = true;
-   ops->mod_exp += gd->reloc_off;
-   }
-#endif
-
if (!ops->mod_exp)
return -ENOSYS;
 
-- 
2.40.1



[PATCH 21/35] cpu: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 drivers/cpu/cpu-uclass.c | 27 ---
 1 file changed, 27 deletions(-)

diff --git a/drivers/cpu/cpu-uclass.c b/drivers/cpu/cpu-uclass.c
index a7548325265..9772578968b 100644
--- a/drivers/cpu/cpu-uclass.c
+++ b/drivers/cpu/cpu-uclass.c
@@ -127,36 +127,9 @@ static int uclass_cpu_init(struct uclass *uc)
return ret;
 }
 
-static int uclass_cpu_post_bind(struct udevice *dev)
-{
-   if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC) &&
-   (gd->flags & GD_FLG_RELOC)) {
-   struct cpu_ops *ops = cpu_get_ops(dev);
-   static int reloc_done;
-
-   if (!reloc_done) {
-   if (ops->get_desc)
-   MANUAL_RELOC(ops->get_desc);
-   if (ops->get_info)
-   MANUAL_RELOC(ops->get_info);
-   if (ops->get_count)
-   MANUAL_RELOC(ops->get_count);
-   if (ops->get_vendor)
-   MANUAL_RELOC(ops->get_vendor);
-   if (ops->is_current)
-   MANUAL_RELOC(ops->is_current);
-
-   reloc_done++;
-   }
-   }
-
-   return 0;
-}
-
 UCLASS_DRIVER(cpu) = {
.id = UCLASS_CPU,
.name   = "cpu",
.flags  = DM_UC_FLAG_SEQ_ALIAS,
.init   = uclass_cpu_init,
-   .post_bind  = uclass_cpu_post_bind,
 };
-- 
2.40.1



[PATCH 20/35] fs: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 fs/fs.c | 16 
 1 file changed, 16 deletions(-)

diff --git a/fs/fs.c b/fs/fs.c
index 2b815b1db0f..cfc781bbb8d 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -422,22 +422,6 @@ int fs_set_blk_dev(const char *ifname, const char 
*dev_part_str, int fstype)
 {
struct fstype_info *info;
int part, i;
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-   static int relocated;
-
-   if (!relocated) {
-   for (i = 0, info = fstypes; i < ARRAY_SIZE(fstypes);
-   i++, info++) {
-   info->name += gd->reloc_off;
-   info->probe += gd->reloc_off;
-   info->close += gd->reloc_off;
-   info->ls += gd->reloc_off;
-   info->read += gd->reloc_off;
-   info->write += gd->reloc_off;
-   }
-   relocated = 1;
-   }
-#endif
 
part = part_get_info_by_dev_and_name_or_num(ifname, dev_part_str, 
_dev_desc,
_partition, 1);
-- 
2.40.1



[PATCH 19/35] image: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 boot/image.c   | 10 +-
 include/relocate.h | 14 --
 2 files changed, 5 insertions(+), 19 deletions(-)

diff --git a/boot/image.c b/boot/image.c
index 5c4f9b807d6..26f68d4c407 100644
--- a/boot/image.c
+++ b/boot/image.c
@@ -571,7 +571,7 @@ const char *genimg_get_cat_name(enum ih_category category, 
uint id)
entry = get_table_entry(table_info[category].table, id);
if (!entry)
return unknown_msg(category);
-   return manual_reloc(entry->lname);
+   return entry->lname;
 }
 
 /**
@@ -591,7 +591,7 @@ const char *genimg_get_cat_short_name(enum ih_category 
category, uint id)
entry = get_table_entry(table_info[category].table, id);
if (!entry)
return unknown_msg(category);
-   return manual_reloc(entry->sname);
+   return entry->sname;
 }
 
 int genimg_get_cat_count(enum ih_category category)
@@ -641,7 +641,7 @@ char *get_table_entry_name(const table_entry_t *table, char 
*msg, int id)
table = get_table_entry(table, id);
if (!table)
return msg;
-   return manual_reloc(table->lname);
+   return table->lname;
 }
 
 const char *genimg_get_os_name(uint8_t os)
@@ -676,7 +676,7 @@ static const char *genimg_get_short_name(const 
table_entry_t *table, int val)
table = get_table_entry(table, val);
if (!table)
return "unknown";
-   return manual_reloc(table->sname);
+   return table->sname;
 }
 
 const char *genimg_get_type_short_name(uint8_t type)
@@ -719,7 +719,7 @@ int get_table_entry_id(const table_entry_t *table,
const table_entry_t *t;
 
for (t = table; t->id >= 0; ++t) {
-   if (t->sname && !strcasecmp(manual_reloc(t->sname), name))
+   if (t->sname && !strcasecmp(t->sname, name))
return t->id;
}
debug("Invalid %s Type: %s\n", table_name, name);
diff --git a/include/relocate.h b/include/relocate.h
index 5ae1a2ed555..8ca25e1105e 100644
--- a/include/relocate.h
+++ b/include/relocate.h
@@ -39,18 +39,4 @@ int clear_bss(void);
  */
 int do_elf_reloc_fixups(void);
 
-/**
- * manual_reloc() - Manually relocate a pointer if needed
- *
- * This is a nop in almost all cases, except for the systems with a broken gcc
- * which need to manually relocate some things.
- *
- * @ptr: Pointer to relocate
- * Return: new pointer value
- */
-static inline void *manual_reloc(void *ptr)
-{
-   return ptr;
-}
-
 #endif /* _RELOCATE_H_ */
-- 
2.40.1



[PATCH 18/35] initcall: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 include/initcall.h | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/include/initcall.h b/include/initcall.h
index 208effd8d13..62d3bb67f08 100644
--- a/include/initcall.h
+++ b/include/initcall.h
@@ -35,11 +35,4 @@ typedef int (*init_fnc_t)(void);
  */
 int initcall_run_list(const init_fnc_t init_sequence[]);
 
-/**
- * initcall_manual_reloc() - Do manual relocation on an initcall sequence
- *
- * @init_sequence: NULL-terminated init sequence to relocate
- */
-void initcall_manual_reloc(init_fnc_t init_sequence[]);
-
 #endif
-- 
2.40.1



[PATCH 17/35] env: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 env/callback.c | 12 
 env/common.c   |  4 
 env/env.c  | 23 ---
 include/env.h  |  5 -
 4 files changed, 44 deletions(-)

diff --git a/env/callback.c b/env/callback.c
index 638a02b28f7..98ddba035ea 100644
--- a/env/callback.c
+++ b/env/callback.c
@@ -9,10 +9,6 @@
 #include 
 #include 
 
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
-DECLARE_GLOBAL_DATA_PTR;
-#endif
-
 /*
  * Look up a callback function pointer by name
  */
@@ -71,11 +67,7 @@ void env_callback_init(struct env_entry *var_entry)
if (!ret && strlen(callback_name)) {
clbkp = find_env_callback(callback_name);
if (clbkp != NULL)
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
-   var_entry->callback = clbkp->callback + gd->reloc_off;
-#else
var_entry->callback = clbkp->callback;
-#endif
}
 }
 
@@ -112,11 +104,7 @@ static int set_callback(const char *name, const char 
*value, void *priv)
/* assign the requested callback */
clbkp = find_env_callback(value);
if (clbkp != NULL)
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
-   ep->callback = clbkp->callback + gd->reloc_off;
-#else
ep->callback = clbkp->callback;
-#endif
}
}
 
diff --git a/env/common.c b/env/common.c
index 4cf2dadc694..21045a7eb33 100644
--- a/env/common.c
+++ b/env/common.c
@@ -428,10 +428,6 @@ int env_export(env_t *env_out)
 
 void env_relocate(void)
 {
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
-   env_fix_drivers();
-   env_htab.change_ok += gd->reloc_off;
-#endif
if (gd->env_valid == ENV_INVALID) {
 #if defined(CONFIG_ENV_IS_NOWHERE) || defined(CONFIG_SPL_BUILD)
/* Environment not changable */
diff --git a/env/env.c b/env/env.c
index 2aa52c98f8f..bae3f6482ae 100644
--- a/env/env.c
+++ b/env/env.c
@@ -14,29 +14,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
-void env_fix_drivers(void)
-{
-   struct env_driver *drv;
-   const int n_ents = ll_entry_count(struct env_driver, env_driver);
-   struct env_driver *entry;
-
-   drv = ll_entry_start(struct env_driver, env_driver);
-   for (entry = drv; entry != drv + n_ents; entry++) {
-   if (entry->name)
-   entry->name += gd->reloc_off;
-   if (entry->load)
-   entry->load += gd->reloc_off;
-   if (entry->save)
-   entry->save += gd->reloc_off;
-   if (entry->erase)
-   entry->erase += gd->reloc_off;
-   if (entry->init)
-   entry->init += gd->reloc_off;
-   }
-}
-#endif
-
 static struct env_driver *_env_driver_lookup(enum env_location loc)
 {
struct env_driver *drv;
diff --git a/include/env.h b/include/env.h
index b28886d80b9..430c4fa94a4 100644
--- a/include/env.h
+++ b/include/env.h
@@ -239,11 +239,6 @@ int eth_env_get_enetaddr(const char *name, uint8_t 
*enetaddr);
  */
 int eth_env_set_enetaddr(const char *name, const uint8_t *enetaddr);
 
-/**
- * env_fix_drivers() - Updates envdriver as per relocation
- */
-void env_fix_drivers(void);
-
 /**
  * env_set_default_vars() - reset variables to their default value
  *
-- 
2.40.1



[PATCH 16/35] dm: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 drivers/core/root.c | 81 -
 1 file changed, 81 deletions(-)

diff --git a/drivers/core/root.c b/drivers/core/root.c
index 79d871ab291..47b1320a441 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -55,81 +55,6 @@ void dm_fixup_for_gd_move(struct global_data *new_gd)
}
 }
 
-void fix_drivers(void)
-{
-   struct driver *drv =
-   ll_entry_start(struct driver, driver);
-   const int n_ents = ll_entry_count(struct driver, driver);
-   struct driver *entry;
-
-   for (entry = drv; entry != drv + n_ents; entry++) {
-   if (entry->of_match)
-   entry->of_match = (const struct udevice_id *)
-   ((ulong)entry->of_match + gd->reloc_off);
-   if (entry->bind)
-   entry->bind += gd->reloc_off;
-   if (entry->probe)
-   entry->probe += gd->reloc_off;
-   if (entry->remove)
-   entry->remove += gd->reloc_off;
-   if (entry->unbind)
-   entry->unbind += gd->reloc_off;
-   if (entry->of_to_plat)
-   entry->of_to_plat += gd->reloc_off;
-   if (entry->child_post_bind)
-   entry->child_post_bind += gd->reloc_off;
-   if (entry->child_pre_probe)
-   entry->child_pre_probe += gd->reloc_off;
-   if (entry->child_post_remove)
-   entry->child_post_remove += gd->reloc_off;
-   /* OPS are fixed in every uclass post_probe function */
-   if (entry->ops)
-   entry->ops += gd->reloc_off;
-   }
-}
-
-void fix_uclass(void)
-{
-   struct uclass_driver *uclass =
-   ll_entry_start(struct uclass_driver, uclass_driver);
-   const int n_ents = ll_entry_count(struct uclass_driver, uclass_driver);
-   struct uclass_driver *entry;
-
-   for (entry = uclass; entry != uclass + n_ents; entry++) {
-   if (entry->post_bind)
-   entry->post_bind += gd->reloc_off;
-   if (entry->pre_unbind)
-   entry->pre_unbind += gd->reloc_off;
-   if (entry->pre_probe)
-   entry->pre_probe += gd->reloc_off;
-   if (entry->post_probe)
-   entry->post_probe += gd->reloc_off;
-   if (entry->pre_remove)
-   entry->pre_remove += gd->reloc_off;
-   if (entry->child_post_bind)
-   entry->child_post_bind += gd->reloc_off;
-   if (entry->child_pre_probe)
-   entry->child_pre_probe += gd->reloc_off;
-   if (entry->init)
-   entry->init += gd->reloc_off;
-   if (entry->destroy)
-   entry->destroy += gd->reloc_off;
-   }
-}
-
-void fix_devices(void)
-{
-   struct driver_info *dev =
-   ll_entry_start(struct driver_info, driver_info);
-   const int n_ents = ll_entry_count(struct driver_info, driver_info);
-   struct driver_info *entry;
-
-   for (entry = dev; entry != dev + n_ents; entry++) {
-   if (entry->plat)
-   entry->plat += gd->reloc_off;
-   }
-}
-
 static int dm_setup_inst(void)
 {
DM_ROOT_NON_CONST = DM_DEVICE_GET(root);
@@ -181,12 +106,6 @@ int dm_init(bool of_live)
INIT_LIST_HEAD(DM_UCLASS_ROOT_NON_CONST);
}
 
-   if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC)) {
-   fix_drivers();
-   fix_uclass();
-   fix_devices();
-   }
-
if (CONFIG_IS_ENABLED(OF_PLATDATA_INST)) {
ret = dm_setup_inst();
if (ret) {
-- 
2.40.1



[PATCH 15/35] cmd: pxe: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 cmd/pxe.c | 14 --
 1 file changed, 14 deletions(-)

diff --git a/cmd/pxe.c b/cmd/pxe.c
index 7bfb1b9b280..704589702f2 100644
--- a/cmd/pxe.c
+++ b/cmd/pxe.c
@@ -299,24 +299,10 @@ static struct cmd_tbl cmd_pxe_sub[] = {
U_BOOT_CMD_MKENT(boot, 3, 1, do_pxe_boot, "", "")
 };
 
-static void __maybe_unused pxe_reloc(void)
-{
-   static int relocated_pxe;
-
-   if (!relocated_pxe) {
-   fixup_cmdtable(cmd_pxe_sub, ARRAY_SIZE(cmd_pxe_sub));
-   relocated_pxe = 1;
-   }
-}
-
 static int do_pxe(struct cmd_tbl *cmdtp, int flag, int argc, char *const 
argv[])
 {
struct cmd_tbl *cp;
 
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
-   pxe_reloc();
-#endif
-
if (argc < 2)
return CMD_RET_USAGE;
 
-- 
2.40.1



[PATCH 14/35] cmd: onenand: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 cmd/onenand.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/cmd/onenand.c b/cmd/onenand.c
index d633f19d3bb..3ec11246f6f 100644
--- a/cmd/onenand.c
+++ b/cmd/onenand.c
@@ -560,12 +560,6 @@ static struct cmd_tbl cmd_onenand_sub[] = {
U_BOOT_CMD_MKENT(markbad, CONFIG_SYS_MAXARGS, 0, do_onenand_markbad, 
"", ""),
 };
 
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-void onenand_reloc(void) {
-   fixup_cmdtable(cmd_onenand_sub, ARRAY_SIZE(cmd_onenand_sub));
-}
-#endif
-
 static int do_onenand(struct cmd_tbl *cmdtp, int flag, int argc,
  char *const argv[])
 {
-- 
2.40.1



[PATCH 13/35] cmd: nvedit: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 cmd/nvedit.c  | 11 ---
 env/common.c  |  1 -
 include/env.h |  8 
 3 files changed, 20 deletions(-)

diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 9e4ee4b0177..fe99157fd17 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -407,11 +407,7 @@ static int print_active_callback(struct env_entry *entry)
for (i = 0, clbkp = ll_entry_start(struct env_clbk_tbl, env_clbk);
 i < num_callbacks;
 i++, clbkp++) {
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
-   if (entry->callback == clbkp->callback + gd->reloc_off)
-#else
if (entry->callback == clbkp->callback)
-#endif
break;
}
 
@@ -1222,13 +1218,6 @@ static struct cmd_tbl cmd_env_sub[] = {
 #endif
 };
 
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
-void env_reloc(void)
-{
-   fixup_cmdtable(cmd_env_sub, ARRAY_SIZE(cmd_env_sub));
-}
-#endif
-
 static int do_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const 
argv[])
 {
struct cmd_tbl *cp;
diff --git a/env/common.c b/env/common.c
index 0ecdb248a08..4cf2dadc694 100644
--- a/env/common.c
+++ b/env/common.c
@@ -429,7 +429,6 @@ int env_export(env_t *env_out)
 void env_relocate(void)
 {
 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
-   env_reloc();
env_fix_drivers();
env_htab.change_ok += gd->reloc_off;
 #endif
diff --git a/include/env.h b/include/env.h
index 1480efa59e3..b28886d80b9 100644
--- a/include/env.h
+++ b/include/env.h
@@ -356,14 +356,6 @@ char *env_get_default(const char *name);
 /* [re]set to the default environment */
 void env_set_default(const char *s, int flags);
 
-/**
- * env_reloc() - Relocate the 'env' sub-commands
- *
- * This is used for those unfortunate archs with crappy toolchains
- */
-void env_reloc(void);
-
-
 /**
  * env_import_fdt() - Import environment values from device tree blob
  *
-- 
2.40.1



[PATCH 12/35] cmd: i2c: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 cmd/i2c.c | 14 --
 1 file changed, 14 deletions(-)

diff --git a/cmd/i2c.c b/cmd/i2c.c
index dd803ee2271..f0a5fa2e741 100644
--- a/cmd/i2c.c
+++ b/cmd/i2c.c
@@ -1939,16 +1939,6 @@ static struct cmd_tbl cmd_i2c_sub[] = {
U_BOOT_CMD_MKENT(speed, 1, 1, do_i2c_bus_speed, "", ""),
 };
 
-static __maybe_unused void i2c_reloc(void)
-{
-   static int relocated;
-
-   if (!relocated) {
-   fixup_cmdtable(cmd_i2c_sub, ARRAY_SIZE(cmd_i2c_sub));
-   relocated = 1;
-   };
-}
-
 /**
  * do_i2c() - Handle the "i2c" command-line command
  * @cmdtp: Command data struct pointer
@@ -1963,10 +1953,6 @@ static int do_i2c(struct cmd_tbl *cmdtp, int flag, int 
argc, char *const argv[])
 {
struct cmd_tbl *c;
 
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-   i2c_reloc();
-#endif
-
if (argc < 2)
return CMD_RET_USAGE;
 
-- 
2.40.1



[PATCH 11/35] cmd: date: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 cmd/date.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/cmd/date.c b/cmd/date.c
index fe9c8c6534e..4f98b470ca2 100644
--- a/cmd/date.c
+++ b/cmd/date.c
@@ -20,12 +20,6 @@ static const char * const weekdays[] = {
"Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur",
 };
 
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-#define RELOC(a)   ((typeof(a))((unsigned long)(a) + gd->reloc_off))
-#else
-#define RELOC(a)   a
-#endif
-
 int mk_date (const char *, struct rtc_time *);
 
 static struct rtc_time default_tm = { 0, 0, 0, 1, 1, 2000, 6, 0, 0 };
@@ -113,7 +107,7 @@ static int do_date(struct cmd_tbl *cmdtp, int flag, int 
argc,
printf ("Date: %4d-%02d-%02d (%sday)Time: %2d:%02d:%02d\n",
tm.tm_year, tm.tm_mon, tm.tm_mday,
(tm.tm_wday<0 || tm.tm_wday>6) ?
-   "unknown " : RELOC(weekdays[tm.tm_wday]),
+   "unknown " : weekdays[tm.tm_wday],
tm.tm_hour, tm.tm_min, tm.tm_sec);
 
break;
-- 
2.40.1



[PATCH 10/35] cmd: bmp: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 common/bmp.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/common/bmp.c b/common/bmp.c
index 57764f3653e..bab6fa7265a 100644
--- a/common/bmp.c
+++ b/common/bmp.c
@@ -81,13 +81,6 @@ struct bmp_image *gunzip_bmp(unsigned long addr, unsigned 
long *lenp,
return bmp;
 }
 
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-void bmp_reloc(void)
-{
-   fixup_cmdtable(cmd_bmp_sub, ARRAY_SIZE(cmd_bmp_sub));
-}
-#endif
-
 int bmp_info(ulong addr)
 {
struct bmp_image *bmp = (struct bmp_image *)map_sysmem(addr, 0);
-- 
2.40.1



[PATCH 09/35] common: stdio: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 common/stdio.c | 12 
 1 file changed, 12 deletions(-)

diff --git a/common/stdio.c b/common/stdio.c
index 894cbd3fb44..010bf576af0 100644
--- a/common/stdio.c
+++ b/common/stdio.c
@@ -293,18 +293,6 @@ int stdio_deregister_dev(struct stdio_dev *dev, int force)
 
 int stdio_init_tables(void)
 {
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
-   /* already relocated for current ARM implementation */
-   ulong relocation_offset = gd->reloc_off;
-   int i;
-
-   /* relocate device name pointers */
-   for (i = 0; i < (sizeof (stdio_names) / sizeof (char *)); ++i) {
-   stdio_names[i] = (char *) (((ulong) stdio_names[i]) +
-   relocation_offset);
-   }
-#endif /* CONFIG_NEEDS_MANUAL_RELOC */
-
/* Initialize the list */
INIT_LIST_HEAD();
 
-- 
2.40.1



[PATCH 08/35] common: hash: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 common/hash.c | 29 -
 1 file changed, 29 deletions(-)

diff --git a/common/hash.c b/common/hash.c
index 159179e7f21..e837c56d443 100644
--- a/common/hash.c
+++ b/common/hash.c
@@ -36,12 +36,6 @@
 #include 
 #include 
 
-#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
-DECLARE_GLOBAL_DATA_PTR;
-#endif
-
-static void reloc_update(void);
-
 static int __maybe_unused hash_init_sha1(struct hash_algo *algo, void **ctxp)
 {
sha1_context *ctx = malloc(sizeof(sha1_context));
@@ -333,31 +327,10 @@ static struct hash_algo hash_algo[] = {
 #define multi_hash()   0
 #endif
 
-static void reloc_update(void)
-{
-#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
-   int i;
-   static bool done;
-
-   if (!done) {
-   done = true;
-   for (i = 0; i < ARRAY_SIZE(hash_algo); i++) {
-   hash_algo[i].name += gd->reloc_off;
-   hash_algo[i].hash_func_ws += gd->reloc_off;
-   hash_algo[i].hash_init += gd->reloc_off;
-   hash_algo[i].hash_update += gd->reloc_off;
-   hash_algo[i].hash_finish += gd->reloc_off;
-   }
-   }
-#endif
-}
-
 int hash_lookup_algo(const char *algo_name, struct hash_algo **algop)
 {
int i;
 
-   reloc_update();
-
for (i = 0; i < ARRAY_SIZE(hash_algo); i++) {
if (!strcmp(algo_name, hash_algo[i].name)) {
*algop = _algo[i];
@@ -374,8 +347,6 @@ int hash_progressive_lookup_algo(const char *algo_name,
 {
int i;
 
-   reloc_update();
-
for (i = 0; i < ARRAY_SIZE(hash_algo); i++) {
if (!strcmp(algo_name, hash_algo[i].name)) {
if (hash_algo[i].hash_init) {
-- 
2.40.1



[PATCH 07/35] common: event: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 common/board_r.c |  3 ---
 common/event.c   | 14 --
 include/event.h  | 10 --
 3 files changed, 27 deletions(-)

diff --git a/common/board_r.c b/common/board_r.c
index 630c104a985..e30963339cf 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -590,9 +590,6 @@ static init_fnc_t init_sequence_r[] = {
 */
 #endif
initr_reloc_global_data,
-#if IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC) && CONFIG_IS_ENABLED(EVENT)
-   event_manual_reloc,
-#endif
 #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
initr_unlock_ram_in_cache,
 #endif
diff --git a/common/event.c b/common/event.c
index d11b37a1d80..3080d9ed754 100644
--- a/common/event.c
+++ b/common/event.c
@@ -168,20 +168,6 @@ void event_show_spy_list(void)
}
 }
 
-#if IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC)
-int event_manual_reloc(void)
-{
-   struct evspy_info *spy, *end;
-
-   spy = ll_entry_start(struct evspy_info, evspy_info);
-   end = ll_entry_end(struct evspy_info, evspy_info);
-   for (; spy < end; spy++)
-   MANUAL_RELOC(spy->func);
-
-   return 0;
-}
-#endif
-
 #if CONFIG_IS_ENABLED(EVENT_DYNAMIC)
 static void spy_free(struct event_spy *spy)
 {
diff --git a/include/event.h b/include/event.h
index 311df878c4a..be4cefd6ae8 100644
--- a/include/event.h
+++ b/include/event.h
@@ -328,16 +328,6 @@ int event_register(const char *id, enum event_t type, 
event_handler_t func,
 /** event_show_spy_list( - Show a list of event spies */
 void event_show_spy_list(void);
 
-/**
- * event_manual_reloc() - Relocate event handler pointers
- *
- * Relocate event handler pointers for all static event spies. It is called
- * during the generic board init sequence, after relocation.
- *
- * Return: 0 if OK
- */
-int event_manual_reloc(void);
-
 /**
  * event_type_name() - Get the name of an event type
  *
-- 
2.40.1



[PATCH 06/35] common: malloc: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 common/dlmalloc.c | 14 --
 1 file changed, 14 deletions(-)

diff --git a/common/dlmalloc.c b/common/dlmalloc.c
index 0f9b7262d51..ebf0f27e165 100644
--- a/common/dlmalloc.c
+++ b/common/dlmalloc.c
@@ -575,19 +575,6 @@ static mbinptr av_[NAV * 2 + 2] = {
  IAV(120), IAV(121), IAV(122), IAV(123), IAV(124), IAV(125), IAV(126), IAV(127)
 };
 
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-static void malloc_bin_reloc(void)
-{
-   mbinptr *p = _[2];
-   size_t i;
-
-   for (i = 2; i < ARRAY_SIZE(av_); ++i, ++p)
-   *p = (mbinptr)((ulong)*p + gd->reloc_off);
-}
-#else
-static inline void malloc_bin_reloc(void) {}
-#endif
-
 #ifdef CONFIG_SYS_MALLOC_DEFAULT_TO_INIT
 static void malloc_init(void);
 #endif
@@ -634,7 +621,6 @@ void mem_malloc_init(ulong start, ulong size)
 #ifdef CONFIG_SYS_MALLOC_CLEAR_ON_INIT
memset((void *)mem_malloc_start, 0x0, size);
 #endif
-   malloc_bin_reloc();
 }
 
 /* field-extraction macros */
-- 
2.40.1



[PATCH 05/35] common: hush: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 common/cli_hush.c | 16 
 1 file changed, 16 deletions(-)

diff --git a/common/cli_hush.c b/common/cli_hush.c
index cee87249bc2..9cda97f30e3 100644
--- a/common/cli_hush.c
+++ b/common/cli_hush.c
@@ -3305,19 +3305,6 @@ int parse_file_outer(void)
 }
 
 #ifdef __U_BOOT__
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-static void u_boot_hush_reloc(void)
-{
-   unsigned long addr;
-   struct reserved_combo *r;
-
-   for (r=reserved_list; rliteral) + gd->reloc_off;
-   r->literal = (char *)addr;
-   }
-}
-#endif
-
 int u_boot_hush_start(void)
 {
if (top_vars == NULL) {
@@ -3327,9 +3314,6 @@ int u_boot_hush_start(void)
top_vars->next = NULL;
top_vars->flg_export = 0;
top_vars->flg_read_only = 1;
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-   u_boot_hush_reloc();
-#endif
}
return 0;
 }
-- 
2.40.1



[PATCH 04/35] common: board_r: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 common/board_r.c   | 22 --
 include/relocate.h | 12 +---
 lib/initcall.c | 10 --
 3 files changed, 1 insertion(+), 43 deletions(-)

diff --git a/common/board_r.c b/common/board_r.c
index 697d4a5bd3d..630c104a985 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -151,13 +151,6 @@ static int initr_reloc_global_data(void)
 */
gd->env_addr += gd->reloc_off;
 #endif
-   /*
-* The fdt_blob needs to be moved to new relocation address
-* incase of FDT blob is embedded with in image
-*/
-   if (IS_ENABLED(CONFIG_OF_EMBED) && 
IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC))
-   gd->fdt_blob += gd->reloc_off;
-
 #ifdef CONFIG_EFI_LOADER
/*
 * On the ARM architecture gd is mapped to a fixed register (r9 or x18).
@@ -295,15 +288,6 @@ static int initr_announce(void)
return 0;
 }
 
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-static int initr_manual_reloc_cmdtable(void)
-{
-   fixup_cmdtable(ll_entry_start(struct cmd_tbl, cmd),
-  ll_entry_count(struct cmd_tbl, cmd));
-   return 0;
-}
-#endif
-
 static int initr_binman(void)
 {
int ret;
@@ -657,9 +641,6 @@ static init_fnc_t init_sequence_r[] = {
initr_watchdog,
 #endif
INIT_FUNC_WATCHDOG_RESET
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-   initr_manual_reloc_cmdtable,
-#endif
arch_initr_trap,
 #if defined(CONFIG_BOARD_EARLY_INIT_R)
board_early_init_r,
@@ -803,9 +784,6 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)
 #endif
gd->flags &= ~GD_FLG_LOG_READY;
 
-   if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC))
-   initcall_manual_reloc(init_sequence_r);
-
if (initcall_run_list(init_sequence_r))
hang();
 
diff --git a/include/relocate.h b/include/relocate.h
index 2dbfd901e4f..5ae1a2ed555 100644
--- a/include/relocate.h
+++ b/include/relocate.h
@@ -50,17 +50,7 @@ int do_elf_reloc_fixups(void);
  */
 static inline void *manual_reloc(void *ptr)
 {
-#ifndef USE_HOSTCC
-   if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC))
-   return ptr + gd->reloc_off;
-#endif
-   return ptr;
+   return ptr;
 }
 
-#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
-#define MANUAL_RELOC(ptr)  (ptr) = manual_reloc(ptr)
-#else
-#define MANUAL_RELOC(ptr)  (void)(ptr)
-#endif
-
 #endif /* _RELOCATE_H_ */
diff --git a/lib/initcall.c b/lib/initcall.c
index 480490ea239..33b7d761dc7 100644
--- a/lib/initcall.c
+++ b/lib/initcall.c
@@ -97,13 +97,3 @@ int initcall_run_list(const init_fnc_t init_sequence[])
 
return 0;
 }
-
-void initcall_manual_reloc(init_fnc_t init_sequence[])
-{
-   init_fnc_t *ptr;
-
-   for (ptr = init_sequence; *ptr; ptr++) {
-   if (!initcall_is_event(*ptr))
-   MANUAL_RELOC(*ptr);
-   }
-}
-- 
2.40.1



[PATCH 03/35] command: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 include/command.h | 21 -
 1 file changed, 21 deletions(-)

diff --git a/include/command.h b/include/command.h
index c4e3170967d..ae7bb4a30b0 100644
--- a/include/command.h
+++ b/include/command.h
@@ -318,24 +318,6 @@ int cmd_source_script(ulong addr, const char *fit_uname, 
const char *confname);
 # define _CMD_HELP(x)
 #endif
 
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-#define U_BOOT_SUBCMDS_RELOC(_cmdname) \
-   static void _cmdname##_subcmds_reloc(void)  \
-   {   \
-   static int relocated;   \
-   \
-   if (relocated)  \
-   return; \
-   \
-   fixup_cmdtable(_cmdname##_subcmds,  \
-  ARRAY_SIZE(_cmdname##_subcmds)); \
-   relocated = 1;  \
-   }
-#else
-#define U_BOOT_SUBCMDS_RELOC(_cmdname) \
-   static void _cmdname##_subcmds_reloc(void) { }
-#endif
-
 #define U_BOOT_SUBCMDS_DO_CMD(_cmdname)
\
static int do_##_cmdname(struct cmd_tbl *cmdtp, int flag,   \
 int argc, char *const argv[],  \
@@ -343,8 +325,6 @@ int cmd_source_script(ulong addr, const char *fit_uname, 
const char *confname);
{   \
struct cmd_tbl *subcmd; \
\
-   _cmdname##_subcmds_reloc(); \
-   \
/* We need at least the cmd and subcmd names. */\
if (argc < 2 || argc > CONFIG_SYS_MAXARGS)  \
return CMD_RET_USAGE;   \
@@ -379,7 +359,6 @@ int cmd_source_script(ulong addr, const char *fit_uname, 
const char *confname);
 
 #define U_BOOT_SUBCMDS(_cmdname, ...)  \
static struct cmd_tbl _cmdname##_subcmds[] = { __VA_ARGS__ };   \
-   U_BOOT_SUBCMDS_RELOC(_cmdname)  \
U_BOOT_SUBCMDS_DO_CMD(_cmdname) \
U_BOOT_SUBCMDS_COMPLETE(_cmdname)
 
-- 
2.40.1



[PATCH 02/35] blkcache: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 cmd/blkcache.c   | 13 -
 common/board_r.c |  3 ---
 drivers/block/blkcache.c | 16 
 include/blk.h|  6 --
 4 files changed, 38 deletions(-)

diff --git a/cmd/blkcache.c b/cmd/blkcache.c
index 47ea1ec0b93..1456654df6f 100644
--- a/cmd/blkcache.c
+++ b/cmd/blkcache.c
@@ -46,24 +46,11 @@ static struct cmd_tbl cmd_blkc_sub[] = {
U_BOOT_CMD_MKENT(configure, 3, 0, blkc_configure, "", ""),
 };
 
-static __maybe_unused void blkc_reloc(void)
-{
-   static int relocated;
-
-   if (!relocated) {
-   fixup_cmdtable(cmd_blkc_sub, ARRAY_SIZE(cmd_blkc_sub));
-   relocated = 1;
-   };
-}
-
 static int do_blkcache(struct cmd_tbl *cmdtp, int flag,
   int argc, char *const argv[])
 {
struct cmd_tbl *c;
 
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-   blkc_reloc();
-#endif
if (argc < 2)
return CMD_RET_USAGE;
 
diff --git a/common/board_r.c b/common/board_r.c
index ad9a3cf6336..697d4a5bd3d 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -657,9 +657,6 @@ static init_fnc_t init_sequence_r[] = {
initr_watchdog,
 #endif
INIT_FUNC_WATCHDOG_RESET
-#if defined(CONFIG_NEEDS_MANUAL_RELOC) && defined(CONFIG_BLOCK_CACHE)
-   blkcache_init,
-#endif
 #ifdef CONFIG_NEEDS_MANUAL_RELOC
initr_manual_reloc_cmdtable,
 #endif
diff --git a/drivers/block/blkcache.c b/drivers/block/blkcache.c
index f99465aa479..26bcbea4353 100644
--- a/drivers/block/blkcache.c
+++ b/drivers/block/blkcache.c
@@ -13,10 +13,6 @@
 #include 
 #include 
 
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-DECLARE_GLOBAL_DATA_PTR;
-#endif
-
 struct block_cache_node {
struct list_head lh;
int iftype;
@@ -34,18 +30,6 @@ static struct block_cache_stats _stats = {
.max_entries = 32
 };
 
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-int blkcache_init(void)
-{
-   struct list_head *head = _cache;
-
-   head->next = (uintptr_t)head->next + gd->reloc_off;
-   head->prev = (uintptr_t)head->prev + gd->reloc_off;
-
-   return 0;
-}
-#endif
-
 static struct block_cache_node *cache_find(int iftype, int devnum,
   lbaint_t start, lbaint_t blkcnt,
   unsigned long blksz)
diff --git a/include/blk.h b/include/blk.h
index b819f97c2f1..95e86e2d5d1 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -105,12 +105,6 @@ struct blk_desc {
(PAD_SIZE(size, blk_desc->blksz))
 
 #if CONFIG_IS_ENABLED(BLOCK_CACHE)
-
-/**
- * blkcache_init() - initialize the block cache list pointers
- */
-int blkcache_init(void);
-
 /**
  * blkcache_read() - attempt to read a set of blocks from cache
  *
-- 
2.40.1



[PATCH 01/35] boot: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

Signed-off-by: Marek Vasut 
---
 boot/bootm_os.c  | 14 --
 boot/image-sig.c | 28 
 cmd/bootm.c  | 14 --
 3 files changed, 56 deletions(-)

diff --git a/boot/bootm_os.c b/boot/bootm_os.c
index 99ff0e6c02d..9c035b5be88 100644
--- a/boot/bootm_os.c
+++ b/boot/bootm_os.c
@@ -609,19 +609,5 @@ int boot_selected_os(int argc, char *const argv[], int 
state,
 
 boot_os_fn *bootm_os_get_boot_func(int os)
 {
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-   static bool relocated;
-
-   if (!relocated) {
-   int i;
-
-   /* relocate boot function table */
-   for (i = 0; i < ARRAY_SIZE(boot_os); i++)
-   if (boot_os[i] != NULL)
-   boot_os[i] += gd->reloc_off;
-
-   relocated = true;
-   }
-#endif
return boot_os[os];
 }
diff --git a/boot/image-sig.c b/boot/image-sig.c
index 1aa0b586450..b5692d58b24 100644
--- a/boot/image-sig.c
+++ b/boot/image-sig.c
@@ -57,20 +57,6 @@ struct checksum_algo *image_get_checksum_algo(const char 
*full_name)
int i;
const char *name;
 
-   if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC)) {
-   static bool done;
-
-   if (!done) {
-   done = true;
-   for (i = 0; i < ARRAY_SIZE(checksum_algos); i++) {
-   struct checksum_algo *algo = _algos[i];
-
-   MANUAL_RELOC(algo->name);
-   MANUAL_RELOC(algo->calculate);
-   }
-   }
-   }
-
for (i = 0; i < ARRAY_SIZE(checksum_algos); i++) {
name = checksum_algos[i].name;
/* Make sure names match and next char is a comma */
@@ -87,20 +73,6 @@ struct crypto_algo *image_get_crypto_algo(const char 
*full_name)
struct crypto_algo *crypto, *end;
const char *name;
 
-   if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC)) {
-   static bool done;
-
-   if (!done) {
-   done = true;
-   crypto = ll_entry_start(struct crypto_algo, cryptos);
-   end = ll_entry_end(struct crypto_algo, cryptos);
-   for (; crypto < end; crypto++) {
-   MANUAL_RELOC(crypto->name);
-   MANUAL_RELOC(crypto->verify);
-   }
-   }
-   }
-
/* Move name to after the comma */
name = strchr(full_name, ',');
if (!name)
diff --git a/cmd/bootm.c b/cmd/bootm.c
index 37c2af96e08..7968415b6d1 100644
--- a/cmd/bootm.c
+++ b/cmd/bootm.c
@@ -123,20 +123,6 @@ int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
int states;
int ret;
 
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-   static int relocated = 0;
-
-   if (!relocated) {
-   int i;
-
-   /* relocate names of sub-command table */
-   for (i = 0; i < ARRAY_SIZE(cmd_bootm_sub); i++)
-   cmd_bootm_sub[i].name += gd->reloc_off;
-
-   relocated = 1;
-   }
-#endif
-
/* determine if we have a sub command */
argc--; argv++;
if (argc > 0) {
-- 
2.40.1



[PATCH 00/35] treewide: Remove unused NEEDS_MANUAL_RELOC code bits

2023-09-06 Thread Marek Vasut
The last user of the NEEDS_MANUAL_RELOC has been removed in commit
26af162ac8f8 ("arch: m68k: Implement relocation")
Remove now unused NEEDS_MANUAL_RELOC code.

This is a follow up on way over decade old commit
2e5167ccad93 ("Replace CONFIG_RELOC_FIXUP_WORKS by CONFIG_NEEDS_MANUAL_RELOC")
"
By now, the majority of architectures have working relocation
support, so the few remaining architectures have become exceptions.
To make this more obvious, we make working relocation now the default
case, and flag the remaining cases with CONFIG_NEEDS_MANUAL_RELOC.
"
It took a bit longer than expected, but now we can really sunset
CONFIG_NEEDS_MANUAL_RELOC.

Make it so.

Marek Vasut (35):
  boot: Remove unused NEEDS_MANUAL_RELOC code bits
  blkcache: Remove unused NEEDS_MANUAL_RELOC code bits
  command: Remove unused NEEDS_MANUAL_RELOC code bits
  common: board_r: Remove unused NEEDS_MANUAL_RELOC code bits
  common: hush: Remove unused NEEDS_MANUAL_RELOC code bits
  common: malloc: Remove unused NEEDS_MANUAL_RELOC code bits
  common: event: Remove unused NEEDS_MANUAL_RELOC code bits
  common: hash: Remove unused NEEDS_MANUAL_RELOC code bits
  common: stdio: Remove unused NEEDS_MANUAL_RELOC code bits
  cmd: bmp: Remove unused NEEDS_MANUAL_RELOC code bits
  cmd: date: Remove unused NEEDS_MANUAL_RELOC code bits
  cmd: i2c: Remove unused NEEDS_MANUAL_RELOC code bits
  cmd: nvedit: Remove unused NEEDS_MANUAL_RELOC code bits
  cmd: onenand: Remove unused NEEDS_MANUAL_RELOC code bits
  cmd: pxe: Remove unused NEEDS_MANUAL_RELOC code bits
  dm: Remove unused NEEDS_MANUAL_RELOC code bits
  env: Remove unused NEEDS_MANUAL_RELOC code bits
  initcall: Remove unused NEEDS_MANUAL_RELOC code bits
  image: Remove unused NEEDS_MANUAL_RELOC code bits
  fs: Remove unused NEEDS_MANUAL_RELOC code bits
  cpu: Remove unused NEEDS_MANUAL_RELOC code bits
  crypto: rsa: Remove unused NEEDS_MANUAL_RELOC code bits
  gpio: Remove unused NEEDS_MANUAL_RELOC code bits
  hwspinlock: Remove unused NEEDS_MANUAL_RELOC code bits
  sf: Remove unused NEEDS_MANUAL_RELOC code bits
  mtd: ubifs: Remove unused NEEDS_MANUAL_RELOC code bits
  net: eth: Remove unused NEEDS_MANUAL_RELOC code bits
  net: miiphybb: Remove unused NEEDS_MANUAL_RELOC code bits
  net: phy: Remove unused NEEDS_MANUAL_RELOC code bits
  serial: Remove unused NEEDS_MANUAL_RELOC code bits
  spi: Remove unused NEEDS_MANUAL_RELOC code bits
  sysreset: Remove unused NEEDS_MANUAL_RELOC code bits
  timer: Remove unused NEEDS_MANUAL_RELOC code bits
  wdt: Remove unused NEEDS_MANUAL_RELOC code bits
  post: Remove unused NEEDS_MANUAL_RELOC code bits

 boot/bootm_os.c | 14 
 boot/image-sig.c| 28 ---
 boot/image.c| 10 +--
 cmd/blkcache.c  | 13 
 cmd/bootm.c | 14 
 cmd/date.c  |  8 +-
 cmd/i2c.c   | 14 
 cmd/nvedit.c| 11 ---
 cmd/onenand.c   |  6 --
 cmd/pxe.c   | 14 
 common/bmp.c|  7 --
 common/board_r.c| 28 ---
 common/cli_hush.c   | 16 
 common/dlmalloc.c   | 14 
 common/event.c  | 14 
 common/hash.c   | 29 
 common/stdio.c  | 12 ---
 doc/README.POST |  5 --
 drivers/block/blkcache.c| 16 
 drivers/core/root.c | 81 -
 drivers/cpu/cpu-uclass.c| 27 ---
 drivers/crypto/rsa_mod_exp/mod_exp_uclass.c | 13 
 drivers/gpio/gpio-uclass.c  | 30 
 drivers/hwspinlock/hwspinlock-uclass.c  | 21 --
 drivers/mtd/spi/sf-uclass.c | 16 
 drivers/net/phy/miiphybb.c  | 20 +
 drivers/net/phy/phy.c   | 31 
 drivers/serial/serial-uclass.c  | 22 --
 drivers/serial/serial.c | 17 -
 drivers/spi/spi-uclass.c| 32 
 drivers/sysreset/sysreset-uclass.c  | 16 
 drivers/timer/timer-uclass.c| 13 
 drivers/watchdog/wdt-uclass.c   | 23 --
 env/callback.c  | 12 ---
 env/common.c|  5 --
 env/env.c   | 23 --
 fs/fs.c | 16 
 fs/ubifs/ubifs.c|  6 --
 include/blk.h   |  6 --
 include/command.h   | 21 --
 include/env.h   | 13 
 include/event.h | 10 ---
 include/initcall.h  |  7 

Re: [PATCH] bootstd: sata: Add bootstd support for ahci sata

2023-09-06 Thread Tony Dinh
Hi Simon,

On Tue, Sep 5, 2023 at 9:00 PM Tony Dinh  wrote:
>
> Add ahci sata bootdev and corresponding hunting function.
>
> Signed-off-by: Tony Dinh 
> ---
>
>  drivers/ata/Makefile   |  1 +
>  drivers/ata/sata.c | 25 +++
>  drivers/ata/sata_bootdev.c | 62 ++
>  include/sata.h |  1 +
>  4 files changed, 89 insertions(+)
>  create mode 100644 drivers/ata/sata_bootdev.c
>
> diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
> index 6e30180b8b..c1b51b5444 100644
> --- a/drivers/ata/Makefile
> +++ b/drivers/ata/Makefile
> @@ -11,6 +11,7 @@ obj-$(CONFIG_DWC_AHSATA) += dwc_ahsata.o
>  obj-$(CONFIG_FSL_SATA) += fsl_sata.o
>  obj-$(CONFIG_LIBATA) += libata.o
>  obj-$(CONFIG_SATA) += sata.o
> +obj-$(CONFIG_BOOTSTD) += sata_bootdev.o
>  obj-$(CONFIG_SATA_CEVA) += sata_ceva.o
>  obj-$(CONFIG_SATA_MV) += sata_mv.o
>  obj-$(CONFIG_SATA_SIL) += sata_sil.o
> diff --git a/drivers/ata/sata.c b/drivers/ata/sata.c
> index ce3e9b5a40..9da7218564 100644
> --- a/drivers/ata/sata.c
> +++ b/drivers/ata/sata.c
> @@ -15,6 +15,8 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>
>  #ifndef CONFIG_AHCI
>  struct blk_desc sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE];
> @@ -50,6 +52,29 @@ int sata_scan(struct udevice *dev)
> return ops->scan(dev);
>  }
>
> +int sata_rescan(bool verbose)
> +{
> +   struct udevice *dev;
> +   int devnum = 0;
> +   int ret;
> +
> +   /* Find and probing the SATA controller */
> +   ret = uclass_get_device(UCLASS_AHCI, devnum, );
> +
> +   /* Sanity check */
> +   if (ret)
> +   ret = uclass_find_first_device(UCLASS_AHCI, );
> +   if (ret) {
> +   printf("Cannot probe SATA device %d (err=%d)\n", devnum, ret);
> +   return -ENOSYS;
> +   }
> +   if (!dev) {
> +   printf("No SATA device found!\n");
> +   return -ENOSYS;
> +   }
> +   return 0;
> +}
> +
>  #ifndef CONFIG_AHCI
>  #ifdef CONFIG_PARTITIONS
>  struct blk_desc *sata_get_dev(int dev)
> diff --git a/drivers/ata/sata_bootdev.c b/drivers/ata/sata_bootdev.c
> new file mode 100644
> index 00..f638493ce0
> --- /dev/null
> +++ b/drivers/ata/sata_bootdev.c
> @@ -0,0 +1,62 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Bootdev for sata
> + *
> + * Copyright 2023 Tony Dinh 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +static int sata_bootdev_bind(struct udevice *dev)
> +{
> +   struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
> +
> +   ucp->prio = BOOTDEVP_4_SCAN_FAST;
> +
> +   return 0;
> +}
> +
> +static int sata_bootdev_hunt(struct bootdev_hunter *info, bool show)
> +{
> +   int ret;
> +
> +   if (IS_ENABLED(CONFIG_PCI)) {
> +   ret = pci_init();
> +   if (ret)
> +   return ret;
> +   }
> +
> +   ret = sata_rescan(true);
> +   if (ret)
> +   return ret;
> +
> +   return 0;
> +}
> +
> +struct bootdev_ops sata_bootdev_ops = {
> +};
> +
> +static const struct udevice_id sata_bootdev_ids[] = {
> +   { .compatible = "u-boot,bootdev-sata" },
> +   { }
> +};
> +
> +U_BOOT_DRIVER(sata_bootdev) = {
> +   .name   = "sata_bootdev",
> +   .id = UCLASS_BOOTDEV,
> +   .ops= _bootdev_ops,
> +   .bind   = sata_bootdev_bind,
> +   .of_match   = sata_bootdev_ids,
> +};
> +
> +BOOTDEV_HUNTER(sata_bootdev_hunter) = {
> +   .prio   = BOOTDEVP_4_SCAN_FAST,
> +   .uclass = UCLASS_AHCI,
> +   .hunt   = sata_bootdev_hunt,
> +   .drv= DM_DRIVER_REF(sata_bootdev),
> +};
> diff --git a/include/sata.h b/include/sata.h
> index d89f7a8a29..0495744bad 100644
> --- a/include/sata.h
> +++ b/include/sata.h
> @@ -20,5 +20,6 @@ extern struct blk_desc sata_dev_desc[];
>
>  int sata_probe(int devnum);
>  int sata_remove(int devnum);
> +int sata_rescan(bool verbose);
>
>  #endif
> --
> 2.39.2
>

This will need a followup patch. It's about how the distro boot
devtype is currently set to "ahci" after the bootflow scanning,
instead of "sata". For example,

load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} ${uImage}

The non-scsi hdd device it must be identified as sata, like below,

load sata  ${devnum}:${distro_bootpart} ${kernel_addr_r} ${uImage}

All the best,
Tony


Re: [PATCH] sunxi: board: provide CPU idle states to loaded OS

2023-09-06 Thread Andrey Skvortsov
Hi Andre,

On 23-09-06 01:12, Andre Przywara wrote:
> On Tue, 5 Sep 2023 11:37:31 +0300
> Andrey Skvortsov  wrote:
> 
> Hi,
> 
> > On 23-09-05 09:27, Andre Przywara wrote:
> > > On Mon,  4 Sep 2023 23:54:30 +0300
> > > Andrey Skvortsov  wrote:
> > > 
> > > Hi Andrey,
> > >   
> > > > When using SCPI as the PSCI backend, firmware can wake up the CPUs and
> > > > cluster from sleep, so CPU idle states are available for loaded OS to
> > > > use. TF-A modifies DTB to advertise available CPU idle states, when
> > > > SCPI is detected. This change copies nodes added by TF-A to any new
> > > > dtb that is used for loaded OS.  
> > > 
> > > Why do you need that, exactly? Why not just use $fdtcontroladdr for the
> > > kernel? We now keep the U-Boot copy of the .dts files in sync with the
> > > kernel. If you need to modify the DT in U-Boot, for instance by applying
> > > overlays, you can copy that DTB into a better suitable location first:  
> > > => fdt move $fdtcontroladdr $fdt_addr_r  
> > > 
> > > In any case, there shall be only one DT, that one in the U-Boot image. Why
> > > do you need to load another one for the kernel?  
> > 
> > extlinux is used by distributions (sometimes with device-specific changes 
> > especially
> 
> What distros are that? I guess some special ones, targeting embedded
> devices, like the Pinephone?

It's more likely universal operating system. In my particular case
this is Mobian (several device-specific packages on top of
Debian). It's very-very close to Debian with a goal to be
pure Debian in the near future.

Rhino Linux is using extlinux as well and will benefit for this change
as well.

> And who is generating extlinux.conf then? Is that some distro specific
> scripting, similar to how grub is configured?

extlinux.conf is automatically generated by standard Debian
u-boot-menu package. See [1] and [2]. 

> Honest questions, I am not a user of extlinux, I mostly use UEFI
> booting, or type U-Boot commands directly for experiments, or use
> boot.scr, as a quick-and-dirty hack.


> > for platforms not fully supported by mainline yet),
> 
> Do you need any changes to the DT? Do you need to apply overlays?
> If you run on a non-mainlined platform, you could still put your DT
> into the U-Boot tree, then you wouldn't need to load another DTB, which
> also simplifies the deployment on the kernel/distro side.

Currently Mobian linux kernel for sunxi-devices contains 36 extra patches with 
DT
modifications (add/remove nodes, modify existing properties). One of
them unconditionally adds cpuidle states to DT, that I'm trying to fix
upstream here with the proposed change.
DT overlays are not used.

Honestly I don't think that using dtb from u-boot will simplify
distribution deployment and maintenance. IMHO, it will make things
more complex. Currently on my device there are records in extlinux.conf
for 5.9, 5.10, 5.15, several 6.1 kernels, that I'm working on. All of
them have slightly (or sometimes more) different device-trees. Having
kernel and dtb deployed together makes life so much easier.

Mobian's dtb can't be put into u-boot. Mobian doesn't provide
device-specific bootloader (u-boot) and there is on-going work on
making device-independent universal images. 
As many other mobile Linux distributions Mobian relies on
Tow-Boot. That is used as a cross-distribution firmware (u-boot/tf-a/crust). [3]

> > then U-Boot loads DT defined in
> > extlinux.conf file. u-boot scripts are not used in case of extlinux at all.
> 
> That's fine, you don't need any U-Boot scripts for this to work. If
> there is no "fdt" or "fdtdir" label in extlinux.conf, then the U-Boot
> PXE code will eventually fall back to $fdtcontroladdr - I just tested
> that.
> So could you make that work for you? I guess all you need to change is
> to remove any fdtdir label from extlinux.conf?
> 
> Cheers,
> Andre

Regardless proposed change. Changes to dtb nodes already copied in
u-boot on the fly in boot/image-fdt.c:image_setup_libfdt. For example,
created optee nodes are copied there. I've just put platform specific
changes into platform specific ft_board_setup, that was made
apparently exactly for that.


1. https://packages.debian.org/trixie/u-boot-menu
2. https://salsa.debian.org/debian/u-boot-menu
3. https://tow-boot.org/

-- 
Best regards,
Andrey Skvortsov


Re: [PATCH 3/5] armv8: fsl-layerscape: create bypass smmu mapping for MC

2023-09-06 Thread Robin Murphy

On 2023-09-06 19:10, Laurentiu Tudor wrote:



On 9/6/2023 8:21 PM, Robin Murphy wrote:

On 2023-09-06 17:01, Laurentiu Tudor wrote:

MC being a plain DMA master as any other device in the SoC and
being live at OS boot time, as soon as the SMMU is probed it
will immediately start triggering faults because there is no
mapping in the SMMU for the MC. Pre-create such a mapping in
the SMMU, being the OS's responsibility to preserve it.


Does U-Boot enable the SMMU? AFAICS the only thing it knows how to do 
is explicitly turn it *off*, therefore programming other registers 
appears to be a complete waste of time.


No, it doesn't enable SMMU but it does mark a SMR as valid for MC FW. 
And the ARM SMMU driver subtly preserves it, see [1] (it's late and I 
might be wrong, but I'll double check tomorrow). :-)


No, that sets the SMR valid bit *if* the corresponding entry is 
allocated and marked as valid in the software state in smmu->smrs, which 
at probe time it isn't, because that's only just been allocated and is 
still zero-initialised. Unless, that is, 
arm_smmu_rmr_install_bypass_smr() found a reserved region and 
preallocated an entry to honour it. But even those entries are still 
constructed from scratch; we can't do anything with the existing 
SMR/S2CR register contents in general since they may be uninitialised 
random reset values, so we don't even look.


Pay no attention to the qcom_smmu_cfg_probe() hack either - that only 
exists on the promise that the relevant platforms couldn't have their 
firmware updated to use proper RMRs.


You're already doing the right thing in patch #2, so there's no need to 
waste code on doing a pointless wrong thing as well.


Thanks,
Robin.

All that should matter to the OS, and that it is responsible for 
upholding, is the reserved memory regions from patch #2. For instance, 
if the OS is Linux, literally the first thing arm_smmu_device_reset() 
does is rewrite all the S2CRs and SMRs without so much as looking.


[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/iommu/arm/arm-smmu/arm-smmu.c#n894


---
Best Regards, Laurentiu




Signed-off-by: Laurentiu Tudor 
---
  arch/arm/cpu/armv8/fsl-layerscape/soc.c   | 26 ---
  .../asm/arch-fsl-layerscape/immap_lsch3.h |  9 +++
  2 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c 
b/arch/arm/cpu/armv8/fsl-layerscape/soc.c

index 3bfdc3f77431..870b99838ab5 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
@@ -376,6 +376,18 @@ void bypass_smmu(void)
  val = (in_le32(SMMU_NSCR0) | SCR0_CLIENTPD_MASK) & 
~(SCR0_USFCFG_MASK);

  out_le32(SMMU_NSCR0, val);
  }
+
+void setup_smmu_mc_bypass(int icid, int mask)
+{
+    u32 val;
+
+    val = SMMU_SMR_VALID_MASK | (icid << SMMU_SMR_ID_SHIFT) |
+    (mask << SMMU_SMR_MASK_SHIFT);
+    out_le32(SMMU_REG_SMR(0), val);
+    val = SMMU_S2CR_EXIDVALID_VALID_MASK | SMMU_S2CR_TYPE_BYPASS_MASK;
+    out_le32(SMMU_REG_S2CR(0), val);
+}
+
  void fsl_lsch3_early_init_f(void)
  {
  erratum_rcw_src();
@@ -402,10 +414,18 @@ void fsl_lsch3_early_init_f(void)
  bypass_smmu();
  #endif
-#if defined(CONFIG_ARCH_LS1088A) || defined(CONFIG_ARCH_LS1028A) || \
-    defined(CONFIG_ARCH_LS2080A) || defined(CONFIG_ARCH_LX2160A) || \
-    defined(CONFIG_ARCH_LX2162A)
+#ifdef CONFIG_ARCH_LS1028A
+    set_icids();
+#endif
+
+#if defined(CONFIG_ARCH_LS1088A) || defined(CONFIG_ARCH_LS2080A)
+    set_icids();
+    setup_smmu_mc_bypass(0x300, 0);
+#endif
+
+#if defined(CONFIG_ARCH_LX2160A) || defined(CONFIG_ARCH_LX2162A)
  set_icids();
+    setup_smmu_mc_bypass(0x4000, 0);
  #endif
  }
diff --git a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h 
b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h

index ca5e33379ba9..bec5355adaed 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h
@@ -190,6 +190,15 @@
  #define SCR0_CLIENTPD_MASK    0x0001
  #define SCR0_USFCFG_MASK    0x0400
+#define SMMU_REG_SMR(n)    (SMMU_BASE + 0x800 + ((n) << 2))
+#define SMMU_REG_S2CR(n)    (SMMU_BASE + 0xc00 + ((n) << 2))
+#define SMMU_SMR_VALID_MASK    0x8000
+#define SMMU_SMR_MASK_MASK    0x
+#define SMMU_SMR_MASK_SHIFT    16
+#define SMMU_SMR_ID_MASK    0x
+#define SMMU_SMR_ID_SHIFT    0
+#define SMMU_S2CR_EXIDVALID_VALID_MASK    0x0400
+#define SMMU_S2CR_TYPE_BYPASS_MASK    0x0001
  /* PCIe */
  #define CFG_SYS_PCIE1_ADDR    (CONFIG_SYS_IMMR + 0x240)


Re: [PATCH 3/3] arm: dts: j7200: dtb sync with Linux 6.5-rc1

2023-09-06 Thread reidt
On 13:10-20230906, Nishanth Menon wrote:
> $subject: s/dtb/device tree or dts
> 
> On 13:13-20230905, Reid Tonking wrote:
> > Sync j7200 device tree files with Linux 6.5-rc1
> 
> With that..
> 
> Reviewed-by: Nishanth Menon 
>

I make that change, appreciate the review and all the help along the
way.

> -- 
> Regards,
> Nishanth Menon
> Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 
> 849D 1736 249D


Thanks,
Reid Tonking


Re: [PATCH 2/3] arm: mach-k3: j7200: Add mcu_timer0 id to the dev list

2023-09-06 Thread reidt
On 13:07-20230906, Nishanth Menon wrote:
> On 13:13-20230905, Reid Tonking wrote:
> > mcu_timer0 is now used as the tick timer in u-boot, so this adds the
> > timer to the soc device list so it can be enabled via the k3 power 
> 
> Drop the trailing whitespace.
> 
> > controller.
> > 
> > Signed-off-by: Reid Tonking 
> 
> with that:
> 
> Reviewed-by: Nishanth Menon 
>

will do, thanks for the review!

> -- 
> Regards,
> Nishanth Menon
> Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 
> 849D 1736 249D

Thanks,
Reid Tonking


Re: [PATCH 1/3] drivers: misc: k3_avs: Add Linux compatible to enable avs in u-boot

2023-09-06 Thread reidt
On 13:06-20230906, Nishanth Menon wrote:
> On 13:13-20230905, Reid Tonking wrote:
> > The ti,j7200-vtm compatible is used for voltage and thermal monitoring 
> > (VTM) by (drivers/thermal/k3_j72xx_bandgap.c) in Linux, but the same 
> > hardware is used for adaptive voltage scaling (AVS) in u-boot, This brings
> > both drivers in line with the same compatible. Since the j7200 uses the 
> > config as the j721e, the data is inherited from j721e vs creating a 
> > duplicate in all but name.
> > 
> > Signed-off-by: Reid Tonking 
> > ---
> >  drivers/misc/k3_avs.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/misc/k3_avs.c b/drivers/misc/k3_avs.c
> > index 840148d090..f7936017ba 100644
> > --- a/drivers/misc/k3_avs.c
> > +++ b/drivers/misc/k3_avs.c
> > @@ -382,7 +382,7 @@ static struct vd_config am654_vd_config = {
> >  static const struct udevice_id k3_avs_ids[] = {
> > { .compatible = "ti,am654-avs", .data = (ulong)_vd_config },
> > { .compatible = "ti,j721e-avs", .data = (ulong)_vd_config },
> > -   {}
> > +   { .compatible = "ti,j7200-vtm", .data = (ulong)_vd_config }
> you don't need the null terminator?
>

Ah, I wasn't aware of its purpose until now, but searched it up. 
I'll add it back in for v3.

> >  };
> >  
> >  U_BOOT_DRIVER(k3_avs) = {
> > -- 
> > 2.34.1
> > 
> https://lore.kernel.org/all/1fed9388-dfc4-0b9c-4502-b5020b2ae...@ti.com/
> 
> Will let Udit and you sort this out.

Udit and I talked a bit about this yesterday. It's something to explore
implementing down the road, after this sync - nothing immediate

> -- 
> Regards,
> Nishanth Menon
> Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 
> 849D 1736 249D

Thanks,
Reid Tonking


Re: [PATCH 3/5] armv8: fsl-layerscape: create bypass smmu mapping for MC

2023-09-06 Thread Laurentiu Tudor




On 9/6/2023 8:21 PM, Robin Murphy wrote:

On 2023-09-06 17:01, Laurentiu Tudor wrote:

MC being a plain DMA master as any other device in the SoC and
being live at OS boot time, as soon as the SMMU is probed it
will immediately start triggering faults because there is no
mapping in the SMMU for the MC. Pre-create such a mapping in
the SMMU, being the OS's responsibility to preserve it.


Does U-Boot enable the SMMU? AFAICS the only thing it knows how to do is 
explicitly turn it *off*, therefore programming other registers appears 
to be a complete waste of time.


No, it doesn't enable SMMU but it does mark a SMR as valid for MC FW. 
And the ARM SMMU driver subtly preserves it, see [1] (it's late and I 
might be wrong, but I'll double check tomorrow). :-)


All that should matter to the OS, and that it is responsible for 
upholding, is the reserved memory regions from patch #2. For instance, 
if the OS is Linux, literally the first thing arm_smmu_device_reset() 
does is rewrite all the S2CRs and SMRs without so much as looking.


[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/iommu/arm/arm-smmu/arm-smmu.c#n894


---
Best Regards, Laurentiu




Signed-off-by: Laurentiu Tudor 
---
  arch/arm/cpu/armv8/fsl-layerscape/soc.c   | 26 ---
  .../asm/arch-fsl-layerscape/immap_lsch3.h |  9 +++
  2 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c 
b/arch/arm/cpu/armv8/fsl-layerscape/soc.c

index 3bfdc3f77431..870b99838ab5 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
@@ -376,6 +376,18 @@ void bypass_smmu(void)
  val = (in_le32(SMMU_NSCR0) | SCR0_CLIENTPD_MASK) & 
~(SCR0_USFCFG_MASK);

  out_le32(SMMU_NSCR0, val);
  }
+
+void setup_smmu_mc_bypass(int icid, int mask)
+{
+    u32 val;
+
+    val = SMMU_SMR_VALID_MASK | (icid << SMMU_SMR_ID_SHIFT) |
+    (mask << SMMU_SMR_MASK_SHIFT);
+    out_le32(SMMU_REG_SMR(0), val);
+    val = SMMU_S2CR_EXIDVALID_VALID_MASK | SMMU_S2CR_TYPE_BYPASS_MASK;
+    out_le32(SMMU_REG_S2CR(0), val);
+}
+
  void fsl_lsch3_early_init_f(void)
  {
  erratum_rcw_src();
@@ -402,10 +414,18 @@ void fsl_lsch3_early_init_f(void)
  bypass_smmu();
  #endif
-#if defined(CONFIG_ARCH_LS1088A) || defined(CONFIG_ARCH_LS1028A) || \
-    defined(CONFIG_ARCH_LS2080A) || defined(CONFIG_ARCH_LX2160A) || \
-    defined(CONFIG_ARCH_LX2162A)
+#ifdef CONFIG_ARCH_LS1028A
+    set_icids();
+#endif
+
+#if defined(CONFIG_ARCH_LS1088A) || defined(CONFIG_ARCH_LS2080A)
+    set_icids();
+    setup_smmu_mc_bypass(0x300, 0);
+#endif
+
+#if defined(CONFIG_ARCH_LX2160A) || defined(CONFIG_ARCH_LX2162A)
  set_icids();
+    setup_smmu_mc_bypass(0x4000, 0);
  #endif
  }
diff --git a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h 
b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h

index ca5e33379ba9..bec5355adaed 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h
@@ -190,6 +190,15 @@
  #define SCR0_CLIENTPD_MASK    0x0001
  #define SCR0_USFCFG_MASK    0x0400
+#define SMMU_REG_SMR(n)    (SMMU_BASE + 0x800 + ((n) << 2))
+#define SMMU_REG_S2CR(n)    (SMMU_BASE + 0xc00 + ((n) << 2))
+#define SMMU_SMR_VALID_MASK    0x8000
+#define SMMU_SMR_MASK_MASK    0x
+#define SMMU_SMR_MASK_SHIFT    16
+#define SMMU_SMR_ID_MASK    0x
+#define SMMU_SMR_ID_SHIFT    0
+#define SMMU_S2CR_EXIDVALID_VALID_MASK    0x0400
+#define SMMU_S2CR_TYPE_BYPASS_MASK    0x0001
  /* PCIe */
  #define CFG_SYS_PCIE1_ADDR    (CONFIG_SYS_IMMR + 0x240)


Re: [PATCH 3/3] arm: dts: j7200: dtb sync with Linux 6.5-rc1

2023-09-06 Thread Nishanth Menon
$subject: s/dtb/device tree or dts

On 13:13-20230905, Reid Tonking wrote:
> Sync j7200 device tree files with Linux 6.5-rc1

With that..

Reviewed-by: Nishanth Menon 

-- 
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 
849D 1736 249D


Re: [PATCH 2/3] arm: mach-k3: j7200: Add mcu_timer0 id to the dev list

2023-09-06 Thread Nishanth Menon
On 13:13-20230905, Reid Tonking wrote:
> mcu_timer0 is now used as the tick timer in u-boot, so this adds the
> timer to the soc device list so it can be enabled via the k3 power 

Drop the trailing whitespace.

> controller.
> 
> Signed-off-by: Reid Tonking 

with that:

Reviewed-by: Nishanth Menon 

-- 
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 
849D 1736 249D


Re: [PATCH 1/3] drivers: misc: k3_avs: Add Linux compatible to enable avs in u-boot

2023-09-06 Thread Nishanth Menon
On 13:13-20230905, Reid Tonking wrote:
> The ti,j7200-vtm compatible is used for voltage and thermal monitoring 
> (VTM) by (drivers/thermal/k3_j72xx_bandgap.c) in Linux, but the same 
> hardware is used for adaptive voltage scaling (AVS) in u-boot, This brings
> both drivers in line with the same compatible. Since the j7200 uses the 
> config as the j721e, the data is inherited from j721e vs creating a 
> duplicate in all but name.
> 
> Signed-off-by: Reid Tonking 
> ---
>  drivers/misc/k3_avs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/k3_avs.c b/drivers/misc/k3_avs.c
> index 840148d090..f7936017ba 100644
> --- a/drivers/misc/k3_avs.c
> +++ b/drivers/misc/k3_avs.c
> @@ -382,7 +382,7 @@ static struct vd_config am654_vd_config = {
>  static const struct udevice_id k3_avs_ids[] = {
>   { .compatible = "ti,am654-avs", .data = (ulong)_vd_config },
>   { .compatible = "ti,j721e-avs", .data = (ulong)_vd_config },
> - {}
> + { .compatible = "ti,j7200-vtm", .data = (ulong)_vd_config }
you don't need the null terminator?

>  };
>  
>  U_BOOT_DRIVER(k3_avs) = {
> -- 
> 2.34.1
> 
https://lore.kernel.org/all/1fed9388-dfc4-0b9c-4502-b5020b2ae...@ti.com/

Will let Udit and you sort this out.
-- 
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 
849D 1736 249D


Re: [PATCH 7/7] fs: Fix a confusing error about overlapping regions

2023-09-06 Thread Tom Rini
On Tue, Sep 05, 2023 at 12:16:56PM -0600, Simon Glass wrote:
> Hi Tom,
> 
> On Sun, 3 Sept 2023 at 13:25, Tom Rini  wrote:
> >
> > On Sun, Sep 03, 2023 at 12:06:13PM -0600, Simon Glass wrote:
> > > Hi Tom,
> > >
> > > On Sun, 3 Sept 2023 at 10:42, Tom Rini  wrote:
> > > >
> > > > On Thu, Aug 31, 2023 at 06:15:19PM -0600, Simon Glass wrote:
> > > > > Hi Tom,
> > > > >
> > > > > On Wed, 23 Aug 2023 at 09:14, Tom Rini  wrote:
> > > > > >
> > > > > > On Wed, Aug 23, 2023 at 07:42:03AM -0600, Simon Glass wrote:
> > > > > >
> > > > > > > When lmb runs out of space in its internal tables, it gives
> errors on
> > > > > > > every fs load operation. This is horribly confusing, as the
> poor user
> > > > > > > tries different memory regions one at a time.
> > > > > > >
> > > > > > > Use the updated API to check the error code and print a helpful
> message.
> > > > > > > Also, allow the operation to proceed.
> > > > > > >
> > > > > > > Update the tests accordingly.
> > > > > > >
> > > > > > > Signed-off-by: Simon Glass 
> > > > > > [snip]
> > > > > > > + if (ret == -E2BIG) {
> > > > > > > + log_warning("Reservation tables exhausted: see
> CONFIG_LMB_USE_MAX_REGIONS\n");
> > > > > > > + return 0;
> > > > > > > + }
> > > > > >
> > > > > > This isn't the right option.  Everyone has
> CONFIG_LMB_USE_MAX_REGIONS
> > > > > > set.  You would want to increase CONFIG_LMB_MAX_REGIONS.
> > > > > >
> > > > > > But it sounds like what you've found and fixed is an underlying
> problem
> > > > > > as to why 16 regions isn't enough in some common cases now?  So
> we could
> > > > >
> > > > > I don't think I have fixed anything. But I'll send v2 and perhaps it
> > > > > will be clearer what is going on here.
> > > > >
> > > > > > possibly avoid the string size growth here and have a comment
> that also
> > > > > > matches up with the help under LMB_MAX_REGIONS?
> > > > >
> > > > > I don't know, sorry. The size of struct(lmb) on 64-bit sandbox is
> > > > > about 400 bytes. There seems to be a lot of code to save not much
> > > > > memory.
> > > >
> > > > What do you mean here?  The alternative is not unlimited ranges but
> > > > instead to define the limit of memory regions and limit of reserved
> > > > ranges.
> > >
> > > A better alternative would be not to limit the number of regions, IMO,
> > > i.e. have an array of regions that can grow as needed.
> >
> > That's not something that we have in the code today, however.
> 
> No, I do have an arraylist thing that I plan to upstream, which could
> handle that.
> 
> But for this series, what do you think of the memregion idea? I am still
> unsure of the saming we should use - see Heinrich's comments too.

My biggest worry here is that we're papering over a real issue, and
should either dig at that and see what's going on (should something be
coalescing adjacent allocations? Were many platforms just right at the
previous limit?) or just bump the default from 16 to "64 if EFI_LOADER"
and then see if anything else really needs tweaking / cleaning up in the
code itself.  I know Heinrich has previously said the LMB system could
be better (or something to that effect, I'm going from memory, sorry if
I'm mis-stating things) and I don't object to replacing what we have
with something more robust/smarter/etc.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 1/1] spl: undefined return value in spl_blk_load_image

2023-09-06 Thread Xavier Drudis Ferran
El Wed, Sep 06, 2023 at 02:25:11PM +0200, Heinrich Schuchardt deia:
> spl_blk_load_image() should not return an uninitialized value if
> blk_get_devnum_by_uclass_id() fails.
> 
> Fixes: 8ce6a2e17577 ("spl: blk: Support loading images from fs")
> Reported-by: Xavier Drudis Ferran 

FWIW:

Reviewed-by:  Xavier Drudis Ferran 


> Signed-off-by: Heinrich Schuchardt 
> ---
>  common/spl/spl_blk_fs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/common/spl/spl_blk_fs.c b/common/spl/spl_blk_fs.c
> index eb6f526689..ea5d1a51d9 100644
> --- a/common/spl/spl_blk_fs.c
> +++ b/common/spl/spl_blk_fs.c
> @@ -53,7 +53,7 @@ int spl_blk_load_image(struct spl_image_info *spl_image,
>   blk_desc = blk_get_devnum_by_uclass_id(uclass_id, devnum);
>   if (!blk_desc) {
>   printf("blk desc for %d %d not found\n", uclass_id, devnum);
> - goto out;
> + return -ENODEV;
>   }
>  
>   blk_show_device(uclass_id, devnum);
> -- 
> 2.40.1
> 


Re: [PATCH 1/2] riscv: Rework riscv_cpu_probe for current event macros

2023-09-06 Thread Tom Rini
On Mon, 04 Sep 2023 15:06:34 -0400, Tom Rini wrote:

> This function should now be a EVENT_SPY_SIMPLE call, update it.
> 
> 

Applied to u-boot/next, thanks!

-- 
Tom



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

2023-09-06 Thread Tom Rini
On Tue, Sep 05, 2023 at 03:49:15PM +0200, Marek Vasut wrote:

> The following changes since commit b53ab97150314674edc25508f4fc528be2baa73f:
> 
>   event.h: Documented some newly added portions better (2023-09-04 11:19:50 
> -0400)
> 
> are available in the Git repository at:
> 
>   https://source.denx.de/u-boot/custodians/u-boot-sh.git next
> 
> for you to fetch changes up to 733fab7177ea3c0402bab9db07422d5dce495139:
> 
>   ARM: rmobile: Clean up rmobile_cpuinfo_idx() (2023-09-05 01:13:35 +0200)
> 

With a quick rewording of the commit to fix a typo, applied to
u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PULL] please pull u-boot-coldfire/next

2023-09-06 Thread Tom Rini
On Wed, Sep 06, 2023 at 01:33:27PM +0200, Angelo Dureghello wrote:

> Hi Tom,
> 
> The following changes since commit b53ab97150314674edc25508f4fc528be2baa73f:
> 
>   event.h: Documented some newly added portions better (2023-09-04 11:19:50
> -0400)
> 
> are available in the Git repository at:
> 
>   git://git.denx.de/u-boot-coldfire.git next
> 
> for you to fetch changes up to 26af162ac8f8ab3222d32f00f06a4774a061150a:
> 
>   arch: m68k: Implement relocation (2023-09-06 13:28:58 +0200)
> 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


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

2023-09-06 Thread Tom Rini
On Tue, Sep 05, 2023 at 03:50:11PM +0200, Marek Vasut wrote:

> The following changes since commit f2bb6d9ffd9ba0d0d89c00445a70cf81327a7af2:
> 
>   Merge tag 'doc-next' of https://source.denx.de/u-boot/custodians/u-boot-efi 
> into next (2023-09-02 09:08:34 -0400)
> 
> are available in the Git repository at:
> 
>   git://source.denx.de/u-boot-usb.git next
> 
> for you to fetch changes up to adee3ba577a6d5902b5af6c2368faf5f509003c6:
> 
>   usb: host: ohci-generic: Make usage of clock/reset bulk() API (2023-09-04 
> 18:25:20 +0200)
> 

Applied to u-boot/next, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v3 3/3] timer: riscv_aclint_timer: add timer_get_boot_us for BOOTSTAGE

2023-09-06 Thread Heinrich Schuchardt

On 06.09.23 07:18, Chanho Park wrote:

timer_get_boot_us function is required to record the boot stages as
us-based timestamp.
To get a micro-second time from a timer tick, this converts the
formula like below to avoid zero result of (tick / rate) part.

From: time(us) = (tick / rate) * 1000


Where is the old implementation that you refer to?


To  : time(us) = (tick * 1000) / (rate / 1000)

Signed-off-by: Chanho Park 
---
  drivers/timer/riscv_aclint_timer.c | 23 +++
  1 file changed, 23 insertions(+)

diff --git a/drivers/timer/riscv_aclint_timer.c 
b/drivers/timer/riscv_aclint_timer.c
index e29d527c8d77..73fb87912851 100644
--- a/drivers/timer/riscv_aclint_timer.c
+++ b/drivers/timer/riscv_aclint_timer.c
@@ -6,6 +6,7 @@
  
  #include 

  #include 
+#include 
  #include 
  #include 
  #include 
@@ -44,6 +45,28 @@ u64 notrace timer_early_get_count(void)
  }
  #endif
  
+#if CONFIG_IS_ENABLED(RISCV_MMODE) && CONFIG_IS_ENABLED(BOOTSTAGE)

+ulong timer_get_boot_us(void)
+{
+   int ret;
+   u64 ticks = 0;
+   u32 rate;
+
+   ret = dm_timer_init();
+   if (!ret) {
+   rate = timer_get_rate(gd->timer);
+   timer_get_count(gd->timer, );
+   } else {
+   rate = RISCV_MMODE_TIMER_FREQ;
+   ticks = readq((void __iomem *)MTIME_REG(RISCV_MMODE_TIMERBASE,
+   RISCV_MMODE_TIMEROFF));
+   }
+
+   /* Below is converted from time(us) = (tick / rate) * 1000 */
+   return lldiv(ticks * 1000, (rate / 1000));


I found similar code in drivers/timer/cadence-ttc.c and 
drivers/timer/omap-timer.c with


us = (ticks * 1000) / rate;
return us.

Either their code or yours must be wrong.

What I am missing in include/timer.h is a documentation that defines if 
timer_dev_priv.clock_rate and timer_get_rate() yield the frequency in Hz 
or kHz.


Once we have added the missing information in the include we can start 
reviewing this patch.


I really dislike that we have code per architecture and don't update and 
use a implementation in lib/time.c (where we also have an 
implementation) or drivers/timer/timer-uclass.c. Can't we have a single 
implementation which is driver model based and eliminate all others?


Best regards

Heinrich


+}
+#endif
+
  static const struct timer_ops riscv_aclint_timer_ops = {
.get_count = riscv_aclint_timer_get_count,
  };




Re: [PATCH 3/5] armv8: fsl-layerscape: create bypass smmu mapping for MC

2023-09-06 Thread Robin Murphy

On 2023-09-06 17:01, Laurentiu Tudor wrote:

MC being a plain DMA master as any other device in the SoC and
being live at OS boot time, as soon as the SMMU is probed it
will immediately start triggering faults because there is no
mapping in the SMMU for the MC. Pre-create such a mapping in
the SMMU, being the OS's responsibility to preserve it.


Does U-Boot enable the SMMU? AFAICS the only thing it knows how to do is 
explicitly turn it *off*, therefore programming other registers appears 
to be a complete waste of time.


All that should matter to the OS, and that it is responsible for 
upholding, is the reserved memory regions from patch #2. For instance, 
if the OS is Linux, literally the first thing arm_smmu_device_reset() 
does is rewrite all the S2CRs and SMRs without so much as looking.


Thanks,
Robin.


Signed-off-by: Laurentiu Tudor 
---
  arch/arm/cpu/armv8/fsl-layerscape/soc.c   | 26 ---
  .../asm/arch-fsl-layerscape/immap_lsch3.h |  9 +++
  2 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c 
b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
index 3bfdc3f77431..870b99838ab5 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
@@ -376,6 +376,18 @@ void bypass_smmu(void)
val = (in_le32(SMMU_NSCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK);
out_le32(SMMU_NSCR0, val);
  }
+
+void setup_smmu_mc_bypass(int icid, int mask)
+{
+   u32 val;
+
+   val = SMMU_SMR_VALID_MASK | (icid << SMMU_SMR_ID_SHIFT) |
+   (mask << SMMU_SMR_MASK_SHIFT);
+   out_le32(SMMU_REG_SMR(0), val);
+   val = SMMU_S2CR_EXIDVALID_VALID_MASK | SMMU_S2CR_TYPE_BYPASS_MASK;
+   out_le32(SMMU_REG_S2CR(0), val);
+}
+
  void fsl_lsch3_early_init_f(void)
  {
erratum_rcw_src();
@@ -402,10 +414,18 @@ void fsl_lsch3_early_init_f(void)
bypass_smmu();
  #endif
  
-#if defined(CONFIG_ARCH_LS1088A) || defined(CONFIG_ARCH_LS1028A) || \

-   defined(CONFIG_ARCH_LS2080A) || defined(CONFIG_ARCH_LX2160A) || \
-   defined(CONFIG_ARCH_LX2162A)
+#ifdef CONFIG_ARCH_LS1028A
+   set_icids();
+#endif
+
+#if defined(CONFIG_ARCH_LS1088A) || defined(CONFIG_ARCH_LS2080A)
+   set_icids();
+   setup_smmu_mc_bypass(0x300, 0);
+#endif
+
+#if defined(CONFIG_ARCH_LX2160A) || defined(CONFIG_ARCH_LX2162A)
set_icids();
+   setup_smmu_mc_bypass(0x4000, 0);
  #endif
  }
  
diff --git a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h

index ca5e33379ba9..bec5355adaed 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h
@@ -190,6 +190,15 @@
  #define SCR0_CLIENTPD_MASK0x0001
  #define SCR0_USFCFG_MASK  0x0400
  
+#define SMMU_REG_SMR(n)			(SMMU_BASE + 0x800 + ((n) << 2))

+#define SMMU_REG_S2CR(n)   (SMMU_BASE + 0xc00 + ((n) << 2))
+#define SMMU_SMR_VALID_MASK0x8000
+#define SMMU_SMR_MASK_MASK 0x
+#define SMMU_SMR_MASK_SHIFT16
+#define SMMU_SMR_ID_MASK   0x
+#define SMMU_SMR_ID_SHIFT  0
+#define SMMU_S2CR_EXIDVALID_VALID_MASK 0x0400
+#define SMMU_S2CR_TYPE_BYPASS_MASK 0x0001
  
  /* PCIe */

  #define CFG_SYS_PCIE1_ADDR(CONFIG_SYS_IMMR + 0x240)


Re: [PATCH v5 3/4] schemas: Add some common reserved-memory usages

2023-09-06 Thread Simon Glass
Hi Ard,

On Wed, Sep 6, 2023, 10:09 Ard Biesheuvel  wrote:

> On Wed, 6 Sept 2023 at 16:54, Simon Glass  wrote:
> >
> > Hi Rob, Ard,
> >
> > On Wed, 6 Sept 2023 at 08:34, Rob Herring  wrote:
> > >
> > > On Tue, Sep 5, 2023 at 4:44 PM Ard Biesheuvel  wrote:
> > > >
> > > > On Thu, 31 Aug 2023 at 01:18, Simon Glass  wrote:
> > > > >
> > > > > The Devicetree specification skips over handling of a logical view
> of
> > > > > the memory map, pointing users to the UEFI specification.
> > > > >
> > > > > It is common to split firmware into 'Platform Init', which does the
> > > > > initial hardware setup and a "Payload" which selects the OS to be
> booted.
> > > > > Thus an handover interface is required between these two pieces.
> > > > >
> > > > > Where UEFI boot-time services are not available, but UEFI firmware
> is
> > > > > present on either side of this interface, information about memory
> usage
> > > > > and attributes must be presented to the "Payload" in some form.
> > > > >
> > > >
> > > > I don't think the UEFI references are needed or helpful here.
> > > >
> > > > > This aims to provide an small schema addition for this mapping.
> > > > >
> > > > > For now, no attempt is made to create an exhaustive binding, so
> there are
> > > > > some example types listed. More can be added later.
> > > > >
> > > > > The compatible string is not included, since the node name is
> enough to
> > > > > indicate the purpose of a node, as per the existing reserved-memory
> > > > > schema.
> > >
> > > Node names reflect the 'class', but not what's specifically in the
> > > node. So really, all reserved-memory nodes should have the same name,
> > > but that ship already sailed for existing users. 'compatible' is the
> > > right thing here. As to what the node name should be, well, we haven't
> > > defined that. I think we just used 'memory' on some platforms.
> >
> > OK
> >
> > >
> > > > > This binding does not include a binding for the memory 'attribute'
> > > > > property, defined by EFI_BOOT_SERVICES.GetMemoryMap(). It may be
> useful
> > > > > to have that as well, but perhaps not as a bit mask.
> > > > >
> > > > > Signed-off-by: Simon Glass 
> > > > > ---
> > > > >
> > > > > Changes in v5:
> > > > > - Drop the memory-map node (should have done that in v4)
> > > > > - Tidy up schema a bit
> > > > >
> > > > > Changes in v4:
> > > > > - Make use of the reserved-memory node instead of creating a new
> one
> > > > >
> > > > > Changes in v3:
> > > > > - Reword commit message again
> > > > > - cc a lot more people, from the FFI patch
> > > > > - Split out the attributes into the /memory nodes
> > > > >
> > > > > Changes in v2:
> > > > > - Reword commit message
> > > > >
> > > > >  .../reserved-memory/common-reserved.yaml  | 53
> +++
> > > > >  1 file changed, 53 insertions(+)
> > > > >  create mode 100644
> dtschema/schemas/reserved-memory/common-reserved.yaml
> > > > >
> > > > > diff --git a/dtschema/schemas/reserved-memory/common-reserved.yaml
> b/dtschema/schemas/reserved-memory/common-reserved.yaml
> > > > > new file mode 100644
> > > > > index 000..d1b466b
> > > > > --- /dev/null
> > > > > +++ b/dtschema/schemas/reserved-memory/common-reserved.yaml
> > > > > @@ -0,0 +1,53 @@
> > > > > +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> > > > > +%YAML 1.2
> > > > > +---
> > > > > +$id:
> http://devicetree.org/schemas/reserved-memory/common-reserved.yaml#
> > > > > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > > > > +
> > > > > +title: Common memory reservations
> > > > > +
> > > > > +description: |
> > > > > +  Specifies that the reserved memory region can be used for the
> purpose
> > > > > +  indicated by its node name.
> > > > > +
> > > > > +  Clients may reuse this reserved memory if they understand what
> it is for.
> > > > > +
> > > > > +maintainers:
> > > > > +  - Simon Glass 
> > > > > +
> > > > > +allOf:
> > > > > +  - $ref: reserved-memory.yaml
> > > > > +
> > > > > +properties:
> > > > > +  $nodename:
> > > > > +enum:
> > > > > +  - acpi-reclaim
> > > > > +  - acpi-nvs
> > > > > +  - boot-code
> > > > > +  - boot-data
> > > > > +  - runtime-code
> > > > > +  - runtime-data
> > > > > +
> > > >
> > > > These types are used by firmware to describe the nature of certain
> > > > memory regions to the OS. Boot code and data can be discarded, as
> well
> > > > as ACPI reclaim after its contents have been consumed. Runtime code
> > > > and data need to be mapped for runtime features to work.
> > > >
> > > > When one firmware phase communicates the purpose of a certain memory
> > > > reservation to another, it is typically not limited to whether its
> > > > needs to be preserved and when it needs to be mapped (and with which
> > > > attributes). I'd expect a memory reservation appearing under this
> node
> > > > to have a clearly defined purpose, and the subsequent phases need to
> > > > be able to discover this information.
> > > >
> > > > For 

Re: [PATCH v4 4/4] memory: Add ECC property

2023-09-06 Thread Lean Sheng Tan
Hi Rob,
Sorry for missing this:
regarding your question on whether if the memory can support both
single-bit and multi-bit ECC, i think the answer is yes.
@Dong, Guo  or @Chiu, Chasel
 could you
help to confirm on this?

Thanks.

Best Regards,
*Lean Sheng Tan*



9elements GmbH, Kortumstraße 19-21, 44787 Bochum, Germany
Email: sheng@9elements.com
Phone: *+49 234 68 94 188 <+492346894188>*
Mobile: *+49 176 76 113842 <+4917676113842>*

Registered office: Bochum
Commercial register: Amtsgericht Bochum, HRB 17519
Management: Sebastian German, Eray Bazaar

Data protection information according to Art. 13 GDPR



On Tue, 29 Aug 2023 at 23:38, Rob Herring  wrote:

> On Tue, Aug 29, 2023 at 2:18 PM Simon Glass  wrote:
> >
> > Some memories provides ECC correction. For software which wants to check
> > memory, it is helpful to see which regions provide this feature.
> >
> > Add this as a property of the /memory nodes, since it presumably follows
> > the hardware-level memory system.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > (no changes since v3)
> >
> > Changes in v3:
> > - Add new patch to update the /memory nodes
> >
> >  dtschema/schemas/memory.yaml | 9 -
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> >
> > diff --git a/dtschema/schemas/memory.yaml b/dtschema/schemas/memory.yaml
> > index 1d74410..981af04 100644
> > --- a/dtschema/schemas/memory.yaml
> > +++ b/dtschema/schemas/memory.yaml
> > @@ -34,7 +34,14 @@ patternProperties:
> >  description:
> >For the purpose of identification, each NUMA node is
> associated with
> >a unique token known as a node id.
> > -
> > +  attr:
>
> Kind of vague.
>
> > +$ref: /schemas/types.yaml#/definitions/string-array
> > +description: |
> > +  Attributes possessed by this memory region:
> > +
> > +"single-bit-ecc" - supports single-bit ECC
> > +"multi-bit-ecc" - supports multiple-bit ECC
>
> "supports" means corrects or reports? Most h/w supports both, but only
> reports multi-bit errors.
>
> > +"no-ecc" - non-ECC memory
>
> Don't define values in free form text.
>
> This form is difficult to validate especially when non-ECC related
> attr's are added to the mix as we can't really define which
> combinations are valid. For example how do we prevent:
>
> attr = "single-bit-ecc", "multi-bit-ecc";
>
> Or maybe that's valid? If so, how would we express that?
>
> Why do we need "no-ecc"? Is that the same as no "attr" property?
>
> I think it's better if we have 'ecc-type' or something? Or generally,
> a property per class/type of attribute.
>
> Rob
>


Re: [PATCH v5 3/4] schemas: Add some common reserved-memory usages

2023-09-06 Thread Ard Biesheuvel
On Wed, 6 Sept 2023 at 16:54, Simon Glass  wrote:
>
> Hi Rob, Ard,
>
> On Wed, 6 Sept 2023 at 08:34, Rob Herring  wrote:
> >
> > On Tue, Sep 5, 2023 at 4:44 PM Ard Biesheuvel  wrote:
> > >
> > > On Thu, 31 Aug 2023 at 01:18, Simon Glass  wrote:
> > > >
> > > > The Devicetree specification skips over handling of a logical view of
> > > > the memory map, pointing users to the UEFI specification.
> > > >
> > > > It is common to split firmware into 'Platform Init', which does the
> > > > initial hardware setup and a "Payload" which selects the OS to be 
> > > > booted.
> > > > Thus an handover interface is required between these two pieces.
> > > >
> > > > Where UEFI boot-time services are not available, but UEFI firmware is
> > > > present on either side of this interface, information about memory usage
> > > > and attributes must be presented to the "Payload" in some form.
> > > >
> > >
> > > I don't think the UEFI references are needed or helpful here.
> > >
> > > > This aims to provide an small schema addition for this mapping.
> > > >
> > > > For now, no attempt is made to create an exhaustive binding, so there 
> > > > are
> > > > some example types listed. More can be added later.
> > > >
> > > > The compatible string is not included, since the node name is enough to
> > > > indicate the purpose of a node, as per the existing reserved-memory
> > > > schema.
> >
> > Node names reflect the 'class', but not what's specifically in the
> > node. So really, all reserved-memory nodes should have the same name,
> > but that ship already sailed for existing users. 'compatible' is the
> > right thing here. As to what the node name should be, well, we haven't
> > defined that. I think we just used 'memory' on some platforms.
>
> OK
>
> >
> > > > This binding does not include a binding for the memory 'attribute'
> > > > property, defined by EFI_BOOT_SERVICES.GetMemoryMap(). It may be useful
> > > > to have that as well, but perhaps not as a bit mask.
> > > >
> > > > Signed-off-by: Simon Glass 
> > > > ---
> > > >
> > > > Changes in v5:
> > > > - Drop the memory-map node (should have done that in v4)
> > > > - Tidy up schema a bit
> > > >
> > > > Changes in v4:
> > > > - Make use of the reserved-memory node instead of creating a new one
> > > >
> > > > Changes in v3:
> > > > - Reword commit message again
> > > > - cc a lot more people, from the FFI patch
> > > > - Split out the attributes into the /memory nodes
> > > >
> > > > Changes in v2:
> > > > - Reword commit message
> > > >
> > > >  .../reserved-memory/common-reserved.yaml  | 53 +++
> > > >  1 file changed, 53 insertions(+)
> > > >  create mode 100644 
> > > > dtschema/schemas/reserved-memory/common-reserved.yaml
> > > >
> > > > diff --git a/dtschema/schemas/reserved-memory/common-reserved.yaml 
> > > > b/dtschema/schemas/reserved-memory/common-reserved.yaml
> > > > new file mode 100644
> > > > index 000..d1b466b
> > > > --- /dev/null
> > > > +++ b/dtschema/schemas/reserved-memory/common-reserved.yaml
> > > > @@ -0,0 +1,53 @@
> > > > +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> > > > +%YAML 1.2
> > > > +---
> > > > +$id: 
> > > > http://devicetree.org/schemas/reserved-memory/common-reserved.yaml#
> > > > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > > > +
> > > > +title: Common memory reservations
> > > > +
> > > > +description: |
> > > > +  Specifies that the reserved memory region can be used for the purpose
> > > > +  indicated by its node name.
> > > > +
> > > > +  Clients may reuse this reserved memory if they understand what it is 
> > > > for.
> > > > +
> > > > +maintainers:
> > > > +  - Simon Glass 
> > > > +
> > > > +allOf:
> > > > +  - $ref: reserved-memory.yaml
> > > > +
> > > > +properties:
> > > > +  $nodename:
> > > > +enum:
> > > > +  - acpi-reclaim
> > > > +  - acpi-nvs
> > > > +  - boot-code
> > > > +  - boot-data
> > > > +  - runtime-code
> > > > +  - runtime-data
> > > > +
> > >
> > > These types are used by firmware to describe the nature of certain
> > > memory regions to the OS. Boot code and data can be discarded, as well
> > > as ACPI reclaim after its contents have been consumed. Runtime code
> > > and data need to be mapped for runtime features to work.
> > >
> > > When one firmware phase communicates the purpose of a certain memory
> > > reservation to another, it is typically not limited to whether its
> > > needs to be preserved and when it needs to be mapped (and with which
> > > attributes). I'd expect a memory reservation appearing under this node
> > > to have a clearly defined purpose, and the subsequent phases need to
> > > be able to discover this information.
> > >
> > > For example, a communication buffer for secure<->non-secure
> > > communication or a page with spin tables used by PSCI. None of the
> > > proposed labels are appropriate for this, and I'd much rather have a
> > > compatible string or some other property that clarifies the 

[PATCH 5/5] board: freescale: ls1088a: declare MC reserved regions

2023-09-06 Thread Laurentiu Tudor
Populate the device tree with the MC reserved memory regions.

Signed-off-by: Laurentiu Tudor 
---
 board/freescale/ls1088a/ls1088a.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/board/freescale/ls1088a/ls1088a.c 
b/board/freescale/ls1088a/ls1088a.c
index 65593f10a3f5..7674e31a268a 100644
--- a/board/freescale/ls1088a/ls1088a.c
+++ b/board/freescale/ls1088a/ls1088a.c
@@ -983,6 +983,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 
 #ifdef CONFIG_FSL_MC_ENET
fdt_fixup_board_enet(blob);
+   fdt_reserve_mc_mem(blob, 0x300);
 #endif
 
fdt_fixup_icid(blob);
-- 
2.17.1



[PATCH 4/5] board: freescale: ls2080a: declare MC reserved regions

2023-09-06 Thread Laurentiu Tudor
Populate the device tree with the MC reserved memory regions.

Signed-off-by: Laurentiu Tudor 
---
 board/freescale/ls2080aqds/ls2080aqds.c | 1 +
 board/freescale/ls2080ardb/ls2080ardb.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/board/freescale/ls2080aqds/ls2080aqds.c 
b/board/freescale/ls2080aqds/ls2080aqds.c
index ba25e9b0b8fc..5c94c83121b5 100644
--- a/board/freescale/ls2080aqds/ls2080aqds.c
+++ b/board/freescale/ls2080aqds/ls2080aqds.c
@@ -325,6 +325,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 
 #if defined(CONFIG_FSL_MC_ENET) && !defined(CONFIG_SPL_BUILD)
fdt_fixup_board_enet(blob);
+   fdt_reserve_mc_mem(blob, 0x300);
 #endif
 
fdt_fixup_icid(blob);
diff --git a/board/freescale/ls2080ardb/ls2080ardb.c 
b/board/freescale/ls2080ardb/ls2080ardb.c
index 8d340f17a256..5c30de83d841 100644
--- a/board/freescale/ls2080ardb/ls2080ardb.c
+++ b/board/freescale/ls2080ardb/ls2080ardb.c
@@ -522,6 +522,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 
 #ifdef CONFIG_FSL_MC_ENET
fdt_fixup_board_enet(blob);
+   fdt_reserve_mc_mem(blob, 0x300);
 #endif
 
fdt_fixup_icid(blob);
-- 
2.17.1



[PATCH 3/5] armv8: fsl-layerscape: create bypass smmu mapping for MC

2023-09-06 Thread Laurentiu Tudor
MC being a plain DMA master as any other device in the SoC and
being live at OS boot time, as soon as the SMMU is probed it
will immediately start triggering faults because there is no
mapping in the SMMU for the MC. Pre-create such a mapping in
the SMMU, being the OS's responsibility to preserve it.

Signed-off-by: Laurentiu Tudor 
---
 arch/arm/cpu/armv8/fsl-layerscape/soc.c   | 26 ---
 .../asm/arch-fsl-layerscape/immap_lsch3.h |  9 +++
 2 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c 
b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
index 3bfdc3f77431..870b99838ab5 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
@@ -376,6 +376,18 @@ void bypass_smmu(void)
val = (in_le32(SMMU_NSCR0) | SCR0_CLIENTPD_MASK) & ~(SCR0_USFCFG_MASK);
out_le32(SMMU_NSCR0, val);
 }
+
+void setup_smmu_mc_bypass(int icid, int mask)
+{
+   u32 val;
+
+   val = SMMU_SMR_VALID_MASK | (icid << SMMU_SMR_ID_SHIFT) |
+   (mask << SMMU_SMR_MASK_SHIFT);
+   out_le32(SMMU_REG_SMR(0), val);
+   val = SMMU_S2CR_EXIDVALID_VALID_MASK | SMMU_S2CR_TYPE_BYPASS_MASK;
+   out_le32(SMMU_REG_S2CR(0), val);
+}
+
 void fsl_lsch3_early_init_f(void)
 {
erratum_rcw_src();
@@ -402,10 +414,18 @@ void fsl_lsch3_early_init_f(void)
bypass_smmu();
 #endif
 
-#if defined(CONFIG_ARCH_LS1088A) || defined(CONFIG_ARCH_LS1028A) || \
-   defined(CONFIG_ARCH_LS2080A) || defined(CONFIG_ARCH_LX2160A) || \
-   defined(CONFIG_ARCH_LX2162A)
+#ifdef CONFIG_ARCH_LS1028A
+   set_icids();
+#endif
+
+#if defined(CONFIG_ARCH_LS1088A) || defined(CONFIG_ARCH_LS2080A)
+   set_icids();
+   setup_smmu_mc_bypass(0x300, 0);
+#endif
+
+#if defined(CONFIG_ARCH_LX2160A) || defined(CONFIG_ARCH_LX2162A)
set_icids();
+   setup_smmu_mc_bypass(0x4000, 0);
 #endif
 }
 
diff --git a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h 
b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h
index ca5e33379ba9..bec5355adaed 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h
@@ -190,6 +190,15 @@
 #define SCR0_CLIENTPD_MASK 0x0001
 #define SCR0_USFCFG_MASK   0x0400
 
+#define SMMU_REG_SMR(n)(SMMU_BASE + 0x800 + ((n) << 2))
+#define SMMU_REG_S2CR(n)   (SMMU_BASE + 0xc00 + ((n) << 2))
+#define SMMU_SMR_VALID_MASK0x8000
+#define SMMU_SMR_MASK_MASK 0x
+#define SMMU_SMR_MASK_SHIFT16
+#define SMMU_SMR_ID_MASK   0x
+#define SMMU_SMR_ID_SHIFT  0
+#define SMMU_S2CR_EXIDVALID_VALID_MASK 0x0400
+#define SMMU_S2CR_TYPE_BYPASS_MASK 0x0001
 
 /* PCIe */
 #define CFG_SYS_PCIE1_ADDR (CONFIG_SYS_IMMR + 0x240)
-- 
2.17.1



[PATCH 2/5] drivers: net: fsl-mc: add support for MC reserved memory

2023-09-06 Thread Laurentiu Tudor
Add support for declaring in device tree the reserved memory ranges
required for MC. Since the MC firmware acts as any DMA master present
in the SoC, the reserved memory ranges need also be identity mapped
in the SMMU, so create the required 'iommu-addresses' property in
the reserved memory nodes.
For now this support is used only on LX2160A SoCs.

Signed-off-by: Laurentiu Tudor 
---
 board/freescale/lx2160a/lx2160a.c |   1 +
 drivers/net/fsl-mc/mc.c   | 110 ++
 include/fsl-mc/fsl_mc.h   |   1 +
 3 files changed, 112 insertions(+)

diff --git a/board/freescale/lx2160a/lx2160a.c 
b/board/freescale/lx2160a/lx2160a.c
index d631a11ff667..688d81f04f64 100644
--- a/board/freescale/lx2160a/lx2160a.c
+++ b/board/freescale/lx2160a/lx2160a.c
@@ -834,6 +834,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 #ifdef CONFIG_FSL_MC_ENET
fdt_fsl_mc_fixup_iommu_map_entry(blob);
fdt_fixup_board_enet(blob);
+   fdt_reserve_mc_mem(blob, 0x4000);
 #endif
fdt_fixup_icid(blob);
 
diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
index 984616fb65c0..f5c5057bec10 100644
--- a/drivers/net/fsl-mc/mc.c
+++ b/drivers/net/fsl-mc/mc.c
@@ -30,6 +30,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #define MC_RAM_BASE_ADDR_ALIGNMENT  (512UL * 1024 * 1024)
 #define MC_RAM_BASE_ADDR_ALIGNMENT_MASK(~(MC_RAM_BASE_ADDR_ALIGNMENT - 
1))
@@ -929,6 +931,114 @@ unsigned long mc_get_dram_block_size(void)
return dram_block_size;
 }
 
+/**
+ * Populate the device tree with MC reserved memory ranges.
+ */
+void fdt_reserve_mc_mem(void *blob, u32 mc_icid)
+{
+   u32 phandle, mc_ph;
+   int noff, ret, i;
+   char mem_name[16];
+   struct fdt_memory mc_mem_ranges[] = {
+   {
+   .start = 0,
+   .end = 0
+   },
+   {
+   .start = CFG_SYS_FSL_MC_BASE,
+   .end = CFG_SYS_FSL_MC_BASE + CFG_SYS_FSL_MC_SIZE - 1
+   },
+   {
+   .start = CFG_SYS_FSL_NI_BASE,
+   .end = CFG_SYS_FSL_NI_BASE + CFG_SYS_FSL_NI_SIZE - 1
+   },
+   {
+   .start = CFG_SYS_FSL_QBMAN_BASE,
+   .end = CFG_SYS_FSL_QBMAN_BASE +
+   CFG_SYS_FSL_QBMAN_SIZE - 1
+   },
+   {
+   .start = CFG_SYS_FSL_PEBUF_BASE,
+   .end = CFG_SYS_FSL_PEBUF_BASE +
+   CFG_SYS_FSL_PEBUF_SIZE - 1
+   },
+   {
+   .start = CFG_SYS_FSL_CCSR_BASE,
+   .end = CFG_SYS_FSL_CCSR_BASE + CFG_SYS_FSL_CCSR_SIZE - 1
+   }
+   };
+
+   mc_mem_ranges[0].start = gd->arch.resv_ram;
+   mc_mem_ranges[0].end = mc_mem_ranges[0].start +
+   mc_get_dram_block_size() - 1;
+
+   for (i = 0; i < ARRAY_SIZE(mc_mem_ranges); i++) {
+   noff = fdt_node_offset_by_compatible(blob, -1, "fsl,qoriq-mc");
+   if (noff < 0) {
+   printf("WARN: failed to get MC node: %d\n", noff);
+   return;
+   }
+   mc_ph = fdt_get_phandle(blob, noff);
+   if (!mc_ph) {
+   mc_ph = fdt_create_phandle(blob, noff);
+   if (!mc_ph) {
+   printf("WARN: failed to get MC node phandle\n");
+   return;
+   }
+   }
+
+   sprintf(mem_name, "mc-mem%d", i);
+   ret = fdtdec_add_reserved_memory(blob, mem_name,
+_mem_ranges[i], NULL, 0,
+, 0);
+   if (ret < 0) {
+   printf("ERROR: failed to reserve MC memory: %d\n", ret);
+   return;
+   }
+
+   noff = fdt_node_offset_by_phandle(blob, phandle);
+   if (noff < 0) {
+   printf("ERROR: failed get resvmem node offset: %d\n",
+  noff);
+   return;
+   }
+   ret = fdt_setprop_u32(blob, noff, "iommu-addresses", mc_ph);
+   if (ret < 0) {
+   printf("ERROR: failed to set 'iommu-addresses': %d\n",
+  ret);
+   return;
+   }
+   ret = fdt_appendprop_u64(blob, noff, "iommu-addresses",
+mc_mem_ranges[i].start);
+   if (ret < 0) {
+   printf("ERROR: failed to set 'iommu-addresses': %d\n",
+  ret);
+   return;
+   }
+   ret = fdt_appendprop_u64(blob, 

[PATCH 1/5] armv8: fsl-layerscape: make some functions static

2023-09-06 Thread Laurentiu Tudor
Some functions are not used outside this file, so make them static.

Signed-off-by: Laurentiu Tudor 
---
 arch/arm/cpu/armv8/fsl-layerscape/icid.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/icid.c 
b/arch/arm/cpu/armv8/fsl-layerscape/icid.c
index ad20d71717b3..c22e73253c3c 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/icid.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/icid.c
@@ -23,8 +23,8 @@ static void set_icid(struct icid_id_table *tbl, int size)
out_be32((u32 *)(tbl[i].reg_addr), tbl[i].reg);
 }
 
-#ifdef CONFIG_SYS_DPAA_FMAN
-void set_fman_icids(struct fman_icid_id_table *tbl, int size)
+#if defined(CONFIG_SYS_DPAA_FMAN) && !defined(CONFIG_SPL_BUILD)
+static void set_fman_icids(struct fman_icid_id_table *tbl, int size)
 {
int i;
ccsr_fman_t *fm = (void *)CFG_SYS_FSL_FM1_ADDR;
@@ -71,7 +71,7 @@ int fdt_set_iommu_prop(void *blob, int off, int smmu_ph, u32 
*ids, int num_ids)
return 0;
 }
 
-int fdt_fixup_icid_tbl(void *blob, int smmu_ph,
+static int fdt_fixup_icid_tbl(void *blob, int smmu_ph,
   struct icid_id_table *tbl, int size)
 {
int i, err, off;
@@ -98,7 +98,7 @@ int fdt_fixup_icid_tbl(void *blob, int smmu_ph,
 }
 
 #ifdef CONFIG_SYS_DPAA_FMAN
-int get_fman_port_icid(int port_id, struct fman_icid_id_table *tbl,
+static int get_fman_port_icid(int port_id, struct fman_icid_id_table *tbl,
   const int size)
 {
int i;
@@ -111,7 +111,7 @@ int get_fman_port_icid(int port_id, struct 
fman_icid_id_table *tbl,
return -1;
 }
 
-void fdt_fixup_fman_port_icid_by_compat(void *blob, int smmu_ph,
+static void fdt_fixup_fman_port_icid_by_compat(void *blob, int smmu_ph,
const char *compat)
 {
int noff, len, icid;
@@ -140,7 +140,7 @@ void fdt_fixup_fman_port_icid_by_compat(void *blob, int 
smmu_ph,
}
 }
 
-void fdt_fixup_fman_icids(void *blob, int smmu_ph)
+static void fdt_fixup_fman_icids(void *blob, int smmu_ph)
 {
static const char * const compats[] = {
"fsl,fman-v3-port-oh",
-- 
2.17.1



Re: [RFC PATCH 0/5] Allow for removal of DT nodes and properties

2023-09-06 Thread Simon Glass
Hi Rob,

On Wed, 6 Sept 2023 at 08:21, Rob Herring  wrote:
>
> On Mon, Aug 28, 2023 at 04:09:29PM -0600, Simon Glass wrote:
> > Hi Peter,
> >
> > On Mon, 28 Aug 2023 at 14:29, Peter Robinson  wrote:
> > >
> > > On Mon, Aug 28, 2023 at 6:54 PM Simon Glass  wrote:
> > > >
> > > > Hi Peter,
> > > >
> > > > On Mon, 28 Aug 2023 at 10:37, Peter Robinson  
> > > > wrote:
> > > > >
> > > > > On Mon, Aug 28, 2023 at 5:20 PM Simon Glass  wrote:
> > > > > >
> > > > > > Hi,
> > > > > >
> > > > > > On Sat, 26 Aug 2023 at 03:07, Sughosh Ganu 
> > > > > >  wrote:
> > > > > > >
> > > > > > >
> > > > > > > Provide a way for removing certain devicetree nodes and/or 
> > > > > > > properties
> > > > > > > from the devicetree. This is needed to purge certain nodes and
> > > > > > > properties which may be relevant only in U-Boot. Such nodes and
> > > > > > > properties are then removed from the devicetree before it is 
> > > > > > > passed to
> > > > > > > the kernel. This ensures that the devicetree passed to the OS 
> > > > > > > does not
> > > > > > > contain any non-compliant nodes and properties.
> > > > > > >
> > > > > > > The removal of the nodes and properties is being done through an
> > > > > > > EVT_FT_FIXUP handler. I am not sure if the removal code needs to 
> > > > > > > be
> > > > > > > behind any Kconfig symbol.
> > > > > > >
> > > > > > > I have only build tested this on sandbox, and tested on qemu arm64
> > > > > > > virt platform. This being a RFC, I have not put this through a CI 
> > > > > > > run.
> > > > > > >
> > > > > > > Sughosh Ganu (5):
> > > > > > >   dt: Provide a way to remove non-compliant nodes and properties
> > > > > > >   fwu: Add the fwu-mdata node for removal from devicetree
> > > > > > >   capsule: Add the capsule-key property for removal from 
> > > > > > > devicetree
> > > > > > >   bootefi: Call the EVT_FT_FIXUP event handler
> > > > > > >   doc: Add a document for non-compliant DT node/property removal
> > > > > > >
> > > > > > >  cmd/bootefi.c | 18 +
> > > > > > >  .../devicetree/dt_non_compliant_purge.rst | 64 
> > > > > > > 
> > > > > > >  drivers/fwu-mdata/fwu-mdata-uclass.c  |  5 ++
> > > > > > >  include/dt-structs.h  | 11 +++
> > > > > > >  lib/Makefile  |  1 +
> > > > > > >  lib/dt_purge.c| 73 
> > > > > > > +++
> > > > > > >  lib/efi_loader/efi_capsule.c  |  7 ++
> > > > > > >  7 files changed, 179 insertions(+)
> > > > > > >  create mode 100644 
> > > > > > > doc/develop/devicetree/dt_non_compliant_purge.rst
> > > > > > >  create mode 100644 lib/dt_purge.c
> > > > > >
> > > > > > What is the point of removing them? Instead, we should make sure 
> > > > > > that
> > > > > > we upstream the bindings and encourage SoC vendors to sync them. If 
> > > > > > we
> > > > > > remove them, no one will bother and U-Boot just becomes a dumping
> > > > > > ground.
> > > > >
> > > > > Well things like the binman entries in DT are U-Boot specific and not
> > > > > useful for HW related descriptions or for Linux or another OS being
> > > > > able to deal with HW so arguably we're already a dumping ground to
> > > > > some degree for not defining hardware.
> > > >
> > > > I have started the process to upstream the binman bindings.
> > >
> > > I don't think they should be in DT at all, they don't describe
> > > anything to do with hardware, or generally even the runtime of a
> > > device, they don't even describe the boot/runtime state of the
> > > firmware, they describe build time, so I don't see what that has to do
> > > with device tree? Can you explain that? To me those sorts of things
> > > should live in a build time style config file.
>
> For the record, I tend to agree.
>
> > I beg to differ. Devicetree is more than just hardware and always has
> > been. See, for example the /chosen and /options nodes.
>
> There are exceptions...

I wish we could stop having this discussion entirely...to me the
devicetree is all that firmware has to handle its configuration, both
within projects and across project boundaries. There is no user space,
no filesystem, etc.

>
> > We need run-time configuration here, since we cannot know at build
> > time what we will be asked to do by a previous firmware phase.
>
> Really, I don't want to have to care about the binman binding. If it is
> u-boot specific, then it should stay in u-boot.

I don't believe it is U-Boot-specific since it describes the system
firmware as a whole. It collects things from multiple projects and we
want to know where they ended up, so we can do firmware update, etc.

> I took /options/u-boot/,
> but now I'm starting to have second thoughts on that being in dtschema
> if it is going to be continually and frequently extended. Validating it
> in SR does little. If a vendor is abusing /options/u-boot/ in some way
> they could just as easily remove the 

Re: [RFC 4/6] gpio: add scmi driver based on pinctrl

2023-09-06 Thread Michal Simek




On 9/6/23 04:40, AKASHI Takahiro wrote:

This DM-compliant driver deals with SCMI pinctrl protocol and presents
gpio devices exposed by SCMI firmware (server).

Signed-off-by: AKASHI Takahiro 
---
  drivers/pinctrl/pinctrl-scmi.c | 544 -
  1 file changed, 539 insertions(+), 5 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c
index 3ebdad57b86c..73d385bdbfcc 100644
--- a/drivers/pinctrl/pinctrl-scmi.c
+++ b/drivers/pinctrl/pinctrl-scmi.c
@@ -11,21 +11,20 @@
  #include 
  #include 
  #include 
+#include 
  #include 
+#include 
+#include 
  #include 
  
  /**

   * struct scmi_pin - attributes for a pin
   * @name: Name of pin
- * @value: Value of pin
- * @flags: A set of flags
   * @function: Function selected
   * @status:   An array of status of configuration types
   */
  struct scmi_pin {
char*name;
-   u32 value;
-   u32 flags;



You have added this in 3/6 then there is no reason to remove it in this version.

M


Re: [PATCH v5 3/4] schemas: Add some common reserved-memory usages

2023-09-06 Thread Simon Glass
Hi Rob, Ard,

On Wed, 6 Sept 2023 at 08:34, Rob Herring  wrote:
>
> On Tue, Sep 5, 2023 at 4:44 PM Ard Biesheuvel  wrote:
> >
> > On Thu, 31 Aug 2023 at 01:18, Simon Glass  wrote:
> > >
> > > The Devicetree specification skips over handling of a logical view of
> > > the memory map, pointing users to the UEFI specification.
> > >
> > > It is common to split firmware into 'Platform Init', which does the
> > > initial hardware setup and a "Payload" which selects the OS to be booted.
> > > Thus an handover interface is required between these two pieces.
> > >
> > > Where UEFI boot-time services are not available, but UEFI firmware is
> > > present on either side of this interface, information about memory usage
> > > and attributes must be presented to the "Payload" in some form.
> > >
> >
> > I don't think the UEFI references are needed or helpful here.
> >
> > > This aims to provide an small schema addition for this mapping.
> > >
> > > For now, no attempt is made to create an exhaustive binding, so there are
> > > some example types listed. More can be added later.
> > >
> > > The compatible string is not included, since the node name is enough to
> > > indicate the purpose of a node, as per the existing reserved-memory
> > > schema.
>
> Node names reflect the 'class', but not what's specifically in the
> node. So really, all reserved-memory nodes should have the same name,
> but that ship already sailed for existing users. 'compatible' is the
> right thing here. As to what the node name should be, well, we haven't
> defined that. I think we just used 'memory' on some platforms.

OK

>
> > > This binding does not include a binding for the memory 'attribute'
> > > property, defined by EFI_BOOT_SERVICES.GetMemoryMap(). It may be useful
> > > to have that as well, but perhaps not as a bit mask.
> > >
> > > Signed-off-by: Simon Glass 
> > > ---
> > >
> > > Changes in v5:
> > > - Drop the memory-map node (should have done that in v4)
> > > - Tidy up schema a bit
> > >
> > > Changes in v4:
> > > - Make use of the reserved-memory node instead of creating a new one
> > >
> > > Changes in v3:
> > > - Reword commit message again
> > > - cc a lot more people, from the FFI patch
> > > - Split out the attributes into the /memory nodes
> > >
> > > Changes in v2:
> > > - Reword commit message
> > >
> > >  .../reserved-memory/common-reserved.yaml  | 53 +++
> > >  1 file changed, 53 insertions(+)
> > >  create mode 100644 dtschema/schemas/reserved-memory/common-reserved.yaml
> > >
> > > diff --git a/dtschema/schemas/reserved-memory/common-reserved.yaml 
> > > b/dtschema/schemas/reserved-memory/common-reserved.yaml
> > > new file mode 100644
> > > index 000..d1b466b
> > > --- /dev/null
> > > +++ b/dtschema/schemas/reserved-memory/common-reserved.yaml
> > > @@ -0,0 +1,53 @@
> > > +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> > > +%YAML 1.2
> > > +---
> > > +$id: http://devicetree.org/schemas/reserved-memory/common-reserved.yaml#
> > > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > > +
> > > +title: Common memory reservations
> > > +
> > > +description: |
> > > +  Specifies that the reserved memory region can be used for the purpose
> > > +  indicated by its node name.
> > > +
> > > +  Clients may reuse this reserved memory if they understand what it is 
> > > for.
> > > +
> > > +maintainers:
> > > +  - Simon Glass 
> > > +
> > > +allOf:
> > > +  - $ref: reserved-memory.yaml
> > > +
> > > +properties:
> > > +  $nodename:
> > > +enum:
> > > +  - acpi-reclaim
> > > +  - acpi-nvs
> > > +  - boot-code
> > > +  - boot-data
> > > +  - runtime-code
> > > +  - runtime-data
> > > +
> >
> > These types are used by firmware to describe the nature of certain
> > memory regions to the OS. Boot code and data can be discarded, as well
> > as ACPI reclaim after its contents have been consumed. Runtime code
> > and data need to be mapped for runtime features to work.
> >
> > When one firmware phase communicates the purpose of a certain memory
> > reservation to another, it is typically not limited to whether its
> > needs to be preserved and when it needs to be mapped (and with which
> > attributes). I'd expect a memory reservation appearing under this node
> > to have a clearly defined purpose, and the subsequent phases need to
> > be able to discover this information.
> >
> > For example, a communication buffer for secure<->non-secure
> > communication or a page with spin tables used by PSCI. None of the
> > proposed labels are appropriate for this, and I'd much rather have a
> > compatible string or some other property that clarifies the nature in
> > a more suitable way. Note that 'no-map' already exists to indicate
> > that the CPU should not map this memory unless it does so for the
> > specific purpose that the reservation was made for.
>
> I agree. I think compatible is the better approach. Some property like
> 'discard' may not be sufficient information if 

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

2023-09-06 Thread Tom Rini
On Tue, Sep 05, 2023 at 03:50:54PM +0200, Marek Vasut wrote:

> The following changes since commit 8999257f219d1e371c2fd66f255b8782897944d9:
> 
>   Merge tag 'doc-2023-10-rc4-2' of 
> https://source.denx.de/u-boot/custodians/u-boot-efi (2023-09-02 09:08:54 
> -0400)
> 
> are available in the Git repository at:
> 
>   git://source.denx.de/u-boot-usb.git master
> 
> for you to fetch changes up to 7f4b73fe6939761dd3891b96628efcab47a0570e:
> 
>   usb: dwc3: Fix enabling USB_DR_MODE_HOST (2023-09-04 15:51:38 +0200)
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH v4 4/4] memory: Add ECC property

2023-09-06 Thread Simon Glass
Hi Sheng,

On Wed, 6 Sept 2023 at 08:47, Lean Sheng Tan  wrote:
>
> Hi Rob,
> Sorry for missing this:
> regarding your question on whether if the memory can support both single-bit 
> and multi-bit ECC, i think the answer is yes.
> @Dong, Guo or @Chiu, Chasel could you help to confirm on this?

I sent a v5 series which breaks these out into separate properties.

Regards,
Simon

>
> Thanks.
>
> Best Regards,
> Lean Sheng Tan
>
>
>
> 9elements GmbH, Kortumstraße 19-21, 44787 Bochum, Germany
> Email: sheng@9elements.com
> Phone: +49 234 68 94 188
> Mobile: +49 176 76 113842
>
> Registered office: Bochum
> Commercial register: Amtsgericht Bochum, HRB 17519
> Management: Sebastian German, Eray Bazaar
>
> Data protection information according to Art. 13 GDPR
>
>
> On Tue, 29 Aug 2023 at 23:38, Rob Herring  wrote:
>>
>> On Tue, Aug 29, 2023 at 2:18 PM Simon Glass  wrote:
>> >
>> > Some memories provides ECC correction. For software which wants to check
>> > memory, it is helpful to see which regions provide this feature.
>> >
>> > Add this as a property of the /memory nodes, since it presumably follows
>> > the hardware-level memory system.
>> >
>> > Signed-off-by: Simon Glass 
>> > ---
>> >
>> > (no changes since v3)
>> >
>> > Changes in v3:
>> > - Add new patch to update the /memory nodes
>> >
>> >  dtschema/schemas/memory.yaml | 9 -
>> >  1 file changed, 8 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/dtschema/schemas/memory.yaml b/dtschema/schemas/memory.yaml
>> > index 1d74410..981af04 100644
>> > --- a/dtschema/schemas/memory.yaml
>> > +++ b/dtschema/schemas/memory.yaml
>> > @@ -34,7 +34,14 @@ patternProperties:
>> >  description:
>> >For the purpose of identification, each NUMA node is associated 
>> > with
>> >a unique token known as a node id.
>> > -
>> > +  attr:
>>
>> Kind of vague.
>>
>> > +$ref: /schemas/types.yaml#/definitions/string-array
>> > +description: |
>> > +  Attributes possessed by this memory region:
>> > +
>> > +"single-bit-ecc" - supports single-bit ECC
>> > +"multi-bit-ecc" - supports multiple-bit ECC
>>
>> "supports" means corrects or reports? Most h/w supports both, but only
>> reports multi-bit errors.
>>
>> > +"no-ecc" - non-ECC memory
>>
>> Don't define values in free form text.
>>
>> This form is difficult to validate especially when non-ECC related
>> attr's are added to the mix as we can't really define which
>> combinations are valid. For example how do we prevent:
>>
>> attr = "single-bit-ecc", "multi-bit-ecc";
>>
>> Or maybe that's valid? If so, how would we express that?
>>
>> Why do we need "no-ecc"? Is that the same as no "attr" property?
>>
>> I think it's better if we have 'ecc-type' or something? Or generally,
>> a property per class/type of attribute.
>>
>> Rob


Re: [PATCH v5 3/4] schemas: Add some common reserved-memory usages

2023-09-06 Thread Rob Herring
On Tue, Sep 5, 2023 at 4:44 PM Ard Biesheuvel  wrote:
>
> On Thu, 31 Aug 2023 at 01:18, Simon Glass  wrote:
> >
> > The Devicetree specification skips over handling of a logical view of
> > the memory map, pointing users to the UEFI specification.
> >
> > It is common to split firmware into 'Platform Init', which does the
> > initial hardware setup and a "Payload" which selects the OS to be booted.
> > Thus an handover interface is required between these two pieces.
> >
> > Where UEFI boot-time services are not available, but UEFI firmware is
> > present on either side of this interface, information about memory usage
> > and attributes must be presented to the "Payload" in some form.
> >
>
> I don't think the UEFI references are needed or helpful here.
>
> > This aims to provide an small schema addition for this mapping.
> >
> > For now, no attempt is made to create an exhaustive binding, so there are
> > some example types listed. More can be added later.
> >
> > The compatible string is not included, since the node name is enough to
> > indicate the purpose of a node, as per the existing reserved-memory
> > schema.

Node names reflect the 'class', but not what's specifically in the
node. So really, all reserved-memory nodes should have the same name,
but that ship already sailed for existing users. 'compatible' is the
right thing here. As to what the node name should be, well, we haven't
defined that. I think we just used 'memory' on some platforms.

> > This binding does not include a binding for the memory 'attribute'
> > property, defined by EFI_BOOT_SERVICES.GetMemoryMap(). It may be useful
> > to have that as well, but perhaps not as a bit mask.
> >
> > Signed-off-by: Simon Glass 
> > ---
> >
> > Changes in v5:
> > - Drop the memory-map node (should have done that in v4)
> > - Tidy up schema a bit
> >
> > Changes in v4:
> > - Make use of the reserved-memory node instead of creating a new one
> >
> > Changes in v3:
> > - Reword commit message again
> > - cc a lot more people, from the FFI patch
> > - Split out the attributes into the /memory nodes
> >
> > Changes in v2:
> > - Reword commit message
> >
> >  .../reserved-memory/common-reserved.yaml  | 53 +++
> >  1 file changed, 53 insertions(+)
> >  create mode 100644 dtschema/schemas/reserved-memory/common-reserved.yaml
> >
> > diff --git a/dtschema/schemas/reserved-memory/common-reserved.yaml 
> > b/dtschema/schemas/reserved-memory/common-reserved.yaml
> > new file mode 100644
> > index 000..d1b466b
> > --- /dev/null
> > +++ b/dtschema/schemas/reserved-memory/common-reserved.yaml
> > @@ -0,0 +1,53 @@
> > +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/reserved-memory/common-reserved.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Common memory reservations
> > +
> > +description: |
> > +  Specifies that the reserved memory region can be used for the purpose
> > +  indicated by its node name.
> > +
> > +  Clients may reuse this reserved memory if they understand what it is for.
> > +
> > +maintainers:
> > +  - Simon Glass 
> > +
> > +allOf:
> > +  - $ref: reserved-memory.yaml
> > +
> > +properties:
> > +  $nodename:
> > +enum:
> > +  - acpi-reclaim
> > +  - acpi-nvs
> > +  - boot-code
> > +  - boot-data
> > +  - runtime-code
> > +  - runtime-data
> > +
>
> These types are used by firmware to describe the nature of certain
> memory regions to the OS. Boot code and data can be discarded, as well
> as ACPI reclaim after its contents have been consumed. Runtime code
> and data need to be mapped for runtime features to work.
>
> When one firmware phase communicates the purpose of a certain memory
> reservation to another, it is typically not limited to whether its
> needs to be preserved and when it needs to be mapped (and with which
> attributes). I'd expect a memory reservation appearing under this node
> to have a clearly defined purpose, and the subsequent phases need to
> be able to discover this information.
>
> For example, a communication buffer for secure<->non-secure
> communication or a page with spin tables used by PSCI. None of the
> proposed labels are appropriate for this, and I'd much rather have a
> compatible string or some other property that clarifies the nature in
> a more suitable way. Note that 'no-map' already exists to indicate
> that the CPU should not map this memory unless it does so for the
> specific purpose that the reservation was made for.

I agree. I think compatible is the better approach. Some property like
'discard' may not be sufficient information if the OS needs to consume
the region first and then discard it. Better to state exactly what's
there and then the OS can imply the rest.

Rob


Re: [RFC PATCH 0/5] Allow for removal of DT nodes and properties

2023-09-06 Thread Rob Herring
On Mon, Aug 28, 2023 at 04:09:29PM -0600, Simon Glass wrote:
> Hi Peter,
> 
> On Mon, 28 Aug 2023 at 14:29, Peter Robinson  wrote:
> >
> > On Mon, Aug 28, 2023 at 6:54 PM Simon Glass  wrote:
> > >
> > > Hi Peter,
> > >
> > > On Mon, 28 Aug 2023 at 10:37, Peter Robinson  wrote:
> > > >
> > > > On Mon, Aug 28, 2023 at 5:20 PM Simon Glass  wrote:
> > > > >
> > > > > Hi,
> > > > >
> > > > > On Sat, 26 Aug 2023 at 03:07, Sughosh Ganu  
> > > > > wrote:
> > > > > >
> > > > > >
> > > > > > Provide a way for removing certain devicetree nodes and/or 
> > > > > > properties
> > > > > > from the devicetree. This is needed to purge certain nodes and
> > > > > > properties which may be relevant only in U-Boot. Such nodes and
> > > > > > properties are then removed from the devicetree before it is passed 
> > > > > > to
> > > > > > the kernel. This ensures that the devicetree passed to the OS does 
> > > > > > not
> > > > > > contain any non-compliant nodes and properties.
> > > > > >
> > > > > > The removal of the nodes and properties is being done through an
> > > > > > EVT_FT_FIXUP handler. I am not sure if the removal code needs to be
> > > > > > behind any Kconfig symbol.
> > > > > >
> > > > > > I have only build tested this on sandbox, and tested on qemu arm64
> > > > > > virt platform. This being a RFC, I have not put this through a CI 
> > > > > > run.
> > > > > >
> > > > > > Sughosh Ganu (5):
> > > > > >   dt: Provide a way to remove non-compliant nodes and properties
> > > > > >   fwu: Add the fwu-mdata node for removal from devicetree
> > > > > >   capsule: Add the capsule-key property for removal from devicetree
> > > > > >   bootefi: Call the EVT_FT_FIXUP event handler
> > > > > >   doc: Add a document for non-compliant DT node/property removal
> > > > > >
> > > > > >  cmd/bootefi.c | 18 +
> > > > > >  .../devicetree/dt_non_compliant_purge.rst | 64 
> > > > > >  drivers/fwu-mdata/fwu-mdata-uclass.c  |  5 ++
> > > > > >  include/dt-structs.h  | 11 +++
> > > > > >  lib/Makefile  |  1 +
> > > > > >  lib/dt_purge.c| 73 
> > > > > > +++
> > > > > >  lib/efi_loader/efi_capsule.c  |  7 ++
> > > > > >  7 files changed, 179 insertions(+)
> > > > > >  create mode 100644 
> > > > > > doc/develop/devicetree/dt_non_compliant_purge.rst
> > > > > >  create mode 100644 lib/dt_purge.c
> > > > >
> > > > > What is the point of removing them? Instead, we should make sure that
> > > > > we upstream the bindings and encourage SoC vendors to sync them. If we
> > > > > remove them, no one will bother and U-Boot just becomes a dumping
> > > > > ground.
> > > >
> > > > Well things like the binman entries in DT are U-Boot specific and not
> > > > useful for HW related descriptions or for Linux or another OS being
> > > > able to deal with HW so arguably we're already a dumping ground to
> > > > some degree for not defining hardware.
> > >
> > > I have started the process to upstream the binman bindings.
> >
> > I don't think they should be in DT at all, they don't describe
> > anything to do with hardware, or generally even the runtime of a
> > device, they don't even describe the boot/runtime state of the
> > firmware, they describe build time, so I don't see what that has to do
> > with device tree? Can you explain that? To me those sorts of things
> > should live in a build time style config file.

For the record, I tend to agree.

> I beg to differ. Devicetree is more than just hardware and always has
> been. See, for example the /chosen and /options nodes.

There are exceptions...

> We need run-time configuration here, since we cannot know at build
> time what we will be asked to do by a previous firmware phase.

Really, I don't want to have to care about the binman binding. If it is 
u-boot specific, then it should stay in u-boot. I took /options/u-boot/, 
but now I'm starting to have second thoughts on that being in dtschema 
if it is going to be continually and frequently extended. Validating it 
in SR does little. If a vendor is abusing /options/u-boot/ in some way 
they could just as easily remove the node in their u-boot fork to pass. 
SR is certainly not going to require the node be there.

On A/B updates, that really doesn't seem like a u-boot specific problem 
to me. No one wants A/B updates in EDK2 or anything else?

Rob


Re: [RFC PATCH 2/2] binman: j721e: Add firewall configurations for atf

2023-09-06 Thread Andrew Davis

On 9/6/23 12:18 AM, Manorit Chawdhry wrote:

Hi Andrew,

On 10:22-20230905, Andrew Davis wrote:

On 9/5/23 3:21 AM, Manorit Chawdhry wrote:

The following commits adds the configuration of firewalls required to
protect ATF and OP-TEE memory region from non-secure reads and
writes using master and slave firewalls present in our K3 SOCs.

Signed-off-by: Manorit Chawdhry 
---
   arch/arm/dts/k3-j721e-binman.dtsi | 161 
++
   1 file changed, 161 insertions(+)

diff --git a/arch/arm/dts/k3-j721e-binman.dtsi 
b/arch/arm/dts/k3-j721e-binman.dtsi
index 4f566c21a9af..0569a592597e 100644
--- a/arch/arm/dts/k3-j721e-binman.dtsi
+++ b/arch/arm/dts/k3-j721e-binman.dtsi
@@ -330,6 +330,73 @@
ti-secure {
content = <>;
keyfile = "custMpk.pem";
+   auth_in_place = <0xa02>;
+
+   // cpu_0_cpu_0_msmc Background 
Firewall - 0


I don't have a personal preference, but I see most comments in DTS
are C style /* */.

Also it might be easier to understand if you put the comments right before
the properties that they relate to, i.g.

firewall-0 {
/* cpu_0_cpu_0_msmc */
id = <257>;
region = <0>;
/* Background, Locked */
control = <0x31a>;
permissions = <0xc3>;
start_address = <0x0 0x0>;
end_address = <0xff 0x>;
};

For permissions, I wonder if it would be easier to read if we add
some helper macros:

#define FWPRIVID_ALL 0xc3

#define FWPERM_SECURE_PRIV_WRITE  BIT(0)
#define FWPERM_SECURE_PRIV_READ   BIT(1)
#define FWPERM_SECURE_PRIV_CACHEABLE  BIT(2)
#define FWPERM_SECURE_PRIV_DEBUG  BIT(3)
#define FWPERM_SECURE_USER_WRITE  BIT(4)
...

Then you would have:

permissions = 

I think we'll have to do some shift here for the right calculations.

   #define FWPRIVID_SHIFT 8

   permissions = <(FWPRIVID_ALL << FWPRIVID_SHIFT)


Right, I must have meant #define FWPRIVID_ALL 0xc3 above, but
a shift looks better.


FWPERM_SECURE_PRIV_WRITE |
FWPERM_SECURE_PRIV_READ |


Also, I would like to make FWPERM_SECURE_PRIV_RWCD too as it'll be
commonly used.

Would be sending another RFC with this change if you are fine with the
suggestions. Thank you for reviewing!



Works for me, should get rid of several of these magic numbers.

Andrew


Regards,
Manorit


...




;



+   firewall-0 {
+   id = <257>;
+   region = <0>;
+   control = <0x31a>;
+   permissions = 
<0xc3>;
+   start_address = <0x0 
0x0>;
+   end_address = <0xff 
0x>;
+   };
+
+   // cpu_0_cpu_0_msmc Foreground 
Firewall
+   firewall-1 {
+   id = <257>;
+   region = <1>;
+   control = <0x1a>;
+   permissions = 
<0x0100ff>;
+   start_address = <0x0 
0x7000>;


This address might change if one moves ATF, might work to use 
CONFIG_K3_ATF_LOAD_ADDR?
Not sure how you would get the end address as we don't really know ATF size..

Andrew


[PATCH 1/1] spl: undefined return value in spl_blk_load_image

2023-09-06 Thread Heinrich Schuchardt
spl_blk_load_image() should not return an uninitialized value if
blk_get_devnum_by_uclass_id() fails.

Fixes: 8ce6a2e17577 ("spl: blk: Support loading images from fs")
Reported-by: Xavier Drudis Ferran 
Signed-off-by: Heinrich Schuchardt 
---
 common/spl/spl_blk_fs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/spl/spl_blk_fs.c b/common/spl/spl_blk_fs.c
index eb6f526689..ea5d1a51d9 100644
--- a/common/spl/spl_blk_fs.c
+++ b/common/spl/spl_blk_fs.c
@@ -53,7 +53,7 @@ int spl_blk_load_image(struct spl_image_info *spl_image,
blk_desc = blk_get_devnum_by_uclass_id(uclass_id, devnum);
if (!blk_desc) {
printf("blk desc for %d %d not found\n", uclass_id, devnum);
-   goto out;
+   return -ENODEV;
}
 
blk_show_device(uclass_id, devnum);
-- 
2.40.1



Re: [PATCH 00/14] bloblist: Align to firmware handoff

2023-09-06 Thread Michal Simek
Hi Simon,

út 25. 7. 2023 v 23:36 odesílatel Simon Glass  napsal:
>
> In moving from v0.8 to v0.9 the Firmware Handoff specification made some
> changes, including:
>
>- Use a packed format for headers to reduce space
>- Add an explicit alignment field in the header
>- Renumber all the tags and reduce their size to 24 bits
>- Drop use of the blob header to specify alignment, in favour of a
>  'void' blob type
>
> This series attempts to align to that specification, including updating
> the API and tests. It is likely that refinements will be made as other
> projects implement the spec too.
>
> As before the code is dual-licensed, to permit use in projects with a
> permissive license.
>
>
> Simon Glass (14):
>   bloblist: Update the tag numbering
>   bloblist: Adjust API to align in powers of 2
>   bloblist: Change the magic value
>   bloblist: Set version to 1
>   bloblist: Access record hdr_size and tag via a function
>   bloblist: Drop the flags value
>   bloblist: Drop the spare values
>   bloblist: Change the checksum algorithm
>   bloblist: Checksum the entire bloblist
>   bloblist: Handle alignment with a void entry
>   bloblist: Reduce blob-header size
>   bloblist: Reduce bloblist header size
>   bloblist: Add alignment to bloblist_new()
>   bloblist: Update documentation and header comment
>
>  arch/x86/lib/tables.c|   3 +-
>  common/bloblist.c| 102 -
>  doc/develop/bloblist.rst |   4 +-
>  include/bloblist.h   | 121 +++
>  test/bloblist.c  |  53 +
>  5 files changed, 152 insertions(+), 131 deletions(-)
>
> --
> 2.41.0.487.g6d72f3e995-goog
>

Would it be also possible to align names in the bloblist_hdr structure?
magic->signature
align_log2->alignment
alloced->size
size->max_size

The same is for bloblist_rec.

I don't know the history but spec is about transfer list and transfer entry.
Do you plan to rename it to avoid confusion?

Thanks,
Michal

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


Re: [PATCH v5 09/11] spl: Convert semihosting to spl_load

2023-09-06 Thread Heinrich Schuchardt

On 03.08.23 10:36, Xavier Drudis Ferran wrote:

El Mon, Jul 31, 2023 at 06:43:01PM -0400, Sean Anderson deia:

This converts the semihosting load method to use spl_load. As a result, it
also adds support for LOAD_FIT_FULL and IMX images.

Signed-off-by: Sean Anderson 
---

Changes in v5:
- Rework to load header in spl_load

Changes in v2:
- New

  common/spl/spl_semihosting.c | 43 
  1 file changed, 14 insertions(+), 29 deletions(-)

diff --git a/common/spl/spl_semihosting.c b/common/spl/spl_semihosting.c
index 5b5e842a11..e7cb9f4ce6 100644
--- a/common/spl/spl_semihosting.c
+++ b/common/spl/spl_semihosting.c
@@ -9,16 +9,16 @@
  #include 
  #include 

-static int smh_read_full(long fd, void *memp, size_t len)
+static ulong spl_smh_fit_read(struct spl_load_info *load, ulong sector,
+ ulong count, void *buf)
  {
-   long read;
+   int ret, fd = *(int *)load->priv;



should ret be long to hold smh_read() return value ?


-   read = smh_read(fd, memp, len);
-   if (read < 0)
-   return read;
-   if (read != len)
-   return -EIO;
-   return 0;
+   if (smh_seek(fd, sector))
+   return 0;
+



I never used smh, but why would this not be :

+   ret = smh_seek(fd, sector);
+   if (ret)
+   return ret;

(why does smh_seek(), smh_write(), smh_open(), smh_close() return
long, by the way? the implementations return either 0 or smh_errno(),
so int would do ?)


The return type used should match the implementation on the host side.
The ARM documentation explicitly refers to register R0 which will match
the length of long (or unsigned long).

For smh_seek, smh_read(), smh_write()  we should investigate if the type
should not better be unsigned long to handle a number of bytes exceeding
2^31 on a 32bit emulation or system. But that is beyond the scope of
this patch series.

Best regards

Heinrich



[PATCH v2 2/2] riscv: dts: starfive: generate u-boot-spl.bin.normal.out

2023-09-06 Thread Heinrich Schuchardt
The StarFive VisionFive 2 board cannot load spl/u-boot-spl.bin but needs a
prefixed header. We have referring to a vendor tool (spl_tool) for this
task. 'mkimage -T sfspl' can generate the prefixed file.

Use binman to invoke mkimage for the generation of file
spl/u-boot-spl.bin.normal.out.

Update the documentation.

Signed-off-by: Heinrich Schuchardt 
Tested-by: Chanho Park 
---
v2:
Fix a typo in a comment in tools/sfspl.c
Add Tested-by credit
---
 .../dts/jh7110-starfive-visionfive-2-u-boot.dtsi   | 10 ++
 doc/board/starfive/visionfive2.rst | 14 ++
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/arch/riscv/dts/jh7110-starfive-visionfive-2-u-boot.dtsi 
b/arch/riscv/dts/jh7110-starfive-visionfive-2-u-boot.dtsi
index 13f69da31e..defe2b605f 100644
--- a/arch/riscv/dts/jh7110-starfive-visionfive-2-u-boot.dtsi
+++ b/arch/riscv/dts/jh7110-starfive-visionfive-2-u-boot.dtsi
@@ -103,4 +103,14 @@
};
};
};
+   u-boot-spl {
+   filename = "spl/u-boot-spl.bin.normal.out";
+
+   mkimage {
+   args = "-T sfspl";
+   blob {
+   filename = "spl/u-boot-spl.bin";
+   };
+   };
+   };
 };
diff --git a/doc/board/starfive/visionfive2.rst 
b/doc/board/starfive/visionfive2.rst
index 941899a0a4..f5575ab68b 100644
--- a/doc/board/starfive/visionfive2.rst
+++ b/doc/board/starfive/visionfive2.rst
@@ -65,18 +65,8 @@ Now build the U-Boot SPL and U-Boot proper
make starfive_visionfive2_defconfig
make 
OPENSBI=$(opensbi_dir)/opensbi/build/platform/generic/firmware/fw_dynamic.bin
 
-This will generate spl/u-boot-spl.bin and FIT image (u-boot.itb)
-
-u-boot-spl.bin cannot be used directly on StarFive VisionFive2,we need
-to convert the u-boot-spl.bin to u-boot-spl.bin.normal.out with
-the below command:
-
-   ./spl_tool -c -f $(Uboot_PATH)/spl/u-boot-spl.bin
-
-More detailed description of spl_tool,please refer spl_tool documenation.
-(Note: spl_tool git repo is at 
https://github.com/starfive-tech/Tools/tree/master/spl_tool)
-
-This will generate u-boot-spl.bin.normal.out file.
+This will generate the U-Boot SPL image (spl/u-boot-spl.bin.normal.out) as well
+as the FIT image (u-boot.itb) with OpenSBI and U-Boot.
 
 Flashing
 
-- 
2.40.1



[PATCH v2 1/2] tools: mkimage: Add StarFive SPL image support

2023-09-06 Thread Heinrich Schuchardt
The StarFive JH7110 base boards require a header to be prefixed to the SPL
binary image. This has previously done with a vendor tool 'spl_tool'
published under a GPL-2-or-later license. Integrate this capability into
mkimage.

Signed-off-by: Heinrich Schuchardt 
Tested-by: Chanho Park 
---
v2:
no change except for Tested-by credit
---
 boot/image.c|   1 +
 include/image.h |   1 +
 tools/Makefile  |   1 +
 tools/sfspl.c   | 174 
 4 files changed, 177 insertions(+)
 create mode 100644 tools/sfspl.c

diff --git a/boot/image.c b/boot/image.c
index 5c4f9b807d..3a99d2e897 100644
--- a/boot/image.c
+++ b/boot/image.c
@@ -182,6 +182,7 @@ static const table_entry_t uimage_type[] = {
{   IH_TYPE_SUNXI_TOC0, "sunxi_toc0",  "Allwinner TOC0 Boot Image" 
},
{   IH_TYPE_FDT_LEGACY, "fdt_legacy", "legacy Image with Flat 
Device Tree ", },
{   IH_TYPE_RENESAS_SPKG, "spkgimage", "Renesas SPKG Image" },
+   {   IH_TYPE_STARFIVE_SPL, "sfspl", "StarFive SPL Image" },
{   -1, "",   "",   },
 };
 
diff --git a/include/image.h b/include/image.h
index 01a6787d21..5f85bf84a2 100644
--- a/include/image.h
+++ b/include/image.h
@@ -231,6 +231,7 @@ enum image_type_t {
IH_TYPE_SUNXI_TOC0, /* Allwinner TOC0 Boot Image */
IH_TYPE_FDT_LEGACY, /* Binary Flat Device Tree Blob in a 
Legacy Image */
IH_TYPE_RENESAS_SPKG,   /* Renesas SPKG image */
+   IH_TYPE_STARFIVE_SPL,   /* StarFive SPL image */
 
IH_TYPE_COUNT,  /* Number of image types */
 };
diff --git a/tools/Makefile b/tools/Makefile
index 3d0c4b0dd6..1aa1e36137 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -123,6 +123,7 @@ dumpimage-mkimage-objs := aisimage.o \
pblimage.o \
pbl_crc32.o \
renesas_spkgimage.o \
+   sfspl.o \
vybridimage.o \
stm32image.o \
$(ROCKCHIP_OBS) \
diff --git a/tools/sfspl.c b/tools/sfspl.c
new file mode 100644
index 00..ec18a0a77e
--- /dev/null
+++ b/tools/sfspl.c
@@ -0,0 +1,174 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright Heinrich Schuchardt 
+ *
+ * The StarFive JH7110 requires to prepend a header to u-boot-spl.bin 
describing
+ * the payload length and CRC32.
+ *
+ * This module implements support in mkimage and dumpimage for this file 
format.
+ *
+ * StarFive's spl_tool available under GPL-2.0-and-later at
+ * https://github.com/starfive-tech/Tools implements writing the same file
+ * format and served as a reference.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include "imagetool.h"
+
+#define DEFAULT_VERSION 0x01010101
+#define DEFAULT_BACKUP 0x20U
+#define DEFAULT_OFFSET 0x240
+
+/**
+ * struct spl_hdr - header for SPL on JH7110
+ *
+ * All fields are low-endian.
+ */
+struct spl_hdr {
+   /** @offset:offset to SPL header (0x240) */
+   unsigned int offset;
+   /** @bkp_offs:  address of backup SPL, defaults to DEFAULT_BACKUP */
+   unsigned int bkp_offs;
+   /** @zero1: set to zero */
+   unsigned int zero1[159];
+   /** @version:   header version, defaults to DEFAULT_VERSION */
+   unsigned int version;
+   /** @file_size: file size */
+   unsigned int file_size;
+   /** @hdr_size:  size of the file header (0x400) */
+   unsigned int hdr_size;
+   /** @crc32: CRC32 */
+   unsigned int crc32;
+   /** @zero2: set to zero */
+   unsigned int zero2[91];
+};
+
+static int sfspl_check_params(struct image_tool_params *params)
+{
+   /* Only the RISC-V architecture is supported */
+   if (params->Aflag && params->arch != IH_ARCH_RISCV)
+   return EXIT_FAILURE;
+
+   return EXIT_SUCCESS;
+}
+
+static int sfspl_verify_header(unsigned char *buf, int size,
+  struct image_tool_params *params)
+{
+   struct spl_hdr *hdr = (void *)buf;
+   unsigned int hdr_size = le32_to_cpu(hdr->hdr_size);
+   unsigned int file_size = le32_to_cpu(hdr->file_size);
+   unsigned int crc = le32_to_cpu(hdr->crc32);
+   unsigned int crc_check;
+
+   if (size < 0 ||
+   (size_t)size < sizeof(struct spl_hdr) ||
+   (size_t)size < hdr_size + file_size) {
+   printf("Truncated file\n");
+   return EXIT_FAILURE;
+   }
+   if (hdr->version != DEFAULT_VERSION) {
+   printf("Unknown file format version\n");
+   return EXIT_FAILURE;
+   }
+   crc_check = crc32(0, [hdr_size], size - hdr_size);
+   if (crc_check != crc) {
+   printf("Incorrect CRC32\n");
+   return EXIT_FAILURE;
+   }
+
+   return EXIT_SUCCESS;
+}
+
+static void sfspl_print_header(const void *buf,
+ 

[PATCH v2 0/2] riscv: starfive: generate u-boot-spl.bin.normal.out

2023-09-06 Thread Heinrich Schuchardt
The StarFive JH7110 base boards require a header to be prefixed to the SPL
binary image. This has previously done with a vendor tool 'spl_tool'
published under a GPL-2-or-later license. Integrate this capability into
mkimage.

Add a binman task into the VisionFive 2 build to build the prefixed
U-Boot SPL file u-boot-spl.bin.normal.out.

v2:
Fix a typo in a comment in tools/sfspl.c
Add Tested-by credits

Heinrich Schuchardt (2):
  tools: mkimage: Add StarFive SPL image support
  riscv: dts: starfive: generate u-boot-spl.bin.normal.out

 .../jh7110-starfive-visionfive-2-u-boot.dtsi  |  10 +
 boot/image.c  |   1 +
 doc/board/starfive/visionfive2.rst|  14 +-
 include/image.h   |   1 +
 tools/Makefile|   1 +
 tools/sfspl.c | 174 ++
 6 files changed, 189 insertions(+), 12 deletions(-)
 create mode 100644 tools/sfspl.c

-- 
2.40.1



[PULL] please pull u-boot-coldfire/next

2023-09-06 Thread Angelo Dureghello

Hi Tom,

The following changes since commit b53ab97150314674edc25508f4fc528be2baa73f:

  event.h: Documented some newly added portions better (2023-09-04 
11:19:50 -0400)


are available in the Git repository at:

  git://git.denx.de/u-boot-coldfire.git next

for you to fetch changes up to 26af162ac8f8ab3222d32f00f06a4774a061150a:

  arch: m68k: Implement relocation (2023-09-06 13:28:58 +0200)


Marek Vasut (3):
  tools: relocate-rela: Fix BE symtab handling
  tools: relocate-rela: Add M68K support
  arch: m68k: Implement relocation

 arch/Kconfig   |   1 -
 arch/m68k/Kconfig  |   4 +--
 arch/m68k/config.mk|   6 ++--
 arch/m68k/cpu/mcf523x/start.S  |  57 +
 arch/m68k/cpu/mcf52x2/start.S  |  57 +
 arch/m68k/cpu/mcf530x/start.S  |  59 +-
 arch/m68k/cpu/mcf532x/start.S  |  57 +
 arch/m68k/cpu/mcf5445x/start.S |  57 +
 arch/m68k/cpu/u-boot.lds   |  14 
 tools/relocate-rela.c  | 134 
+

 10 files changed, 303 insertions(+), 143 deletions(-)


Re: [PATCH 1/2] tools: mkimage: Add StarFive SPL image support

2023-09-06 Thread Heinrich Schuchardt

On 06.09.23 12:47, Chanho Park wrote:

Hi,


-Original Message-
From: Heinrich Schuchardt 
Sent: Wednesday, September 6, 2023 7:08 PM
To: Rick Chen ; Leo ; Yanhong
Wang 
Cc: Simon Glass ; Marc Kleine-Budde

;

Chanho Park ; u-boot@lists.denx.de; Heinrich
Schuchardt 
Subject: [PATCH 1/2] tools: mkimage: Add StarFive SPL image support

The StarFive JH7110 base boards require a header to be prefixed to the SPL
binary image. This has previously done with a vendor tool 'spl_tool'
published under a GPL-2-or-later license. Integrate this capability into
mkimage.

Signed-off-by: Heinrich Schuchardt 
---
  boot/image.c|   1 +
  include/image.h |   1 +
  tools/Makefile  |   1 +
  tools/sfspl.c   | 174 
  4 files changed, 177 insertions(+)
  create mode 100644 tools/sfspl.c

diff --git a/boot/image.c b/boot/image.c
index 5c4f9b807d..3a99d2e897 100644
--- a/boot/image.c
+++ b/boot/image.c
@@ -182,6 +182,7 @@ static const table_entry_t uimage_type[] = {
{   IH_TYPE_SUNXI_TOC0, "sunxi_toc0",  "Allwinner TOC0 Boot
Image" },
{   IH_TYPE_FDT_LEGACY, "fdt_legacy", "legacy Image with Flat
Device Tree ", },
{   IH_TYPE_RENESAS_SPKG, "spkgimage", "Renesas SPKG Image" },
+   {   IH_TYPE_STARFIVE_SPL, "sfspl", "StarFive SPL Image" },
{   -1, "", "", },
  };

diff --git a/include/image.h b/include/image.h
index 01a6787d21..5f85bf84a2 100644
--- a/include/image.h
+++ b/include/image.h
@@ -231,6 +231,7 @@ enum image_type_t {
IH_TYPE_SUNXI_TOC0, /* Allwinner TOC0 Boot Image */
IH_TYPE_FDT_LEGACY, /* Binary Flat Device Tree Blob in a
Legacy Image */
IH_TYPE_RENESAS_SPKG,   /* Renesas SPKG image */
+   IH_TYPE_STARFIVE_SPL,   /* StarFive SPL image */

IH_TYPE_COUNT,  /* Number of image types */
  };
diff --git a/tools/Makefile b/tools/Makefile
index 3d0c4b0dd6..1aa1e36137 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -123,6 +123,7 @@ dumpimage-mkimage-objs := aisimage.o \
pblimage.o \
pbl_crc32.o \
renesas_spkgimage.o \
+   sfspl.o \
vybridimage.o \
stm32image.o \
$(ROCKCHIP_OBS) \
diff --git a/tools/sfspl.c b/tools/sfspl.c
new file mode 100644
index 00..428542d885
--- /dev/null
+++ b/tools/sfspl.c
@@ -0,0 +1,174 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright Heinrich Schuchardt 
+ *
+ * The StarFive JH710 requires to prepend a header to u-boot-spl.bin
describing


Nit: JH7110 or JH7100? If you'd like to indicate both, JH71x0?


Thank you for testing. This should be JH7110.

The JH7100 on the BeagleV Starlight Beta uses a different format. Only a 
4 byte length field is prepended to the SPL binary. See

https://github.com/starfive-tech/freelight-u-sdk/blob/JH7100_VisionFive/fsz.sh

Best regards

Heinrich



Tested-by: Chanho Park 

Best Regards,
Chanho Park




  1   2   >