Re: [PATCH v4 0/3] cyclic/watchdog patches

2024-05-21 Thread Stefan Roese

On 5/21/24 14:45, Rasmus Villemoes wrote:

On 21/05/2024 13.54, Stefan Roese wrote:

On 5/21/24 11:47, Rasmus Villemoes wrote:

On 21/05/2024 10.46, Rasmus Villemoes wrote:

A bit of a mixed bag. I've been wanting to submit something like 3/3
for a while. So when I stumbled on Marek's patch
https://lore.kernel.org/u-boot/20240316201416.211480-1-marek.vasut+rene...@mailbox.org/
, I got reminded of that plan, and I think that patch could be more
readable if we adopt this model.

While actually doing those mostly mechanical changes, I stumbled on
two separate issues that probably want fixing regardless of the fate
of 3/3.

Mostly just compile-tested, and now also checked that at least the
sandbox test runs succesfully, and that it builds both with and
without CONFIG_CYCLIC.


So I managed to trigger an azure test by pushing to github and creating
a dummy PR: https://github.com/u-boot/u-boot/pull/542

That fails, and while it involves the cyclic framework, I'm pretty sure
these patches are not to blame, since the same error also exists in
other pipelines. It's an "expect" failure, because some watchdog
callback apparently sometimes takes more than 1ms, so the default 1000us
threshold is exceeded, and that prints a warning which breaks the
"expect".

An example is

https://dev.azure.com/u-boot/u-boot/_build/results?buildId=8459=logs=a1270dec-081b-5c65-5cd5-5e915a842596=69f6cf72-86f3-551a-807d-f28f62a1426f=1055
.

I don't know why it only/mostly seems to happen in clang builds, but I
think the fact that these happen quite frequently warrants either
bumping the threshold used in the CI builds quite a lot, or adding a
config option to suppress that warning/limit altogether for CI builds.


I've also seen CI build issues from time to time and restarting the
build magically solved these issues. I'm all for making this CI
build more stable, perhaps Tom has some ideas?


Well, the problem seems to be inherent in the warning from the cyclic
framework; maybe more so when the build server is overloaded (as
sometimes those callbacks are reported to have taken 5+ ms). So when
running sandbox, or under qemu, I think that warning should be disabled.


Agreed.


Regarding this cyclic patch:

Still some problems, MIPS64 related at least, octeon_nic23 target:

https://dev.azure.com/sr0718/0cded7c3-6e6a-4b57-8d0f-65c99496c42f/_apis/build/builds/357/logs/415


Oh my, this is starting to be really embarrassing. The fix is trivial
(as the callback doesn't even use any context):

-static void octeon_board_restore_pf(void *ctx)
+static void octeon_board_restore_pf(struct cyclic_info *c)

Should I resend yet again?


No need. I'll apply this and squash it here. If CI build works, I'll
send the pull request. Otherwise this needs to wait for the next
merge window I'm afraid.

Thanks,
Stefan


Re: [PATCH v4 0/3] cyclic/watchdog patches

2024-05-21 Thread Stefan Roese

On 5/21/24 11:47, Rasmus Villemoes wrote:

On 21/05/2024 10.46, Rasmus Villemoes wrote:

A bit of a mixed bag. I've been wanting to submit something like 3/3
for a while. So when I stumbled on Marek's patch
https://lore.kernel.org/u-boot/20240316201416.211480-1-marek.vasut+rene...@mailbox.org/
, I got reminded of that plan, and I think that patch could be more
readable if we adopt this model.

While actually doing those mostly mechanical changes, I stumbled on
two separate issues that probably want fixing regardless of the fate
of 3/3.

Mostly just compile-tested, and now also checked that at least the
sandbox test runs succesfully, and that it builds both with and
without CONFIG_CYCLIC.


So I managed to trigger an azure test by pushing to github and creating
a dummy PR: https://github.com/u-boot/u-boot/pull/542

That fails, and while it involves the cyclic framework, I'm pretty sure
these patches are not to blame, since the same error also exists in
other pipelines. It's an "expect" failure, because some watchdog
callback apparently sometimes takes more than 1ms, so the default 1000us
threshold is exceeded, and that prints a warning which breaks the "expect".

An example is

https://dev.azure.com/u-boot/u-boot/_build/results?buildId=8459=logs=a1270dec-081b-5c65-5cd5-5e915a842596=69f6cf72-86f3-551a-807d-f28f62a1426f=1055
.

I don't know why it only/mostly seems to happen in clang builds, but I
think the fact that these happen quite frequently warrants either
bumping the threshold used in the CI builds quite a lot, or adding a
config option to suppress that warning/limit altogether for CI builds.


I've also seen CI build issues from time to time and restarting the
build magically solved these issues. I'm all for making this CI
build more stable, perhaps Tom has some ideas?

Regarding this cyclic patch:

Still some problems, MIPS64 related at least, octeon_nic23 target:

https://dev.azure.com/sr0718/0cded7c3-6e6a-4b57-8d0f-65c99496c42f/_apis/build/builds/357/logs/415

Thanks,
Stefan


Re: [PATCH v2 3/3] cyclic: make clients embed a struct cyclic_info in their own data structure

2024-05-21 Thread Stefan Roese

On 5/21/24 10:38, Rasmus Villemoes wrote:

On 21/05/2024 08.57, Stefan Roese wrote:

On 5/19/24 21:44, Rasmus Villemoes wrote:

On 18/05/2024 09.34, Stefan Roese wrote:


This introduces some problems when compiling e.g. sandbox:

In file included from test/common/cyclic.c:10:
test/common/cyclic.c: In function ‘dm_test_cyclic_running’:
test/common/cyclic.c:25:42: warning: passing argument 1 of
‘cyclic_register’ from incompatible pointer type
[-Wincompatible-pointer-types]
     25 | ut_assertnonnull(cyclic_register(cyclic_test, 10 *
1000,
"cyclic_demo",
    |  ^~~
    |  |
    |  void (*)(void *)
include/test/ut.h:298:29: note: in definition of macro
‘ut_assertnonnull’

[...]


Could you please also change the test file accordingly? I'll then
try to get this upstream shortly.


Whoops, I don't know how I managed to miss that when grepping for users.
Sorry about that. Updated version coming shortly.


Thanks. Still the new version also fails in the CI build. I'm using
MS Azure for this, here the link to the failing build:

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


Apparently I'm blind, the full definition of 'struct cyclic_info' was
not guarded by CONFIG_CYCLIC.


Yes, I already "played" a bit here but still got other problems.


Could you please make sure that CI fully builds?


Is there a way I can trigger that from my side without sending patches?


You need to have an azure account and push a branch with your patches
into your u-boot repo to trigger the CI build. Gitlab also is possible
AFAIK.


BTW: Not sure if I still can pull this (updated version) in, since I'm
leaving for a 2 week vacation tomorrow morning.


NP, I should have been more careful. I'll send an updated version in a
moment anyway.


Thanks,
Stefan


Re: [PATCH v2 3/3] cyclic: make clients embed a struct cyclic_info in their own data structure

2024-05-21 Thread Stefan Roese

On 5/19/24 21:44, Rasmus Villemoes wrote:

On 18/05/2024 09.34, Stefan Roese wrote:


This introduces some problems when compiling e.g. sandbox:

In file included from test/common/cyclic.c:10:
test/common/cyclic.c: In function ‘dm_test_cyclic_running’:
test/common/cyclic.c:25:42: warning: passing argument 1 of
‘cyclic_register’ from incompatible pointer type
[-Wincompatible-pointer-types]
    25 | ut_assertnonnull(cyclic_register(cyclic_test, 10 * 1000,
"cyclic_demo",
   |  ^~~
   |  |
   |  void (*)(void *)
include/test/ut.h:298:29: note: in definition of macro ‘ut_assertnonnull’

[...]


Could you please also change the test file accordingly? I'll then
try to get this upstream shortly.


Whoops, I don't know how I managed to miss that when grepping for users.
Sorry about that. Updated version coming shortly.


Thanks. Still the new version also fails in the CI build. I'm using
MS Azure for this, here the link to the failing build:

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

Could you please make sure that CI fully builds?

BTW: Not sure if I still can pull this (updated version) in, since I'm
leaving for a 2 week vacation tomorrow morning.

Thanks,
Stefan


Re: [PATCH v2 3/3] cyclic: make clients embed a struct cyclic_info in their own data structure

2024-05-18 Thread Stefan Roese

Hi Rasmus,

On 5/16/24 09:53, Rasmus Villemoes wrote:

There are of course not a whole lot of examples in-tree yet, but
before they appear, let's make this API change: Instead of separately
allocating a 'struct cyclic_info', make the users embed such an
instance in their own structure, and make the convention that the
callback simply receives the 'struct cyclic_info *', from which the
clients can get their own data using the container_of() macro.

This has a number of advantages.

First, it means cyclic_register() simply cannot fail, simplifying the
code. The necessary storage will simply be allocated automatically
when the client's own structure is allocated (often via
uclass_priv_auto or similar).

Second, code for which CONFIG_CYCLIC is just an option can more easily
be written without #ifdefs, if we just provide an empty struct
cyclic_info {}. For example, the nested CONFIG_IS_ENABLED()s in
https://lore.kernel.org/u-boot/20240316201416.211480-1-marek.vasut+rene...@mailbox.org/
are mostly due to the existence of the 'struct cyclic_info *' member
being guarded by #ifdef CONFIG_CYCLIC.

And we do probably want to avoid the extra memory overhead of that
member when !CONFIG_CYCLIC. But that is automatic if, instead of a
'struct cyclic_info *', one simply embeds a 'struct cyclic_info',
which will have size 0 when !CONFIG_CYCLIC. Also, the no-op
cyclic_register() function can just unconditionally be called, and the
compiler will see that (1) the callback is referenced, so not emit a
warning for a maybe-unused function and (2) see that it can actually
never be reached, so not emit any code for it.

Reviewed-by: Stefan Roese 
Signed-off-by: Rasmus Villemoes 
---
  board/Marvell/octeon_nic23/board.c |  9 +---
  cmd/cyclic.c   | 12 +--
  common/cyclic.c| 22 +--
  doc/develop/cyclic.rst | 26 ++-
  drivers/watchdog/wdt-uclass.c  | 33 +
  include/cyclic.h   | 34 +++---
  6 files changed, 64 insertions(+), 72 deletions(-)


This introduces some problems when compiling e.g. sandbox:

In file included from test/common/cyclic.c:10:
test/common/cyclic.c: In function ‘dm_test_cyclic_running’:
test/common/cyclic.c:25:42: warning: passing argument 1 of 
‘cyclic_register’ from incompatible pointer type 
[-Wincompatible-pointer-types]
   25 | ut_assertnonnull(cyclic_register(cyclic_test, 10 * 
1000, "cyclic_demo",

  |  ^~~
  |  |
  |  void (*)(void *)
include/test/ut.h:298:29: note: in definition of macro ‘ut_assertnonnull’
  298 | const void *_val = (expr); 
\

  | ^~~~
In file included from test/common/cyclic.c:6:
include/cyclic.h:58:42: note: expected ‘struct cyclic_info *’ but 
argument is of type ‘void (*)(void *)’
   58 | void cyclic_register(struct cyclic_info *cyclic, cyclic_func_t 
func,

  |  ^~
test/common/cyclic.c:25:55: warning: passing argument 2 of 
‘cyclic_register’ makes pointer from integer without a cast 
[-Wint-conversion]
   25 | ut_assertnonnull(cyclic_register(cyclic_test, 10 * 
1000, "cyclic_demo",

  |   ^
  |   |
  |   int

Could you please also change the test file accordingly? I'll then
try to get this upstream shortly.

Many thanks in advance,
Stefan



diff --git a/board/Marvell/octeon_nic23/board.c 
b/board/Marvell/octeon_nic23/board.c
index bc9332cb74a..74b9c741b7b 100644
--- a/board/Marvell/octeon_nic23/board.c
+++ b/board/Marvell/octeon_nic23/board.c
@@ -357,10 +357,13 @@ int board_late_init(void)
board_configure_qlms();
  
  	/* Register cyclic function for PCIe FLR fixup */

-   cyclic = cyclic_register(octeon_board_restore_pf, 100,
-"pcie_flr_fix", NULL);
-   if (!cyclic)
+   cyclic = calloc(1, sizeof(*cyclic));
+   if (cyclic) {
+   cyclic_register(cyclic, octeon_board_restore_pf, 100,
+   "pcie_flr_fix");
+   } else {
printf("Registering of cyclic function failed\n");
+   }
  
  	return 0;

  }
diff --git a/cmd/cyclic.c b/cmd/cyclic.c
index 40e966de9aa..339dd4a7bce 100644
--- a/cmd/cyclic.c
+++ b/cmd/cyclic.c
@@ -15,14 +15,16 @@
  #include 
  #include 
  #include 
+#include 
  
  struct cyclic_demo_info {

+   struct cyclic_info cyclic;
uint delay_us;
  };
  
-static void cyclic_demo(void *ctx)

+static void cyclic_demo(struct cyclic_info *c)
  {
-   struct cyclic_demo_info *info = ctx;
+   stru

Re: [PATCH 3/3] cyclic: make clients embed a struct cyclic_info in their own data structure

2024-05-16 Thread Stefan Roese

Hi Rasmus,

On 5/9/24 02:47, Rasmus Villemoes wrote:

There are of course not a whole lot of examples in-tree yet, but
before they appear, let's make this API change: Instead of separately
allocating a 'struct cyclic_info', make the users embed such an
instance in their own structure, and make the convention that the
callback simply receives the 'struct cyclic_info *', from which the
clients can get their own data using the container_of() macro.

This has a number of advantages.

First, it means cyclic_register() simply cannot fail, simplifying the
code. The necessary storage will simply be allocated automatically
when the client's own structure is allocated (often via
uclass_priv_auto or similar).

Second, code for which CONFIG_CYCLIC is just an option can more easily
be written without #ifdefs, if we just provide an empty struct
cyclic_info {}. For example, the nested CONFIG_IS_ENABLED()s in
https://lore.kernel.org/u-boot/20240316201416.211480-1-marek.vasut+rene...@mailbox.org/
are mostly due to the existence of the 'struct cyclic_info *' member
being guarded by #ifdef CONFIG_CYCLIC.

And we do probably want to avoid the extra memory overhead of that
member when !CONFIG_CYCLIC. But that is automatic if, instead of a
'struct cyclic_info *', one simply embeds a 'struct cyclic_info',
which will have size 0 when !CONFIG_CYCLIC. Also, the no-op
cyclic_register() function can just unconditionally be called, and the
compiler will see that (1) the callback is referenced, so not emit a
warning for a maybe-unused function and (2) see that it can actually
never be reached, so not emit any code for it.

Signed-off-by: Rasmus Villemoes 
---
  board/Marvell/octeon_nic23/board.c |  9 +---
  cmd/cyclic.c   | 12 +--
  common/cyclic.c| 22 +--
  doc/develop/cyclic.rst | 26 ++-
  drivers/watchdog/wdt-uclass.c  | 33 +
  include/cyclic.h   | 34 +++---
  6 files changed, 64 insertions(+), 72 deletions(-)


I like this approach. And would like to pull this in as well, perhaps
before leaving on a 2 week vacation mid of next week. Unfortunately
this patch 3/3 does not apply on TOT any more. Could you please rebase
and re-submit?

Reviewed-by: Stefan Roese 

Thanks,
Stefan


diff --git a/board/Marvell/octeon_nic23/board.c 
b/board/Marvell/octeon_nic23/board.c
index bc9332cb74a..74b9c741b7b 100644
--- a/board/Marvell/octeon_nic23/board.c
+++ b/board/Marvell/octeon_nic23/board.c
@@ -357,10 +357,13 @@ int board_late_init(void)
board_configure_qlms();
  
  	/* Register cyclic function for PCIe FLR fixup */

-   cyclic = cyclic_register(octeon_board_restore_pf, 100,
-"pcie_flr_fix", NULL);
-   if (!cyclic)
+   cyclic = calloc(1, sizeof(*cyclic));
+   if (cyclic) {
+   cyclic_register(cyclic, octeon_board_restore_pf, 100,
+   "pcie_flr_fix");
+   } else {
printf("Registering of cyclic function failed\n");
+   }
  
  	return 0;

  }
diff --git a/cmd/cyclic.c b/cmd/cyclic.c
index ad7fc3b975e..315546515f0 100644
--- a/cmd/cyclic.c
+++ b/cmd/cyclic.c
@@ -14,14 +14,16 @@
  #include 
  #include 
  #include 
+#include 
  
  struct cyclic_demo_info {

+   struct cyclic_info cyclic;
uint delay_us;
  };
  
-static void cyclic_demo(void *ctx)

+static void cyclic_demo(struct cyclic_info *c)
  {
-   struct cyclic_demo_info *info = ctx;
+   struct cyclic_demo_info *info = container_of(c, struct 
cyclic_demo_info, cyclic);
  
  	/* Just a small dummy delay here */

udelay(info->delay_us);
@@ -31,7 +33,6 @@ static int do_cyclic_demo(struct cmd_tbl *cmdtp, int flag, 
int argc,
  char *const argv[])
  {
struct cyclic_demo_info *info;
-   struct cyclic_info *cyclic;
uint time_ms;
  
  	if (argc < 3)

@@ -47,10 +48,7 @@ static int do_cyclic_demo(struct cmd_tbl *cmdtp, int flag, 
int argc,
info->delay_us = simple_strtoul(argv[2], NULL, 0);
  
  	/* Register demo cyclic function */

-   cyclic = cyclic_register(cyclic_demo, time_ms * 1000, "cyclic_demo",
-info);
-   if (!cyclic)
-   printf("Registering of cyclic_demo failed\n");
+   cyclic_register(>cyclic, cyclic_demo, time_ms * 1000, 
"cyclic_demo");
  
  	printf("Registered function \"%s\" to be executed all %dms\n",

   "cyclic_demo", time_ms);
diff --git a/common/cyclic.c b/common/cyclic.c
index c62e7fa7d19..ec38fad6775 100644
--- a/common/cyclic.c
+++ b/common/cyclic.c
@@ -26,34 +26,22 @@ struct hlist_head *cyclic_get_list(void)
return (struct hlist_head *)>cyclic_list;
  }
  
-struct cyclic_info *cyclic_register(cyclic_func_t func, uint64_t delay_us,


Re: [PATCH 07/11] watchdog: Add support for ADI SC5XX-family watchdog peripheral

2024-05-15 Thread Stefan Roese

On 5/15/24 23:57, Greg Malysa wrote:

From: Nathan Barrett-Morrison 

Co-developed-by: Greg Malysa 
Signed-off-by: Greg Malysa 
Co-developed-by: Ian Roberts 
Signed-off-by: Ian Roberts 
Signed-off-by: Vasileios Bimpikas 
Signed-off-by: Utsav Agarwal 
Signed-off-by: Arturs Artamonovs 
Signed-off-by: Nathan Barrett-Morrison 
---

  MAINTAINERS|   1 +
  drivers/watchdog/Kconfig   |   9 +++
  drivers/watchdog/Makefile  |   1 +
  drivers/watchdog/adi_wdt.c | 145 +
  4 files changed, 156 insertions(+)
  create mode 100644 drivers/watchdog/adi_wdt.c


Reviewed-by: Stefan Roese 

Thanks,
Stefan


diff --git a/MAINTAINERS b/MAINTAINERS
index c1685f0352..6feb7e540b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -618,6 +618,7 @@ F:  drivers/pinctrl/pinctrl-adi-adsp.c
  F:drivers/serial/serial_adi_uart4.c
  F:drivers/timer/adi_sc5xx_timer.c
  F:drivers/usb/musb-new/sc5xx.c
+F: drivers/watchdog/adi_wdt.c
  F:include/env/adi/
  
  ARM SNAPDRAGON

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 8318fd77a3..5a62000272 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -94,6 +94,15 @@ config WDT_APPLE
  The watchdog will perform a full SoC reset resulting in a
  reboot of the entire system.
  
+config WDT_ADI

+   bool "Analog Devices watchdog timer support"
+   select WDT
+   select SPL_WDT if SPL
+   depends on (SC57X || SC58X || SC59X || SC59X_64)
+   help
+ Enable this to support Watchdog Timer on ADI SC57X, SC58X, SC59X,
+ and SC59X_64 processors
+
  config WDT_ARMADA_37XX
bool "Marvell Armada 37xx watchdog timer support"
depends on WDT && ARMADA_3700
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 7b39adcf0f..7ad61b513c 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -50,3 +50,4 @@ obj-$(CONFIG_WDT_STM32MP) += stm32mp_wdt.o
  obj-$(CONFIG_WDT_SUNXI) += sunxi_wdt.o
  obj-$(CONFIG_WDT_TANGIER) += tangier_wdt.o
  obj-$(CONFIG_WDT_XILINX) += xilinx_wwdt.o
+obj-$(CONFIG_WDT_ADI) += adi_wdt.o
diff --git a/drivers/watchdog/adi_wdt.c b/drivers/watchdog/adi_wdt.c
new file mode 100644
index 00..67d17dc692
--- /dev/null
+++ b/drivers/watchdog/adi_wdt.c
@@ -0,0 +1,145 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * (C) Copyright 2022 - Analog Devices, Inc.
+ *
+ * Written and/or maintained by Timesys Corporation
+ *
+ * Converted to driver model by Nathan Barrett-Morrison
+ *
+ * Contact: Nathan Barrett-Morrison 
+ * Contact: Greg Malysa 
+ *
+ * adi_wtd.c - driver for ADI on-chip watchdog
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define WDOG_CTL  0x0
+#define WDOG_CNT  0x4
+#define WDOG_STAT 0x8
+
+#define RCU_CTL   0x0
+#define RCU_STAT  0x4
+
+#define SEC_GCTL  0x0
+#define SEC_FCTL  0x10
+#define SEC_SCTL0 0x800
+
+#define WDEN  0x0010
+#define WDDIS 0x0AD0
+
+struct adi_wdt_priv {
+   void __iomem *rcu_base;
+   void __iomem *sec_base;
+   void __iomem *wdt_base;
+   struct clk clock;
+};
+
+static int adi_wdt_reset(struct udevice *dev)
+{
+   struct adi_wdt_priv *priv = dev_get_priv(dev);
+
+   writel(0, priv->wdt_base + WDOG_STAT);
+
+   return 0;
+}
+
+static int adi_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
+{
+   struct adi_wdt_priv *priv = dev_get_priv(dev);
+   u32 sctl_val;
+
+   /* Disable SYSCD_RESETb input and clear the RCU0 reset status */
+   writel(0xf, priv->rcu_base + RCU_STAT);
+   writel(0x0, priv->rcu_base + RCU_CTL);
+
+   /* reset the SEC controller */
+   writel(0x2, priv->sec_base + SEC_GCTL);
+   writel(0x2, priv->sec_base + SEC_FCTL);
+
+   udelay(50);
+
+   /* enable SEC fault event */
+   writel(0x1, priv->sec_base + SEC_GCTL);
+
+   /* ANOMALY 3614 Spurious External Fault event occurs when FCTL
+* is re-programmed when currently active fault is not cleared
+*/
+   writel(0xc0, priv->sec_base + SEC_FCTL);
+   writel(0xc1, priv->sec_base + SEC_FCTL);
+
+   /* enable SEC fault source for watchdog0 */
+   sctl_val = readl((priv->sec_base + SEC_SCTL0) + 3 * 8) | 0x6;
+   writel(sctl_val, (priv->sec_base + SEC_SCTL0) + 3 * 8);
+
+   /* Enable SYSCD_RESETb input */
+   writel(0x100, priv->rcu_base + RCU_CTL);
+
+   /* enable watchdog0 */
+   writel(WDDIS, priv->wdt_base + WDOG_CTL);
+
+   writel(timeout_ms / 1000 *
+  (clk_get_rate(>clock) / (IS_ENABLED(CONFIG_SC58X) ? 2 : 
1)),
+  priv->wdt_base + WDOG_CNT);
+
+   writel(0, priv->wdt_base + WDOG_STAT);
+   writel(WDEN, priv->wdt_base + WDOG_CTL);
+
+   return 0;
+}
+
+static int adi_wdt_probe(struct udevice *dev)
+{
+   struct adi_wdt_priv *priv = dev_get_priv(dev);
+   int ret;
+  

Re: [PATCH u-boot-mvebu 10/10] arm: mvebu: turris_omnia: Support old DDR3 training, selectable via env var

2024-05-15 Thread Stefan Roese

On 5/15/24 11:24, Marek Behún wrote:

On Wed, 15 May 2024 11:10:09 +0200
Stefan Roese  wrote:


Hi Marek,

On 5/15/24 10:59, Marek Behún wrote:

On Mon, 6 May 2024 12:03:55 +0200
Stefan Roese  wrote:
   

Hi Marek,

On 4/15/24 18:30, Marek Behún wrote:

Support old DDR3 training code on Turris Omnia, selectable by U-Boot
enviroment variable.

Users experiencing DDR3 initialization failures or random crashes of the
operating system due to incorrect DDR3 configuration can select the old
DDR3 training implementation to fix those issues by setting the
environment variable
 env set omnia_ddr3_training old
 env save

Signed-off-by: Marek Behún 
---
arch/arm/mach-mvebu/Kconfig   |  1 +
board/CZ.NIC/turris_omnia/Makefile|  1 +
board/CZ.NIC/turris_omnia/old_ddr3_training.c | 79 +++
board/CZ.NIC/turris_omnia/turris_omnia.c  |  2 +-
4 files changed, 82 insertions(+), 1 deletion(-)
create mode 100644 board/CZ.NIC/turris_omnia/old_ddr3_training.c


For turris_omnia_defconfig, this is dropped when compiled:

drivers/ddr/marvell/a38x/old/ddr3_debug.c:776:12: warning:
'ddr3_tip_access_atr' declared 'static' but never defined
[-Wunused-function]
 776 | static int ddr3_tip_access_atr(u32 dev_num, u32 flag_id, u32
value, u32 **ptr);
 |^~~


And it also seems that there is still something wrong with this
old DDR training code port. Some boards still experience random bugs
with this, but not with the U-Boot from 2015. :-(


Hmmm, strange.

How to continue? Are these "old DDR training patches" on hold for now?


The first 5 patches should be fine, the "old DDR training" comes in the
second half. Is it possible to merge only the first 5? And also the one
patch I sent on April 30:
   arm: mvebu: turris_omnia: Fix ethernet PHY reset gpio FDT fixup


Yes, that might be possible. Let me check...

Thanks,
Stefan


Re: [PATCH 3/3] drivers: misc: Add driver to access ZynqMP efuses

2024-05-15 Thread Stefan Roese

Hi Lukas,

On 5/15/24 08:33, Lukas Funke wrote:

Hi Stefan,

On 15.05.2024 08:12, Stefan Roese wrote:

Hi Lukas,

On 5/14/24 16:04, lukas.funke-...@weidmueller.com wrote:

From: Lukas Funke 

Add driver to access ZynqMP efuses. This is a u-boot port of [1].

[1] 
https://lore.kernel.org/all/20240224114516.86365-8-srinivas.kandaga...@linaro.org/


Signed-off-by: Lukas Funke 
---

  drivers/misc/Kconfig    |   8 ++
  drivers/misc/Makefile   |   1 +
  drivers/misc/zynqmp_efuse.c | 213 
  3 files changed, 222 insertions(+)
  create mode 100644 drivers/misc/zynqmp_efuse.c

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 6009d55f400..c07f50c9a76 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -298,6 +298,14 @@ config FSL_SEC_MON
    Security Monitor can be transitioned on any security failures,
    like software violations or hardware security violations.
+config ZYNQMP_EFUSE
+    bool "Enable ZynqMP eFUSE Driver"
+    depends on ZYNQMP_FIRMWARE
+    help
+  Enable access to Zynq UltraScale (ZynqMP) eFUSEs thought PMU 
firmware
+  interface. ZnyqMP has 256 eFUSEs where some of them are 
security related

+  and cannot be read back (i.e. AES key).
+
  choice
  prompt "Security monitor interaction endianess"
  depends on FSL_SEC_MON
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index e53d52c47b3..68ba5648eab 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -92,3 +92,4 @@ obj-$(CONFIG_ESM_K3) += k3_esm.o
  obj-$(CONFIG_ESM_PMIC) += esm_pmic.o
  obj-$(CONFIG_SL28CPLD) += sl28cpld.o
  obj-$(CONFIG_SPL_SOCFPGA_DT_REG) += socfpga_dtreg.o
+obj-$(CONFIG_ZYNQMP_EFUSE) += zynqmp_efuse.o
diff --git a/drivers/misc/zynqmp_efuse.c b/drivers/misc/zynqmp_efuse.c
new file mode 100644
index 000..0cfc42a4f39
--- /dev/null
+++ b/drivers/misc/zynqmp_efuse.c
@@ -0,0 +1,213 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2014 - 2015 Xilinx, Inc.
+ * Michal Simek 
+ *
+ * (C) Copyright 2024 Weidmueller Interface GmbH
+ * Lukas Funke 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define SILICON_REVISION_MASK 0xF
+#define P_USER_0_64_UPPER_MASK    0x5FFF
+#define P_USER_127_LOWER_4_BIT_MASK 0xF
+#define WORD_INBYTES    (4)
+#define SOC_VER_SIZE    (0x4)
+#define EFUSE_MEMORY_SIZE    (0x177)
+#define UNUSED_SPACE    (0x8)
+#define ZYNQMP_NVMEM_SIZE    (SOC_VER_SIZE + UNUSED_SPACE + \
+ EFUSE_MEMORY_SIZE)
+#define SOC_VERSION_OFFSET    (0x0)
+#define EFUSE_START_OFFSET    (0xC)
+#define EFUSE_END_OFFSET    (0xFC)
+#define EFUSE_PUF_START_OFFSET    (0x100)
+#define EFUSE_PUF_MID_OFFSET    (0x140)
+#define EFUSE_PUF_END_OFFSET    (0x17F)
+#define EFUSE_NOT_ENABLED    (29)
+#define EFUSE_READ    (0)
+#define EFUSE_WRITE    (1)
+
+/**
+ * struct xilinx_efuse - the basic structure
+ * @src:    address of the buffer to store the data to be write/read
+ * @size:    no of words to be read/write
+ * @offset:    offset to be read/write`
+ * @flag:    0 - represents efuse read and 1- represents efuse write
+ * @pufuserfuse:0 - represents non-puf efuses, offset is used for 
read/write

+ *    1 - represents puf user fuse row number.
+ *
+ * this structure stores all the required details to
+ * read/write efuse memory.
+ */
+struct xilinx_efuse {
+    u64 src;
+    u32 size;
+    u32 offset;
+    u32 flag;
+    u32 pufuserfuse;
+};
+
+static int zynqmp_efuse_access(struct udevice *dev, unsigned int 
offset,

+   void *val, size_t bytes, unsigned int flag,
+   unsigned int pufflag)
+{
+    size_t words = bytes / WORD_INBYTES;
+    ulong dma_addr, dma_buf;
+    struct xilinx_efuse *efuse;
+    char *data;
+    int ret, value;
+
+    if (bytes % WORD_INBYTES != 0) {
+    dev_err(dev, "Bytes requested should be word aligned\n");
+    return -EOPNOTSUPP;
+    }
+
+    if (pufflag == 0 && offset % WORD_INBYTES) {
+    dev_err(dev, "Offset requested should be word aligned\n");
+    return -EOPNOTSUPP;
+    }
+
+    if (pufflag == 1 && flag == EFUSE_WRITE) {
+    memcpy(, val, bytes);
+    if ((offset == EFUSE_PUF_START_OFFSET ||
+ offset == EFUSE_PUF_MID_OFFSET) &&
+    value & P_USER_0_64_UPPER_MASK) {
+    dev_err(dev, "Only lower 4 bytes are allowed to be 
programmed in P_USER_0 & P_USER_64\n");

+    return -EOPNOTSUPP;
+    }
+
+    if (offset == EFUSE_PUF_END_OFFSET &&
+    (value & P_USER_127_LOWER_4_BIT_MASK)) {
+    dev_err(dev, "Only MSB 28 bits are allowed to be 
programmed for P_USER_127\n");

+    return -EOPNOTSUPP;
+    }
+    }
+
+    efuse = dma_alloc_coherent(sizeof(struct xilinx_efuse), _addr);
+    if (!efuse)
+    return -ENOMEM;
+
+    data = dma_a

Re: [PATCH u-boot-mvebu 10/10] arm: mvebu: turris_omnia: Support old DDR3 training, selectable via env var

2024-05-15 Thread Stefan Roese

Hi Marek,

On 5/15/24 10:59, Marek Behún wrote:

On Mon, 6 May 2024 12:03:55 +0200
Stefan Roese  wrote:


Hi Marek,

On 4/15/24 18:30, Marek Behún wrote:

Support old DDR3 training code on Turris Omnia, selectable by U-Boot
enviroment variable.

Users experiencing DDR3 initialization failures or random crashes of the
operating system due to incorrect DDR3 configuration can select the old
DDR3 training implementation to fix those issues by setting the
environment variable
env set omnia_ddr3_training old
env save

Signed-off-by: Marek Behún 
---
   arch/arm/mach-mvebu/Kconfig   |  1 +
   board/CZ.NIC/turris_omnia/Makefile|  1 +
   board/CZ.NIC/turris_omnia/old_ddr3_training.c | 79 +++
   board/CZ.NIC/turris_omnia/turris_omnia.c  |  2 +-
   4 files changed, 82 insertions(+), 1 deletion(-)
   create mode 100644 board/CZ.NIC/turris_omnia/old_ddr3_training.c


For turris_omnia_defconfig, this is dropped when compiled:

drivers/ddr/marvell/a38x/old/ddr3_debug.c:776:12: warning:
'ddr3_tip_access_atr' declared 'static' but never defined
[-Wunused-function]
776 | static int ddr3_tip_access_atr(u32 dev_num, u32 flag_id, u32
value, u32 **ptr);
|^~~


And it also seems that there is still something wrong with this
old DDR training code port. Some boards still experience random bugs
with this, but not with the U-Boot from 2015. :-(


Hmmm, strange.

How to continue? Are these "old DDR training patches" on hold for now?

Thanks,
Stefan


Re: [PATCH 3/3] drivers: misc: Add driver to access ZynqMP efuses

2024-05-15 Thread Stefan Roese
UPP;
+   }
+   }
+
+   efuse = dma_alloc_coherent(sizeof(struct xilinx_efuse), _addr);
+   if (!efuse)
+   return -ENOMEM;
+
+   data = dma_alloc_coherent(bytes, _buf);
+   if (!data) {
+   dma_free_coherent(efuse);
+   return -ENOMEM;
+   }
+
+   if (flag == EFUSE_WRITE) {
+   memcpy(data, val, bytes);
+   efuse->flag = EFUSE_WRITE;
+   } else {
+   efuse->flag = EFUSE_READ;
+   }
+
+   efuse->src = dma_buf;
+   efuse->size = words;
+   efuse->offset = offset;
+   efuse->pufuserfuse = pufflag;
+
+   flush_dcache_range((ulong)efuse, (ulong)efuse +
+  roundup(sizeof(struct xilinx_efuse), 
ARCH_DMA_MINALIGN));
+   flush_dcache_range((ulong)data, (ulong)data +
+  roundup(sizeof(struct xilinx_efuse), 
ARCH_DMA_MINALIGN));


efuse and data are allocated via dma_alloc_coherent(). It should not be
necessary to use flush the cache here IIUTC.


+
+   zynqmp_pm_efuse_access(dma_addr, (u32 *));
+   if (ret != 0) {
+   if (ret == EFUSE_NOT_ENABLED) {
+   dev_err(dev, "efuse access is not enabled\n");
+   ret = -EOPNOTSUPP;
+   goto END;
+   }
+   dev_err(dev, "Error in efuse read %x\n", ret);
+   ret = -EPERM;
+   goto END;
+   }
+
+   if (flag == EFUSE_READ)
+   memcpy(val, data, bytes);
+END:


Nitpicking: Upper case label ist pretty uncommon AFAIK.


+
+   dma_free_coherent(efuse);
+   dma_free_coherent(data);
+
+   return ret;
+}
+
+static int zynqmp_nvmem_read(struct udevice *dev, int offset,
+void *val, int bytes)
+{
+   int ret, pufflag = 0;
+   int idcode, version;
+
+   if (offset >= EFUSE_PUF_START_OFFSET && offset <= EFUSE_PUF_END_OFFSET)
+   pufflag = 1;
+
+   dev_dbg(dev, "reading from offset=0x%x, bytes=%d\n", offset, bytes);
+
+   switch (offset) {
+   /* Soc version offset is zero */
+   case SOC_VERSION_OFFSET:
+   if (bytes != SOC_VER_SIZE)
+   return -EOPNOTSUPP;
+
+   ret = zynqmp_pm_get_chipid((u32 *), (u32 *));
+   if (ret < 0)
+   return ret;
+
+   *(int *)val = version & SILICON_REVISION_MASK;
+   break;
+   /* Efuse offset starts from 0xc */
+   case EFUSE_START_OFFSET ... EFUSE_END_OFFSET:
+   case EFUSE_PUF_START_OFFSET ... EFUSE_PUF_END_OFFSET:
+   ret = zynqmp_efuse_access(dev, offset, val,
+ bytes, EFUSE_READ, pufflag);
+   break;
+   default:
+   *(u32 *)val = 0xDEADBEEF;
+   ret = 0;
+   break;
+   }
+
+   return ret;
+}
+
+static int zynqmp_nvmem_write(struct udevice *dev, int offset, const void *val,
+ int bytes)
+{
+   int pufflag = 0;
+
+   dev_dbg(dev, "writing to offset=0x%x, bytes=%d", offset, bytes);
+
+   if (offset < EFUSE_START_OFFSET || offset > EFUSE_PUF_END_OFFSET)
+   return -EOPNOTSUPP;
+
+   if (offset >= EFUSE_PUF_START_OFFSET && offset <= EFUSE_PUF_END_OFFSET)
+   pufflag = 1;
+
+   return zynqmp_efuse_access(dev, offset,
+  (void *)val, bytes, EFUSE_WRITE, pufflag);
+}
+
+static const struct udevice_id zynqmp_efuse_match[] = {
+   { .compatible = "xlnx,zynqmp-nvmem-fw", },
+   { /* sentinel */ },
+};
+
+static const struct misc_ops zynqmp_efuse_ops = {
+   .read = zynqmp_nvmem_read,
+   .write = zynqmp_nvmem_write,
+};
+
+U_BOOT_DRIVER(zynqmp_efuse) = {
+   .name = "zynqmp_efuse",
+   .id = UCLASS_MISC,
+   .of_match = zynqmp_efuse_match,
+   .ops = _efuse_ops,
+};


Viele Grüße,
Stefan Roese

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


Re: [PATCH 1/3] firmware: zynqmp: Add support to access efuses

2024-05-15 Thread Stefan Roese

Hi Lukas,

On 5/14/24 16:04, lukas.funke-...@weidmueller.com wrote:

From: Lukas Funke 

Add functions to access efuses through PMU firmware
interface.

Signed-off-by: Lukas Funke 
---

  drivers/firmware/firmware-zynqmp.c | 31 ++
  include/zynqmp_firmware.h  |  2 ++
  2 files changed, 33 insertions(+)

diff --git a/drivers/firmware/firmware-zynqmp.c 
b/drivers/firmware/firmware-zynqmp.c
index f99507d86c6..7483f2a8709 100644
--- a/drivers/firmware/firmware-zynqmp.c
+++ b/drivers/firmware/firmware-zynqmp.c
@@ -210,6 +210,37 @@ int zynqmp_pm_feature(const u32 api_id)
return ret_payload[1] & FIRMWARE_VERSION_MASK;
  }
  
+int zynqmp_pm_get_chipid(u32 *idcode, u32 *version)

+{
+   int ret;
+   u32 ret_payload[PAYLOAD_ARG_CNT];


Reverse x-mas tree ordering looks better IMHO.


+
+   if (!idcode || !version)
+   return -EINVAL;
+
+   ret = xilinx_pm_request(PM_GET_CHIPID, 0, 0, 0, 0, ret_payload);
+   *idcode = ret_payload[1];
+   *version = ret_payload[2];


You don't check ret for an error above but still pass the return values
here. Perhaps it makes sense to return with error above instead?


+
+   return ret;
+}
+
+int zynqmp_pm_efuse_access(const u64 address, u32 *out)
+{
+   int ret;
+   u32 ret_payload[PAYLOAD_ARG_CNT];
+
+   if (!out)
+   return -EINVAL;
+
+   ret = xilinx_pm_request(PM_EFUSE_ACCESS, upper_32_bits(address),
+   lower_32_bits(address), 0, 0, ret_payload);


Same here.

Thanks,
Stefan


+
+   *out = ret_payload[1];
+
+   return ret;
+}
+
  int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id)
  {
int ret;
diff --git a/include/zynqmp_firmware.h b/include/zynqmp_firmware.h
index 73198a6a6ea..7f18b4d59bf 100644
--- a/include/zynqmp_firmware.h
+++ b/include/zynqmp_firmware.h
@@ -453,6 +453,8 @@ int xilinx_pm_request(u32 api_id, u32 arg0, u32 arg1, u32 
arg2,
  int zynqmp_pm_set_sd_config(u32 node, enum pm_sd_config_type config, u32 
value);
  int zynqmp_pm_set_gem_config(u32 node, enum pm_gem_config_type config,
 u32 value);
+int zynqmp_pm_get_chipid(u32 *idcode, u32 *version);
+int zynqmp_pm_efuse_access(const u64 address, u32 *out);
  int zynqmp_pm_is_function_supported(const u32 api_id, const u32 id);
  int zynqmp_mmio_read(const u32 address, u32 *value);
  int zynqmp_mmio_write(const u32 address, const u32 mask, const u32 value);


Viele Grüße,
Stefan Roese

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


Re: [PATCH 2/3] wdt-uclass: prevent multiple cyclic_register calls

2024-05-13 Thread Stefan Roese

Hi Rasmus,

On 5/13/24 13:09, Rasmus Villemoes wrote:

On 13/05/2024 12.40, Stefan Roese wrote:

On 5/9/24 02:47, Rasmus Villemoes wrote:

Currently, the cyclic_register() done in wdt_start() is not undone in
wdt_stop(). Moreover, calling wdt_start multiple times (which is
perfectly allowed on an already started device, e.g. to change the
timeout value) will result in another struct cyclic_info being
registered, referring to the same watchdog device.

This can easily be seen on e.g. a wandboard:

=> cyclic list
function: watchdog@20bc000, cpu-time: 22 us, frequency: 1.01 times/s
=> wdt list
watchdog@20bc000 (imx_wdt)
=> wdt dev watchdog@20bc000
=> wdt start 5
WDT:   Started watchdog@20bc000 with servicing every 1000ms (50s timeout)
=> cyclic list
function: watchdog@20bc000, cpu-time: 37 us, frequency: 1.03 times/s
function: watchdog@20bc000, cpu-time: 241 us, frequency: 1.01 times/s
=> wdt start 12345
WDT:   Started watchdog@20bc000 with servicing every 1000ms (12s timeout)
=> cyclic list
function: watchdog@20bc000, cpu-time: 36 us, frequency: 1.03 times/s
function: watchdog@20bc000, cpu-time: 100 us, frequency: 1.04 times/s
function: watchdog@20bc000, cpu-time: 299 us, frequency: 1.00 times/s

So properly unregister the watchdog device from the cyclic framework
in wdt_stop(). In wdt_start(), we cannot just skip the registration,
as the (new) timeout value may mean that we have to ask the cyclic
framework to call us more often. So if we're already running,
first unregister the old cyclic instance.


Thanks again for all your valuable work here. I do have a question
regarding this patch though. AFAIU, it's a valid use-case to enable
2 different watchdog devices. And this patch will prevent such a
setup. Or do I misunderstand this?


No, that shouldn't prevent enabling or petting two different watchdogs
at all, that should work just as well as today. All the state I'm
looking at and modifying belongs to one specific device, it's not
wdt-uclass-global state, it's wdt-uclass-per-device state.


That's what I was hoping, but was too lazy to figure out myself.


But with the existing code, if one calls wdt_start() a second time on an
already started device, the existing priv->cyclic pointer is dropped on
the floor (it gets unconditionally overwritten by the new
cyclic_register() return value), so one gets the situation that the same
device has multiple cyclic callbacks registered. Also, we're not
unregistering the device from the cyclic framework upon ->stop().


Understood.


Today, that's "mostly harmless". It does mean 'cyclic list' becomes
cluttered, and is a memory leak, so you could exhaust memory by doing
wdt_start in a loop, and cyclic_run() ends up doing extra callbacks to
the same device (all but one will be no-ops due to the per-device
rate-limiting of ->reset callbacks). In practice there's no chance of
memory corruption or other failures. However, that changes with 3/3,
where it would be catastrophic to call cyclic_register() with an already
registered cyclic_info instance, as the hlist would become corrupt. I
think it's worth fixing regardless of whether 3/3 is accepted.


Agreed.

Reviewed-by: Stefan Roese 

Thanks,
Stefan


Re: [PATCH 2/3] wdt-uclass: prevent multiple cyclic_register calls

2024-05-13 Thread Stefan Roese

On 5/9/24 02:47, Rasmus Villemoes wrote:

Currently, the cyclic_register() done in wdt_start() is not undone in
wdt_stop(). Moreover, calling wdt_start multiple times (which is
perfectly allowed on an already started device, e.g. to change the
timeout value) will result in another struct cyclic_info being
registered, referring to the same watchdog device.

This can easily be seen on e.g. a wandboard:

=> cyclic list
function: watchdog@20bc000, cpu-time: 22 us, frequency: 1.01 times/s
=> wdt list
watchdog@20bc000 (imx_wdt)
=> wdt dev watchdog@20bc000
=> wdt start 5
WDT:   Started watchdog@20bc000 with servicing every 1000ms (50s timeout)
=> cyclic list
function: watchdog@20bc000, cpu-time: 37 us, frequency: 1.03 times/s
function: watchdog@20bc000, cpu-time: 241 us, frequency: 1.01 times/s
=> wdt start 12345
WDT:   Started watchdog@20bc000 with servicing every 1000ms (12s timeout)
=> cyclic list
function: watchdog@20bc000, cpu-time: 36 us, frequency: 1.03 times/s
function: watchdog@20bc000, cpu-time: 100 us, frequency: 1.04 times/s
function: watchdog@20bc000, cpu-time: 299 us, frequency: 1.00 times/s

So properly unregister the watchdog device from the cyclic framework
in wdt_stop(). In wdt_start(), we cannot just skip the registration,
as the (new) timeout value may mean that we have to ask the cyclic
framework to call us more often. So if we're already running,
first unregister the old cyclic instance.


Thanks again for all your valuable work here. I do have a question
regarding this patch though. AFAIU, it's a valid use-case to enable
2 different watchdog devices. And this patch will prevent such a
setup. Or do I misunderstand this?

Thanks,
Stefan


Signed-off-by: Rasmus Villemoes 
---
  drivers/watchdog/wdt-uclass.c | 9 +++--
  1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/wdt-uclass.c b/drivers/watchdog/wdt-uclass.c
index 417e8d7eef9..caa1567e0c3 100644
--- a/drivers/watchdog/wdt-uclass.c
+++ b/drivers/watchdog/wdt-uclass.c
@@ -122,10 +122,11 @@ int wdt_start(struct udevice *dev, u64 timeout_ms, ulong 
flags)
struct wdt_priv *priv = dev_get_uclass_priv(dev);
char str[16];
  
-		priv->running = true;

-
memset(str, 0, 16);
if (IS_ENABLED(CONFIG_WATCHDOG)) {
+   if (priv->running)
+   cyclic_unregister(priv->cyclic);
+
/* Register the watchdog driver as a cyclic function */
priv->cyclic = cyclic_register(wdt_cyclic,
   priv->reset_period * 
1000,
@@ -140,6 +141,7 @@ int wdt_start(struct udevice *dev, u64 timeout_ms, ulong 
flags)
}
}
  
+		priv->running = true;

printf("WDT:   Started %s with%s servicing %s (%ds timeout)\n",
   dev->name, IS_ENABLED(CONFIG_WATCHDOG) ? "" : "out",
   str, (u32)lldiv(timeout_ms, 1000));
@@ -160,6 +162,9 @@ int wdt_stop(struct udevice *dev)
if (ret == 0) {
struct wdt_priv *priv = dev_get_uclass_priv(dev);
  
+		if (IS_ENABLED(CONFIG_WATCHDOG) && priv->running)

+   cyclic_unregister(priv->cyclic);
+
priv->running = false;
}
  


Viele Grüße,
Stefan Roese

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


Re: [PATCH 1/3] cyclic: stop strdup'ing name in cyclic_register()

2024-05-13 Thread Stefan Roese

On 5/9/24 02:47, Rasmus Villemoes wrote:

We are not checking the return value of strdup(), nor
freeing the string in cyclic_unregister().

However, all current users either pass a string literal or the
dev->name of the client device. So in all cases the name string will
live at least as long as the cyclic_info is registered, so just make
that a requirement.

Signed-off-by: Rasmus Villemoes 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  common/cyclic.c  | 2 +-
  include/cyclic.h | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/cyclic.c b/common/cyclic.c
index a49bfc88f5c..c62e7fa7d19 100644
--- a/common/cyclic.c
+++ b/common/cyclic.c
@@ -40,7 +40,7 @@ struct cyclic_info *cyclic_register(cyclic_func_t func, 
uint64_t delay_us,
/* Store values in struct */
cyclic->func = func;
cyclic->ctx = ctx;
-   cyclic->name = strdup(name);
+   cyclic->name = name;
cyclic->delay_us = delay_us;
cyclic->start_time_us = timer_get_us();
hlist_add_head(>list, cyclic_get_list());
diff --git a/include/cyclic.h b/include/cyclic.h
index 44ad3cb6b80..38946216fb8 100644
--- a/include/cyclic.h
+++ b/include/cyclic.h
@@ -31,7 +31,7 @@
  struct cyclic_info {
void (*func)(void *ctx);
void *ctx;
-   char *name;
+   const char *name;
uint64_t delay_us;
uint64_t start_time_us;
uint64_t cpu_time_us;


Viele Grüße,
Stefan Roese

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


Re: [PATCH u-boot-mvebu 10/10] arm: mvebu: turris_omnia: Support old DDR3 training, selectable via env var

2024-05-06 Thread Stefan Roese
a/turris_omnia.c 
b/board/CZ.NIC/turris_omnia/turris_omnia.c
index 3b7a71bdad..225c6f4bc5 100644
--- a/board/CZ.NIC/turris_omnia/turris_omnia.c
+++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
@@ -465,7 +465,7 @@ static bool omnia_read_eeprom(struct omnia_eeprom *oep)
return true;
  }
  
-static int omnia_get_ram_size_gb(void)

+int omnia_get_ram_size_gb(void)
  {
static int ram_size;
struct omnia_eeprom oep;


Viele Grüße,
Stefan Roese

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


Re: [PATCH 010/149] board: Marvell: Remove and add needed includes

2024-05-02 Thread Stefan Roese

On 5/1/24 04:40, Tom Rini wrote:

Remove  from this board vendor directory and when needed
add missing include files directly.

Signed-off-by: Tom Rini 
---
Cc: Stefan Roese 
Cc: Chris Packham 
Cc: Tony Dinh 
Cc: Jason Cooper 
Cc: Siddarth Gore 
Cc: Aaron Williams 
---
  arch/arm/mach-kirkwood/include/mach/mpp.h | 2 ++
  board/Marvell/db-88f6720/db-88f6720.c | 1 -
  board/Marvell/db-88f6820-amc/db-88f6820-amc.c | 2 +-
  board/Marvell/db-88f6820-gp/db-88f6820-gp.c   | 2 +-
  board/Marvell/db-mv784mp-gp/db-mv784mp-gp.c   | 1 -
  board/Marvell/db-xc3-24g4xg/db-xc3-24g4xg.c   | 1 -
  board/Marvell/dreamplug/dreamplug.c   | 1 -
  board/Marvell/guruplug/guruplug.c | 1 -
  board/Marvell/mvebu_alleycat-5/board.c| 2 +-
  board/Marvell/mvebu_armada-37xx/board.c   | 2 +-
  board/Marvell/mvebu_armada-8k/board.c | 2 +-
  board/Marvell/octeontx2/soc-utils.c   | 1 -
  board/Marvell/openrd/openrd.c | 1 -
  board/Marvell/sheevaplug/sheevaplug.c | 1 -
  14 files changed, 7 insertions(+), 13 deletions(-)


Reviewed-by: Stefan Roese 

Thanks,
Stefan


diff --git a/arch/arm/mach-kirkwood/include/mach/mpp.h 
b/arch/arm/mach-kirkwood/include/mach/mpp.h
index 4d1f58c0cbdf..e2757942590b 100644
--- a/arch/arm/mach-kirkwood/include/mach/mpp.h
+++ b/arch/arm/mach-kirkwood/include/mach/mpp.h
@@ -8,6 +8,8 @@
  #ifndef __KIRKWOOD_MPP_H
  #define __KIRKWOOD_MPP_H
  
+#include 

+
  #define MPP(_num, _sel, _in, _out, _F6180, _F6190, _F6192, _F6281) ( \
/* MPP number */((_num) & 0xff) | \
/* MPP select value */  (((_sel) & 0xf) << 8) | \
diff --git a/board/Marvell/db-88f6720/db-88f6720.c 
b/board/Marvell/db-88f6720/db-88f6720.c
index 26c30647fbb0..920421366f11 100644
--- a/board/Marvell/db-88f6720/db-88f6720.c
+++ b/board/Marvell/db-88f6720/db-88f6720.c
@@ -3,7 +3,6 @@
   * Copyright (C) 2016 Stefan Roese 
   */
  
-#include 

  #include 
  #include 
  #include 
diff --git a/board/Marvell/db-88f6820-amc/db-88f6820-amc.c 
b/board/Marvell/db-88f6820-amc/db-88f6820-amc.c
index 122c63d11f99..0f92cc385bc8 100644
--- a/board/Marvell/db-88f6820-amc/db-88f6820-amc.c
+++ b/board/Marvell/db-88f6820-amc/db-88f6820-amc.c
@@ -3,7 +3,7 @@
   * Copyright (C) 2015 Stefan Roese 
   */
  
-#include 

+#include 
  #include 
  #include 
  #include 
diff --git a/board/Marvell/db-88f6820-gp/db-88f6820-gp.c 
b/board/Marvell/db-88f6820-gp/db-88f6820-gp.c
index 1edc1cb6515c..8f8b2720107a 100644
--- a/board/Marvell/db-88f6820-gp/db-88f6820-gp.c
+++ b/board/Marvell/db-88f6820-gp/db-88f6820-gp.c
@@ -3,7 +3,7 @@
   * Copyright (C) 2015 Stefan Roese 
   */
  
-#include 

+#include 
  #include 
  #include 
  #include 
diff --git a/board/Marvell/db-mv784mp-gp/db-mv784mp-gp.c 
b/board/Marvell/db-mv784mp-gp/db-mv784mp-gp.c
index 9e1fdecfca4d..6bca1f91a0a4 100644
--- a/board/Marvell/db-mv784mp-gp/db-mv784mp-gp.c
+++ b/board/Marvell/db-mv784mp-gp/db-mv784mp-gp.c
@@ -3,7 +3,6 @@
   * Copyright (C) 2014 Stefan Roese 
   */
  
-#include 

  #include 
  #include 
  #include 
diff --git a/board/Marvell/db-xc3-24g4xg/db-xc3-24g4xg.c 
b/board/Marvell/db-xc3-24g4xg/db-xc3-24g4xg.c
index 0abdca1cd210..a7a84798a53b 100644
--- a/board/Marvell/db-xc3-24g4xg/db-xc3-24g4xg.c
+++ b/board/Marvell/db-xc3-24g4xg/db-xc3-24g4xg.c
@@ -3,7 +3,6 @@
   * Copyright (C) 2015 Stefan Roese 
   */
  
-#include 

  #include 
  #include 
  #include 
diff --git a/board/Marvell/dreamplug/dreamplug.c 
b/board/Marvell/dreamplug/dreamplug.c
index d15faa1cb7ff..381275061318 100644
--- a/board/Marvell/dreamplug/dreamplug.c
+++ b/board/Marvell/dreamplug/dreamplug.c
@@ -8,7 +8,6 @@
   * Written-by: Siddarth Gore 
   */
  
-#include 

  #include 
  #include 
  #include 
diff --git a/board/Marvell/guruplug/guruplug.c 
b/board/Marvell/guruplug/guruplug.c
index ea87ded222e6..7c3cea22b936 100644
--- a/board/Marvell/guruplug/guruplug.c
+++ b/board/Marvell/guruplug/guruplug.c
@@ -5,7 +5,6 @@
   * Written-by: Siddarth Gore 
   */
  
-#include 

  #include 
  #include 
  #include 
diff --git a/board/Marvell/mvebu_alleycat-5/board.c 
b/board/Marvell/mvebu_alleycat-5/board.c
index 0c4f8e03b859..c1b7cc3b613c 100644
--- a/board/Marvell/mvebu_alleycat-5/board.c
+++ b/board/Marvell/mvebu_alleycat-5/board.c
@@ -1,6 +1,6 @@
  // SPDX-License-Identifier: GPL-2.0+
  
-#include 

+#include 
  #include 
  
  DECLARE_GLOBAL_DATA_PTR;

diff --git a/board/Marvell/mvebu_armada-37xx/board.c 
b/board/Marvell/mvebu_armada-37xx/board.c
index 1685b12b8478..df3fb6d21645 100644
--- a/board/Marvell/mvebu_armada-37xx/board.c
+++ b/board/Marvell/mvebu_armada-37xx/board.c
@@ -3,7 +3,7 @@
   * Copyright (C) 2016 Stefan Roese 
   */
  
-#include 

+#include 
  #include 
  #include 
  #include 
diff --git a/board/Marvell/mvebu_armada-8k/board.c 
b/board/Marvell/mvebu_armada-8k/board.c
index a8899af6e5af..6d7042117424 100644
--- a/board/Marvell/mvebu_armada-8k/board.c
+++ b/board/Marvell/mvebu_armada-8k/board.

Re: [PATCH] arm: dts: kirkwood: Remove DTS files for Kirkwood boards

2024-04-04 Thread Stefan Roese

On 3/26/24 22:12, Tony Dinh wrote:

Remove DTS and DTSI files for Kirkwood boards that have upstream supports.

This patch depends on
"arm: dts: kirkwood: Enable upstream DT on Kirkwood boards"
https://patchwork.ozlabs.org/project/uboot/patch/20240322021747.14873-1-mibo...@gmail.com/

Signed-off-by: Tony Dinh 


Applied to u-boot-marvell/master

Thanks,
Stefan


---

  arch/arm/dts/Makefile |  28 +-
  arch/arm/dts/kirkwood-6192.dtsi   |  88 --
  arch/arm/dts/kirkwood-6281.dtsi   |  90 --
  arch/arm/dts/kirkwood-6282.dtsi   | 161 
  arch/arm/dts/kirkwood-98dx4122.dtsi   |  53 --
  arch/arm/dts/kirkwood-blackarmor-nas220.dts   | 172 
  arch/arm/dts/kirkwood-d2net.dts   |  45 -
  arch/arm/dts/kirkwood-dns325.dts  |  63 --
  arch/arm/dts/kirkwood-dnskw.dtsi  | 235 -
  arch/arm/dts/kirkwood-dockstar.dts| 110 ---
  arch/arm/dts/kirkwood-dreamplug.dts   | 131 ---
  arch/arm/dts/kirkwood-ds109.dts   |  40 -
  arch/arm/dts/kirkwood-goflexnet.dts   | 190 
  .../arm/dts/kirkwood-guruplug-server-plus.dts | 133 ---
  arch/arm/dts/kirkwood-ib62x0.dts  | 146 ---
  arch/arm/dts/kirkwood-iconnect.dts| 195 
  arch/arm/dts/kirkwood-is2.dts |  40 -
  arch/arm/dts/kirkwood-lschlv2.dts |  20 -
  arch/arm/dts/kirkwood-lsxhl.dts   |  20 -
  arch/arm/dts/kirkwood-lsxl.dtsi   | 241 -
  arch/arm/dts/kirkwood-net2big.dts |  63 --
  arch/arm/dts/kirkwood-netxbig.dtsi| 232 -
  arch/arm/dts/kirkwood-ns2-common.dtsi |  97 --
  arch/arm/dts/kirkwood-ns2.dts |  40 -
  arch/arm/dts/kirkwood-ns2lite.dts |  35 -
  arch/arm/dts/kirkwood-ns2max.dts  |  59 --
  arch/arm/dts/kirkwood-ns2mini.dts |  60 --
  arch/arm/dts/kirkwood-nsa310s.dts | 319 ---
  arch/arm/dts/kirkwood-nsa325.dts  | 231 -
  arch/arm/dts/kirkwood-nsa3x0-common.dtsi  | 157 
  arch/arm/dts/kirkwood-openrd-base.dts |  39 -
  arch/arm/dts/kirkwood-openrd-client.dts   |  73 --
  arch/arm/dts/kirkwood-openrd-ultimate.dts |  55 --
  arch/arm/dts/kirkwood-openrd.dtsi | 122 ---
  arch/arm/dts/kirkwood-pogo_e02.dts| 132 ---
  arch/arm/dts/kirkwood-pogoplug-series-4.dts   | 180 
  arch/arm/dts/kirkwood-sheevaplug-common.dtsi  | 104 ---
  arch/arm/dts/kirkwood-sheevaplug.dts  |  42 -
  arch/arm/dts/kirkwood-synology.dtsi   | 855 --
  arch/arm/dts/kirkwood.dtsi| 393 
  40 files changed, 1 insertion(+), 5488 deletions(-)
  delete mode 100644 arch/arm/dts/kirkwood-6192.dtsi
  delete mode 100644 arch/arm/dts/kirkwood-6281.dtsi
  delete mode 100644 arch/arm/dts/kirkwood-6282.dtsi
  delete mode 100644 arch/arm/dts/kirkwood-98dx4122.dtsi
  delete mode 100644 arch/arm/dts/kirkwood-blackarmor-nas220.dts
  delete mode 100644 arch/arm/dts/kirkwood-d2net.dts
  delete mode 100644 arch/arm/dts/kirkwood-dns325.dts
  delete mode 100644 arch/arm/dts/kirkwood-dnskw.dtsi
  delete mode 100644 arch/arm/dts/kirkwood-dockstar.dts
  delete mode 100644 arch/arm/dts/kirkwood-dreamplug.dts
  delete mode 100644 arch/arm/dts/kirkwood-ds109.dts
  delete mode 100644 arch/arm/dts/kirkwood-goflexnet.dts
  delete mode 100644 arch/arm/dts/kirkwood-guruplug-server-plus.dts
  delete mode 100644 arch/arm/dts/kirkwood-ib62x0.dts
  delete mode 100644 arch/arm/dts/kirkwood-iconnect.dts
  delete mode 100644 arch/arm/dts/kirkwood-is2.dts
  delete mode 100644 arch/arm/dts/kirkwood-lschlv2.dts
  delete mode 100644 arch/arm/dts/kirkwood-lsxhl.dts
  delete mode 100644 arch/arm/dts/kirkwood-lsxl.dtsi
  delete mode 100644 arch/arm/dts/kirkwood-net2big.dts
  delete mode 100644 arch/arm/dts/kirkwood-netxbig.dtsi
  delete mode 100644 arch/arm/dts/kirkwood-ns2-common.dtsi
  delete mode 100644 arch/arm/dts/kirkwood-ns2.dts
  delete mode 100644 arch/arm/dts/kirkwood-ns2lite.dts
  delete mode 100644 arch/arm/dts/kirkwood-ns2max.dts
  delete mode 100644 arch/arm/dts/kirkwood-ns2mini.dts
  delete mode 100644 arch/arm/dts/kirkwood-nsa310s.dts
  delete mode 100644 arch/arm/dts/kirkwood-nsa325.dts
  delete mode 100644 arch/arm/dts/kirkwood-nsa3x0-common.dtsi
  delete mode 100644 arch/arm/dts/kirkwood-openrd-base.dts
  delete mode 100644 arch/arm/dts/kirkwood-openrd-client.dts
  delete mode 100644 arch/arm/dts/kirkwood-openrd-ultimate.dts
  delete mode 100644 arch/arm/dts/kirkwood-openrd.dtsi
  delete mode 100644 arch/arm/dts/kirkwood-pogo_e02.dts
  delete mode 100644 arch/arm/dts/kirkwood-pogoplug-series-4.dts
  delete mode 100644 arch/arm/dts/kirkwood-sheevaplug-common.dtsi
  delete mode 100644 arch/arm/dts/kirkwood-sheevaplug.dts
  delete mode 100644 arch/arm/dts/kirkwood-synology.dtsi
  delete mode 100644 arch/arm/dts/kirkwood.dtsi

diff --git a/arch/arm/dts/Makefile 

Please pull u-boot-marvell/master

2024-04-04 Thread Stefan Roese

Hi Tom,

please pull the first batch of mostly Marvell related patches:


- kirkwood: Switch to using upstream dts/dtsi files (Tony)
- mvebu: Turris Omnia - New board revision support (Marek)


Here the Azure build, without any issues:

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

Thanks,
Stefan

The following changes since commit cdfcc37428e06f4730ab9a17cc084eeb7676ea1a:

  Merge tag 'u-boot-dfu-next-20240402' of 
https://source.denx.de/u-boot/custodians/u-boot-dfu (2024-04-02 22:37:23 
-0400)


are available in the Git repository at:

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

for you to fetch changes up to 53bdcd1e9eacd6992d990b288fd6d48f43d94a0b:

  arm: mvebu: turris_omnia: Enable rng command in defconfig (2024-04-04 
10:45:27 +0200)



Marek Behún (18):
  arm: mvebu: turris_omnia: Enable LTO by default on Turris Omnia
  arm: mvebu: turris_omnia: Add header containing MCU command 
interface and use it

  arm: mvebu: turris_{omnia, mox}: Don't print model two times
  arm: mvebu: turris_omnia: Update MCU status and features reading
  arm: mvebu: turris_omnia: Implement getting board information 
from MCU

  arm: mvebu: turris_omnia: Print board ECDSA public key if available
  arm: mvebu: turris_omnia: Disable Atmel SHA node if not present
  arm: mvebu: spl: Do not build mvebu-reset in SPL
  arm: mvebu: system-controller: Rework to use UCLASS_SYSCON
  arm: mvebu: system-controller: Select mvebu-reset if DM_RESET && 
PCI_MVEBU

  arm: mvebu: system-controller: Add support for SYSRESET
  gpio: turris_omnia_mcu: Use byteorder conversion functions
  gpio: turris_omnia_mcu: Update firmware features reading
  gpio: turris_omnia_mcu: Add support for system power off via sysreset
  arm: mvebu: turris_omnia: Enable poweroff command via sysreset in 
defconfig

  cmd: rng: Print "Abort" on -EINTR
  misc: turris_omnia_mcu: Add support for rng provided by MCU
  arm: mvebu: turris_omnia: Enable rng command in defconfig

Tony Dinh (2):
  arm: dts: kirkwood: Enable upstream DT on Kirkwood boards
  arm: dts: kirkwood: Remove DTS files for Kirkwood boards

 arch/arm/dts/Makefile  |  28 +-
 arch/arm/dts/kirkwood-6192.dtsi|  88 ---
 arch/arm/dts/kirkwood-6281.dtsi|  90 ---
 arch/arm/dts/kirkwood-6282.dtsi| 161 -
 arch/arm/dts/kirkwood-98dx4122.dtsi|  53 --
 arch/arm/dts/kirkwood-blackarmor-nas220.dts| 172 -
 arch/arm/dts/kirkwood-d2net.dts|  45 --
 arch/arm/dts/kirkwood-dns325.dts   |  63 --
 arch/arm/dts/kirkwood-dnskw.dtsi   | 235 ---
 arch/arm/dts/kirkwood-dockstar.dts | 110 
 arch/arm/dts/kirkwood-dreamplug-u-boot.dtsi|   7 +
 arch/arm/dts/kirkwood-dreamplug.dts| 131 
 arch/arm/dts/kirkwood-ds109.dts|  40 --
 arch/arm/dts/kirkwood-goflexnet.dts| 190 --
 arch/arm/dts/kirkwood-guruplug-server-plus.dts | 133 
 arch/arm/dts/kirkwood-ib62x0.dts   | 146 -
 arch/arm/dts/kirkwood-iconnect.dts | 195 --
 arch/arm/dts/kirkwood-is2.dts  |  40 --
 arch/arm/dts/kirkwood-lschlv2-u-boot.dtsi  |   6 +-
 arch/arm/dts/kirkwood-lschlv2.dts  |  20 -
 arch/arm/dts/kirkwood-lsxhl-u-boot.dtsi|   6 +-
 arch/arm/dts/kirkwood-lsxhl.dts|  20 -
 arch/arm/dts/kirkwood-lsxl.dtsi| 241 ---
 arch/arm/dts/kirkwood-net2big.dts  |  63 --
 arch/arm/dts/kirkwood-netxbig.dtsi | 232 ---
 arch/arm/dts/kirkwood-ns2-common.dtsi  |  97 ---
 arch/arm/dts/kirkwood-ns2.dts  |  40 --
 arch/arm/dts/kirkwood-ns2lite.dts  |  35 -
 arch/arm/dts/kirkwood-ns2max.dts   |  59 --
 arch/arm/dts/kirkwood-ns2mini.dts  |  60 --
 arch/arm/dts/kirkwood-nsa310s.dts  | 319 -
 arch/arm/dts/kirkwood-nsa325-u-boot.dtsi   |   7 +
 arch/arm/dts/kirkwood-nsa325.dts   | 231 ---
 arch/arm/dts/kirkwood-nsa3x0-common.dtsi   | 157 -
 arch/arm/dts/kirkwood-openrd-base.dts  |  39 --
 arch/arm/dts/kirkwood-openrd-client.dts|  73 ---
 arch/arm/dts/kirkwood-openrd-ultimate.dts  |  55 --
 arch/arm/dts/kirkwood-openrd.dtsi  | 122 
 arch/arm/dts/kirkwood-pogo_e02.dts | 132 
 arch/arm/dts/kirkwood-pogoplug-series-4.dts| 180 --
 arch/arm/dts/kirkwood-sheevaplug-common.dtsi   | 104 ---
 arch/arm/dts/kirkwood-sheevaplug.dts   |  42 --
 arch/arm/dts/kirkwood-synology.dtsi| 855 
-

 arch/arm/dts/kirkwood.dtsi | 393 
 

Re: [PATCH v3] arm: dts: kirkwood: Enable upstream DT on Kirkwood boards

2024-04-04 Thread Stefan Roese

On 4/2/24 00:08, Tony Dinh wrote:

Enable OF_UPSTREAM to use upstream DT and add marvell/ prefix to the
DEFAULT_DEVICE_TREE for Kirkwood boards. And so we can directly build
DTBs from dts/upstream/src/arm/marvell, and including *-u-boot.dtsi
files from arch/arm/dts/ directory.

Background:

The following 2 commands and filters were used in the analysis to determine
which upstream DTS and DTSI files can be used as they are, or need to have
modified/created *-u-boot.dtsi for u-boot specific implementation, and
which board should be opt-out from OF_UPSTREAM.

"git grep -li arch_kirkwood configs | xargs grep DEVICE_TREE | cut -d '"' -f2 | 
xargs -n1 sh -c 'diff -qs  arch/arm/dts/$1.dts dts/upstream/src/arm/marvell/$1.dts' sh | grep 
differ"
"diff -qrbu arch/arm/dts/ dts/upstream/src/arm/marvell/ | grep kirkwood | grep ".dtsi 
""

More detailed information can be found at:
https://lore.kernel.org/u-boot/20240328021825.17935-1-mibo...@gmail.com/T/#u

I've regression tested this patch with the Zyxel NSA325 (Kirkwood 88F6282)
and Zyxel NSA310S (Kirkwood 88F6281). The Zyxel NSA325 board has a
USB 3.0 controller attached to the PCIe bus. And the Zyxel NSA310S
has an extensive overhaul in bindings and styles in upstream DTS version.

Tested-by: Michael Walle  # on lschv2
Acked-by: Sumit Garg 
Reviewed-by: Stefan Roese 

Signed-off-by: Tony Dinh 


Applied to u-boot-marvell/master

Thanks,
Stefan


---

Changes in v3:
- Collect Reviewed/Tested/Acked-by tags.
- Trim the commit description and point to lore.kernel.org for detailed 
information.
- No change from the V2 patch.

Changes in v2:
Remove unnecessary redefined OF_UPSTREAM and use "imply OF_UPSTREAM" for
KW88F6281 and KW88F6192 SoCs.

  arch/arm/dts/kirkwood-dreamplug-u-boot.dtsi | 7 +++
  arch/arm/dts/kirkwood-lschlv2-u-boot.dtsi   | 6 --
  arch/arm/dts/kirkwood-lsxhl-u-boot.dtsi | 6 --
  arch/arm/dts/kirkwood-nsa325-u-boot.dtsi| 7 +++
  arch/arm/mach-kirkwood/Kconfig  | 2 ++
  configs/SBx81LIFKW_defconfig| 1 +
  configs/SBx81LIFXCAT_defconfig  | 1 +
  configs/d2net_v2_defconfig  | 2 +-
  configs/dns325_defconfig| 2 +-
  configs/dockstar_defconfig  | 2 +-
  configs/dreamplug_defconfig | 2 +-
  configs/ds109_defconfig | 2 +-
  configs/goflexhome_defconfig| 2 +-
  configs/guruplug_defconfig  | 2 +-
  configs/ib62x0_defconfig| 2 +-
  configs/iconnect_defconfig  | 2 +-
  configs/inetspace_v2_defconfig  | 2 +-
  configs/lschlv2_defconfig   | 2 +-
  configs/lsxhl_defconfig | 2 +-
  configs/nas220_defconfig| 2 +-
  configs/net2big_v2_defconfig| 2 +-
  configs/netspace_lite_v2_defconfig  | 2 +-
  configs/netspace_max_v2_defconfig   | 2 +-
  configs/netspace_mini_v2_defconfig  | 2 +-
  configs/netspace_v2_defconfig   | 2 +-
  configs/nsa310s_defconfig   | 2 +-
  configs/nsa325_defconfig| 2 +-
  configs/openrd_base_defconfig   | 2 +-
  configs/openrd_client_defconfig | 2 +-
  configs/openrd_ultimate_defconfig   | 2 +-
  configs/pogo_e02_defconfig  | 2 +-
  configs/pogo_v4_defconfig   | 2 +-
  configs/sheevaplug_defconfig| 2 +-
  33 files changed, 52 insertions(+), 30 deletions(-)
  create mode 100644 arch/arm/dts/kirkwood-dreamplug-u-boot.dtsi
  create mode 100644 arch/arm/dts/kirkwood-nsa325-u-boot.dtsi

diff --git a/arch/arm/dts/kirkwood-dreamplug-u-boot.dtsi 
b/arch/arm/dts/kirkwood-dreamplug-u-boot.dtsi
new file mode 100644
index 00..59f19a211f
--- /dev/null
+++ b/arch/arm/dts/kirkwood-dreamplug-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/ {
+   aliases {
+   spi0 = 
+   };
+};
diff --git a/arch/arm/dts/kirkwood-lschlv2-u-boot.dtsi 
b/arch/arm/dts/kirkwood-lschlv2-u-boot.dtsi
index 7fc2d7d3b4..cf33ff822e 100644
--- a/arch/arm/dts/kirkwood-lschlv2-u-boot.dtsi
+++ b/arch/arm/dts/kirkwood-lschlv2-u-boot.dtsi
@@ -1,7 +1,9 @@
  // SPDX-License-Identifier: GPL-2.0+
  
- {

-   status = "disabled";
+/ {
+   aliases {
+   spi0 = 
+   };
  };
  
  _power {

diff --git a/arch/arm/dts/kirkwood-lsxhl-u-boot.dtsi 
b/arch/arm/dts/kirkwood-lsxhl-u-boot.dtsi
index 7fc2d7d3b4..cf33ff822e 100644
--- a/arch/arm/dts/kirkwood-lsxhl-u-boot.dtsi
+++ b/arch/arm/dts/kirkwood-lsxhl-u-boot.dtsi
@@ -1,7 +1,9 @@
  // SPDX-License-Identifier: GPL-2.0+
  
- {

-   status = "disabled";
+/ {
+   aliases {
+   spi0 = 
+   };
  };
  
  _power {

diff --git a/arch/arm/dts/kirkwood-nsa325-u-boot.dtsi 
b/arch/arm/dts/kirkwood-nsa325-u-boot.dtsi
new file mode 100644
index 00..dec27b

Re: [PATCH u-boot-mvebu v4 00/18] Turris Omnia - New board revision support

2024-04-04 Thread Stefan Roese

On 4/4/24 09:50, Marek Behún wrote:

changes since v3:
- added missing files turris_common.c and turris_common.h to patch 05/18
- added comment to patch 11/18 before while (1); as discussed in v3

v1, v2 and v3 at:
   
https://patchwork.ozlabs.org/project/uboot/cover/20240304152148.3847-1-ka...@kernel.org/
   
https://patchwork.ozlabs.org/project/uboot/cover/20240323180711.5498-1-ka...@kernel.org/
   
https://patchwork.ozlabs.org/project/uboot/cover/20240327162355.24584-1-ka...@kernel.org/

Marek Behún (18):
   arm: mvebu: turris_omnia: Enable LTO by default on Turris Omnia
   arm: mvebu: turris_omnia: Add header containing MCU command interface
 and use it
   arm: mvebu: turris_{omnia, mox}: Don't print model two times
   arm: mvebu: turris_omnia: Update MCU status and features reading
   arm: mvebu: turris_omnia: Implement getting board information from MCU
   arm: mvebu: turris_omnia: Print board ECDSA public key if available
   arm: mvebu: turris_omnia: Disable Atmel SHA node if not present
   arm: mvebu: spl: Do not build mvebu-reset in SPL
   arm: mvebu: system-controller: Rework to use UCLASS_SYSCON
   arm: mvebu: system-controller: Select mvebu-reset if DM_RESET &&
 PCI_MVEBU
   arm: mvebu: system-controller: Add support for SYSRESET
   gpio: turris_omnia_mcu: Use byteorder conversion functions
   gpio: turris_omnia_mcu: Update firmware features reading
   gpio: turris_omnia_mcu: Add support for system power off via sysreset
   arm: mvebu: turris_omnia: Enable poweroff command via sysreset in
 defconfig
   cmd: rng: Print "Abort" on -EINTR
   misc: turris_omnia_mcu: Add support for rng provided by MCU
   arm: mvebu: turris_omnia: Enable rng command in defconfig

  arch/arm/mach-mvebu/Kconfig  |  25 ++
  arch/arm/mach-mvebu/Makefile |   3 +-
  arch/arm/mach-mvebu/cpu.c|   2 +
  arch/arm/mach-mvebu/system-controller.c  | 145 ++--
  board/CZ.NIC/turris_atsha_otp.c  |  27 +-
  board/CZ.NIC/turris_common.c |  42 +++
  board/CZ.NIC/turris_common.h |  10 +
  board/CZ.NIC/turris_mox/turris_mox.c |   5 +-
  board/CZ.NIC/turris_omnia/Makefile   |   2 +-
  board/CZ.NIC/turris_omnia/turris_omnia.c | 310 -
  cmd/rng.c|   7 +-
  configs/turris_omnia_defconfig   |   6 +
  drivers/gpio/Kconfig |   7 -
  drivers/gpio/Makefile|   1 -
  drivers/gpio/turris_omnia_mcu.c  | 316 -
  drivers/misc/Kconfig |  11 +
  drivers/misc/Makefile|   1 +
  drivers/misc/turris_omnia_mcu.c  | 411 +++
  include/turris-omnia-mcu-interface.h | 248 ++
  19 files changed, 1097 insertions(+), 482 deletions(-)
  create mode 100644 board/CZ.NIC/turris_common.c
  create mode 100644 board/CZ.NIC/turris_common.h
  delete mode 100644 drivers/gpio/turris_omnia_mcu.c
  create mode 100644 drivers/misc/turris_omnia_mcu.c
  create mode 100644 include/turris-omnia-mcu-interface.h


Applied to u-boot-marvell/master

Thanks,
Stefan


Re: [PATCH u-boot-mvebu v3 00/18] Turris Omnia - New board revision support

2024-04-04 Thread Stefan Roese

Hi Marek,

On 3/27/24 17:23, Marek Behún wrote:

Hi Stefan,

this is v3 of series adding support for new board revision of Turris
Omnia.

Changes since v2:
- patch 2: updated MCU command interface header
- patch 6: fixed bug setting \0 as end of string in src array instead
of dst array after bin2hex() call
- patch 16: updated commit message (added the bit about ctrl+c)

v1 and v2 at:
   
https://patchwork.ozlabs.org/project/uboot/cover/20240304152148.3847-1-ka...@kernel.org/
   
https://patchwork.ozlabs.org/project/uboot/cover/20240323180711.5498-1-ka...@kernel.org/


After pushing there changes in my current master I get these build
errors for "turris_omnia_defconfig":

make[1]: *** No rule to make target 
'board/CZ.NIC/turris_omnia/../turris_common.o', needed by 
'board/CZ.NIC/turris_omnia/built-in.o'.  Stop.

make[1]: *** Waiting for unfinished jobs
board/CZ.NIC/turris_omnia/../turris_atsha_otp.c:14:10: fatal error: 
turris_common.h: No such file or directory

   14 | #include "turris_common.h"
  |  ^
compilation terminated.
make[1]: *** [scripts/Makefile.build:257: 
board/CZ.NIC/turris_omnia/../turris_atsha_otp.o] Error 1
board/CZ.NIC/turris_omnia/turris_omnia.c:36:10: fatal error: 
../turris_common.h: No such file or directory

   36 | #include "../turris_common.h"
  |  ^~~~
compilation terminated.

Available here:

https://source.denx.de/u-boot/custodians/u-boot-marvell/-/commits/master?ref_type=heads

Could you please have a look?

Thanks,
Stefan


Marek Behún (18):
   arm: mvebu: turris_omnia: Enable LTO by default on Turris Omnia
   arm: mvebu: turris_omnia: Add header containing MCU command interface
 and use it
   arm: mvebu: turris_{omnia, mox}: Don't print model two times
   arm: mvebu: turris_omnia: Update MCU status and features reading
   arm: mvebu: turris_omnia: Implement getting board information from MCU
   arm: mvebu: turris_omnia: Print board ECDSA public key if available
   arm: mvebu: turris_omnia: Disable Atmel SHA node if not present
   arm: mvebu: spl: Do not build mvebu-reset in SPL
   arm: mvebu: system-controller: Rework to use UCLASS_SYSCON
   arm: mvebu: system-controller: Select mvebu-reset if DM_RESET &&
 PCI_MVEBU
   arm: mvebu: system-controller: Add support for SYSRESET
   gpio: turris_omnia_mcu: Use byteorder conversion functions
   gpio: turris_omnia_mcu: Update firmware features reading
   gpio: turris_omnia_mcu: Add support for system power off via sysreset
   arm: mvebu: turris_omnia: Enable poweroff command via sysreset in
 defconfig
   cmd: rng: Print "Abort" on -EINTR
   misc: turris_omnia_mcu: Add support for rng provided by MCU
   arm: mvebu: turris_omnia: Enable rng command in defconfig

  arch/arm/mach-mvebu/Kconfig  |  25 ++
  arch/arm/mach-mvebu/Makefile |   3 +-
  arch/arm/mach-mvebu/cpu.c|   2 +
  arch/arm/mach-mvebu/system-controller.c  | 144 ++--
  board/CZ.NIC/turris_atsha_otp.c  |  27 +-
  board/CZ.NIC/turris_mox/turris_mox.c |   5 +-
  board/CZ.NIC/turris_omnia/Makefile   |   2 +-
  board/CZ.NIC/turris_omnia/turris_omnia.c | 310 -
  cmd/rng.c|   7 +-
  configs/turris_omnia_defconfig   |   6 +
  drivers/gpio/Kconfig |   7 -
  drivers/gpio/Makefile|   1 -
  drivers/gpio/turris_omnia_mcu.c  | 316 -
  drivers/misc/Kconfig |  11 +
  drivers/misc/Makefile|   1 +
  drivers/misc/turris_omnia_mcu.c  | 411 +++
  include/turris-omnia-mcu-interface.h | 248 ++
  17 files changed, 1044 insertions(+), 482 deletions(-)
  delete mode 100644 drivers/gpio/turris_omnia_mcu.c
  create mode 100644 drivers/misc/turris_omnia_mcu.c
  create mode 100644 include/turris-omnia-mcu-interface.h



Viele Grüße,
Stefan Roese

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


Re: [PATCH u-boot-mvebu v3 11/18] arm: mvebu: system-controller: Add support for SYSRESET

2024-03-28 Thread Stefan Roese

On 3/28/24 12:21, Marek Behún wrote:

On Thu, 28 Mar 2024 11:04:45 +0100
Stefan Roese  wrote:


+static int mvebu_sysreset_request(struct udevice *dev, enum sysreset_t type)
+{
+   struct regmap *regmap = syscon_get_regmap(dev->parent);
+   uint bit;
+
+   if (type != SYSRESET_COLD)
+   return -EPROTONOSUPPORT;
+
+   bit = MVEBU_GLOBAL_SOFT_RST_BIT;
+
+   regmap_update_bits(regmap, MVEBU_RSTOUTN_MASK_REG, bit, bit);
+   regmap_update_bits(regmap, MVEBU_SYS_SOFT_RST_REG, bit, bit);
+
+   while (1)
+   ;


A comment before this endless loop might be helpful here.


The code does the same as reset_cpu() in cpu.c, and the while() cycle
is not commented there.


Sure, other code might suffer this undocumented endless loop as well.
And again, this is more a nitpicking comment than a real requirement.


But we can add something like
   /* something has gone wrong if we reach here, so we may as well stay
* here */

What do you think? Could you amend the patch?


More something like this:

/* Loop while waiting for the reset */
while (1)
;

And yes, I can fold this into your patchset, if I don't forget about
this. Still, if there is need for a v4, then please add it yourself.

Thanks,
Stefan


Re: [PATCH u-boot-mvebu v3 05/18] arm: mvebu: turris_omnia: Implement getting board information from MCU

2024-03-28 Thread Stefan Roese

On 3/28/24 12:17, Marek Behún wrote:

On Thu, 28 Mar 2024 10:56:01 +0100
Stefan Roese  wrote:


On 3/27/24 17:23, Marek Behún wrote:

Implement reading board serial number, first MAC address and board
version from MCU. MCU supports board information if the FEAT_BOARD_INFO
feature bit is set in MCU features.

Prefer getting board information from MCU if supported, fallback to
Atmel SHA chip.

Signed-off-by: Marek Behún 


Minor comment below. Other than this:

Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
   board/CZ.NIC/turris_atsha_otp.c  | 27 +--
   board/CZ.NIC/turris_omnia/Makefile   |  2 +-
   board/CZ.NIC/turris_omnia/turris_omnia.c | 94 +++-
   3 files changed, 93 insertions(+), 30 deletions(-)

diff --git a/board/CZ.NIC/turris_atsha_otp.c b/board/CZ.NIC/turris_atsha_otp.c
index a29fe36231..85eebcdf18 100644
--- a/board/CZ.NIC/turris_atsha_otp.c
+++ b/board/CZ.NIC/turris_atsha_otp.c
@@ -11,6 +11,7 @@
   #include 
   
   #include "turris_atsha_otp.h"

+#include "turris_common.h"
   
   #define TURRIS_ATSHA_OTP_VERSION	0

   #define TURRIS_ATSHA_OTP_SERIAL  1
@@ -32,26 +33,6 @@ static struct udevice *get_atsha204a_dev(void)
return dev;
   }
   
-static void increment_mac(u8 *mac)

-{
-   int i;
-
-   for (i = 5; i >= 3; i--) {
-   mac[i] += 1;
-   if (mac[i])
-   break;
-   }
-}
-
-static void set_mac_if_invalid(int i, u8 *mac)
-{
-   u8 oldmac[6];
-
-   if (is_valid_ethaddr(mac) &&
-   !eth_env_get_enetaddr_by_index("eth", i, oldmac))
-   eth_env_set_enetaddr_by_index("eth", i, mac);
-}
-
   int turris_atsha_otp_init_mac_addresses(int first_idx)
   {
struct udevice *dev = get_atsha204a_dev();
@@ -84,11 +65,7 @@ int turris_atsha_otp_init_mac_addresses(int first_idx)
mac[4] = mac1[2];
mac[5] = mac1[3];
   
-	set_mac_if_invalid((first_idx + 0) % 3, mac);

-   increment_mac(mac);
-   set_mac_if_invalid((first_idx + 1) % 3, mac);
-   increment_mac(mac);
-   set_mac_if_invalid((first_idx + 2) % 3, mac);
+   turris_init_mac_addresses(first_idx, mac);
   
   	return 0;

   }
diff --git a/board/CZ.NIC/turris_omnia/Makefile 
b/board/CZ.NIC/turris_omnia/Makefile
index dc39b44ae1..341378b4e5 100644
--- a/board/CZ.NIC/turris_omnia/Makefile
+++ b/board/CZ.NIC/turris_omnia/Makefile
@@ -2,4 +2,4 @@
   #
   # Copyright (C) 2017 Marek Behún 
   
-obj-y	:= turris_omnia.o ../turris_atsha_otp.o

+obj-y  := turris_omnia.o ../turris_atsha_otp.o ../turris_common.o
diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c 
b/board/CZ.NIC/turris_omnia/turris_omnia.c
index 6dfde5ee7a..f63640ad64 100644
--- a/board/CZ.NIC/turris_omnia/turris_omnia.c
+++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
@@ -18,6 +18,7 @@
   #include 
   #include 
   #include 
+#include 
   #include 
   #include 
   #include 
@@ -25,12 +26,14 @@
   #include 
   #include 
   #include 
+#include 
   #include 
   #include 
   
   #include "../drivers/ddr/marvell/a38x/ddr3_init.h"

   #include <../serdes/a38x/high_speed_env_spec.h>
   #include "../turris_atsha_otp.h"
+#include "../turris_common.h"
   
   DECLARE_GLOBAL_DATA_PTR;
   
@@ -186,6 +189,70 @@ static bool omnia_mcu_has_feature(u32 feature)

return feature & features;
   }
   
+static u32 omnia_mcu_crc32(const void *p, size_t len)

+{
+   u32 val, crc = 0;
+
+   compiletime_assert(!(len % 4), "length has to be a multiple of 4");
+
+   while (len) {
+   val = bitrev32(get_unaligned_le32(p));
+   crc = crc32(crc, (void *), 4);
+   p += 4;
+   len -= 4;
+   }
+
+   return ~bitrev32(crc);
+}
+
+/* Can only be called after relocation, since it needs cleared BSS */
+static int omnia_mcu_board_info(char *serial, u8 *mac, char *version)
+{
+   static u8 reply[17];
+   static bool cached;
+
+   if (!cached) {
+   u8 csum;
+   int ret;
+
+   ret = omnia_mcu_read(CMD_BOARD_INFO_GET, reply, sizeof(reply));
+   if (ret)
+   return ret;
+
+   if (reply[0] != 16)
+   return -EBADMSG;
+
+   csum = reply[16];
+   reply[16] = 0;
+
+   if ((omnia_mcu_crc32([1], 16) & 0xff) != csum)
+   return -EBADMSG;
+
+   cached = true;
+   }
+
+   if (serial) {
+   const char *serial_env;
+
+   serial_env = env_get("serial#");
+   if (serial_env && strlen(serial_env) == 16) {
+   strcpy(serial, serial_env);


Usage of strcpy() is discouraged AFAIK.


Yeah, it would make sense to use strncpy, but the potential leak is
prevented by strlen() check.


strncpy is also not optimal. Please see here if you are interes

Re: [PATCH u-boot-mvebu v3 18/18] arm: mvebu: turris_omnia: Enable rng command in defconfig

2024-03-28 Thread Stefan Roese

On 3/27/24 17:23, Marek Behún wrote:

Now that Turris Omnia has a rng driver provided in the MCU driver,
enable the rng command in defconfig.

Signed-off-by: Marek Behún 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  configs/turris_omnia_defconfig | 1 +
  1 file changed, 1 insertion(+)

diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig
index 4c21635ec9..f2b39115fe 100644
--- a/configs/turris_omnia_defconfig
+++ b/configs/turris_omnia_defconfig
@@ -73,6 +73,7 @@ CONFIG_CMD_WDT=y
  CONFIG_CMD_TFTPPUT=y
  CONFIG_CMD_CACHE=y
  CONFIG_CMD_TIME=y
+CONFIG_CMD_RNG=y
  CONFIG_CMD_AES=y
  CONFIG_CMD_HASH=y
  CONFIG_CMD_BTRFS=y


Viele Grüße,
Stefan Roese

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


Re: [PATCH u-boot-mvebu v3 17/18] misc: turris_omnia_mcu: Add support for rng provided by MCU

2024-03-28 Thread Stefan Roese

On 3/27/24 17:23, Marek Behún wrote:

Add support for true random number generator provided by the MCU on
Turris Omnia. The MCU firmware supports TRNG if the FEAT_TRNG bit is set
in features. In that case we bind the rng driver.

Signed-off-by: Marek Behún 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  configs/turris_omnia_defconfig  |  1 +
  drivers/misc/Kconfig|  1 +
  drivers/misc/turris_omnia_mcu.c | 57 +
  3 files changed, 59 insertions(+)

diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig
index 0df0f3c90b..4c21635ec9 100644
--- a/configs/turris_omnia_defconfig
+++ b/configs/turris_omnia_defconfig
@@ -107,6 +107,7 @@ CONFIG_NVME_PCI=y
  CONFIG_PCI_MVEBU=y
  CONFIG_PINCTRL=y
  CONFIG_PINCTRL_ARMADA_38X=y
+CONFIG_DM_RNG=y
  CONFIG_DM_RTC=y
  CONFIG_RTC_ARMADA38X=y
  CONFIG_SERIAL_PROBE_ALL=y
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 844a21be47..a08f02196f 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -509,6 +509,7 @@ config TURRIS_OMNIA_MCU
bool "Enable Turris Omnia MCU driver"
depends on DM_I2C
depends on DM_GPIO
+   depends on DM_RNG
depends on SYSRESET
default y if TARGET_TURRIS_OMNIA
help
diff --git a/drivers/misc/turris_omnia_mcu.c b/drivers/misc/turris_omnia_mcu.c
index 77a0424d61..6b2f17c000 100644
--- a/drivers/misc/turris_omnia_mcu.c
+++ b/drivers/misc/turris_omnia_mcu.c
@@ -5,15 +5,20 @@
   */
  
  #include 

+#include 
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
  #include 
+#include 
  #include 
  
+#define CMD_TRNG_MAX_ENTROPY_LEN	64

+
  struct turris_omnia_mcu_info {
u32 features;
  };
@@ -282,6 +287,49 @@ U_BOOT_DRIVER(turris_omnia_mcu_sysreset) = {
.ops= _sysreset_ops,
  };
  
+static int omnia_rng_read(struct udevice *dev, void *data, size_t count)

+{
+   u8 buf[1 + CMD_TRNG_MAX_ENTROPY_LEN];
+   size_t len;
+   int ret;
+
+   while (count) {
+   ret = dm_i2c_read(dev->parent, CMD_TRNG_COLLECT_ENTROPY, buf,
+ sizeof(buf));
+   if (ret)
+   return ret;
+
+   len = min_t(size_t, buf[0],
+   min_t(size_t, CMD_TRNG_MAX_ENTROPY_LEN, count));
+
+   if (!len) {
+   /* wait 500ms (fail if interrupted), then try again */
+   for (int i = 0; i < 5; ++i) {
+   mdelay(100);
+   if (ctrlc())
+   return -EINTR;
+   }
+   continue;
+   }
+
+   memcpy(data, [1], len);
+   data += len;
+   count -= len;
+   }
+
+   return 0;
+}
+
+static const struct dm_rng_ops omnia_rng_ops = {
+   .read   = omnia_rng_read,
+};
+
+U_BOOT_DRIVER(turris_omnia_mcu_trng) = {
+   .name   = "turris-omnia-mcu-trng",
+   .id = UCLASS_RNG,
+   .ops= _rng_ops,
+};
+
  static int turris_omnia_mcu_bind(struct udevice *dev)
  {
/* bind MCU GPIOs as a child device */
@@ -336,6 +384,15 @@ static int turris_omnia_mcu_probe(struct udevice *dev)
return ret;
}
  
+	/* bind rng if trng is supported */

+   if (info->features & FEAT_TRNG) {
+   ret = device_bind_driver_to_node(dev, "turris-omnia-mcu-trng",
+"turris-omnia-mcu-trng",
+dev_ofnode(dev), NULL);
+   if (ret < 0)
+   return ret;
+   }
+
return 0;
  }
  


Viele Grüße,
Stefan Roese

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


Re: [PATCH u-boot-mvebu v3 16/18] cmd: rng: Print "Abort" on -EINTR

2024-03-28 Thread Stefan Roese

On 3/27/24 17:23, Marek Behún wrote:

In the rng command, print
   Abort
instead of
   Reading RNG failed
if the error number is -EINTR, which can happen if the user pressed
CTRL-C.

Signed-off-by: Marek Behún 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


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

diff --git a/cmd/rng.c b/cmd/rng.c
index 52f722c7af..48ba67061b 100644
--- a/cmd/rng.c
+++ b/cmd/rng.c
@@ -17,7 +17,7 @@ static int do_rng(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
u8 buf[64];
int devnum;
struct udevice *dev;
-   int ret = CMD_RET_SUCCESS;
+   int ret = CMD_RET_SUCCESS, err;
  
  	switch (argc) {

case 1:
@@ -46,8 +46,9 @@ static int do_rng(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
  
  	n = min(n, sizeof(buf));
  
-	if (dm_rng_read(dev, buf, n)) {

-   printf("Reading RNG failed\n");
+   err = dm_rng_read(dev, buf, n);
+   if (err) {
+   puts(err == -EINTR ? "Abort\n" : "Reading RNG failed\n");
ret = CMD_RET_FAILURE;
} else {
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, buf, n);


Viele Grüße,
Stefan Roese

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


Re: [PATCH u-boot-mvebu v3 15/18] arm: mvebu: turris_omnia: Enable poweroff command via sysreset in defconfig

2024-03-28 Thread Stefan Roese

On 3/27/24 17:23, Marek Behún wrote:

Enable support for the poweroff command via sysreset for Turris Omnia.

Signed-off-by: Marek Behún 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  configs/turris_omnia_defconfig | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig
index 9d5171c6a8..0df0f3c90b 100644
--- a/configs/turris_omnia_defconfig
+++ b/configs/turris_omnia_defconfig
@@ -65,6 +65,7 @@ CONFIG_CMD_I2C=y
  CONFIG_CMD_MMC=y
  CONFIG_CMD_MTD=y
  CONFIG_CMD_PCI=y
+CONFIG_CMD_POWEROFF=y
  CONFIG_CMD_SATA=y
  CONFIG_CMD_SPI=y
  CONFIG_CMD_USB=y
@@ -114,6 +115,7 @@ CONFIG_DEBUG_UART_SHIFT=2
  CONFIG_SYS_NS16550=y
  CONFIG_KIRKWOOD_SPI=y
  CONFIG_SYSRESET=y
+CONFIG_SYSRESET_CMD_POWEROFF=y
  CONFIG_USB=y
  CONFIG_USB_XHCI_HCD=y
  CONFIG_USB_EHCI_HCD=y


Viele Grüße,
Stefan Roese

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


Re: [PATCH u-boot-mvebu v3 14/18] gpio: turris_omnia_mcu: Add support for system power off via sysreset

2024-03-28 Thread Stefan Roese

On 3/27/24 17:23, Marek Behún wrote:

Add support for system power off via UCLASS_SYSRESET. Newer versions of
Turris Omnia MCU firmware can power off the board (MCU will disable
almost all voltage regulators and go into low power mode).

Move the MCU driver into drivers/misc and register it under UCLASS_MISC.
The sysreset and gpio device are bound as child devices of the MCU device.

Signed-off-by: Marek Behún 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  configs/turris_omnia_defconfig|   1 +
  drivers/gpio/Kconfig  |   7 -
  drivers/gpio/Makefile |   1 -
  drivers/misc/Kconfig  |  10 ++
  drivers/misc/Makefile |   1 +
  drivers/{gpio => misc}/turris_omnia_mcu.c | 150 --
  6 files changed, 120 insertions(+), 50 deletions(-)
  rename drivers/{gpio => misc}/turris_omnia_mcu.c (60%)

diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig
index 39e15043df..9d5171c6a8 100644
--- a/configs/turris_omnia_defconfig
+++ b/configs/turris_omnia_defconfig
@@ -113,6 +113,7 @@ CONFIG_SPL_DEBUG_UART_BASE=0xd0012000
  CONFIG_DEBUG_UART_SHIFT=2
  CONFIG_SYS_NS16550=y
  CONFIG_KIRKWOOD_SPI=y
+CONFIG_SYSRESET=y
  CONFIG_USB=y
  CONFIG_USB_XHCI_HCD=y
  CONFIG_USB_EHCI_HCD=y
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index 2df3dc42d0..020c6ae74c 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -662,13 +662,6 @@ config SLG7XL45106_I2C_GPO
   8-bit gpo expander, all gpo lines are controlled by writing
   value into data register.
  
-config TURRIS_OMNIA_MCU

-   bool "Turris Omnia MCU GPIO driver"
-   depends on DM_GPIO
-   default y if TARGET_TURRIS_OMNIA
-   help
-  Support for GPIOs on MCU connected to Turris Omnia via i2c.
-
  config FTGPIO010
bool "Faraday Technology FTGPIO010 driver"
depends on DM_GPIO
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index da3da5da2b..d637895c7a 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -73,7 +73,6 @@ obj-$(CONFIG_$(SPL_)MAX77663_GPIO)+= max77663_gpio.o
  obj-$(CONFIG_SL28CPLD_GPIO)   += sl28cpld-gpio.o
  obj-$(CONFIG_ZYNQMP_GPIO_MODEPIN) += zynqmp_gpio_modepin.o
  obj-$(CONFIG_SLG7XL45106_I2C_GPO) += gpio_slg7xl45106.o
-obj-$(CONFIG_$(SPL_TPL_)TURRIS_OMNIA_MCU)  += turris_omnia_mcu.o
  obj-$(CONFIG_FTGPIO010)   += ftgpio010.o
  obj-$(CONFIG_ADP5585_GPIO)+= adp5585_gpio.o
  obj-$(CONFIG_RZG2L_GPIO)  += rzg2l-gpio.o
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index f11ce72525..844a21be47 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -505,6 +505,16 @@ config TEST_DRV
  model. This should only be enabled for testing as it is not useful for
  anything else.
  
+config TURRIS_OMNIA_MCU

+   bool "Enable Turris Omnia MCU driver"
+   depends on DM_I2C
+   depends on DM_GPIO
+   depends on SYSRESET
+   default y if TARGET_TURRIS_OMNIA
+   help
+ This enables support for Turris Omnia MCU connected GPIOs and
+ board power off.
+
  config USB_HUB_USB251XB
tristate "USB251XB Hub Controller Configuration Driver"
depends on I2C
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 0432db6ed1..3cd8e2fd48 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -81,6 +81,7 @@ obj-$(CONFIG_SYS_DPAA_QBMAN) += fsl_portals.o
  obj-$(CONFIG_TEGRA186_BPMP) += tegra186_bpmp.o
  obj-$(CONFIG_TEGRA_CAR) += tegra_car.o
  obj-$(CONFIG_TEST_DRV) += test_drv.o
+obj-$(CONFIG_$(SPL_TPL_)TURRIS_OMNIA_MCU) += turris_omnia_mcu.o
  obj-$(CONFIG_TWL4030_LED) += twl4030_led.o
  obj-$(CONFIG_VEXPRESS_CONFIG) += vexpress_config.o
  obj-$(CONFIG_WINBOND_W83627) += winbond_w83627.o
diff --git a/drivers/gpio/turris_omnia_mcu.c b/drivers/misc/turris_omnia_mcu.c
similarity index 60%
rename from drivers/gpio/turris_omnia_mcu.c
rename to drivers/misc/turris_omnia_mcu.c
index 40ced261e3..77a0424d61 100644
--- a/drivers/gpio/turris_omnia_mcu.c
+++ b/drivers/misc/turris_omnia_mcu.c
@@ -1,9 +1,14 @@
  // SPDX-License-Identifier: GPL-2.0+
-// (C) 2022 Pali Rohár 
+/*
+ * Copyright (C) 2022 Pali Rohár 
+ * Copyright (C) 2024 Marek Behún 
+ */
  
  #include 

  #include 
+#include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -13,9 +18,9 @@ struct turris_omnia_mcu_info {
u32 features;
  };
  
-static int turris_omnia_mcu_get_function(struct udevice *dev, uint offset)

+static int omnia_gpio_get_function(struct udevice *dev, uint offset)
  {
-   struct turris_omnia_mcu_info *info = dev_get_plat(dev);
+   struct turris_omnia_mcu_info *info = dev_get_priv(dev->parent);
  
  	switch (offset) {

/* bank 0 */
@@ -49,9 +54,9 @@ static int turris_omnia_mcu_get_function(struct udevice *dev, 
uint offset)
}
  }
  
-static int turris_omn

Re: [PATCH u-boot-mvebu v3 13/18] gpio: turris_omnia_mcu: Update firmware features reading

2024-03-28 Thread Stefan Roese

On 3/27/24 17:23, Marek Behún wrote:

Update firmware features reading to try reading 32 bits of features and
fallback to reading 16 bits.

Signed-off-by: Marek Behún 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  drivers/gpio/turris_omnia_mcu.c | 32 ++--
  1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/drivers/gpio/turris_omnia_mcu.c b/drivers/gpio/turris_omnia_mcu.c
index c441d07d69..40ced261e3 100644
--- a/drivers/gpio/turris_omnia_mcu.c
+++ b/drivers/gpio/turris_omnia_mcu.c
@@ -10,7 +10,7 @@
  #include 
  
  struct turris_omnia_mcu_info {

-   u16 features;
+   u32 features;
  };
  
  static int turris_omnia_mcu_get_function(struct udevice *dev, uint offset)

@@ -228,25 +228,37 @@ static int turris_omnia_mcu_probe(struct udevice *dev)
  {
struct turris_omnia_mcu_info *info = dev_get_plat(dev);
struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
-   u16 val;
+   u32 dword;
+   u16 word;
int ret;
  
-	ret = dm_i2c_read(dev, CMD_GET_STATUS_WORD, (void *), sizeof(val));

+   ret = dm_i2c_read(dev, CMD_GET_STATUS_WORD, (void *), 
sizeof(word));
if (ret < 0) {
printf("Error: turris_omnia_mcu CMD_GET_STATUS_WORD failed: 
%d\n",
   ret);
return ret;
}
  
-	if (le16_to_cpu(val) & STS_FEATURES_SUPPORTED) {

-   ret = dm_i2c_read(dev, CMD_GET_FEATURES, (void *),
- sizeof(val));
+   if (le16_to_cpu(word) & STS_FEATURES_SUPPORTED) {
+   /* try read 32-bit features */
+   ret = dm_i2c_read(dev, CMD_GET_FEATURES, (void *),
+ sizeof(dword));
if (ret < 0) {
-   printf("Error: turris_omnia_mcu CMD_GET_FEATURES failed: 
%d\n",
-  ret);
-   return ret;
+   /* try read 16-bit features */
+   ret = dm_i2c_read(dev, CMD_GET_FEATURES, (void *),
+ sizeof(word));
+   if (ret < 0) {
+   printf("Error: turris_omnia_mcu CMD_GET_FEATURES 
failed: %d\n",
+  ret);
+   return ret;
+   }
+
+   info->features = le16_to_cpu(word);
+   } else {
+   info->features = le32_to_cpu(dword);
+   if (info->features & FEAT_FROM_BIT_16_INVALID)
+   info->features &= GENMASK(15, 0);
}
-   info->features = le16_to_cpu(val);
    }
  
  	uc_priv->bank_name = "mcu_";


Viele Grüße,
Stefan Roese

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


Re: [PATCH u-boot-mvebu v3 12/18] gpio: turris_omnia_mcu: Use byteorder conversion functions

2024-03-28 Thread Stefan Roese

On 3/27/24 17:23, Marek Behún wrote:

Use byteorder conversion function instead of manually assembling data
from/to MCU.

Signed-off-by: Marek Behún 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  drivers/gpio/turris_omnia_mcu.c | 80 +++--
  1 file changed, 46 insertions(+), 34 deletions(-)

diff --git a/drivers/gpio/turris_omnia_mcu.c b/drivers/gpio/turris_omnia_mcu.c
index da9a6efe6d..c441d07d69 100644
--- a/drivers/gpio/turris_omnia_mcu.c
+++ b/drivers/gpio/turris_omnia_mcu.c
@@ -5,6 +5,7 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  
@@ -51,27 +52,31 @@ static int turris_omnia_mcu_get_function(struct udevice *dev, uint offset)

  static int turris_omnia_mcu_get_value(struct udevice *dev, uint offset)
  {
struct turris_omnia_mcu_info *info = dev_get_plat(dev);
-   u8 val16[2];
-   u8 val32[4];
+   u32 val32;
+   u16 val16;
int ret;
  
  	switch (offset) {

/* bank 0 */
case 0 ... 15:
-   ret = dm_i2c_read(dev, CMD_GET_STATUS_WORD, val16, 2);
+   ret = dm_i2c_read(dev, CMD_GET_STATUS_WORD, (void *),
+ sizeof(val16));
if (ret)
return ret;
-   return u16)val16[1] << 8) | val16[0]) >> offset) & 0x1;
+
+   return !!(le16_to_cpu(val16) & BIT(offset));
  
  	/* bank 1 - supported only when FEAT_EXT_CMDS is set */

case (16 + 0) ... (16 + 31):
if (!(info->features & FEAT_EXT_CMDS))
return -EINVAL;
-   ret = dm_i2c_read(dev, CMD_GET_EXT_STATUS_DWORD, val32, 4);
+
+   ret = dm_i2c_read(dev, CMD_GET_EXT_STATUS_DWORD, (void *),
+ sizeof(val32));
if (ret)
return ret;
-   return u32)val32[3] << 24) | ((u32)val32[2] << 16) |
-((u32)val32[1] << 8) | val32[0]) >> (offset - 16)) & 
0x1;
+
+   return !!(le32_to_cpu(val32) & BIT(offset - 16));
  
  	/* bank 2 - supported only when FEAT_EXT_CMDS and FEAT_PERIPH_MCU is set */

case (16 + 32 + 0) ... (16 + 32 + 15):
@@ -79,10 +84,13 @@ static int turris_omnia_mcu_get_value(struct udevice *dev, 
uint offset)
return -EINVAL;
if (!(info->features & FEAT_PERIPH_MCU))
return -EINVAL;
-   ret = dm_i2c_read(dev, CMD_GET_EXT_CONTROL_STATUS, val16, 2);
+
+   ret = dm_i2c_read(dev, CMD_GET_EXT_CONTROL_STATUS,
+ (void *), sizeof(val16));
if (ret)
return ret;
-   return u16)val16[1] << 8) | val16[0]) >> (offset - 16 - 32)) 
& 0x1;
+
+   return !!(le16_to_cpu(val16) & BIT(offset - 16 - 32));
  
  	default:

return -EINVAL;
@@ -92,30 +100,33 @@ static int turris_omnia_mcu_get_value(struct udevice *dev, 
uint offset)
  static int turris_omnia_mcu_set_value(struct udevice *dev, uint offset, int 
value)
  {
struct turris_omnia_mcu_info *info = dev_get_plat(dev);
-   u8 val16[2];
-   u8 val32[4];
+   u16 valmask16[2];
+   u8 valmask8[2];
  
  	switch (offset) {

/* bank 0 */
case 0 ... 15:
switch (offset) {
case ilog2(STS_USB30_PWRON):
-   val16[1] = CTL_USB30_PWRON;
+   valmask8[1] = CTL_USB30_PWRON;
break;
case ilog2(STS_USB31_PWRON):
-   val16[1] = CTL_USB31_PWRON;
+   valmask8[1] = CTL_USB31_PWRON;
break;
case ilog2(STS_ENABLE_4V5):
-   val16[1] = CTL_ENABLE_4V5;
+   valmask8[1] = CTL_ENABLE_4V5;
break;
case ilog2(STS_BUTTON_MODE):
-   val16[1] = CTL_BUTTON_MODE;
+   valmask8[1] = CTL_BUTTON_MODE;
break;
default:
return -EINVAL;
}
-   val16[0] = value ? val16[1] : 0;
-   return dm_i2c_write(dev, CMD_GENERAL_CONTROL, val16, 
sizeof(val16));
+
+   valmask8[0] = value ? valmask8[1] : 0;
+
+   return dm_i2c_write(dev, CMD_GENERAL_CONTROL, valmask8,
+   sizeof(valmask8));
  
  	/* bank 2 - supported only when FEAT_EXT_CMDS and FEAT_PERIPH_MCU is set */

case (16 + 32 + 0) ... (16 + 32 + 15):
@@ -123,11 +134,12 @@ static int turris_omnia_mcu_set_value(struct udevice 
*dev, uint offset, int valu
return -EINVAL;
if (!(info->features & FEAT_PERIPH_MCU))
return -EINVAL;
-   v

Re: [PATCH u-boot-mvebu v3 11/18] arm: mvebu: system-controller: Add support for SYSRESET

2024-03-28 Thread Stefan Roese

On 3/27/24 17:23, Marek Behún wrote:

Add driver model support for sysreset via mvebu system controller. This is
currently only available for U-Boot proper.

Signed-off-by: Marek Behún 


Only a minor comment below. Other than this:

Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  arch/arm/mach-mvebu/Kconfig | 18 +-
  arch/arm/mach-mvebu/Makefile|  2 +-
  arch/arm/mach-mvebu/cpu.c   |  2 +
  arch/arm/mach-mvebu/system-controller.c | 74 +++--
  4 files changed, 89 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index 623432a60e..f15d3cc5ed 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -19,6 +19,7 @@ config ARMADA_32BIT
select SPL_SYS_NO_VECTOR_TABLE if SPL
select ARCH_VERY_EARLY_INIT
select ARMADA_32BIT_SYSCON_RESET if DM_RESET && PCI_MVEBU
+   select ARMADA_32BIT_SYSCON_SYSRESET if SYSRESET
  
  # ARMv7 SoCs...

  config ARMADA_375
@@ -457,16 +458,29 @@ config SF_DEFAULT_MODE
default 0x0
depends on MVEBU_SPL_BOOT_DEVICE_SPI
  
+config ARMADA_32BIT_SYSCON

+   bool
+   depends on ARMADA_32BIT
+   select REGMAP
+   select SYSCON
+
  config ARMADA_32BIT_SYSCON_RESET
bool "Support Armada XP/375/38x/39x reset controller"
depends on ARMADA_32BIT
depends on DM_RESET
-   select REGMAP
-   select SYSCON
+   select ARMADA_32BIT_SYSCON
help
  Build support for Armada XP/375/38x/39x reset controller. This is
  needed for PCIe support.
  
+config ARMADA_32BIT_SYSCON_SYSRESET

+   bool "Support Armada XP/375/38x/39x sysreset via driver model"
+   depends on ARMADA_32BIT
+   depends on SYSRESET
+   select ARMADA_32BIT_SYSCON
+   help
+ Build support for Armada XP/375/38x/39x system reset via driver model.
+
  source "board/solidrun/clearfog/Kconfig"
  source "board/kobol/helios4/Kconfig"
  
diff --git a/arch/arm/mach-mvebu/Makefile b/arch/arm/mach-mvebu/Makefile

index d44ca3a0df..329c2e4915 100644
--- a/arch/arm/mach-mvebu/Makefile
+++ b/arch/arm/mach-mvebu/Makefile
@@ -28,7 +28,7 @@ obj-$(CONFIG_ARMADA_38X) += 
../../../drivers/ddr/marvell/a38x/xor.o
  obj-$(CONFIG_ARMADA_XP) += ../../../drivers/ddr/marvell/axp/xor.o
  obj-$(CONFIG_ARMADA_MSYS) += ../../../drivers/ddr/marvell/axp/xor.o
  
-obj-$(CONFIG_ARMADA_32BIT_SYSCON_RESET) += system-controller.o

+obj-$(CONFIG_ARMADA_32BIT_SYSCON) += system-controller.o
  
  ifdef CONFIG_ARMADA_38X

  obj-$(CONFIG_MVEBU_EFUSE) += efuse.o
diff --git a/arch/arm/mach-mvebu/cpu.c b/arch/arm/mach-mvebu/cpu.c
index 8e0de93538..7c62a5dbb6 100644
--- a/arch/arm/mach-mvebu/cpu.c
+++ b/arch/arm/mach-mvebu/cpu.c
@@ -52,6 +52,7 @@ void lowlevel_init(void)
 */
  }
  
+#if defined(CONFIG_SPL_BUILD) || !defined(CONFIG_ARMADA_32BIT_SYSCON_SYSRESET)

  void reset_cpu(void)
  {
struct mvebu_system_registers *reg =
@@ -62,6 +63,7 @@ void reset_cpu(void)
while (1)
;
  }
+#endif
  
  u32 get_boot_device(void)

  {
diff --git a/arch/arm/mach-mvebu/system-controller.c 
b/arch/arm/mach-mvebu/system-controller.c
index c5c05922f2..b5f8afb96d 100644
--- a/arch/arm/mach-mvebu/system-controller.c
+++ b/arch/arm/mach-mvebu/system-controller.c
@@ -10,11 +10,24 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  
-#define MVEBU_SOC_CONTROL_1_REG 0x4

+#define MVEBU_SOC_CONTROL_1_REG0x4
  
-#define MVEBU_PCIE_ID 0

+#if defined(CONFIG_ARMADA_375)
+# define MVEBU_RSTOUTN_MASK_REG0x54
+# define MVEBU_SYS_SOFT_RST_REG0x58
+#else
+# define MVEBU_RSTOUTN_MASK_REG0x60
+# define MVEBU_SYS_SOFT_RST_REG0x64
+#endif
+
+#define MVEBU_GLOBAL_SOFT_RST_BIT  BIT(0)
+
+#define MVEBU_PCIE_ID  0
+
+#if IS_ENABLED(CONFIG_ARMADA_32BIT_SYSCON_RESET)
  
  static int mvebu_reset_of_xlate(struct reset_ctl *rst,

struct ofnode_phandle_args *args)
@@ -90,11 +103,64 @@ U_BOOT_DRIVER(mvebu_reset) = {
.ops = _reset_ops,
  };
  
+#endif /* IS_ENABLED(CONFIG_ARMADA_32BIT_SYSCON_RESET) */

+
+#if IS_ENABLED(CONFIG_ARMADA_32BIT_SYSCON_SYSRESET)
+
+static int mvebu_sysreset_request(struct udevice *dev, enum sysreset_t type)
+{
+   struct regmap *regmap = syscon_get_regmap(dev->parent);
+   uint bit;
+
+   if (type != SYSRESET_COLD)
+   return -EPROTONOSUPPORT;
+
+   bit = MVEBU_GLOBAL_SOFT_RST_BIT;
+
+   regmap_update_bits(regmap, MVEBU_RSTOUTN_MASK_REG, bit, bit);
+   regmap_update_bits(regmap, MVEBU_SYS_SOFT_RST_REG, bit, bit);
+
+   while (1)
+   ;


A comment before this endless loop might be helpful here.


+
+   return 0;
+}
+
+static struct sysreset_ops mvebu_sysreset_ops = {
+   .request = mvebu_sysreset_request,
+};
+
+U_BOOT_DRIVER(

Re: [PATCH u-boot-mvebu v3 10/18] arm: mvebu: system-controller: Select mvebu-reset if DM_RESET && PCI_MVEBU

2024-03-28 Thread Stefan Roese

On 3/27/24 17:23, Marek Behún wrote:

The mvebu-reset driver is only needed by the mvebu PCIe driver, but
currently it is automatically selected if DM_RESET is enabled. Add the
condition of PCI_MVEBU also being enabled for mvebu-reset to be
selected.

Signed-off-by: Marek Behún 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  arch/arm/mach-mvebu/Kconfig | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index 62a2bc5958..623432a60e 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -18,7 +18,7 @@ config ARMADA_32BIT
select TOOLS_KWBIMAGE if SPL
select SPL_SYS_NO_VECTOR_TABLE if SPL
select ARCH_VERY_EARLY_INIT
-   select ARMADA_32BIT_SYSCON_RESET if DM_RESET
+   select ARMADA_32BIT_SYSCON_RESET if DM_RESET && PCI_MVEBU
  
  # ARMv7 SoCs...

  config ARMADA_375


Viele Grüße,
Stefan Roese

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


Re: [PATCH u-boot-mvebu v3 09/18] arm: mvebu: system-controller: Rework to use UCLASS_SYSCON

2024-03-28 Thread Stefan Roese

On 3/27/24 17:23, Marek Behún wrote:

The system-controller driver for 32-bit Armada is currently registered
as UCLASS_RESET, since it only provides enabling/disabling PCIe ports.

Rework it as UCLASS_SYSCON and bind mvebu-reset as a child device.

Signed-off-by: Marek Behún 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  arch/arm/mach-mvebu/Kconfig | 11 
  arch/arm/mach-mvebu/Makefile|  2 +-
  arch/arm/mach-mvebu/system-controller.c | 76 ++---
  3 files changed, 54 insertions(+), 35 deletions(-)

diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index 2058c95ca2..62a2bc5958 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -18,6 +18,7 @@ config ARMADA_32BIT
select TOOLS_KWBIMAGE if SPL
select SPL_SYS_NO_VECTOR_TABLE if SPL
select ARCH_VERY_EARLY_INIT
+   select ARMADA_32BIT_SYSCON_RESET if DM_RESET
  
  # ARMv7 SoCs...

  config ARMADA_375
@@ -456,6 +457,16 @@ config SF_DEFAULT_MODE
default 0x0
depends on MVEBU_SPL_BOOT_DEVICE_SPI
  
+config ARMADA_32BIT_SYSCON_RESET

+   bool "Support Armada XP/375/38x/39x reset controller"
+   depends on ARMADA_32BIT
+   depends on DM_RESET
+   select REGMAP
+   select SYSCON
+   help
+ Build support for Armada XP/375/38x/39x reset controller. This is
+ needed for PCIe support.
+
  source "board/solidrun/clearfog/Kconfig"
  source "board/kobol/helios4/Kconfig"
  
diff --git a/arch/arm/mach-mvebu/Makefile b/arch/arm/mach-mvebu/Makefile

index ef790d97fe..d44ca3a0df 100644
--- a/arch/arm/mach-mvebu/Makefile
+++ b/arch/arm/mach-mvebu/Makefile
@@ -28,7 +28,7 @@ obj-$(CONFIG_ARMADA_38X) += 
../../../drivers/ddr/marvell/a38x/xor.o
  obj-$(CONFIG_ARMADA_XP) += ../../../drivers/ddr/marvell/axp/xor.o
  obj-$(CONFIG_ARMADA_MSYS) += ../../../drivers/ddr/marvell/axp/xor.o
  
-obj-$(CONFIG_DM_RESET) += system-controller.o

+obj-$(CONFIG_ARMADA_32BIT_SYSCON_RESET) += system-controller.o
  
  ifdef CONFIG_ARMADA_38X

  obj-$(CONFIG_MVEBU_EFUSE) += efuse.o
diff --git a/arch/arm/mach-mvebu/system-controller.c 
b/arch/arm/mach-mvebu/system-controller.c
index 7cdde11cbd..c5c05922f2 100644
--- a/arch/arm/mach-mvebu/system-controller.c
+++ b/arch/arm/mach-mvebu/system-controller.c
@@ -1,19 +1,21 @@
  // SPDX-License-Identifier: GPL-2.0+
-// (C) 2021 Pali Rohár 
+/*
+ * Copyright (C) 2021 Pali Rohár 
+ * Copyright (C) 2024 Marek Behún 
+ */
  
  #include 

  #include 
+#include 
+#include 
  #include 
+#include 
  #include 
  
  #define MVEBU_SOC_CONTROL_1_REG 0x4
  
  #define MVEBU_PCIE_ID 0
  
-struct mvebu_reset_data {

-   void *base;
-};
-
  static int mvebu_reset_of_xlate(struct reset_ctl *rst,
struct ofnode_phandle_args *args)
  {
@@ -46,46 +48,33 @@ static int mvebu_reset_free(struct reset_ctl *rst)
  
  static int mvebu_reset_assert(struct reset_ctl *rst)

  {
-   struct mvebu_reset_data *data = dev_get_priv(rst->dev);
+   struct regmap *regmap = syscon_get_regmap(rst->dev->parent);
  
-	clrbits_32(data->base + MVEBU_SOC_CONTROL_1_REG, BIT(rst->data));

-   return 0;
+   return regmap_update_bits(regmap, MVEBU_SOC_CONTROL_1_REG,
+ BIT(rst->data), 0);
  }
  
  static int mvebu_reset_deassert(struct reset_ctl *rst)

  {
-   struct mvebu_reset_data *data = dev_get_priv(rst->dev);
+   struct regmap *regmap = syscon_get_regmap(rst->dev->parent);
  
-	setbits_32(data->base + MVEBU_SOC_CONTROL_1_REG, BIT(rst->data));

-   return 0;
+   return regmap_update_bits(regmap, MVEBU_SOC_CONTROL_1_REG,
+ BIT(rst->data), BIT(rst->data));
  }
  
  static int mvebu_reset_status(struct reset_ctl *rst)

  {
-   struct mvebu_reset_data *data = dev_get_priv(rst->dev);
+   struct regmap *regmap = syscon_get_regmap(rst->dev->parent);
+   uint val;
+   int ret;
  
-	return !(readl(data->base + MVEBU_SOC_CONTROL_1_REG) & BIT(rst->data));

-}
-
-static int mvebu_reset_of_to_plat(struct udevice *dev)
-{
-   struct mvebu_reset_data *data = dev_get_priv(dev);
+   ret = regmap_read(regmap, MVEBU_SOC_CONTROL_1_REG, );
+   if (ret < 0)
+   return ret;
  
-	data->base = dev_read_addr_ptr(dev);

-   if (!data->base)
-   return -EINVAL;
-
-   return 0;
+   return !(val & BIT(rst->data));
  }
  
-static const struct udevice_id mvebu_reset_of_match[] = {

-   { .compatible = "marvell,armada-370-xp-system-controller" },
-   { .compatible = "marvell,armada-375-system-controller" },
-   { .compatible = "marvell,armada-380-system-controller" },
-   { .compatible = "marvell,armada-390-system-controller" },
-   { },
-};
-
  static const struct reset_ops mvebu_reset_ops = {
  

Re: [PATCH u-boot-mvebu v3 08/18] arm: mvebu: spl: Do not build mvebu-reset in SPL

2024-03-28 Thread Stefan Roese

On 3/27/24 17:23, Marek Behún wrote:

Commit 35e29e89a386 ("arm: mvebu: Implement simple mvebu-reset driver
for enabling/disabling PCIe ports") made it so that the mvebu reset
driver for enabling/disabling PCIe ports is build if CONFIG_DM_RESET is
enabled. This is because PCI_MVEBU depends on DM_RESET.

But the driver should not be built for SPL. Indeed the PCI_MVEBU driver
is not supported in SPL now, and so the mvebu-reset driver is not needed.

Signed-off-by: Marek Behún 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  arch/arm/mach-mvebu/Makefile | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-mvebu/Makefile b/arch/arm/mach-mvebu/Makefile
index 0584ed2be5..ef790d97fe 100644
--- a/arch/arm/mach-mvebu/Makefile
+++ b/arch/arm/mach-mvebu/Makefile
@@ -22,13 +22,14 @@ else # CONFIG_ARCH_KIRKWOOD
  obj-y = cpu.o
  obj-y += dram.o
  obj-y += lowlevel.o
-obj-$(CONFIG_DM_RESET) += system-controller.o
  ifndef CONFIG_SPL_BUILD
  obj-$(CONFIG_ARMADA_375) += ../../../drivers/ddr/marvell/axp/xor.o
  obj-$(CONFIG_ARMADA_38X) += ../../../drivers/ddr/marvell/a38x/xor.o
  obj-$(CONFIG_ARMADA_XP) += ../../../drivers/ddr/marvell/axp/xor.o
  obj-$(CONFIG_ARMADA_MSYS) += ../../../drivers/ddr/marvell/axp/xor.o
  
+obj-$(CONFIG_DM_RESET) += system-controller.o

+
  ifdef CONFIG_ARMADA_38X
  obj-$(CONFIG_MVEBU_EFUSE) += efuse.o
  endif


Viele Grüße,
Stefan Roese

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


Re: [PATCH u-boot-mvebu v3 07/18] arm: mvebu: turris_omnia: Disable Atmel SHA node if not present

2024-03-28 Thread Stefan Roese

On 3/27/24 17:23, Marek Behún wrote:

If the FEAT_CRYPTO feature bit is present in MCU features, the board
crypto is implemented by MCU and the Atmel SHA chip is not present.
Disable Atmel SHA device-tree node in that case.

Signed-off-by: Marek Behún 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  board/CZ.NIC/turris_omnia/turris_omnia.c | 23 +++
  1 file changed, 23 insertions(+)

diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c 
b/board/CZ.NIC/turris_omnia/turris_omnia.c
index b2f0088e5e..3b7a71bdad 100644
--- a/board/CZ.NIC/turris_omnia/turris_omnia.c
+++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
@@ -1007,6 +1007,25 @@ static int fixup_mcu_gpio_in_eth_wan_node(void *blob)
return 0;
  }
  
+static void fixup_atsha_node(void *blob)

+{
+   int node;
+
+   if (!omnia_mcu_has_feature(FEAT_CRYPTO))
+   return;
+
+   node = fdt_node_offset_by_compatible(blob, -1, "atmel,atsha204a");
+   if (node < 0) {
+   printf("Cannot find ATSHA204A node!\n");
+   return;
+   }
+
+   if (fdt_status_disabled(blob, node) < 0)
+   printf("Cannot disable ATSHA204A node!\n");
+   else
+   debug("Disabled ATSHA204A node\n");
+}
+
  #endif
  
  #if IS_ENABLED(CONFIG_OF_BOARD_FIXUP)

@@ -1020,6 +1039,8 @@ int board_fix_fdt(void *blob)
fixup_msata_port_nodes(blob);
fixup_wwan_port_nodes(blob);
  
+	fixup_atsha_node(blob);

+
return 0;
  }
  #endif
@@ -1211,6 +1232,8 @@ int ft_board_setup(void *blob, struct bd_info *bd)
fixup_msata_port_nodes(blob);
fixup_wwan_port_nodes(blob);
  
+	fixup_atsha_node(blob);

+
    return 0;
  }
  #endif


Viele Grüße,
Stefan Roese

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


Re: [PATCH u-boot-mvebu v3 06/18] arm: mvebu: turris_omnia: Print board ECDSA public key if available

2024-03-28 Thread Stefan Roese

On 3/27/24 17:23, Marek Behún wrote:

If MCU supports the FEAT_CRYPTO feature, read board ECDSA public key
from MCU and print it.

Signed-off-by: Marek Behún 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  board/CZ.NIC/turris_omnia/turris_omnia.c | 25 +++-
  1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c 
b/board/CZ.NIC/turris_omnia/turris_omnia.c
index f63640ad64..b2f0088e5e 100644
--- a/board/CZ.NIC/turris_omnia/turris_omnia.c
+++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
@@ -253,6 +253,24 @@ static int omnia_mcu_board_info(char *serial, u8 *mac, 
char *version)
return 0;
  }
  
+static int omnia_mcu_get_board_public_key(char pub_key[static 67])

+{
+   u8 reply[34];
+   int ret;
+
+   ret = omnia_mcu_read(CMD_CRYPTO_GET_PUBLIC_KEY, reply, sizeof(reply));
+   if (ret)
+   return ret;
+
+   if (reply[0] != 33)
+   return -EBADMSG;
+
+   bin2hex(pub_key, [1], 33);
+   pub_key[66] = '\0';
+
+   return 0;
+}
+
  static void enable_a385_watchdog(unsigned int timeout_minutes)
  {
struct sar_freq_modes sar_freq;
@@ -1032,7 +1050,7 @@ int board_late_init(void)
  
  int checkboard(void)

  {
-   char serial[17], version[4];
+   char serial[17], version[4], pub_key[67];
bool has_version;
int err;
  
@@ -1051,6 +1069,11 @@ int checkboard(void)

printf("  Board version: %s\n", has_version ? version : "unknown");
printf("  Serial Number: %s\n", !err ? serial : "unknown");
  
+	if (omnia_mcu_has_feature(FEAT_CRYPTO)) {

+   err = omnia_mcu_get_board_public_key(pub_key);
+   printf("  ECDSA Public Key: %s\n", !err ? pub_key : "unknown");
+   }
+
return 0;
  }
  


Viele Grüße,
Stefan Roese

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


Re: [PATCH u-boot-mvebu v3 05/18] arm: mvebu: turris_omnia: Implement getting board information from MCU

2024-03-28 Thread Stefan Roese

On 3/27/24 17:23, Marek Behún wrote:

Implement reading board serial number, first MAC address and board
version from MCU. MCU supports board information if the FEAT_BOARD_INFO
feature bit is set in MCU features.

Prefer getting board information from MCU if supported, fallback to
Atmel SHA chip.

Signed-off-by: Marek Behún 


Minor comment below. Other than this:

Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  board/CZ.NIC/turris_atsha_otp.c  | 27 +--
  board/CZ.NIC/turris_omnia/Makefile   |  2 +-
  board/CZ.NIC/turris_omnia/turris_omnia.c | 94 +++-
  3 files changed, 93 insertions(+), 30 deletions(-)

diff --git a/board/CZ.NIC/turris_atsha_otp.c b/board/CZ.NIC/turris_atsha_otp.c
index a29fe36231..85eebcdf18 100644
--- a/board/CZ.NIC/turris_atsha_otp.c
+++ b/board/CZ.NIC/turris_atsha_otp.c
@@ -11,6 +11,7 @@
  #include 
  
  #include "turris_atsha_otp.h"

+#include "turris_common.h"
  
  #define TURRIS_ATSHA_OTP_VERSION	0

  #define TURRIS_ATSHA_OTP_SERIAL   1
@@ -32,26 +33,6 @@ static struct udevice *get_atsha204a_dev(void)
return dev;
  }
  
-static void increment_mac(u8 *mac)

-{
-   int i;
-
-   for (i = 5; i >= 3; i--) {
-   mac[i] += 1;
-   if (mac[i])
-   break;
-   }
-}
-
-static void set_mac_if_invalid(int i, u8 *mac)
-{
-   u8 oldmac[6];
-
-   if (is_valid_ethaddr(mac) &&
-   !eth_env_get_enetaddr_by_index("eth", i, oldmac))
-   eth_env_set_enetaddr_by_index("eth", i, mac);
-}
-
  int turris_atsha_otp_init_mac_addresses(int first_idx)
  {
struct udevice *dev = get_atsha204a_dev();
@@ -84,11 +65,7 @@ int turris_atsha_otp_init_mac_addresses(int first_idx)
mac[4] = mac1[2];
mac[5] = mac1[3];
  
-	set_mac_if_invalid((first_idx + 0) % 3, mac);

-   increment_mac(mac);
-   set_mac_if_invalid((first_idx + 1) % 3, mac);
-   increment_mac(mac);
-   set_mac_if_invalid((first_idx + 2) % 3, mac);
+   turris_init_mac_addresses(first_idx, mac);
  
  	return 0;

  }
diff --git a/board/CZ.NIC/turris_omnia/Makefile 
b/board/CZ.NIC/turris_omnia/Makefile
index dc39b44ae1..341378b4e5 100644
--- a/board/CZ.NIC/turris_omnia/Makefile
+++ b/board/CZ.NIC/turris_omnia/Makefile
@@ -2,4 +2,4 @@
  #
  # Copyright (C) 2017 Marek Behún 
  
-obj-y	:= turris_omnia.o ../turris_atsha_otp.o

+obj-y  := turris_omnia.o ../turris_atsha_otp.o ../turris_common.o
diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c 
b/board/CZ.NIC/turris_omnia/turris_omnia.c
index 6dfde5ee7a..f63640ad64 100644
--- a/board/CZ.NIC/turris_omnia/turris_omnia.c
+++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
@@ -18,6 +18,7 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -25,12 +26,14 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  
  #include "../drivers/ddr/marvell/a38x/ddr3_init.h"

  #include <../serdes/a38x/high_speed_env_spec.h>
  #include "../turris_atsha_otp.h"
+#include "../turris_common.h"
  
  DECLARE_GLOBAL_DATA_PTR;
  
@@ -186,6 +189,70 @@ static bool omnia_mcu_has_feature(u32 feature)

return feature & features;
  }
  
+static u32 omnia_mcu_crc32(const void *p, size_t len)

+{
+   u32 val, crc = 0;
+
+   compiletime_assert(!(len % 4), "length has to be a multiple of 4");
+
+   while (len) {
+   val = bitrev32(get_unaligned_le32(p));
+   crc = crc32(crc, (void *), 4);
+   p += 4;
+   len -= 4;
+   }
+
+   return ~bitrev32(crc);
+}
+
+/* Can only be called after relocation, since it needs cleared BSS */
+static int omnia_mcu_board_info(char *serial, u8 *mac, char *version)
+{
+   static u8 reply[17];
+   static bool cached;
+
+   if (!cached) {
+   u8 csum;
+   int ret;
+
+   ret = omnia_mcu_read(CMD_BOARD_INFO_GET, reply, sizeof(reply));
+   if (ret)
+   return ret;
+
+   if (reply[0] != 16)
+   return -EBADMSG;
+
+   csum = reply[16];
+   reply[16] = 0;
+
+   if ((omnia_mcu_crc32([1], 16) & 0xff) != csum)
+   return -EBADMSG;
+
+   cached = true;
+   }
+
+   if (serial) {
+   const char *serial_env;
+
+   serial_env = env_get("serial#");
+   if (serial_env && strlen(serial_env) == 16) {
+   strcpy(serial, serial_env);


Usage of strcpy() is discouraged AFAIK.


+   } else {
+   sprintf(serial, "%016llX",
+   get_unaligned_le64([1]));
+   env_set("serial#", serial);
+   }
+   }
+
+   if (mac)
+   memcpy(mac, [9], ETH_ALEN);
+
+

Re: [PATCH u-boot-mvebu v3 04/18] arm: mvebu: turris_omnia: Update MCU status and features reading

2024-03-28 Thread Stefan Roese

On 3/27/24 17:23, Marek Behún wrote:

Refactor MCU status word and MCU firmware features reading to make it
simpler to use.

Try reading 32 bits of features, if that fails, read 16 bits. Older MCU
firmware supports only 16-bit wide features, and if more bytes are read,
either 0xff is sent or I2C transaction fails. Handle both cases.

Signed-off-by: Marek Behún 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  board/CZ.NIC/turris_omnia/turris_omnia.c | 100 +++
  1 file changed, 68 insertions(+), 32 deletions(-)

diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c 
b/board/CZ.NIC/turris_omnia/turris_omnia.c
index 87e33d88c4..6dfde5ee7a 100644
--- a/board/CZ.NIC/turris_omnia/turris_omnia.c
+++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
@@ -133,6 +133,59 @@ static int omnia_mcu_write(u8 cmd, const void *buf, int 
len)
return dm_i2c_write(chip, cmd, buf, len);
  }
  
+static int omnia_mcu_get_sts_and_features(u16 *psts, u32 *pfeatures)

+{
+   u16 sts, feat16;
+   int ret;
+
+   ret = omnia_mcu_read(CMD_GET_STATUS_WORD, , sizeof(sts));
+   if (ret)
+   return ret;
+
+   if (psts)
+   *psts = sts;
+
+   if (!pfeatures)
+   return 0;
+
+   if (sts & STS_FEATURES_SUPPORTED) {
+   /* try read 32-bit features */
+   ret = omnia_mcu_read(CMD_GET_FEATURES, pfeatures,
+sizeof(*pfeatures));
+   if (ret) {
+   /* try read 16-bit features */
+   ret = omnia_mcu_read(CMD_GET_FEATURES, ,
+sizeof());
+   if (ret)
+   return ret;
+
+   *pfeatures = feat16;
+   } else {
+   if (*pfeatures & FEAT_FROM_BIT_16_INVALID)
+   *pfeatures &= GENMASK(15, 0);
+   }
+   } else {
+   *pfeatures = 0;
+   }
+
+   return 0;
+}
+
+static int omnia_mcu_get_sts(u16 *sts)
+{
+   return omnia_mcu_get_sts_and_features(sts, NULL);
+}
+
+static bool omnia_mcu_has_feature(u32 feature)
+{
+   u32 features;
+
+   if (omnia_mcu_get_sts_and_features(NULL, ))
+   return false;
+
+   return feature & features;
+}
+
  static void enable_a385_watchdog(unsigned int timeout_minutes)
  {
struct sar_freq_modes sar_freq;
@@ -194,7 +247,7 @@ static bool disable_mcu_watchdog(void)
  static bool omnia_detect_sata(const char *msata_slot)
  {
int ret;
-   u16 stsword;
+   u16 sts;
  
  	puts("MiniPCIe/mSATA card detection... ");
  
@@ -210,24 +263,24 @@ static bool omnia_detect_sata(const char *msata_slot)

}
}
  
-	ret = omnia_mcu_read(CMD_GET_STATUS_WORD, , sizeof(stsword));

+   ret = omnia_mcu_get_sts();
if (ret) {
printf("omnia_mcu_read failed: %i, defaulting to MiniPCIe 
card\n",
   ret);
return false;
}
  
-	if (!(stsword & STS_CARD_DET)) {

+   if (!(sts & STS_CARD_DET)) {
puts("none\n");
return false;
}
  
-	if (stsword & STS_MSATA_IND)

+   if (sts & STS_MSATA_IND)
puts("mSATA\n");
else
puts("MiniPCIe\n");
  
-	return stsword & STS_MSATA_IND;

+   return sts & STS_MSATA_IND;
  }
  
  static bool omnia_detect_wwan_usb3(const char *wwan_slot)

@@ -355,14 +408,14 @@ static int omnia_get_ram_size_gb(void)
  static const char * const omnia_get_mcu_type(void)
  {
static char result[] = "xxx (with peripheral resets)";
-   u16 stsword, features;
+   u16 sts;
int ret;
  
-	ret = omnia_mcu_read(CMD_GET_STATUS_WORD, , sizeof(stsword));

+   ret = omnia_mcu_get_sts();
if (ret)
return "unknown";
  
-	switch (stsword & STS_MCU_TYPE_MASK) {

+   switch (sts & STS_MCU_TYPE_MASK) {
case STS_MCU_TYPE_STM32:
strcpy(result, "STM32");
break;
@@ -377,11 +430,8 @@ static const char * const omnia_get_mcu_type(void)
break;
}
  
-	if (stsword & STS_FEATURES_SUPPORTED) {

-   ret = omnia_mcu_read(CMD_GET_FEATURES, , 
sizeof(features));
-   if (ret == 0 && (features & FEAT_PERIPH_MCU))
-   strcat(result, " (with peripheral resets)");
-   }
+   if (omnia_mcu_has_feature(FEAT_PERIPH_MCU))
+   strcat(result, " (with peripheral resets)");
  
  	return result;

  }
@@ -660,9 +710,6 @@ int board_early_init_f(void)
  
  void spl_board_init(void)

  {
-   u16 val;
-   int ret;
-
/*
 * If booting from UART, disable MCU watchdog in SPL, since uploading
 * U-B

Re: [PATCH u-boot-mvebu v3 03/18] arm: mvebu: turris_{omnia, mox}: Don't print model two times

2024-03-28 Thread Stefan Roese

On 3/27/24 17:23, Marek Behún wrote:

Since commit 8cd4bf7dc9ba ("turris: Use checkboard() instead of
show_board_info()") the model is show two times during boot:
   Model: Turris Omnia
   Model: Turris Omnia

This is because the common function show_board_info() shows it, and
Turris' checkboard() also does.

Remove the second print.

Fixes: 8cd4bf7dc9ba ("turris: Use checkboard() instead of show_board_info()")
Signed-off-by: Marek Behún 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  board/CZ.NIC/turris_mox/turris_mox.c | 5 +
  board/CZ.NIC/turris_omnia/turris_omnia.c | 1 -
  2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/board/CZ.NIC/turris_mox/turris_mox.c 
b/board/CZ.NIC/turris_mox/turris_mox.c
index 3489bdd74b..1a2f60e3d1 100644
--- a/board/CZ.NIC/turris_mox/turris_mox.c
+++ b/board/CZ.NIC/turris_mox/turris_mox.c
@@ -565,13 +565,10 @@ static void handle_reset_button(void)
  int checkboard(void)
  {
int i, ret, board_version, ram_size, is_sd;
-   const char *pub_key, *model;
+   const char *pub_key;
const u8 *topology;
u64 serial_number;
  
-	model = fdt_getprop(gd->fdt_blob, 0, "model", NULL);

-   printf("Model: %s\n", model);
-
ret = mbox_sp_get_board_info(_number, NULL, NULL, _version,
 _size, NULL);
if (ret < 0) {
diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c 
b/board/CZ.NIC/turris_omnia/turris_omnia.c
index 6c2d7da528..87e33d88c4 100644
--- a/board/CZ.NIC/turris_omnia/turris_omnia.c
+++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
@@ -933,7 +933,6 @@ int checkboard(void)
int err;
  
  	err = turris_atsha_otp_get_serial_number(serial);

-   printf("Model: Turris Omnia\n");
printf("  MCU type: %s\n", omnia_get_mcu_type());
printf("  MCU version: %s\n", omnia_get_mcu_version());
printf("  RAM size: %i MiB\n", omnia_get_ram_size_gb() * 1024);


Viele Grüße,
Stefan Roese

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


Re: [PATCH u-boot-mvebu v3 02/18] arm: mvebu: turris_omnia: Add header containing MCU command interface and use it

2024-03-28 Thread Stefan Roese

On 3/27/24 17:23, Marek Behún wrote:

Add header containing all MCU command definitions and use it in board
code and in MCU driver.

Signed-off-by: Marek Behún 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  board/CZ.NIC/turris_omnia/turris_omnia.c |  81 +++-
  drivers/gpio/turris_omnia_mcu.c  |  54 +
  include/turris-omnia-mcu-interface.h | 248 +++
  3 files changed, 272 insertions(+), 111 deletions(-)
  create mode 100644 include/turris-omnia-mcu-interface.h

diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c 
b/board/CZ.NIC/turris_omnia/turris_omnia.c
index adeb69a205..6c2d7da528 100644
--- a/board/CZ.NIC/turris_omnia/turris_omnia.c
+++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
@@ -23,6 +23,7 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -59,46 +60,6 @@ DECLARE_GLOBAL_DATA_PTR;
  #define A385_WD_RSTOUT_UNMASK MVEBU_REGISTER(0x20704)
  #define   A385_WD_RSTOUT_UNMASK_GLOBALBIT(8)
  
-enum mcu_commands {

-   CMD_GET_STATUS_WORD = 0x01,
-   CMD_GET_RESET   = 0x09,
-   CMD_GET_FW_VERSION_APP  = 0x0a,
-   CMD_WATCHDOG_STATE  = 0x0b,
-   CMD_GET_FW_VERSION_BOOT = 0x0e,
-
-   /* available if STS_FEATURES_SUPPORTED bit set in status word */
-   CMD_GET_FEATURES= 0x10,
-
-   /* available if EXT_CMD bit set in features */
-   CMD_EXT_CONTROL = 0x12,
-};
-
-enum status_word_bits {
-   STS_MCU_TYPE_MASK   = GENMASK(1, 0),
-   STS_MCU_TYPE_STM32  = 0,
-   STS_MCU_TYPE_GD32   = 1,
-   STS_MCU_TYPE_MKL= 2,
-   STS_MCU_TYPE_UNKN   = 3,
-   STS_FEATURES_SUPPORTED  = BIT(2),
-   CARD_DET_STSBIT = 0x0010,
-   MSATA_IND_STSBIT= 0x0020,
-};
-
-/* CMD_GET_FEATURES */
-enum features_e {
-   FEAT_PERIPH_MCU = BIT(0),
-   FEAT_EXT_CMDS   = BIT(1),
-};
-
-/* CMD_EXT_CONTROL */
-enum ext_ctl_e {
-   EXT_CTL_nRES_LAN= BIT(1),
-   EXT_CTL_nRES_PHY= BIT(2),
-   EXT_CTL_nPERST0 = BIT(3),
-   EXT_CTL_nPERST1 = BIT(4),
-   EXT_CTL_nPERST2 = BIT(5),
-};
-
  /*
   * Those values and defines are taken from the Marvell U-Boot version
   * "u-boot-2013.01-2014_T3.0"
@@ -219,7 +180,7 @@ static bool disable_mcu_watchdog(void)
  
  	puts("Disabling MCU watchdog... ");
  
-	ret = omnia_mcu_write(CMD_WATCHDOG_STATE, "\x00", 1);

+   ret = omnia_mcu_write(CMD_SET_WATCHDOG_STATE, "\x00", 1);
if (ret) {
printf("omnia_mcu_write failed: %i\n", ret);
return false;
@@ -256,17 +217,17 @@ static bool omnia_detect_sata(const char *msata_slot)
return false;
}
  
-	if (!(stsword & CARD_DET_STSBIT)) {

+   if (!(stsword & STS_CARD_DET)) {
puts("none\n");
return false;
}
  
-	if (stsword & MSATA_IND_STSBIT)

+   if (stsword & STS_MSATA_IND)
puts("mSATA\n");
else
puts("MiniPCIe\n");
  
-	return stsword & MSATA_IND_STSBIT ? true : false;

+   return stsword & STS_MSATA_IND;
  }
  
  static bool omnia_detect_wwan_usb3(const char *wwan_slot)

@@ -393,18 +354,7 @@ static int omnia_get_ram_size_gb(void)
  
  static const char * const omnia_get_mcu_type(void)

  {
-   static const char * const mcu_types[] = {
-   [STS_MCU_TYPE_STM32] = "STM32",
-   [STS_MCU_TYPE_GD32]  = "GD32",
-   [STS_MCU_TYPE_MKL]   = "MKL",
-   [STS_MCU_TYPE_UNKN]  = "unknown",
-   };
-   static const char * const mcu_types_with_perip_resets[] = {
-   [STS_MCU_TYPE_STM32] = "STM32 (with peripheral resets)",
-   [STS_MCU_TYPE_GD32]  = "GD32 (with peripheral resets)",
-   [STS_MCU_TYPE_MKL]   = "MKL (with peripheral resets)",
-   [STS_MCU_TYPE_UNKN]  = "unknown (with peripheral resets)",
-   };
+   static char result[] = "xxx (with peripheral resets)";
u16 stsword, features;
int ret;
  
@@ -412,13 +362,28 @@ static const char * const omnia_get_mcu_type(void)

if (ret)
return "unknown";
  
+	switch (stsword & STS_MCU_TYPE_MASK) {

+   case STS_MCU_TYPE_STM32:
+   strcpy(result, "STM32");
+   break;
+   case STS_MCU_TYPE_GD32:
+   strcpy(result, "GD32");
+   break;
+   case STS_MCU_TYPE_MKL:
+   strcpy(result, "MKL");
+   break;
+   default:
+   strcpy(result, "unknown");
+   break;
+   }
+
if (stsword & STS_FEATURES_SUPPORTED) {
ret = omnia_mcu_read(CMD_

Re: [PATCH u-boot-mvebu v3 01/18] arm: mvebu: turris_omnia: Enable LTO by default on Turris Omnia

2024-03-28 Thread Stefan Roese

On 3/27/24 17:23, Marek Behún wrote:

U-Boot builds for Turris Omnia are approaching the limit of 0xf
bytes, which is the size of the U-Boot partition on Omnia.

Enable LTO to get more size optimized binaries.

Signed-off-by: Marek Behún 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  configs/turris_omnia_defconfig | 1 +
  1 file changed, 1 insertion(+)

diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig
index 29148402a1..39e15043df 100644
--- a/configs/turris_omnia_defconfig
+++ b/configs/turris_omnia_defconfig
@@ -31,6 +31,7 @@ CONFIG_AHCI=y
  CONFIG_OF_BOARD_FIXUP=y
  CONFIG_SYS_MEMTEST_START=0x0080
  CONFIG_SYS_MEMTEST_END=0x00ff
+CONFIG_LTO=y
  CONFIG_HAS_BOARD_SIZE_LIMIT=y
  CONFIG_BOARD_SIZE_LIMIT=983040
  CONFIG_FIT=y


Viele Grüße,
Stefan Roese

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


Re: [PATCH v2] arm: dts: kirkwood: Enable upstream DT on Kirkwood boards

2024-03-28 Thread Stefan Roese

Hi Tony,

On 3/28/24 08:41, Michael Walle wrote:

Hi,

On Thu Mar 28, 2024 at 3:18 AM CET, Tony Dinh wrote:

Enable OF_UPSTREAM to use upstream DT and add marvell/ prefix to the
DEFAULT_DEVICE_TREE for Kirkwood boards. And so we can directly build
DTBs from dts/upstream/src/arm/marvell, and including *-u-boot.dtsi
files from arch/arm/dts/ directory.

Background:

Hi Stefan,
Hi Michael,

I did a survey and we currently have 28 Kirkwood boards. Using some
commands and filters, here are the finding.

git grep -li arch_kirkwood configs | xargs grep DEVICE_TREE | cut -d '"' -f2 | 
xargs -n1 sh -c 'diff -qs  arch/arm/dts/$1.dts dts/upstream/src/arm/marvell/$1.dts' 
sh | grep differ

diff: dts/upstream/src/arm/marvell/kirkwood-atl-sbx81lifkw.dts: No such file or 
directory
diff: dts/upstream/src/arm/marvell/kirkwood-atl-sbx81lifxcat.dts: No such file 
or directory


...

Are you sure you want to have all this text in the commit log?


This is also my concern. Even though I love descriptive commit messages,
this seems to be a bit too much IMHO. Not sure if and how to get these
findings of yours archived otherwise.


You seem to have forgotten my tag:
Tested-by: Michael Walle  # on lschv2


Tony, many thanks to work on this consolidation. Very impressive
results. I can't test anything of this though, but my plan would be
to pull this in the upcoming merge window, if nobody complains.

Reviewed-by: Stefan Roese 

Thanks,
Stefan


Please pull u-boot-marvell/master

2024-03-05 Thread Stefan Roese

Hi Tom,

please pull this next batch of mostly Marvell related patches:


- net: mv88e6xxx: fix missing SMI address initialization (Marek)
- mvebu: turris_omnia: Enable networking via ethernet switch (Marek)
- mvebu: helios-4: add config fragment for spi booting et al (Josua)
- rng: Add Turris Mox rTWM RNG driver (Max)


Here the Azure build, without any issues:

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

Thanks,
Stefan

The following changes since commit 773cb2bca7743406e34ab4f441fc0a8a0d200a19:

  Merge tag 'u-boot-imx-master-20240304' of 
https://gitlab.denx.de/u-boot/custodians/u-boot-imx (2024-03-04 15:41:38 
-0500)


are available in the Git repository at:

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

for you to fetch changes up to d61b485dbd766970816ae9da09004dc4b30f8395:

  rng: Add Turris Mox rTWM RNG driver (2024-03-05 08:27:59 +0100)


Josua Mayer (3):
  arm: dts: armada-38x-solidrun-microsom: configure i2c0 bus
  arm: mvebu: helios4_defconfig: enable setexpr command
  board: helios-4: add config fragment for spi booting

Marek Mojík (2):
  net: mv88e6xxx: fix missing SMI address initialization
  arm: mvebu: turris_omnia: Enable networking via ethernet switch

Max Resch (1):
  rng: Add Turris Mox rTWM RNG driver

 arch/arm/dts/armada-385-turris-omnia-u-boot.dtsi |  51 ++
 arch/arm/dts/armada-38x-solidrun-microsom.dtsi   |   5 +
 board/kobol/helios4/spiboot.config   |   4 +
 configs/helios4_defconfig|   1 -
 configs/turris_omnia_defconfig   |   2 +
 drivers/net/mv88e6xxx.c  |   8 ++
 drivers/rng/Kconfig  |   8 ++
 drivers/rng/Makefile |   1 +
 drivers/rng/turris_rwtm_rng.c| 123 
+++

 9 files changed, 202 insertions(+), 1 deletion(-)
 create mode 100644 board/kobol/helios4/spiboot.config
 create mode 100644 drivers/rng/turris_rwtm_rng.c


Re: [PATCH v5] rng: Add Turris Mox rTWM RNG driver

2024-03-05 Thread Stefan Roese
   = UCLASS_RNG,
+   .of_match = turris_rwtm_rng_match,
+   .ops= _rwtm_rng_ops,
+   .probe  = turris_rwtm_rng_probe,
+   .remove = turris_rwtm_rng_remove,
+   .priv_auto = sizeof(struct turris_rwtm_rng_priv),
+};


Viele Grüße,
Stefan Roese

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


Re: [PATCH v2 3/3] board: helios-4: add config fragment for spi booting

2024-03-05 Thread Stefan Roese

On 2/2/24 16:13, Josua Mayer wrote:

Add a config fragment with required differences for booting from spi
flash instead of sd-card (default).

Settings for environment location are based on vendor u-boot:
https://github.com/kobol-io/u-boot/blob/helios4/include/configs/helios4.h#L59

The fragment can be applied on top of helios4_defconfig by make:
make helios4_defconfig spiboot.config

Signed-off-by: Josua Mayer 


Applied to u-boot-marvell/master

Thanks,
Stefan


---
  board/kobol/helios4/spiboot.config | 4 
  1 file changed, 4 insertions(+)

diff --git a/board/kobol/helios4/spiboot.config 
b/board/kobol/helios4/spiboot.config
new file mode 100644
index 00..5ffb7d2e3b
--- /dev/null
+++ b/board/kobol/helios4/spiboot.config
@@ -0,0 +1,4 @@
+CONFIG_MVEBU_SPL_BOOT_DEVICE_SPI=y
+# CONFIG_MVEBU_SPL_BOOT_DEVICE_MMC is not set
+CONFIG_ENV_OFFSET=0x10
+CONFIG_ENV_SECT_SIZE=0x1



Viele Grüße,
Stefan Roese

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


Re: [PATCH v2 2/3] arm: mvebu: helios4_defconfig: enable setexpr command

2024-03-05 Thread Stefan Roese

On 2/2/24 16:13, Josua Mayer wrote:

Update the helios4 defconfig to enable the 'setexpr' command, which is a
default and useful for various complex boot-scripts.

Signed-off-by: Josua Mayer 


Applied to u-boot-marvell/master

Thanks,
Stefan


---
  configs/helios4_defconfig | 1 -
  1 file changed, 1 deletion(-)

diff --git a/configs/helios4_defconfig b/configs/helios4_defconfig
index 04194004f0..73f0638344 100644
--- a/configs/helios4_defconfig
+++ b/configs/helios4_defconfig
@@ -44,7 +44,6 @@ CONFIG_CMD_MMC=y
  CONFIG_CMD_PCI=y
  CONFIG_CMD_SPI=y
  CONFIG_CMD_USB=y
-# CONFIG_CMD_SETEXPR is not set
  CONFIG_CMD_TFTPPUT=y
  CONFIG_CMD_CACHE=y
  CONFIG_CMD_TIME=y



Viele Grüße,
Stefan Roese

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


Re: [PATCH v2 1/3] arm: dts: armada-38x-solidrun-microsom: configure i2c0 bus

2024-03-05 Thread Stefan Roese

On 2/2/24 16:13, Josua Mayer wrote:

SolidRun Armada-388 SoM has an i2c bus supporting on-som eeprom, and
peripherals on a carrier.
armada-38x.dtsi disables this bus by default, it should be enabled by
som or carrier dts.

Linux has moved i2c0 from helios-4 board dts to som dtsi, including
status, pinctrl and clock speed.
Copy these settings from mainline.

This fixes accessing i2c bus from u-boot commandline.

Signed-off-by: Josua Mayer 


Applied to u-boot-marvell/master

Thanks,
Stefan


---
  arch/arm/dts/armada-38x-solidrun-microsom.dtsi | 5 +
  1 file changed, 5 insertions(+)

diff --git a/arch/arm/dts/armada-38x-solidrun-microsom.dtsi 
b/arch/arm/dts/armada-38x-solidrun-microsom.dtsi
index f6ae784bed..1540162e03 100644
--- a/arch/arm/dts/armada-38x-solidrun-microsom.dtsi
+++ b/arch/arm/dts/armada-38x-solidrun-microsom.dtsi
@@ -99,6 +99,11 @@
  };
  
   {

+   clock-frequency = <40>;
+   pinctrl-0 = <_pins>;
+   pinctrl-names = "default";
+   status = "okay";
+
eeprom@53 {
compatible = "atmel,24c02";
    reg = <0x53>;



Viele Grüße,
Stefan Roese

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


Re: [PATCH u-boot-marvell] arm: mvebu: turris_omnia: Enable networking via ethernet switch

2024-03-05 Thread Stefan Roese

On 12/19/23 10:55, Marek Behún wrote:

From: Marek Mojík 

The Turris Omnia contains the Marvell 88E6176 ethernet switch. Add
config options and device tree to enable the support.

Signed-off-by: Marek Mojík 
Signed-off-by: Marek Behún 


Applied to u-boot-marvell/master

Thanks,
Stefan


---
Stefan, this patch depends on
   [v2] net: mv88e6xxx: fix missing SMI address initialization
   
https://patchwork.ozlabs.org/project/uboot/patch/62eoapvurxkedw74vpzb55q3nuqgb4cef3bl2laayx57cpjzus@vlpx57cjc4ph/
---
  .../dts/armada-385-turris-omnia-u-boot.dtsi   | 51 +++
  configs/turris_omnia_defconfig|  2 +
  2 files changed, 53 insertions(+)

diff --git a/arch/arm/dts/armada-385-turris-omnia-u-boot.dtsi 
b/arch/arm/dts/armada-385-turris-omnia-u-boot.dtsi
index 509d6ca69c..c63a331d69 100644
--- a/arch/arm/dts/armada-385-turris-omnia-u-boot.dtsi
+++ b/arch/arm/dts/armada-385-turris-omnia-u-boot.dtsi
@@ -35,6 +35,57 @@
};
  };
  
+ {

+   switch@10 {
+   mdio {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   sw_phy0: ethernet-phy@0 {
+   reg = <0x0>;
+   };
+
+   sw_phy1: ethernet-phy@1 {
+   reg = <0x1>;
+   };
+
+   sw_phy2: ethernet-phy@2 {
+   reg = <0x2>;
+   };
+
+   sw_phy3: ethernet-phy@3 {
+   reg = <0x3>;
+   };
+
+   sw_phy4: ethernet-phy@4 {
+   reg = <0x4>;
+   };
+   };
+   ports {
+   ports@0 {
+   phy-handle = <_phy0>;
+   phy-mode = "internal";
+   };
+   ports@1 {
+   phy-handle = <_phy1>;
+   phy-mode = "internal";
+   };
+   ports@2 {
+   phy-handle = <_phy2>;
+   phy-mode = "internal";
+   };
+   ports@3 {
+   phy-handle = <_phy3>;
+   phy-mode = "internal";
+   };
+   ports@4 {
+   phy-handle = <_phy4>;
+   phy-mode = "internal";
+   };
+   };
+   };
+};
+
  #ifdef CONFIG_ENV_IS_IN_SPI_FLASH
   {
flash@0 {
diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig
index 65d4a296e7..3aaee276ea 100644
--- a/configs/turris_omnia_defconfig
+++ b/configs/turris_omnia_defconfig
@@ -96,7 +96,9 @@ CONFIG_SPI_FLASH_WINBOND=y
  CONFIG_SPI_FLASH_MTD=y
  CONFIG_PHY_MARVELL=y
  CONFIG_PHY_FIXED=y
+CONFIG_DM_DSA=y
  CONFIG_PHY_GIGE=y
+CONFIG_MV88E6XXX=y
  CONFIG_MVNETA=y
  CONFIG_MII=y
  CONFIG_MVMDIO=y


Viele Grüße,
Stefan Roese

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


Re: [PATCH v2] net: mv88e6xxx: fix missing SMI address initialization

2024-03-05 Thread Stefan Roese

On 12/6/23 15:35, Marek Mojík wrote:

The mv88e6xxx driver does not currently initialize the smi_addr field, but
instead keeps the default zero value. This leads to driver being unusable
on devices where the switch is not on address zero of the mdio bus. Fix
this problem by reading the SMI address from device tree.

Signed-off-by: Marek Mojík 


Applied to u-boot-marvell/master

Thanks,
Stefan


---
  drivers/net/mv88e6xxx.c | 8 
  1 file changed, 8 insertions(+)

diff --git a/drivers/net/mv88e6xxx.c b/drivers/net/mv88e6xxx.c
index c073f81e72..8fbbc1cacc 100644
--- a/drivers/net/mv88e6xxx.c
+++ b/drivers/net/mv88e6xxx.c
@@ -745,6 +745,7 @@ static int mv88e6xxx_probe(struct udevice *dev)
  {
struct dsa_pdata *dsa_pdata = dev_get_uclass_plat(dev);
struct mv88e6xxx_priv *priv = dev_get_priv(dev);
+   fdt_addr_t smi_addr;
int val, ret;
  
  	if (ofnode_valid(dev_ofnode(dev)) &&

@@ -753,6 +754,13 @@ static int mv88e6xxx_probe(struct udevice *dev)
return -ENODEV;
}
  
+	smi_addr = dev_read_addr(dev);

+   if (smi_addr == FDT_ADDR_T_NONE) {
+   dev_err(dev, "Missing SMI address\n");
+   return -EINVAL;
+   }
+   priv->smi_addr = smi_addr;
+
/* probe internal mdio bus */
ret = mv88e6xxx_probe_mdio(dev);
if (ret)


Viele Grüße,
Stefan Roese

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


Re: [PATCH v2] net: mv88e6xxx: fix missing SMI address initialization

2024-03-05 Thread Stefan Roese

Hi Marek,

On 3/4/24 15:48, Marek Behún wrote:

Hi Stefan,

On Wed, 14 Feb 2024 08:50:16 +0100
Stefan Roese  wrote:


Hi Ramon,

On 1/9/24 10:37, Stefan Roese wrote:

On 12/18/23 17:09, Marek Behún wrote:

On Wed, 6 Dec 2023 15:35:56 +0100
Marek Mojík  wrote:
  

The mv88e6xxx driver does not currently initialize the smi_addr
field, but
instead keeps the default zero value. This leads to driver being
unusable
on devices where the switch is not on address zero of the mdio bus. Fix
this problem by reading the SMI address from device tree.

Signed-off-by: Marek Mojík 
---
   drivers/net/mv88e6xxx.c | 8 
   1 file changed, 8 insertions(+)

diff --git a/drivers/net/mv88e6xxx.c b/drivers/net/mv88e6xxx.c
index c073f81e72..8fbbc1cacc 100644
--- a/drivers/net/mv88e6xxx.c
+++ b/drivers/net/mv88e6xxx.c
@@ -745,6 +745,7 @@ static int mv88e6xxx_probe(struct udevice *dev)
   {
   struct dsa_pdata *dsa_pdata = dev_get_uclass_plat(dev);
   struct mv88e6xxx_priv *priv = dev_get_priv(dev);
+    fdt_addr_t smi_addr;
   int val, ret;
   if (ofnode_valid(dev_ofnode(dev)) &&
@@ -753,6 +754,13 @@ static int mv88e6xxx_probe(struct udevice *dev)
   return -ENODEV;
   }
+    smi_addr = dev_read_addr(dev);
+    if (smi_addr == FDT_ADDR_T_NONE) {
+    dev_err(dev, "Missing SMI address\n");
+    return -EINVAL;
+    }
+    priv->smi_addr = smi_addr;
+
   /* probe internal mdio bus */
   ret = mv88e6xxx_probe_mdio(dev);
   if (ret)


Reviewed-by: Marek Behún 


Reviewed-by: Stefan Roese 

Ramon, this patch was assigned to me as an Marvell MVEBU patch
depends on it. I've assigned it to you now. Or if it's okay that
I pull it with the Marvell tree, just let me know.


Any updates on this?

Thanks,
Stefan


Stefan, it seems that Ramon is unavailable for this.
Can we take this? We've been using it on Omnia and it works correctly.


Yes, I also thought about pulling this one in. As a matter of fact,
I'm currently busy with creating a pull request for Tom.

Thanks,
Stefan


Re: [PATCH v5] rng: Add Turris Mox rTWM RNG driver

2024-02-16 Thread Stefan Roese
+   .ops= _rwtm_rng_ops,
+   .probe  = turris_rwtm_rng_probe,
+   .remove = turris_rwtm_rng_remove,
+   .priv_auto = sizeof(struct turris_rwtm_rng_priv),
+};


Reviewed-by: Stefan Roese 

Thanks,
Stefan


Re: [PATCH v2] net: mv88e6xxx: fix missing SMI address initialization

2024-02-13 Thread Stefan Roese

Hi Ramon,

On 1/9/24 10:37, Stefan Roese wrote:

On 12/18/23 17:09, Marek Behún wrote:

On Wed, 6 Dec 2023 15:35:56 +0100
Marek Mojík  wrote:

The mv88e6xxx driver does not currently initialize the smi_addr 
field, but
instead keeps the default zero value. This leads to driver being 
unusable

on devices where the switch is not on address zero of the mdio bus. Fix
this problem by reading the SMI address from device tree.

Signed-off-by: Marek Mojík 
---
  drivers/net/mv88e6xxx.c | 8 
  1 file changed, 8 insertions(+)

diff --git a/drivers/net/mv88e6xxx.c b/drivers/net/mv88e6xxx.c
index c073f81e72..8fbbc1cacc 100644
--- a/drivers/net/mv88e6xxx.c
+++ b/drivers/net/mv88e6xxx.c
@@ -745,6 +745,7 @@ static int mv88e6xxx_probe(struct udevice *dev)
  {
  struct dsa_pdata *dsa_pdata = dev_get_uclass_plat(dev);
  struct mv88e6xxx_priv *priv = dev_get_priv(dev);
+    fdt_addr_t smi_addr;
  int val, ret;
  if (ofnode_valid(dev_ofnode(dev)) &&
@@ -753,6 +754,13 @@ static int mv88e6xxx_probe(struct udevice *dev)
  return -ENODEV;
  }
+    smi_addr = dev_read_addr(dev);
+    if (smi_addr == FDT_ADDR_T_NONE) {
+    dev_err(dev, "Missing SMI address\n");
+    return -EINVAL;
+    }
+    priv->smi_addr = smi_addr;
+
  /* probe internal mdio bus */
  ret = mv88e6xxx_probe_mdio(dev);
  if (ret)


Reviewed-by: Marek Behún 


Reviewed-by: Stefan Roese 

Ramon, this patch was assigned to me as an Marvell MVEBU patch
depends on it. I've assigned it to you now. Or if it's okay that
I pull it with the Marvell tree, just let me know.


Any updates on this?

Thanks,
Stefan


Re: [PATCH v4] rng: Add Turris Mox rTWM RNG driver

2024-02-13 Thread Stefan Roese

Hi Max,

mostly some nitpicking comments below.

On 2/11/24 14:04, Max Resch wrote:

A RNG driver for Armada 3720 boards running the Turris Mox rWTM firmware
from CZ.NIC in the secure processor.

Signed-off-by: Max Resch 
---

Changes in v4:
  - wrongful/missing git rebase

Changes in v3:
  - More meaningful variable names in accordance with review

Changes in v2:
  - Removed ring buffer implementation

  drivers/rng/Kconfig   |   8 +++
  drivers/rng/Makefile  |   1 +
  drivers/rng/turris_rwtm_rng.c | 122 ++
  3 files changed, 131 insertions(+)
  create mode 100644 drivers/rng/turris_rwtm_rng.c

diff --git a/drivers/rng/Kconfig b/drivers/rng/Kconfig
index a89c899568..cd72852a47 100644
--- a/drivers/rng/Kconfig
+++ b/drivers/rng/Kconfig
@@ -105,4 +105,12 @@ config RNG_JH7110
help
  Enable True Random Number Generator in StarFive JH7110 SoCs.
  
+config RNG_TURRIS_RWTM

+   bool "Turris Mox TRNG in Secure Processor"
+   depends on DM_RNG && ARMADA_3700
+   help
+ Use TRNG in Turris Mox Secure Processor Firmware. Can be used
+ on other Armada-3700 devices (like EspressoBin) if Secure
+ Firmware from CZ.NIC is used.
+
  endif
diff --git a/drivers/rng/Makefile b/drivers/rng/Makefile
index 7e64c4cdfc..ecae1a3da3 100644
--- a/drivers/rng/Makefile
+++ b/drivers/rng/Makefile
@@ -17,3 +17,4 @@ obj-$(CONFIG_RNG_SMCCC_TRNG) += smccc_trng.o
  obj-$(CONFIG_RNG_ARM_RNDR) += arm_rndr.o
  obj-$(CONFIG_TPM_RNG) += tpm_rng.o
  obj-$(CONFIG_RNG_JH7110) += jh7110_rng.o
+obj-$(CONFIG_RNG_TURRIS_RWTM) += turris_rwtm_rng.o
diff --git a/drivers/rng/turris_rwtm_rng.c b/drivers/rng/turris_rwtm_rng.c
new file mode 100644
index 00..ec2cb0bca3
--- /dev/null
+++ b/drivers/rng/turris_rwtm_rng.c
@@ -0,0 +1,122 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR BSD-3-Clause
+/*
+ * Copyright (c) 2024, Max Resch
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* size of entropy buffer */
+#define RNG_BUFFER_SIZE128U
+
+struct turris_rwtm_rng_priv {
+   phys_addr_t buffer;
+};
+
+static int turris_rwtm_rng_fill_entropy(phys_addr_t entropy, size_t size)
+{
+   u32 args[3] = { 1, (u32)entropy, size };
+   int ret;
+
+   /* flush data cache */
+   flush_dcache_range(entropy, entropy + size);
+
+   /*
+* get entropy
+* args[0] = 1 copies BYTES array in args[1] of length args[2]
+*/
+   ret = mbox_do_cmd(MBOX_CMD_GET_RANDOM, args, 3, NULL, 0);
+   if (ret < 0)
+   return ret;
+
+   /* invalidate data cache */
+   invalidate_dcache_range(entropy, entropy + size);
+
+   return 0;
+}
+
+static int turris_rwtm_rng_random_read(struct udevice *dev, void *data, size_t 
count)
+{
+   struct turris_rwtm_rng_priv *priv = dev_get_priv(dev);
+   phys_addr_t phys;
+   size_t size;
+   int ret;
+
+   phys = priv->buffer;
+
+   while (count) {
+   size = min_t(size_t, RNG_BUFFER_SIZE, count);
+
+   ret = turris_rwtm_rng_fill_entropy(phys, size);


Return code check missing here.


+
+   memcpy(data, (void *)phys, size);
+   count -= size;
+   data = (u8 *)data + size;
+   }
+
+   return 0;
+}
+
+static int turris_rwtm_rng_probe(struct udevice *dev)
+{
+   struct turris_rwtm_rng_priv *priv = dev_get_priv(dev);
+   u32 args[] = { 0 };
+   int ret;
+
+   /*
+* check if the random command is supported
+* args[0] = 0 would copy 16 DWORDS entropy to out but we ignore them
+*/
+   ret = mbox_do_cmd(MBOX_CMD_GET_RANDOM, args, ARRAY_SIZE(args), NULL, 0);
+


Please drop this empty line before the ret check.


+   if (ret < 0)
+   return ret;
+
+   /* entropy buffer */
+   priv->buffer = 0;
+
+   /* buffer address need to be aligned */
+   dma_alloc_coherent(RNG_BUFFER_SIZE, (unsigned long *)>buffer);
+   if (!priv->buffer)
+   return -ENOMEM;
+
+   return 0;
+}
+
+static int turris_rwtm_rng_remove(struct udevice *dev)
+{
+   struct turris_rwtm_rng_priv *priv = dev_get_priv(dev);
+   phys_addr_t phys = priv->buffer;
+
+   dma_free_coherent((void *)phys);
+
+   return 0;
+}
+
+static const struct dm_rng_ops turris_rwtm_rng_ops = {
+   .read = turris_rwtm_rng_random_read,
+};
+
+/*
+ * only Turris MOX firmware has the RNG but allow all probable devices to be
+ * probed the default firmware will just reject the probe
+ */
+static const struct udevice_id turris_rwtm_rng_match[] = {
+   { .compatible = "cznic,turris-mox-rwtm" },
+   { .compatible = "marvell,armada-3700-rwtm-firmware" },
+   {},
+};
+
+U_BOOT_DRIVER(turris_rwtm_rng) = {
+   .name   = "turris-rwtm-rng",
+   .id = UCLASS_RNG,
+   .of_match = turris_rwtm_rng_match,
+   .ops= _rwtm_rng_ops,
+   .probe  = turris_rwtm_rng_probe,
+   .remove = 

Re: [PATCH v3] rng: Add Turris Mox rTWM RNG driver

2024-02-07 Thread Stefan Roese

Hi Max,

On 2/7/24 16:00, Max Resch wrote:

A RNG driver for Armada 3720 boards running the Turris Mox rWTM firmware
from CZ.NIC in the secure processor.

Signed-off-by: Max Resch 
---

Changes in v3:
  - More meaningful variable names in accordance with review

Changes in v2:
  - Removed ring buffer implementation

  drivers/rng/turris_rwtm_rng.c | 18 +-
  1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/rng/turris_rwtm_rng.c b/drivers/rng/turris_rwtm_rng.c
index 143fe0b47f..ec2cb0bca3 100644
--- a/drivers/rng/turris_rwtm_rng.c
+++ b/drivers/rng/turris_rwtm_rng.c
@@ -41,18 +41,19 @@ static int turris_rwtm_rng_fill_entropy(phys_addr_t 
entropy, size_t size)
  
  static int turris_rwtm_rng_random_read(struct udevice *dev, void *data, size_t count)

  {
-   phys_addr_t p;
+   struct turris_rwtm_rng_priv *priv = dev_get_priv(dev);
+   phys_addr_t phys;


You've now just sent the update v2->v3. As v2 is not applied yet
this is not the way to do it. Please squash this patch into the v2
one a send this as v3 or even better v4 now.

Thanks,
Stefan


size_t size;
int ret;
  
-	p = ((struct turris_rwtm_rng_priv *)dev_get_priv(dev))->buffer;

+   phys = priv->buffer;
  
  	while (count) {

size = min_t(size_t, RNG_BUFFER_SIZE, count);
  
-		ret = turris_rwtm_rng_fill_entropy(p, size);

+   ret = turris_rwtm_rng_fill_entropy(phys, size);
  
-		memcpy(data, (void *)p, size);

+   memcpy(data, (void *)phys, size);
count -= size;
data = (u8 *)data + size;
}
@@ -62,7 +63,7 @@ static int turris_rwtm_rng_random_read(struct udevice *dev, 
void *data, size_t c
  
  static int turris_rwtm_rng_probe(struct udevice *dev)

  {
-   struct turris_rwtm_rng_priv *priv;
+   struct turris_rwtm_rng_priv *priv = dev_get_priv(dev);
u32 args[] = { 0 };
int ret;
  
@@ -76,7 +77,6 @@ static int turris_rwtm_rng_probe(struct udevice *dev)

return ret;
  
  	/* entropy buffer */

-   priv = (struct turris_rwtm_rng_priv *)dev_get_priv(dev);
priv->buffer = 0;
  
  	/* buffer address need to be aligned */

@@ -89,10 +89,10 @@ static int turris_rwtm_rng_probe(struct udevice *dev)
  
  static int turris_rwtm_rng_remove(struct udevice *dev)

  {
-   phys_addr_t p;
+   struct turris_rwtm_rng_priv *priv = dev_get_priv(dev);
+   phys_addr_t phys = priv->buffer;
  
-	p = ((struct turris_rwtm_rng_priv *)dev_get_priv(dev))->buffer;

-   dma_free_coherent((void *)p);
+   dma_free_coherent((void *)phys);
  
  	return 0;

  }


Viele Grüße,
Stefan Roese

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


Please pull u-boot-watchdog/master

2024-02-01 Thread Stefan Roese

Hi Tom,

please pull the following watchdog related last minute fixes:


- add andes atcwdt200 support (Randolph)


Here the Azure build, without any issues:

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

Thanks,
Stefan


The following changes since commit b6d8969bcb94321dfed1399f2eaa8768ba42caaa:

  Merge tag 'u-boot-at91-2024.04-a' of 
https://source.denx.de/u-boot/custodians/u-boot-at91 (2024-01-31 
10:44:33 -0500)


are available in the Git repository at:

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

for you to fetch changes up to 094eda0660d419f35e10c49fade75a6738a56137:

  configs: andes: add watchdog support fot andes ae350 (2024-02-01 
09:08:44 +0100)



Randolph (2):
  drivers: watchdog: add andes atcwdt200 support
  configs: andes: add watchdog support fot andes ae350

 configs/ae350_rv32_defconfig |   4 +
 configs/ae350_rv32_spl_defconfig |   4 +
 configs/ae350_rv32_spl_xip_defconfig |   4 +
 configs/ae350_rv32_xip_defconfig |   4 +
 configs/ae350_rv64_defconfig |   4 +
 configs/ae350_rv64_spl_defconfig |   4 +
 configs/ae350_rv64_spl_xip_defconfig |   4 +
 configs/ae350_rv64_xip_defconfig |   4 +
 drivers/watchdog/Kconfig |   6 +
 drivers/watchdog/Makefile|   1 +
 drivers/watchdog/atcwdt200_wdt.c | 220 
+++

 11 files changed, 259 insertions(+)
 create mode 100644 drivers/watchdog/atcwdt200_wdt.c


Re: [PATCH V4 2/2] configs: andes: add watchdog support fot andes ae350

2024-02-01 Thread Stefan Roese
b/configs/ae350_rv64_xip_defconfig
index 5432b6d6d7..835f020990 100644
--- a/configs/ae350_rv64_xip_defconfig
+++ b/configs/ae350_rv64_xip_defconfig
@@ -24,6 +24,7 @@ CONFIG_SYS_PROMPT="RISC-V # "
  CONFIG_CMD_IMLS=y
  CONFIG_CMD_MMC=y
  CONFIG_CMD_SF_TEST=y
+CONFIG_CMD_WDT=y
  # CONFIG_CMD_SETEXPR is not set
  CONFIG_BOOTP_PREFER_SERVERIP=y
  CONFIG_CMD_CACHE=y
@@ -50,3 +51,6 @@ CONFIG_BAUDRATE=38400
  CONFIG_SYS_NS16550=y
  CONFIG_SPI=y
  CONFIG_ATCSPI200_SPI=y
+# CONFIG_WATCHDOG_AUTOSTART is not set
+CONFIG_WDT=y
+CONFIG_WDT_ATCWDT200=y


Viele Grüße,
Stefan Roese

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


Re: [PATCH V4 1/2] drivers: watchdog: add andes atcwdt200 support

2024-02-01 Thread Stefan Roese
4 freq_ms, u8 type)
+{
+   u64 result;
+   u64 freq_sec;
+   u8 index;
+
+   freq_sec = freq_ms / 1000;
+   for (index = 0; index < type; index++) {
+   result = freq_sec >> atcwdt_get_2_power_of_n(index, type);
+
+   if (result <= 1)
+   break;
+   }
+
+   return index;
+}
+
+static int atcwdt_wdt_start(struct udevice *dev, u64 timeout, ulong flags)
+{
+   struct wdt_priv *priv = dev_get_priv(dev);
+   u64 rst_max_count;
+   u32 rst_max_time_ms;
+   u64 rst_time_ms;
+   u64 int_time_ms;
+   u8  rst_time;
+   u8  int_time;
+
+   rst_max_count = 1 << atcwdt_get_2_power_of_n(RST_TIME_ARRAY, 
RST_TIME_ARRAY);
+   rst_max_time_ms = (rst_max_count * 1000) / priv->clk_freq;
+
+   if (timeout > rst_max_time_ms) {
+   int_time_ms = timeout - rst_max_time_ms;
+   rst_time_ms = rst_max_time_ms;
+   } else {
+   int_time_ms = 0;
+   rst_time_ms = timeout;
+   }
+
+   rst_time = atcwdt_search_msb(rst_time_ms * priv->clk_freq, 
RST_TIME_ARRAY);
+
+   if (int_time_ms) {
+   int_time = atcwdt_search_msb(int_time_ms * priv->clk_freq, 
INT_TIME_ARRAY);
+   if (int_time > priv->max_clk)
+   int_time = priv->max_clk;
+   } else {
+   int_time = 0;
+   }
+
+   writel(WDT_WP_MAGIC, priv->base + REG_WDT_WE);
+   writel(((rst_time << RST_TIME_OFF) & RST_TIME_MSK) | ((int_time << 
INT_TIME_OFF) &
+   INT_TIME_MSK) | INT_EN | RST_EN | priv->wdt_clk_src | WDT_EN,
+   priv->base + REG_WDT_CFG);
+
+   return 0;
+}
+
+static int atcwdt_wdt_stop(struct udevice *dev)
+{
+   struct wdt_priv *priv = dev_get_priv(dev);
+
+   writel(WDT_WP_MAGIC, priv->base + REG_WDT_WE);
+   writel(0, priv->base + REG_WDT_CFG);
+
+   return 0;
+}
+
+static int atcwdt_wdt_restart(struct udevice *dev)
+{
+   struct wdt_priv *priv = dev_get_priv(dev);
+
+   writel(WDT_WP_MAGIC, priv->base + REG_WDT_WE);
+   writel(WDT_RESTART_MAGIC, priv->base + REG_WDT_RS);
+   setbits_le32(priv->base + REG_WDT_STA, INT_EXPIRED);
+
+   return 0;
+}
+
+static int atcwdt_wdt_expire_now(struct udevice *dev, ulong flags)
+{
+   atcwdt_wdt_start(dev, 0, 0);
+   hang();
+
+   return 0;
+}
+
+static int atcwdt_wdt_probe(struct udevice *dev)
+{
+   struct wdt_priv *priv = dev_get_priv(dev);
+   int timer_16bit;
+
+   priv->base = dev_remap_addr_index(dev, 0);
+   if (!priv->base)
+   return -EFAULT;
+
+   priv->wdt_clk_src = dev_read_u32_default(dev, "clock-source", 
NODE_NOT_FOUND);
+   if (priv->wdt_clk_src == NODE_NOT_FOUND || priv->wdt_clk_src > 1)
+   priv->wdt_clk_src = CLK_PCLK;
+
+   timer_16bit = dev_read_u32_default(dev, "16bit_timer", NODE_NOT_FOUND);
+   if (timer_16bit == 1 || timer_16bit == NODE_NOT_FOUND)
+   priv->max_clk = INT_CLK_MAX_16B;
+   else
+   priv->max_clk = INT_CLK_MAX_32B;
+
+   priv->clk_freq = dev_read_u32_default(dev, "clock-frequency", 
NODE_NOT_FOUND);
+   if (priv->clk_freq == NODE_NOT_FOUND) {
+   printf("atcwdt200: Please provide a valid \"clock-frequency\" in 
DTB\n");
+   return -EINVAL;
+   }
+
+   atcwdt_wdt_stop(dev);
+
+   return 0;
+}
+
+static const struct wdt_ops atcwdt_wdt_ops = {
+   .start = atcwdt_wdt_start,
+   .reset = atcwdt_wdt_restart,
+   .stop = atcwdt_wdt_stop,
+   .expire_now = atcwdt_wdt_expire_now,
+};
+
+static const struct udevice_id atcwdt_wdt_ids[] = {
+   {.compatible = "andestech,atcwdt200"},
+   {}
+};
+
+U_BOOT_DRIVER(atcwdt) = {
+   .name = "atcwdt200",
+   .id = UCLASS_WDT,
+   .probe = atcwdt_wdt_probe,
+   .of_match = atcwdt_wdt_ids,
+   .ops = _wdt_ops,
+   .priv_auto = sizeof(struct wdt_priv),
+};


Viele Grüße,
Stefan Roese

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


Re: [PATCH V4 2/2] configs: andes: add watchdog support fot andes ae350

2024-02-01 Thread Stefan Roese

Hi Randolph,

On 1/31/24 07:30, Randolph Lin wrote:

On Wed, Jan 24, 2024 at 09:37:41AM +0100, Stefan Roese wrote:
Hi Stefan,
Thank you for testing and reviewing.
I have checked the error message and the relationship to my patch.
The reason for the failure has nothing to do with my patch.
Could you kindly help me run the CI test again?


Now it works. Thanks for clarifying and sorry for the confusion.

Thanks,
Stefan


Randolph
Sincerely

Hi Randolph,

On 1/24/24 07:21, Randolph wrote:

It adds the ATCWDT200 support for Andes AE350 platform.
It also enables wdt command support.

Signed-off-by: CL Wang 
Signed-off-by: Randolph 
Reviewed-by: Leo Yu-Chi Liang 


This fails in world CI build in "test.py for sandbox":

https://dev.azure.com/sr0718/0cded7c3-6e6a-4b57-8d0f-65c99496c42f/_apis/build/builds/338/logs/181

Not sure how this is related. Could you please take a look?

Thanks,
Stefan


---
   configs/ae350_rv32_defconfig | 4 
   configs/ae350_rv32_spl_defconfig | 4 
   configs/ae350_rv32_spl_xip_defconfig | 4 
   configs/ae350_rv32_xip_defconfig | 4 
   configs/ae350_rv64_defconfig | 4 
   configs/ae350_rv64_spl_defconfig | 4 
   configs/ae350_rv64_spl_xip_defconfig | 4 
   configs/ae350_rv64_xip_defconfig | 4 
   8 files changed, 32 insertions(+)

diff --git a/configs/ae350_rv32_defconfig b/configs/ae350_rv32_defconfig
index 3bfa3e9f8e..35ad62c845 100644
--- a/configs/ae350_rv32_defconfig
+++ b/configs/ae350_rv32_defconfig
@@ -23,6 +23,7 @@ CONFIG_SYS_PROMPT="RISC-V # "
   CONFIG_CMD_IMLS=y
   CONFIG_CMD_MMC=y
   CONFIG_CMD_SF_TEST=y
+CONFIG_CMD_WDT=y
   # CONFIG_CMD_SETEXPR is not set
   CONFIG_BOOTP_PREFER_SERVERIP=y
   CONFIG_CMD_CACHE=y
@@ -49,3 +50,6 @@ CONFIG_BAUDRATE=38400
   CONFIG_SYS_NS16550=y
   CONFIG_SPI=y
   CONFIG_ATCSPI200_SPI=y
+# CONFIG_WATCHDOG_AUTOSTART is not set
+CONFIG_WDT=y
+CONFIG_WDT_ATCWDT200=y
diff --git a/configs/ae350_rv32_spl_defconfig b/configs/ae350_rv32_spl_defconfig
index aeb50206d2..41cd457bc3 100644
--- a/configs/ae350_rv32_spl_defconfig
+++ b/configs/ae350_rv32_spl_defconfig
@@ -33,6 +33,7 @@ CONFIG_SYS_PROMPT="RISC-V # "
   CONFIG_CMD_IMLS=y
   CONFIG_CMD_MMC=y
   CONFIG_CMD_SF_TEST=y
+CONFIG_CMD_WDT=y
   # CONFIG_CMD_SETEXPR is not set
   CONFIG_BOOTP_PREFER_SERVERIP=y
   CONFIG_CMD_CACHE=y
@@ -58,3 +59,6 @@ CONFIG_SYS_NS16550=y
   CONFIG_SPI=y
   CONFIG_ATCSPI200_SPI=y
   # CONFIG_BINMAN_FDT is not set
+# CONFIG_WATCHDOG_AUTOSTART is not set
+CONFIG_WDT=y
+CONFIG_WDT_ATCWDT200=y
diff --git a/configs/ae350_rv32_spl_xip_defconfig 
b/configs/ae350_rv32_spl_xip_defconfig
index f15ec301ce..954e2f2de7 100644
--- a/configs/ae350_rv32_spl_xip_defconfig
+++ b/configs/ae350_rv32_spl_xip_defconfig
@@ -34,6 +34,7 @@ CONFIG_SYS_PROMPT="RISC-V # "
   CONFIG_CMD_IMLS=y
   CONFIG_CMD_MMC=y
   CONFIG_CMD_SF_TEST=y
+CONFIG_CMD_WDT=y
   # CONFIG_CMD_SETEXPR is not set
   CONFIG_BOOTP_PREFER_SERVERIP=y
   CONFIG_CMD_CACHE=y
@@ -59,3 +60,6 @@ CONFIG_SYS_NS16550=y
   CONFIG_SPI=y
   CONFIG_ATCSPI200_SPI=y
   # CONFIG_BINMAN_FDT is not set
+# CONFIG_WATCHDOG_AUTOSTART is not set
+CONFIG_WDT=y
+CONFIG_WDT_ATCWDT200=y
diff --git a/configs/ae350_rv32_xip_defconfig b/configs/ae350_rv32_xip_defconfig
index c40eb043c5..95863595d2 100644
--- a/configs/ae350_rv32_xip_defconfig
+++ b/configs/ae350_rv32_xip_defconfig
@@ -24,6 +24,7 @@ CONFIG_SYS_PROMPT="RISC-V # "
   CONFIG_CMD_IMLS=y
   CONFIG_CMD_MMC=y
   CONFIG_CMD_SF_TEST=y
+CONFIG_CMD_WDT=y
   # CONFIG_CMD_SETEXPR is not set
   CONFIG_BOOTP_PREFER_SERVERIP=y
   CONFIG_CMD_CACHE=y
@@ -50,3 +51,6 @@ CONFIG_BAUDRATE=38400
   CONFIG_SYS_NS16550=y
   CONFIG_SPI=y
   CONFIG_ATCSPI200_SPI=y
+# CONFIG_WATCHDOG_AUTOSTART is not set
+CONFIG_WDT=y
+CONFIG_WDT_ATCWDT200=y
diff --git a/configs/ae350_rv64_defconfig b/configs/ae350_rv64_defconfig
index 7ae938aeb2..988214285a 100644
--- a/configs/ae350_rv64_defconfig
+++ b/configs/ae350_rv64_defconfig
@@ -23,6 +23,7 @@ CONFIG_SYS_PROMPT="RISC-V # "
   CONFIG_CMD_IMLS=y
   CONFIG_CMD_MMC=y
   CONFIG_CMD_SF_TEST=y
+CONFIG_CMD_WDT=y
   # CONFIG_CMD_SETEXPR is not set
   CONFIG_BOOTP_PREFER_SERVERIP=y
   CONFIG_CMD_CACHE=y
@@ -49,3 +50,6 @@ CONFIG_BAUDRATE=38400
   CONFIG_SYS_NS16550=y
   CONFIG_SPI=y
   CONFIG_ATCSPI200_SPI=y
+# CONFIG_WATCHDOG_AUTOSTART is not set
+CONFIG_WDT=y
+CONFIG_WDT_ATCWDT200=y
diff --git a/configs/ae350_rv64_spl_defconfig b/configs/ae350_rv64_spl_defconfig
index 68ac4325ab..e929320433 100644
--- a/configs/ae350_rv64_spl_defconfig
+++ b/configs/ae350_rv64_spl_defconfig
@@ -33,6 +33,7 @@ CONFIG_SYS_PROMPT="RISC-V # "
   CONFIG_CMD_IMLS=y
   CONFIG_CMD_MMC=y
   CONFIG_CMD_SF_TEST=y
+CONFIG_CMD_WDT=y
   # CONFIG_CMD_SETEXPR is not set
   CONFIG_BOOTP_PREFER_SERVERIP=y
   CONFIG_CMD_CACHE=y
@@ -58,3 +59,6 @@ CONFIG_SYS_NS16550=y
   CONFIG_SPI=y
   CONFIG_ATCSPI200_SPI=y
   # CONFIG_BINMAN_FDT is not set
+# CONFIG_WATCHDOG_AUTOSTART

Re: [PATCH V4 2/2] configs: andes: add watchdog support fot andes ae350

2024-01-24 Thread Stefan Roese
16550=y
  CONFIG_SPI=y
  CONFIG_ATCSPI200_SPI=y
  # CONFIG_BINMAN_FDT is not set
+# CONFIG_WATCHDOG_AUTOSTART is not set
+CONFIG_WDT=y
+CONFIG_WDT_ATCWDT200=y
diff --git a/configs/ae350_rv64_xip_defconfig b/configs/ae350_rv64_xip_defconfig
index 5432b6d6d7..835f020990 100644
--- a/configs/ae350_rv64_xip_defconfig
+++ b/configs/ae350_rv64_xip_defconfig
@@ -24,6 +24,7 @@ CONFIG_SYS_PROMPT="RISC-V # "
  CONFIG_CMD_IMLS=y
  CONFIG_CMD_MMC=y
  CONFIG_CMD_SF_TEST=y
+CONFIG_CMD_WDT=y
  # CONFIG_CMD_SETEXPR is not set
  CONFIG_BOOTP_PREFER_SERVERIP=y
  CONFIG_CMD_CACHE=y
@@ -50,3 +51,6 @@ CONFIG_BAUDRATE=38400
  CONFIG_SYS_NS16550=y
  CONFIG_SPI=y
  CONFIG_ATCSPI200_SPI=y
+# CONFIG_WATCHDOG_AUTOSTART is not set
+CONFIG_WDT=y
+CONFIG_WDT_ATCWDT200=y


Viele Grüße,
Stefan Roese

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


Please pull u-boot-marvell/master

2024-01-22 Thread Stefan Roese

Hi Tom,

please pull this next batch of Marvell related patches:


- solidrun: clearfog gtr: add serdes configuration (Josua)


Here the Azure build, without any issues:

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

Thanks,
Stefan


The following changes since commit 3c04fcf3137d5f694d52b8f355373e4baabe5f78:

  Merge patch series "k3-j721e: beagleboneai: Fix USB" (2024-01-20 
11:39:13 -0500)


are available in the Git repository at:

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

for you to fetch changes up to bb6e89048ceaf26a4d775750715e3279dbd73d07:

  board: solidrun: clearfog: fix serdes 1 / eth2 speed for clearfog gtr 
(2024-01-22 12:47:45 +0100)



Josua Mayer (2):
  arm: mvebu: clearfog gtr: add config option to select serdes0 
interface

  board: solidrun: clearfog: fix serdes 1 / eth2 speed for clearfog gtr

 board/solidrun/clearfog/Kconfig| 19 +++
 board/solidrun/clearfog/clearfog.c | 19 ---
 2 files changed, 35 insertions(+), 3 deletions(-)



Re: [PATCH v2 0/2] board: solidrun: clearfog gtr: add serdes configuration

2024-01-22 Thread Stefan Roese

On 1/12/24 14:35, Josua Mayer wrote:

Add missing configuration options for clearog gtr serdes:

1. select between sata and pci-e for serdes 0
2. configure serdes 2 for 2.5Gbps link with managed switch

Signed-off-by: Josua Mayer 
---
Changes in v2:
- change choice default logic to remove kconfig warning
- Link to v1: 
https://lore.kernel.org/r/20240106-clearfog-gtr-serdes-v1-0-66cbc350c...@solid-run.com

---
Josua Mayer (2):
   arm: mvebu: clearfog gtr: add config option to select serdes0 interface
   board: solidrun: clearfog: fix serdes 1 / eth2 speed for clearfog gtr

  board/solidrun/clearfog/Kconfig| 19 +++
  board/solidrun/clearfog/clearfog.c | 19 ---
  2 files changed, 35 insertions(+), 3 deletions(-)
---
base-commit: 2ee7a8ec6f1711abe9619fd8765edc16742be9de
change-id: 20240106-clearfog-gtr-serdes-8a927f496bda

Sincerely,


Applied to u-boot-mavell/master

Thanks,
Stefan


Re: [PATCH 3/3] arm: mvebu: helios-4: add defconfig for spi booting

2024-01-22 Thread Stefan Roese

Hi Josua,

On 1/13/24 18:22, Tom Rini wrote:

On Sat, Jan 13, 2024 at 05:36:57PM +0100, Josua Mayer wrote:


Add a new defconfig based on existing helios4_config file to support
booting from spi flash.

Settings for environment location are based on vendor u-boot:
https://github.com/kobol-io/u-boot/blob/helios4/include/configs/helios4.h#L59

A separate defconfig is required because the options are not
intuitive from menuconfig, numeric values in particular.

Signed-off-by: Josua Mayer 
---
  configs/helios4_spi_defconfig | 81 +++
  1 file changed, 81 insertions(+)


So, a super new thing that might be of interest, but please try this
since I'd like to prove/disprove the use-case.  This could instead be:
configs/helios4_spi_defconfig:
#include "configs/helios4_defconfig"
... enable/disable options specific to the SPI boot use case ...

And so now both boards will otherwise be kept in-sync for general config
changes.  It could further be done as:
configs/helios4_spi_defconfig:
#include "configs/helios4_defconfig"
#include "board/kobol/helios4/spiboot.config"

And have board/kobol/helios4/spiboot.config contain the SPI-boot
specific options.  This path would allow for:
make helios4_defconfig spiboot.config
to be a valid alternative way of configuring a build for spiboot.


That would be cool.

Still:
The current version leads to this compilation warning:

WARNING: no maintainers for 'helios4_spi'

Please fix in v2.

Thanks,
Stefan

BTW: Could you please also Cc me directly with such patches?


Please pull u-boot-marvell/master

2024-01-10 Thread Stefan Roese

Hi Tom,

please pull this next batch of Marvell related patches:


- AC5: Use finer grained memory map (Chris)
- Espressobin: Misc improvements (Robert)
- eDPU: Support new board revision (Robert)


Here the Azure build, without any issues:

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

Thanks,
Stefan


The following changes since commit 344667db6450de838bd83f0f57e177e6d4744d89:

  Merge tag 'smbios-2024-04-rc1' of 
https://source.denx.de/u-boot/custodians/u-boot-efi (2024-01-09 12:50:04 
-0500)


are available in the Git repository at:

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

for you to fetch changes up to 46471e6c1d58442140259f7e44a5c3e0d6e02351:

  arm: mvebu: eDPU: support new board revision (2024-01-10 09:38:55 +0100)


Chris Packham (1):
  arm: mvebu: AC5: Use finer grained memory map

Robert Marko (3):
  arm: mvebu: Espressobin: move FDT fixup into a separate function
  arm: mvebu: Espressobin: move network setup into a separate function
  arm: mvebu: eDPU: support new board revision

 arch/arm/dts/armada-3720-eDPU-u-boot.dtsi |  13 ++-
 arch/arm/dts/armada-3720-eDPU.dts |  47 +
 arch/arm/mach-mvebu/alleycat5/cpu.c   |  66 ++---
 board/Marvell/mvebu_armada-37xx/board.c   | 159 
--

 configs/eDPU_defconfig|   1 +
 5 files changed, 256 insertions(+), 30 deletions(-)


Re: [PATCH v3 3/3] arm: mvebu: eDPU: support new board revision

2024-01-10 Thread Stefan Roese

On 11/29/23 11:11, Robert Marko wrote:

There is a new eDPU revision that uses Marvell 88E6361 switch onboard.
We can rely on detecting the switch to enable and fixup the Linux DTS
so a single DTS can be used.

There is currently no support for the 88E6361 switch and thus no working
networking in U-Boot, so we disable both ports.

Signed-off-by: Robert Marko 
Reviewed-by: Stefan Roese 


Applied to u-boot-marvell/master

Thanks,
Stefan


---
Changes in v3:
* Add check for DM_MDIO

  arch/arm/dts/armada-3720-eDPU-u-boot.dtsi |  13 ++-
  arch/arm/dts/armada-3720-eDPU.dts |  47 
  board/Marvell/mvebu_armada-37xx/board.c   | 128 ++
  configs/eDPU_defconfig|   1 +
  4 files changed, 184 insertions(+), 5 deletions(-)

diff --git a/arch/arm/dts/armada-3720-eDPU-u-boot.dtsi 
b/arch/arm/dts/armada-3720-eDPU-u-boot.dtsi
index cb02b70e54..c3d450dd83 100644
--- a/arch/arm/dts/armada-3720-eDPU-u-boot.dtsi
+++ b/arch/arm/dts/armada-3720-eDPU-u-boot.dtsi
@@ -32,14 +32,17 @@
bootph-all;
  };
  
- {

-   /* G.hn does not work without additional configuration */
-   status = "disabled";
-};
-
   {
fixed-link {
speed = <1000>;
full-duplex;
};
  };
+
+/*
+ * eDPU v2 has a MV88E6361 switch on the MDIO bus and U-boot is used
+ * to patch the Linux DTS if its found so enable MDIO by default.
+ */
+ {
+   status = "okay";
+};
diff --git a/arch/arm/dts/armada-3720-eDPU.dts 
b/arch/arm/dts/armada-3720-eDPU.dts
index 57fc698e55..d6d37a1f6f 100644
--- a/arch/arm/dts/armada-3720-eDPU.dts
+++ b/arch/arm/dts/armada-3720-eDPU.dts
@@ -12,3 +12,50 @@
   {
phy-mode = "2500base-x";
  };
+
+/*
+ * External MV88E6361 switch is only available on v2 of the board.
+ * U-Boot will enable the MDIO bus and switch nodes.
+ */
+ {
+   status = "disabled";
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>;
+
+   /* Actual device is MV88E6361 */
+   switch: switch@0 {
+   compatible = "marvell,mv88e6190";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   reg = <0>;
+   status = "disabled";
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0>;
+   label = "cpu";
+   phy-mode = "2500base-x";
+   managed = "in-band-status";
+   ethernet = <>;
+   };
+
+   port@9 {
+   reg = <9>;
+   label = "downlink";
+   phy-mode = "2500base-x";
+   managed = "in-band-status";
+   };
+
+   port@a {
+   reg = <10>;
+   label = "uplink";
+   phy-mode = "2500base-x";
+   managed = "in-band-status";
+   sfp = <_eth1>;
+   };
+   };
+   };
+};
diff --git a/board/Marvell/mvebu_armada-37xx/board.c 
b/board/Marvell/mvebu_armada-37xx/board.c
index f532486b70..1685b12b84 100644
--- a/board/Marvell/mvebu_armada-37xx/board.c
+++ b/board/Marvell/mvebu_armada-37xx/board.c
@@ -14,6 +14,7 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -50,6 +51,7 @@ DECLARE_GLOBAL_DATA_PTR;
  /* Single-chip mode */
  /* Switch Port Registers */
  #define MVEBU_SW_LINK_CTRL_REG(1)
+#define MVEBU_SW_PORT_SWITCH_ID(3)
  #define MVEBU_SW_PORT_CTRL_REG(4)
  #define MVEBU_SW_PORT_BASE_VLAN   (6)
  
@@ -57,6 +59,8 @@ DECLARE_GLOBAL_DATA_PTR;

  #define MVEBU_G2_SMI_PHY_CMD_REG  (24)
  #define MVEBU_G2_SMI_PHY_DATA_REG (25)
  
+#define SWITCH_88E6361_PRODUCT_NUMBER	0x2610

+
  /*
   * Memory Controller Registers
   *
@@ -73,6 +77,30 @@ DECLARE_GLOBAL_DATA_PTR;
  #define A3700_MC_CTRL2_SDRAM_TYPE_DDR32
  #define A3700_MC_CTRL2_SDRAM_TYPE_DDR43
  
+static bool is_edpu_plus(void)

+{
+   struct udevice *bus;
+   ofnode node;
+   int val;
+
+   if (!CONFIG_IS_ENABLED(DM_MDIO))
+   return false;
+
+   node = ofnode_by_compatible(ofnode_null(), "marvell,orion-mdio");
+   if (!ofnode_valid(node) ||
+   uclass_get_device_by_ofnode(UCLASS_MDIO, node, ) ||
+   device_probe(bus)) {
+   printf("Cannot find MDIO bus\n");
+   return -ENOD

Re: [PATCH v3 2/3] arm: mvebu: Espressobin: move network setup into a separate function

2024-01-10 Thread Stefan Roese

On 11/29/23 11:11, Robert Marko wrote:

Currently, Esspresobin switch is being setup directly in last_stage_init()
which makes it hard to add support for any other board to be setup.

So, lets just move the switch setup code to a separate function and call it
if compatible matches, there should be no functional change.

Signed-off-by: Robert Marko 
Reviewed-by: Stefan Roese 


Applied to u-boot-marvell/master

Thanks,
Stefan


---
Changes in v2:
* Rebase on top of current master and resolve conflicts

  board/Marvell/mvebu_armada-37xx/board.c | 17 -
  1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/board/Marvell/mvebu_armada-37xx/board.c 
b/board/Marvell/mvebu_armada-37xx/board.c
index 1471caa9a6..f532486b70 100644
--- a/board/Marvell/mvebu_armada-37xx/board.c
+++ b/board/Marvell/mvebu_armada-37xx/board.c
@@ -301,14 +301,12 @@ static int mii_multi_chip_mode_write(struct udevice *bus, 
int dev_smi_addr,
return 0;
  }
  
-/* Bring-up board-specific network stuff */

-static int last_stage_init(void)
+static int espressobin_last_stage_init(void)
  {
struct udevice *bus;
ofnode node;
  
-	if (!CONFIG_IS_ENABLED(DM_MDIO) ||

-   !of_machine_is_compatible("globalscale,espressobin"))
+   if (!CONFIG_IS_ENABLED(DM_MDIO))
return 0;
  
  	node = ofnode_by_compatible(ofnode_null(), "marvell,orion-mdio");

@@ -358,8 +356,17 @@ static int last_stage_init(void)
  
  	return 0;

  }
-EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init);
  
+/* Bring-up board-specific network stuff */

+static int last_stage_init(void)
+{
+
+   if (of_machine_is_compatible("globalscale,espressobin"))
+   return espressobin_last_stage_init();
+
+   return 0;
+}
+EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init);
  #endif
  
  #ifdef CONFIG_OF_BOARD_SETUP


Viele Grüße,
Stefan Roese

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


Re: [PATCH v3 1/3] arm: mvebu: Espressobin: move FDT fixup into a separate function

2024-01-10 Thread Stefan Roese

On 11/29/23 11:11, Robert Marko wrote:

Currently, Esspresobin FDT is being fixed up directly in ft_board_setup()
which makes it hard to add support for any other board to be fixed up.

So, lets just move the FDT fixup code to a separate function and call it
if compatible matches, there should be no functional change.

Signed-off-by: Robert Marko 
Reviewed-by: Stefan Roese 


Applied to u-boot-marvell/master

Thanks,
Stefan


---
  board/Marvell/mvebu_armada-37xx/board.c | 14 +-
  1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/board/Marvell/mvebu_armada-37xx/board.c 
b/board/Marvell/mvebu_armada-37xx/board.c
index 04124d8014..1471caa9a6 100644
--- a/board/Marvell/mvebu_armada-37xx/board.c
+++ b/board/Marvell/mvebu_armada-37xx/board.c
@@ -363,18 +363,14 @@ EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init);
  #endif
  
  #ifdef CONFIG_OF_BOARD_SETUP

-int ft_board_setup(void *blob, struct bd_info *bd)
+static int espressobin_fdt_setup(void *blob)
  {
-#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
int ret;
int spi_off;
int parts_off;
int part_off;
  
  	/* Fill SPI MTD partitions for Linux kernel on Espressobin */

-   if (!of_machine_is_compatible("globalscale,espressobin"))
-   return 0;
-
spi_off = fdt_node_offset_by_compatible(blob, -1, "jedec,spi-nor");
if (spi_off < 0)
return 0;
@@ -459,6 +455,14 @@ int ft_board_setup(void *blob, struct bd_info *bd)
return 0;
}
  
+	return 0;

+}
+
+int ft_board_setup(void *blob, struct bd_info *bd)
+{
+#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
+   if (of_machine_is_compatible("globalscale,espressobin"))
+   return espressobin_fdt_setup(blob);
  #endif
return 0;
  }


Viele Grüße,
Stefan Roese

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


Re: [PATCH] arm: mvebu: AC5: Use finer grained memory map

2024-01-10 Thread Stefan Roese

On 10/27/23 02:44, Chris Packham wrote:

The ATF implementation for AC5/AC5X ends up with bl31 living in some
internal SRAM. This is in the middle of the large MMIO region that we
were using. Adjust this to be finer grained blocks based on the address
map from the AC5X Family Control and Management Subsystem Functional
Datasheet.

Signed-off-by: Chris Packham 


Applied to u-boot-marvell/master

Thanks,
Stefan


---

  arch/arm/mach-mvebu/alleycat5/cpu.c | 66 ++---
  1 file changed, 51 insertions(+), 15 deletions(-)

diff --git a/arch/arm/mach-mvebu/alleycat5/cpu.c 
b/arch/arm/mach-mvebu/alleycat5/cpu.c
index 8204d9627515..0f72ae1709be 100644
--- a/arch/arm/mach-mvebu/alleycat5/cpu.c
+++ b/arch/arm/mach-mvebu/alleycat5/cpu.c
@@ -16,7 +16,10 @@
  
  DECLARE_GLOBAL_DATA_PTR;
  
-#define RAM_SIZE	SZ_1G

+#define AC5_PTE_BLOCK_DEVICE \
+   (PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | \
+PTE_BLOCK_NON_SHARE | \
+PTE_BLOCK_PXN | PTE_BLOCK_UXN)
  
  static struct mm_region ac5_mem_map[] = {

{
@@ -31,30 +34,63 @@ static struct mm_region ac5_mem_map[] = {
.phys = 0x,
.virt = 0xa000,
.size = 0x10,
-
-   .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-PTE_BLOCK_NON_SHARE |
-PTE_BLOCK_PXN | PTE_BLOCK_UXN
+   .attrs = AC5_PTE_BLOCK_DEVICE,
},
{
/* MMIO regions */
.phys = 0x10,
.virt = 0x10,
.size = 0x3ff0,
-
-   .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-PTE_BLOCK_NON_SHARE |
-PTE_BLOCK_PXN | PTE_BLOCK_UXN
+   .attrs = AC5_PTE_BLOCK_DEVICE,
},
{
-   /* MMIO regions */
.phys = 0x7F00,
.virt = 0x7F00,
-   .size = 0x2100,
-
-   .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-PTE_BLOCK_NON_SHARE |
-PTE_BLOCK_PXN | PTE_BLOCK_UXN
+   .size = SZ_8M,
+   .attrs = AC5_PTE_BLOCK_DEVICE,
+   },
+   {
+   .phys = 0x7F80,
+   .virt = 0x7F80,
+   .size = SZ_4M,
+   .attrs = AC5_PTE_BLOCK_DEVICE,
+   },
+   {
+   .phys = 0x7FC0,
+   .virt = 0x7FC0,
+   .size = SZ_512K,
+   .attrs = AC5_PTE_BLOCK_DEVICE,
+   },
+   {
+   .phys = 0x7FC8,
+   .virt = 0x7FC8,
+   .size = SZ_512K,
+   .attrs = AC5_PTE_BLOCK_DEVICE,
+   },
+   {
+   .phys = 0x7FD0,
+   .virt = 0x7FD0,
+   .size = SZ_512K,
+   .attrs = AC5_PTE_BLOCK_DEVICE,
+   },
+   /* ATF region 0x7FE0-0x7FE2 not mapped */
+   {
+   .phys = 0x7FE8,
+   .virt = 0x7FE8,
+   .size = SZ_512K,
+   .attrs = AC5_PTE_BLOCK_DEVICE,
+   },
+   {
+   .phys = 0x7FFF,
+   .virt = 0x7FFF,
+   .size = SZ_1M,
+   .attrs = AC5_PTE_BLOCK_DEVICE,
+   },
+   {
+   .phys = 0x8000,
+   .virt = 0x8000,
+   .size = SZ_2G,
+   .attrs = AC5_PTE_BLOCK_DEVICE,
},
{
0,


Viele Grüße,
Stefan Roese

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


Re: [PATCH v3 1/3] arm: mvebu: Espressobin: move FDT fixup into a separate function

2024-01-09 Thread Stefan Roese

Hi Robert,

On 1/9/24 14:16, Robert Marko wrote:

On Wed, Nov 29, 2023 at 11:11 AM Robert Marko  wrote:


Currently, Esspresobin FDT is being fixed up directly in ft_board_setup()
which makes it hard to add support for any other board to be fixed up.

So, lets just move the FDT fixup code to a separate function and call it
if compatible matches, there should be no functional change.

Signed-off-by: Robert Marko 
Reviewed-by: Stefan Roese 



Hi Stefan,
Since 2024.01 was released, can this series be pulled in now?


It's on my list. I actually already started with some CI build tests.
Hope to get this done by end of this week, before I leave for a
short vacation.

Thanks,
Stefan


Regards,
Robert



---
  board/Marvell/mvebu_armada-37xx/board.c | 14 +-
  1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/board/Marvell/mvebu_armada-37xx/board.c 
b/board/Marvell/mvebu_armada-37xx/board.c
index 04124d8014..1471caa9a6 100644
--- a/board/Marvell/mvebu_armada-37xx/board.c
+++ b/board/Marvell/mvebu_armada-37xx/board.c
@@ -363,18 +363,14 @@ EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init);
  #endif

  #ifdef CONFIG_OF_BOARD_SETUP
-int ft_board_setup(void *blob, struct bd_info *bd)
+static int espressobin_fdt_setup(void *blob)
  {
-#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
 int ret;
 int spi_off;
 int parts_off;
 int part_off;

 /* Fill SPI MTD partitions for Linux kernel on Espressobin */
-   if (!of_machine_is_compatible("globalscale,espressobin"))
-   return 0;
-
 spi_off = fdt_node_offset_by_compatible(blob, -1, "jedec,spi-nor");
 if (spi_off < 0)
 return 0;
@@ -459,6 +455,14 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 return 0;
 }

+   return 0;
+}
+
+int ft_board_setup(void *blob, struct bd_info *bd)
+{
+#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
+   if (of_machine_is_compatible("globalscale,espressobin"))
+   return espressobin_fdt_setup(blob);
  #endif
 return 0;
  }
--
2.43.0






Viele Grüße,
Stefan Roese

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


Re: [PATCH 1/2] arm: mvebu: clearfog gtr: add config option to select serdes0 interface

2024-01-09 Thread Stefan Roese

On 1/6/24 18:29, Josua Mayer wrote:

Clearfog GTR has an assembly option for a SATA connector, CON18.
It shares the serdes with mini-pcie connector CON3.

Add new kconfig option to select betweenata and pci, defaulting to pci
as it was previously configured in board-file.

Clearfog GTR connects eth2 / serdes 1 to a 2.5Gbps capable ethernet
switch port. Linux already configures a fixed-link at speed 2500 from
device-tree.
Upgrade serdes 1 rate to 3.125Gbps to support a 2.5Gbps network link on
Clearfog GTR.

Signed-off-by: Josua Mayer 
---
  board/solidrun/clearfog/Kconfig| 19 +++
  board/solidrun/clearfog/clearfog.c | 11 ---
  2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/board/solidrun/clearfog/Kconfig b/board/solidrun/clearfog/Kconfig
index 60d3921307..765d8a6355 100644
--- a/board/solidrun/clearfog/Kconfig
+++ b/board/solidrun/clearfog/Kconfig
@@ -39,6 +39,25 @@ config CLEARFOG_SFP_25GB
  SGMII connection (requires a supporting SFP). By default, transfer 
speed
  of 1.25 Gbps is used, suitable for a more common 1 Gbps SFP module.
  
+choice CLEARFOG_GTR_SERDES0

+   prompt "Select Clearfog GTR SerDes 0 Function"
+   help
+ Select function for SerDes 0 which is shared between CON3 and CON18
+ for either pci-e or sata.
+
+config CLEARFOG_GTR_SERDES0_PCIE
+   bool "PCI-E on CON3"
+   default y


After applying this patch I get this warning:

board/solidrun/clearfog/Kconfig:50:warning: defaults for choice values 
not supported


Could you please take a look?

Thanks,
Stefan


+   help
+ Configure SerDes 0 for PCI-E to enable CON3 mini-PCI-E connector.
+
+config CLEARFOG_GTR_SERDES0_SATA
+   bool "SATA on CON18"
+   help
+ Configure SerDes 0 for SATA to enable CON18 SATA connector.
+
+endchoice
+
  config ENV_SIZE
hex "Environment Size"
default 0x1
diff --git a/board/solidrun/clearfog/clearfog.c 
b/board/solidrun/clearfog/clearfog.c
index 6fa2fe5fe3..51c5be518a 100644
--- a/board/solidrun/clearfog/clearfog.c
+++ b/board/solidrun/clearfog/clearfog.c
@@ -90,9 +90,14 @@ int hws_board_topology_load(struct serdes_map 
**serdes_map_array, u8 *count)
  
  	/* Apply runtime detection changes */

if (sr_product_is(_tlv_data, "Clearfog GTR")) {
-   board_serdes_map[0].serdes_type = PEX0;
-   board_serdes_map[0].serdes_speed = SERDES_SPEED_5_GBPS;
-   board_serdes_map[0].serdes_mode = PEX_ROOT_COMPLEX_X1;
+   if (IS_ENABLED(CONFIG_CLEARFOG_GTR_SERDES0_SATA)) {
+   /* serdes 0 is sata (like clearfog pro) */
+   } else if (IS_ENABLED(CONFIG_CLEARFOG_GTR_SERDES0_PCIE)) {
+   /* serdes 0 is pci */
+   board_serdes_map[0].serdes_type = PEX0;
+   board_serdes_map[0].serdes_speed = SERDES_SPEED_5_GBPS;
+   board_serdes_map[0].serdes_mode = PEX_ROOT_COMPLEX_X1;
+   }
} else if (sr_product_is(_tlv_data, "Clearfog Pro")) {
/* handle recognized product as noop, no adjustment required */
} else if (sr_product_is(_tlv_data, "Clearfog Base")) {



Viele Grüße,
Stefan Roese

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


Re: [PATCH v2] net: mv88e6xxx: fix missing SMI address initialization

2024-01-09 Thread Stefan Roese

On 12/18/23 17:09, Marek Behún wrote:

On Wed, 6 Dec 2023 15:35:56 +0100
Marek Mojík  wrote:


The mv88e6xxx driver does not currently initialize the smi_addr field, but
instead keeps the default zero value. This leads to driver being unusable
on devices where the switch is not on address zero of the mdio bus. Fix
this problem by reading the SMI address from device tree.

Signed-off-by: Marek Mojík 
---
  drivers/net/mv88e6xxx.c | 8 
  1 file changed, 8 insertions(+)

diff --git a/drivers/net/mv88e6xxx.c b/drivers/net/mv88e6xxx.c
index c073f81e72..8fbbc1cacc 100644
--- a/drivers/net/mv88e6xxx.c
+++ b/drivers/net/mv88e6xxx.c
@@ -745,6 +745,7 @@ static int mv88e6xxx_probe(struct udevice *dev)
  {
struct dsa_pdata *dsa_pdata = dev_get_uclass_plat(dev);
struct mv88e6xxx_priv *priv = dev_get_priv(dev);
+   fdt_addr_t smi_addr;
int val, ret;
  
  	if (ofnode_valid(dev_ofnode(dev)) &&

@@ -753,6 +754,13 @@ static int mv88e6xxx_probe(struct udevice *dev)
return -ENODEV;
}
  
+	smi_addr = dev_read_addr(dev);

+   if (smi_addr == FDT_ADDR_T_NONE) {
+   dev_err(dev, "Missing SMI address\n");
+   return -EINVAL;
+   }
+   priv->smi_addr = smi_addr;
+
/* probe internal mdio bus */
ret = mv88e6xxx_probe_mdio(dev);
if (ret)


Reviewed-by: Marek Behún 


Reviewed-by: Stefan Roese 

Ramon, this patch was assigned to me as an Marvell MVEBU patch
depends on it. I've assigned it to you now. Or if it's okay that
I pull it with the Marvell tree, just let me know.

Thanks,
Stefan

Viele Grüße,
Stefan Roese

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


Re: [PATCH 2/4] watchdog: Add StarFive Watchdog driver

2023-12-04 Thread Stefan Roese

On 11/6/23 00:13, Chanho Park wrote:

Add to support StarFive watchdog driver. The driver is imported from
linux kernel's drivers/watchdog/starfive-wdt.c without jh7100 support
because there is no support of jh7100 SoC in u-boot yet.
Howver, this patch has been kept the variant coding style because JH7100
can be added later and have a consistency with the linux driver.

Signed-off-by: Chanho Park 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  drivers/watchdog/Kconfig|   7 +
  drivers/watchdog/Makefile   |   1 +
  drivers/watchdog/starfive_wdt.c | 329 
  3 files changed, 337 insertions(+)
  create mode 100644 drivers/watchdog/starfive_wdt.c

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 07fc4940e918..569726119ca1 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -344,6 +344,13 @@ config WDT_STM32MP
  Enable the STM32 watchdog (IWDG) driver. Enable support to
  configure STM32's on-SoC watchdog.
  
+config WDT_STARFIVE

+   bool "StarFive watchdog timer support"
+   depends on WDT
+   imply WATCHDOG
+   help
+ Enable support for the watchdog timer of StarFive JH7110 SoC.
+
  config WDT_SUNXI
bool "Allwinner sunxi watchdog timer support"
depends on WDT && ARCH_SUNXI
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index eef786f5e74e..5520d3d9ae8a 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -44,6 +44,7 @@ obj-$(CONFIG_WDT_SBSA) += sbsa_gwdt.o
  obj-$(CONFIG_WDT_K3_RTI) += rti_wdt.o
  obj-$(CONFIG_WDT_SL28CPLD) += sl28cpld-wdt.o
  obj-$(CONFIG_WDT_SP805) += sp805_wdt.o
+obj-$(CONFIG_WDT_STARFIVE) += starfive_wdt.o
  obj-$(CONFIG_WDT_STM32MP) += stm32mp_wdt.o
  obj-$(CONFIG_WDT_SUNXI) += sunxi_wdt.o
  obj-$(CONFIG_WDT_TANGIER) += tangier_wdt.o
diff --git a/drivers/watchdog/starfive_wdt.c b/drivers/watchdog/starfive_wdt.c
new file mode 100644
index ..ee9ec4cdc3a4
--- /dev/null
+++ b/drivers/watchdog/starfive_wdt.c
@@ -0,0 +1,329 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Starfive Watchdog driver
+ *
+ * Copyright (C) 2022 StarFive Technology Co., Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* JH7110 Watchdog register define */
+#define STARFIVE_WDT_JH7110_LOAD   0x000
+#define STARFIVE_WDT_JH7110_VALUE  0x004
+#define STARFIVE_WDT_JH7110_CONTROL0x008   /*
+* [0]: reset enable;
+* [1]: interrupt enable && 
watchdog enable
+* [31:2]: reserved.
+*/
+#define STARFIVE_WDT_JH7110_INTCLR 0x00c   /* clear intterupt and reload 
the counter */
+#define STARFIVE_WDT_JH7110_IMS0x014
+#define STARFIVE_WDT_JH7110_LOCK   0xc00   /* write 0x1ACCE551 to unlock */
+
+/* WDOGCONTROL */
+#define STARFIVE_WDT_ENABLE0x1
+#define STARFIVE_WDT_EN_SHIFT  0
+#define STARFIVE_WDT_RESET_EN  0x1
+#define STARFIVE_WDT_JH7110_RST_EN_SHIFT   1
+
+/* WDOGLOCK */
+#define STARFIVE_WDT_JH7110_UNLOCK_KEY 0x1acce551
+
+/* WDOGINTCLR */
+#define STARFIVE_WDT_INTCLR0x1
+#define STARFIVE_WDT_JH7100_INTCLR_AVA_SHIFT   1   /* Watchdog can clear 
interrupt when 0 */
+
+#define STARFIVE_WDT_MAXCNT0x
+#define STARFIVE_WDT_DEFAULT_TIME  (15)
+#define STARFIVE_WDT_DELAY_US  0
+#define STARFIVE_WDT_TIMEOUT_US1
+
+/* module parameter */
+#define STARFIVE_WDT_EARLY_ENA 0
+
+struct starfive_wdt_variant {
+   unsigned int control;   /* Watchdog Control Resgister for reset 
enable */
+   unsigned int load;  /* Watchdog Load register */
+   unsigned int reload;/* Watchdog Reload Control register */
+   unsigned int enable;/* Watchdog Enable Register */
+   unsigned int value; /* Watchdog Counter Value Register */
+   unsigned int int_clr;   /* Watchdog Interrupt Clear Register */
+   unsigned int unlock;/* Watchdog Lock Register */
+   unsigned int int_status;/* Watchdog Interrupt Status Register */
+
+   u32 unlock_key;
+   char enrst_shift;
+   char en_shift;
+   bool intclr_check;  /*  whether need to check it before 
clearing interrupt */
+   char intclr_ava_shift;
+   bool double_timeout;/* The watchdog need twice timeout to 
reboot */
+};
+
+struct starfive_wdt_priv {
+   void __iomem *base;
+   struct clk *core_clk;
+   struct clk *apb_clk;
+   struct reset_ctl_bulk *rst;
+   const struct starfive_wdt_variant *variant;
+   unsigned long freq;
+   u32 count;  /* co

Please pull u-boot-watchdog/master

2023-12-04 Thread Stefan Roese

Hi Tom,

please pull the following watchdog related fix:


- Correct watchdog timeout print message (Chanho Park)


Here the Azure build, without any issues:

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

Thanks,
Stefan


The following changes since commit 5c4e9d0c74a8c2f8d0f4e0ab9cf44959298c2bad:

  Merge branch 'master-rpc-off' of 
https://source.denx.de/u-boot/custodians/u-boot-sh (2023-12-03 16:30:32 
-0500)


are available in the Git repository at:

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

for you to fetch changes up to a341a0e01f8087904eccbf3fe7baba63a62f9674:

  watchdog: Correct watchdog timeout print message (2023-12-04 08:09:09 
+0100)



Chanho Park (1):
  watchdog: Correct watchdog timeout print message

 drivers/watchdog/wdt-uclass.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)


Re: [PATCH v2] watchdog: Correct watchdog timeout print message

2023-12-04 Thread Stefan Roese

On 12/3/23 09:30, Chanho Park wrote:

The wdt_start function takes timeout_ms as a parameter and starts the
watchdog with this value. However, when you output the message, it shows
the default timeout value for the watchdog device.
So this patch fixes that part to output the correct timeout value.

Before -->
StarFive # wdt start 3000
WDT:   Started watchdog@1307 without servicing  (60s timeout)

After -->
StarFive # wdt start 3000
WDT:   Started watchdog@1307 without servicing  (3s timeout)

Fixes: c2fd0ca1a822 ("watchdog: Integrate watchdog triggering into the cyclic 
framework")
Signed-off-by: Chanho Park 


Applied to u-boot-watchdog/master

Thanks,
Stefan


---
Change from v1:
- Use lldiv to fix a build error of m68k arch

  drivers/watchdog/wdt-uclass.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/watchdog/wdt-uclass.c b/drivers/watchdog/wdt-uclass.c
index ed329284decb..417e8d7eef95 100644
--- a/drivers/watchdog/wdt-uclass.c
+++ b/drivers/watchdog/wdt-uclass.c
@@ -7,6 +7,7 @@
  
  #include 

  #include 
+#include 
  #include 
  #include 
  #include 
@@ -141,7 +142,7 @@ int wdt_start(struct udevice *dev, u64 timeout_ms, ulong 
flags)
  
  		printf("WDT:   Started %s with%s servicing %s (%ds timeout)\n",

   dev->name, IS_ENABLED(CONFIG_WATCHDOG) ? "" : "out",
-  str, priv->timeout);
+  str, (u32)lldiv(timeout_ms, 1000));
    }
  
  	return ret;


Viele Grüße,
Stefan Roese

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


Re: [PATCH 1/5] cyclic: Disable in SPL builds

2023-12-03 Thread Stefan Roese

Hi Simon,

On 11/19/23 19:23, Simon Glass wrote:

Hi Tom,

On Sun, 19 Nov 2023 at 08:59, Tom Rini  wrote:


On Sun, Nov 19, 2023 at 07:46:39AM -0700, Simon Glass wrote:


The cyclic subsystem is currently enabled in all build phases or none.
So far it doesn't have any purpose within SPL builds, so adjust the
rules to prevent it being built in that case.

Signed-off-by: Simon Glass 
---

  common/Makefile  | 2 +-
  include/cyclic.h | 6 --
  2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/common/Makefile b/common/Makefile
index 1495436d5d45..27443863bf9b 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -77,7 +77,7 @@ obj-$(CONFIG_CROS_EC) += cros_ec.o
  obj-y += dlmalloc.o
  obj-$(CONFIG_$(SPL_TPL_)SYS_MALLOC_F) += malloc_simple.o

-obj-$(CONFIG_CYCLIC) += cyclic.o
+obj-$(CONFIG_$(SPL_TPL_)CYCLIC) += cyclic.o
  obj-$(CONFIG_$(SPL_TPL_)EVENT) += event.o

  obj-$(CONFIG_$(SPL_TPL_)HASH) += hash.o


This is fine, but I suspect we're missing SPL_CYCLIC as a symbol and
SPL_WDT should be select'ing that, same as "WDT".


Ooops I had assumed that it wasn't used in SPL but of course watchdog
is completely migrated to it now...I will add a symbol.

BTW the watchdog Kconfig seems a little confusiing. There is only one
board using WATCHDOG without WDT and only 3 using HW_WATCHDOG

Setfan, I wonder if some more clean-up could be done?


I fully agree that the watchdog Kconfig options are confusing. Perhaps
I can find some time in the Holidays to try to clean this up and finally
get rid of this HW_WATCHDOG stuff completely.

Thanks,
Stefan




diff --git a/include/cyclic.h b/include/cyclic.h
index 44ad3cb6b803..d3b368dd90df 100644
--- a/include/cyclic.h
+++ b/include/cyclic.h
@@ -11,6 +11,7 @@
  #ifndef __cyclic_h
  #define __cyclic_h

+#include 
  #include 
  #include 


Is this really needed? What's blowing up since we should have -include
.../linux/kconfig.h cover this.


It is the CONFIG_IS_ENABLED() when building. We have kconfig.h in a
few other places (used by tools) too.

In file included from include/watchdog.h:13,
  from tools/../lib/sha1.c:25,
  from tools/generated/lib/sha1.c:1:
include/cyclic.h:47:22: error: missing binary operator before token "("
47 | #if CONFIG_IS_ENABLED(CYCLIC)
   |  ^

Regards,
Simon


Viele Grüße,
Stefan Roese

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


Re: [PATCH v2 1/5] cyclic: Add a symbol for SPL

2023-12-03 Thread Stefan Roese

On 12/2/23 16:33, Simon Glass wrote:

The cyclic subsystem is currently enabled either in all build phases
or none. For tools this should not be enabled, but since lib/shc256.c
and other files include watchdog.h in the host build, we must make
sure that it is not enabled there.

Add an SPL symbol so that there is more control of this.

Add an include into cyclic.h so that tools can include this file.

Also add the kconfig.h header so that CONFIG_IS_ENABLED() works. We
could avoid this for now by moving the location of the watchdog.h
inclusion to outside the USE_HOSTCC area. But at some point the #ifdefs
from these files will likely be removed, so there is no benefit in
going that way.

Signed-off-by: Simon Glass 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---

Changes in v2:
- Add an SPL_CYCLIC symbol
- Add a lot more explanation about the header files

  common/Kconfig| 8 
  common/Makefile   | 2 +-
  drivers/watchdog/Kconfig  | 1 +
  include/asm-generic/global_data.h | 2 +-
  include/cyclic.h  | 6 --
  5 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index 0283701f1d05..5906a4af7c33 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -626,6 +626,14 @@ config CYCLIC
  
  if CYCLIC
  
+config SPL_CYCLIC

+   bool "General-purpose cyclic execution mechanism (SPL)"
+   help
+ This enables a general-purpose cyclic execution infrastructure in SPL,
+ to allow "small" (run-time wise) functions to be executed at
+ a specified frequency. Things like LED blinking or watchdog
+ triggering are examples for such tasks.
+
  config CYCLIC_MAX_CPU_TIME_US
int "Sets the max allowed time for a cyclic function in us"
default 1000
diff --git a/common/Makefile b/common/Makefile
index 1495436d5d45..27443863bf9b 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -77,7 +77,7 @@ obj-$(CONFIG_CROS_EC) += cros_ec.o
  obj-y += dlmalloc.o
  obj-$(CONFIG_$(SPL_TPL_)SYS_MALLOC_F) += malloc_simple.o
  
-obj-$(CONFIG_CYCLIC) += cyclic.o

+obj-$(CONFIG_$(SPL_TPL_)CYCLIC) += cyclic.o
  obj-$(CONFIG_$(SPL_TPL_)EVENT) += event.o
  
  obj-$(CONFIG_$(SPL_TPL_)HASH) += hash.o

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 07fc4940e918..378435c55cc7 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -395,6 +395,7 @@ config WDT_ARM_SMC
  config SPL_WDT
bool "Enable driver model for watchdog timer drivers in SPL"
depends on SPL_DM
+   select SPL_CYCLIC if CYCLIC
help
  Enable driver model for watchdog timer in SPL.
  This is similar to CONFIG_WDT in U-Boot.
diff --git a/include/asm-generic/global_data.h 
b/include/asm-generic/global_data.h
index e8c6412e3f8d..77f11a4383c9 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -485,7 +485,7 @@ struct global_data {
 */
struct event_state event_state;
  #endif
-#ifdef CONFIG_CYCLIC
+#if CONFIG_IS_ENABLED(CYCLIC)
/**
 * @cyclic_list: list of registered cyclic functions
 */
diff --git a/include/cyclic.h b/include/cyclic.h
index 44ad3cb6b803..d3b368dd90df 100644
--- a/include/cyclic.h
+++ b/include/cyclic.h
@@ -11,6 +11,7 @@
  #ifndef __cyclic_h
  #define __cyclic_h
  
+#include 

  #include 
  #include 
  
@@ -44,7 +45,8 @@ struct cyclic_info {

  /** Function type for cyclic functions */
  typedef void (*cyclic_func_t)(void *ctx);
  
-#if defined(CONFIG_CYCLIC)

+#if CONFIG_IS_ENABLED(CYCLIC)
+
  /**
   * cyclic_register - Register a new cyclic function
   *
@@ -122,6 +124,6 @@ static inline int cyclic_unregister_all(void)
  {
return 0;
  }
-#endif
+#endif /* CYCLIC */
  
  #endif


Viele Grüße,
Stefan Roese

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


Re: [PATCH] mmc: Poll CD in case cyclic framework is enabled

2023-12-03 Thread Stefan Roese

On 12/4/23 02:05, Marek Vasut wrote:

On 12/4/23 01:44, Simon Glass wrote:

Hi Marek,

On Sun, 3 Dec 2023 at 14:01, Marek Vasut  wrote:


On 12/3/23 18:44, Simon Glass wrote:

Hi Marek,

On Sat, 2 Dec 2023 at 16:41, Marek Vasut
 wrote:


In case the cyclic framework is enabled, poll the card detect of 
already
initialized cards and deinitialize them in case they are removed. 
Since

the card initialization is a longer process and card initialization is
done on first access to an uninitialized card anyway, avoid 
initializing

newly detected uninitialized cards in the cyclic callback.

Signed-off-by: Marek Vasut 
---
Cc: Jaehoon Chung 
Cc: Peng Fan 
---
   drivers/mmc/mmc-uclass.c | 27 +++
   1 file changed, 27 insertions(+)


This is really nice!


I wonder whether we can use this cyclic stuff for USB , that's on my
roadmap to look at . We could auto-detect new devices in the background,
which would be tidy. And maybe do block transfers in the background ?


Just the detect would be amazing!!

One thing on my mind is that we could have a console buffer, so that
output from background tasks can be collected and written just before
displaying the U-Boot prompt. I am itching to implement that part of
it :-)


And a 'dmesg' command to go along with it ?

Go for it.


It's very nice to see, that the cyclic infrastructure is finally getting
used by other interfaces / devices etc. Really interesting. I assume
there are many more potential use cases where it may be helpful.

Thanks for all your work on this,
Stefan


Re: [PATCH v2] watchdog: Correct watchdog timeout print message

2023-12-03 Thread Stefan Roese

On 12/3/23 09:30, Chanho Park wrote:

The wdt_start function takes timeout_ms as a parameter and starts the
watchdog with this value. However, when you output the message, it shows
the default timeout value for the watchdog device.
So this patch fixes that part to output the correct timeout value.

Before -->
StarFive # wdt start 3000
WDT:   Started watchdog@1307 without servicing  (60s timeout)

After -->
StarFive # wdt start 3000
WDT:   Started watchdog@1307 without servicing  (3s timeout)

Fixes: c2fd0ca1a822 ("watchdog: Integrate watchdog triggering into the cyclic 
framework")
Signed-off-by: Chanho Park 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
Change from v1:
- Use lldiv to fix a build error of m68k arch

  drivers/watchdog/wdt-uclass.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/watchdog/wdt-uclass.c b/drivers/watchdog/wdt-uclass.c
index ed329284decb..417e8d7eef95 100644
--- a/drivers/watchdog/wdt-uclass.c
+++ b/drivers/watchdog/wdt-uclass.c
@@ -7,6 +7,7 @@
  
  #include 

  #include 
+#include 
  #include 
  #include 
  #include 
@@ -141,7 +142,7 @@ int wdt_start(struct udevice *dev, u64 timeout_ms, ulong 
flags)
  
  		printf("WDT:   Started %s with%s servicing %s (%ds timeout)\n",

   dev->name, IS_ENABLED(CONFIG_WATCHDOG) ? "" : "out",
-  str, priv->timeout);
+  str, (u32)lldiv(timeout_ms, 1000));
    }
  
  	return ret;


Viele Grüße,
Stefan Roese

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


Re: [PATCH] watchdog: Correct watchdog timeout print message

2023-12-01 Thread Stefan Roese

On 12/1/23 08:37, Stefan Roese wrote:

On 11/27/23 02:05, Chanho Park wrote:

The wdt_start function takes timeout_ms as a parameter and starts the
watchdog with this value. However, when you output the message, it shows
the default timeout value for the watchdog device.
So this patch fixes that part to output the correct timeout value.

Before -->
StarFive # wdt start 3000
WDT:   Started watchdog@1307 without servicing  (60s timeout)

After -->
StarFive # wdt start 3000
WDT:   Started watchdog@1307 without servicing  (3s timeout)

Fixes: c2fd0ca1a822 ("watchdog: Integrate watchdog triggering into the 
cyclic framework")

Signed-off-by: Chanho Park 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  drivers/watchdog/wdt-uclass.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/watchdog/wdt-uclass.c 
b/drivers/watchdog/wdt-uclass.c

index ed329284decb..65a4bc1f90ed 100644
--- a/drivers/watchdog/wdt-uclass.c
+++ b/drivers/watchdog/wdt-uclass.c
@@ -141,7 +141,7 @@ int wdt_start(struct udevice *dev, u64 timeout_ms, 
ulong flags)

  printf("WDT:   Started %s with%s servicing %s (%ds timeout)\n",
 dev->name, IS_ENABLED(CONFIG_WATCHDOG) ? "" : "out",
-   str, priv->timeout);
+   str, (u32)(timeout_ms / 1000));


Unfortunately this commit break CI build - I tested using Azure CI:

test.py for QEMU platforms qemu_m68k:


Successfully installed attrs-23.1.0 jsonschema-4.17.3 pyrsistent-0.20.0 
pyyaml-6.0
+ tools/buildman/buildman -o /tmp/M5208EVBE -w -E -W -e --board 
M5208EVBE -a CONFIG_M68K_QEMU=y -a '~CONFIG_MCFTMR'

Building current source for 1 boards (1 thread, 2 jobs per thread)

Starting build...


000 /1   -1  (starting)

  m68k:  +   M5208EVBE
+m68k-linux-ld.bfd: drivers/watchdog/wdt-uclass.o: in function `wdt_start':
+drivers/watchdog/wdt-uclass.c:144:(.text.wdt_start+0xc6): undefined 
reference to `__udivdi3'

+make[1]: *** [Makefile:1765: u-boot] Error 1
+make: *** [Makefile:177: sub-make] Error 2

001 /1  M5208EVBE
Completed: 1 total built, 1 newly), duration 0:00:21, rate 0.05
##[error]Bash exited with code '100'.
##[warning]RetryHelper encountered task failure, will retry (attempt #: 
1 out of 2) after 1000 ms

Generating script.

Could you please take a look?

Thanks,
Stefan


Re: [PATCH] watchdog: Correct watchdog timeout print message

2023-11-30 Thread Stefan Roese

On 11/27/23 02:05, Chanho Park wrote:

The wdt_start function takes timeout_ms as a parameter and starts the
watchdog with this value. However, when you output the message, it shows
the default timeout value for the watchdog device.
So this patch fixes that part to output the correct timeout value.

Before -->
StarFive # wdt start 3000
WDT:   Started watchdog@1307 without servicing  (60s timeout)

After -->
StarFive # wdt start 3000
WDT:   Started watchdog@1307 without servicing  (3s timeout)

Fixes: c2fd0ca1a822 ("watchdog: Integrate watchdog triggering into the cyclic 
framework")
Signed-off-by: Chanho Park 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
  drivers/watchdog/wdt-uclass.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/watchdog/wdt-uclass.c b/drivers/watchdog/wdt-uclass.c
index ed329284decb..65a4bc1f90ed 100644
--- a/drivers/watchdog/wdt-uclass.c
+++ b/drivers/watchdog/wdt-uclass.c
@@ -141,7 +141,7 @@ int wdt_start(struct udevice *dev, u64 timeout_ms, ulong 
flags)
  
  		printf("WDT:   Started %s with%s servicing %s (%ds timeout)\n",

   dev->name, IS_ENABLED(CONFIG_WATCHDOG) ? "" : "out",
-  str, priv->timeout);
+  str, (u32)(timeout_ms / 1000));
    }
  
  	return ret;


Viele Grüße,
Stefan Roese

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


Re: [PATCH v2 1/3] arm: mvebu: Espressobin: move FDT fixup into a separate function

2023-11-28 Thread Stefan Roese

Hi Robert,

On 11/28/23 16:44, Stefan Roese wrote:

Hi Robert,

On 11/28/23 11:19, Robert Marko wrote:
On Fri, Oct 20, 2023 at 12:21 PM Robert Marko 
 wrote:


Currently, Esspresobin FDT is being fixed up directly in 
ft_board_setup()

which makes it hard to add support for any other board to be fixed up.

So, lets just move the FDT fixup code to a separate function and call it
if compatible matches, there should be no functional change.

Signed-off-by: Robert Marko 
Reviewed-by: Stefan Roese 


Hi Stefan,

Is there anything I can do to get this series merged?


I just looked at it (again). My recollection was that something was
missing here - so I was waiting for a new version. Does not seem to
be the case though. So I guess I forgot to pull it (sorry for that)
and now with rc3 out it seems a bit too late in the release cycle.
I hope you don't mind that it's postponed to the next merge window.


Seems my memory is not that bad after all. A world CI build fails with
these 3 commits. Could you please have a look?

Completed: 84 total built, 84 newly), duration 1:01:11, rate 0.02
+ ret=100
+ [[ 100 -ne 0 ]]
+ tools/buildman/buildman -o /tmp -seP am33xx at91_kirkwood mvebu omap 
-x siemens

Summary of current source for 84 boards (2 threads, 1 job per thread)
   aarch64:  w+   x240 turris_mox mvebu_ac5_rd eDPU 
mvebu_espressobin-88f3720 uDPU clearfog_gt_8k mvebu_db_armada8k 
mvebu_mcbin-88f8040 mvebu_puzzle-m801-88f8040 mvebu_crb_cn9130 
mvebu_db_cn9130 +   mvebu_db-88f3720
   arm:  w+   am335x_shc am335x_shc_ict am335x_shc_netboot 
am335x_shc_sdboot brsmarc1 cm_t43 chiliboard am335x_igep003x am335x_sl50 
am43xx_evm_qspiboot am43xx_hs_evm_qspi controlcenterdc db-88f6720 
db-88f6820-gp igep00x0 sniper omap3_beagle omap4_panda omap4_sdp4430
+aarch64-linux-ld.bfd: board/Marvell/mvebu_armada-37xx/board.o: in 
function `is_edpu_plus':
+board/Marvell/mvebu_armada-37xx/board.c:94:(.text.last_stage_init+0xb4): 
undefined reference to `dm_mdio_read'

+make[1]: *** [Makefile:1765: u-boot] Error 139
+make[1]: *** Deleting file 'u-boot'
+make: *** [Makefile:177: sub-make] Error 2


Thanks,
Stefan



Thanks,
Stefan


Regards,
Robert


---
  board/Marvell/mvebu_armada-37xx/board.c | 14 +-
  1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/board/Marvell/mvebu_armada-37xx/board.c 
b/board/Marvell/mvebu_armada-37xx/board.c

index 04124d8014..1471caa9a6 100644
--- a/board/Marvell/mvebu_armada-37xx/board.c
+++ b/board/Marvell/mvebu_armada-37xx/board.c
@@ -363,18 +363,14 @@ EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, 
last_stage_init);

  #endif

  #ifdef CONFIG_OF_BOARD_SETUP
-int ft_board_setup(void *blob, struct bd_info *bd)
+static int espressobin_fdt_setup(void *blob)
  {
-#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
 int ret;
 int spi_off;
 int parts_off;
 int part_off;

 /* Fill SPI MTD partitions for Linux kernel on Espressobin */
-   if (!of_machine_is_compatible("globalscale,espressobin"))
-   return 0;
-
 spi_off = fdt_node_offset_by_compatible(blob, -1, 
"jedec,spi-nor");

 if (spi_off < 0)
 return 0;
@@ -459,6 +455,14 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 return 0;
 }

+   return 0;
+}
+
+int ft_board_setup(void *blob, struct bd_info *bd)
+{
+#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
+   if (of_machine_is_compatible("globalscale,espressobin"))
+   return espressobin_fdt_setup(blob);
  #endif
 return 0;
  }
--
2.41.0






Viele Grüße,
Stefan Roese



Viele Grüße,
Stefan Roese

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


Re: [PATCH v2 1/3] arm: mvebu: Espressobin: move FDT fixup into a separate function

2023-11-28 Thread Stefan Roese

Hi Robert,

On 11/28/23 11:19, Robert Marko wrote:

On Fri, Oct 20, 2023 at 12:21 PM Robert Marko  wrote:


Currently, Esspresobin FDT is being fixed up directly in ft_board_setup()
which makes it hard to add support for any other board to be fixed up.

So, lets just move the FDT fixup code to a separate function and call it
if compatible matches, there should be no functional change.

Signed-off-by: Robert Marko 
Reviewed-by: Stefan Roese 


Hi Stefan,

Is there anything I can do to get this series merged?


I just looked at it (again). My recollection was that something was
missing here - so I was waiting for a new version. Does not seem to
be the case though. So I guess I forgot to pull it (sorry for that)
and now with rc3 out it seems a bit too late in the release cycle.
I hope you don't mind that it's postponed to the next merge window.

Thanks,
Stefan


Regards,
Robert


---
  board/Marvell/mvebu_armada-37xx/board.c | 14 +-
  1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/board/Marvell/mvebu_armada-37xx/board.c 
b/board/Marvell/mvebu_armada-37xx/board.c
index 04124d8014..1471caa9a6 100644
--- a/board/Marvell/mvebu_armada-37xx/board.c
+++ b/board/Marvell/mvebu_armada-37xx/board.c
@@ -363,18 +363,14 @@ EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, last_stage_init);
  #endif

  #ifdef CONFIG_OF_BOARD_SETUP
-int ft_board_setup(void *blob, struct bd_info *bd)
+static int espressobin_fdt_setup(void *blob)
  {
-#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
 int ret;
 int spi_off;
 int parts_off;
 int part_off;

 /* Fill SPI MTD partitions for Linux kernel on Espressobin */
-   if (!of_machine_is_compatible("globalscale,espressobin"))
-   return 0;
-
 spi_off = fdt_node_offset_by_compatible(blob, -1, "jedec,spi-nor");
 if (spi_off < 0)
 return 0;
@@ -459,6 +455,14 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 return 0;
 }

+   return 0;
+}
+
+int ft_board_setup(void *blob, struct bd_info *bd)
+{
+#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
+   if (of_machine_is_compatible("globalscale,espressobin"))
+   return espressobin_fdt_setup(blob);
  #endif
 return 0;
  }
--
2.41.0






Viele Grüße,
Stefan Roese

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


Re: Error building PX30 Ringneck with WDT support

2023-11-16 Thread Stefan Roese

Hi Quentin,

On 11/15/23 19:00, Quentin Schulz wrote:

Hi all,

I'm trying to add watchdog support to the PX30 Ringneck board but it 
fails to compile:


"""
diff --git a/configs/ringneck-px30_defconfig 
b/configs/ringneck-px30_defconfig

index b314636b4d9..3dab0dab5d4 100644
--- a/configs/ringneck-px30_defconfig
+++ b/configs/ringneck-px30_defconfig
@@ -122,6 +122,10 @@ CONFIG_USB_EHCI_HCD=y
  CONFIG_USB_EHCI_GENERIC=y
  CONFIG_USB_GADGET=y
  CONFIG_USB_GADGET_DWC2_OTG=y
+# CONFIG_WATCHDOG is not set
+# CONFIG_WATCHDOG_AUTOSTART is not set
+CONFIG_DESIGNWARE_WATCHDOG=y
+CONFIG_WDT=y
  CONFIG_SPL_TINY_MEMSET=y
  CONFIG_TPL_TINY_MEMSET=y
  CONFIG_LZO=y
"""

$ make CROSS_COMPILE="aarch64-linux-gnu-" ringneck-px30_defconfig
$ make CROSS_COMPILE="aarch64-linux-gnu-"
[...]
/usr/bin/aarch64-linux-gnu-ld.bfd: lib/time.o: in function `udelay':
/home/qschulz/work/upstream/u-boot/lib/time.c:199: undefined reference 
to `schedule'
/home/qschulz/work/upstream/u-boot/lib/time.c:199:(.text.udelay+0x1c): 
relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol 
`schedule'

make[1]: *** [scripts/Makefile.spl:527: tpl/u-boot-tpl] Error 1
make: *** [Makefile:2073: tpl/u-boot-tpl] Error 2

FWIW, I had this kept on a downstream U-Boot (v2022.10, on top of: 
https://git.theobroma-systems.com/ringneck-u-boot.git/log/?h=v2022.10-ringneck) and it both compiled and worked. I assume this may be related to the "new" cyclic support?


This seems very likely.

Looking for pointers as somehow I don't really understand the error. 
schedule() definition seems to be existing in headers included in 
lib/time.c so a bit clueless at the moment. Probably related to TPL also 
as it doesn't fail in neither proper nor SPL build stages it seems.


Correct. I assume that this cyclic / WDT support was never used /
implemented with TPL. Could you please take a deeper look at this
to see, where exactly the problem originates.

Thanks,
Stefan


Re: [PATCH] spi: cadence-quadspi: Fix error message on stuck busy state

2023-10-31 Thread Stefan Roese

On 10/30/23 17:20, Jan Kiszka wrote:

From: Jan Kiszka 

We are not iterating CQSPI_REG_RETRY, we are waiting 'timeout' ms, since
day 1.

Signed-off-by: Jan Kiszka 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---

We are unfortunately seeing that message right now, rarely but then
prominently...

  drivers/spi/cadence_qspi_apb.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c
index 9ce2c0f254f..d033184aa46 100644
--- a/drivers/spi/cadence_qspi_apb.c
+++ b/drivers/spi/cadence_qspi_apb.c
@@ -171,8 +171,7 @@ static unsigned int cadence_qspi_wait_idle(void *reg_base)
}
  
  	/* Timeout, still in busy mode. */

-   printf("QSPI: QSPI is still busy after poll for %d times.\n",
-  CQSPI_REG_RETRY);
+   printf("QSPI: QSPI is still busy after poll for %d ms.\n", timeout);
return 0;
  }
  


Viele Grüße,
Stefan Roese

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


Please pull u-boot-marvell/master

2023-10-27 Thread Stefan Roese

Hi Tom,

please pull this next batch of Marvell related patches:


- kirkwood: Enable bootstd on some boards (Tony)
- mvebu: turris_mox: Extend to support RIPE Atlas Probe (Marek)
- mvebu/bubt: Support eMMC data partition booting (Josua)


Here the Azure build, without any issues:

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

Thanks,
Stefan


The following changes since commit fb428b61819444b9337075f49c72f326f5d12085:

  Merge branch '2023-10-24-assorted-general-fixes-and-updates' 
(2023-10-24 19:12:21 -0400)


are available in the Git repository at:

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

for you to fetch changes up to b6014f209f15bd49dd4ceb987d3a52e99b0305d4:

  arm: kirkwood: Enable bootstd for Zyxel NSA310S board (2023-10-26 
14:49:36 +0200)



Josua Mayer (2):
  arm: mvebu: allow additional 4096 offset for bootable mmc image
  cmd: mvebu/bubt: move eMMC data-partition uboot from LBA-0 to 4096

Marek Behún (1):
  arm: mvebu: turris_mox: Extend to support RIPE Atlas Probe

Tony Dinh (2):
  arm: kirkwood: Enable bootstd for Pogo V4 board
  arm: kirkwood: Enable bootstd for Zyxel NSA310S board

 arch/arm/dts/Makefile   |  1 +
 arch/arm/dts/armada-3720-ripe-atlas.dts | 91 
+

 arch/arm/mach-mvebu/Kconfig |  6 ++-
 arch/arm/mach-mvebu/spl.c   |  5 +-
 board/CZ.NIC/turris_mox/mox_sp.c| 12 +++--
 board/CZ.NIC/turris_mox/mox_sp.h|  8 ++-
 board/CZ.NIC/turris_mox/turris_mox.c| 72 +++---
 cmd/mvebu/bubt.c| 11 +++-
 configs/nsa310s_defconfig   |  3 +-
 configs/pogo_v4_defconfig   |  3 +-
 configs/turris_mox_defconfig|  3 +-
 include/configs/nsa310s.h   | 17 +-
 include/configs/pogo_v4.h   | 35 +
 13 files changed, 200 insertions(+), 67 deletions(-)
 create mode 100644 arch/arm/dts/armada-3720-ripe-atlas.dts


Re: [PATCH v2 2/2] cmd: mvebu/bubt: move eMMC data-partition uboot from LBA-0 to 4096

2023-10-27 Thread Stefan Roese

On 10/26/23 09:10, Stefan Roese wrote:

On 10/25/23 10:22, Josua Mayer wrote:

A38x bootrom only searches 2 sectors when booting from eMMC,
irregardless of data or boot partition: 0 & 4096.

For eMMC boot partitions sector 0 is fine, but on data partition it
conflicts with MBR.

Change bubt command default to 4096 for eMMC data partition only, to
allow using an MBR partition table on the eMMC data partition while also
booting from it.

Signed-off-by: Josua Mayer 


Reviewed-by: Stefan Roese 


Applied to u-boot-marvell/master

Thanks,
Stefan


Thanks,
Stefan


---
V1 -> V2: fixed build without CONFIG_SUPPORT_EMMC_BOOT

  cmd/mvebu/bubt.c | 11 +--
  1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c
index ca24a5c1c4b..744b1c20aa8 100644
--- a/cmd/mvebu/bubt.c
+++ b/cmd/mvebu/bubt.c
@@ -240,9 +240,16 @@ static int mmc_burn_image(size_t image_size)
  #endif
  /* SD reserves LBA-0 for MBR and boots from LBA-1,
- * MMC/eMMC boots from LBA-0
+ * MMC/eMMC boots from LBA-0 and LBA-4096
   */
-    start_lba = IS_SD(mmc) ? 1 : 0;
+    if (IS_SD(mmc))
+    start_lba = 1;
+#ifdef CONFIG_SUPPORT_EMMC_BOOT
+    else if (part)
+    start_lba = 0;
+#endif
+    else
+    start_lba = 4096;
  #ifdef CONFIG_BLK
  blk_count = image_size / mmc->write_bl_len;
  if (image_size % mmc->write_bl_len)


Viele Grüße,
Stefan Roese



Viele Grüße,
Stefan Roese

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


Re: [PATCH v2 1/2] arm: mvebu: allow additional 4096 offset for bootable mmc image

2023-10-27 Thread Stefan Roese

On 10/26/23 09:10, Stefan Roese wrote:

On 10/25/23 10:22, Josua Mayer wrote:

Disarm the error message forcing u-boot/spl image to be located at
sector 0 on eMMC data-partition and microSD.
Offset 0 makes sense on eMMC boot partitions only, data partition must
use 4096 to avoid conflicting with MBR.

Valid offsets when booting from microSD, reported by boot-rom v1.73:

BootROM: Bad header at offset 0200
BootROM: Bad header at offset 4400
BootROM: Bad header at offset 0020
BootROM: Bad header at offset 0040
BootROM: Bad header at offset 0060
BootROM: Bad header at offset 0080
BootROM: Bad header at offset 00A0
BootROM: Bad header at offset 00C0
BootROM: Bad header at offset 00E0
BootROM: Bad header at offset 0100
BootROM: Bad header at offset 0120
BootROM: Bad header at offset 0140
BootROM: Bad header at offset 0160
BootROM: Bad header at offset 0180
BootROM: Bad header at offset 01A0
BootROM: Bad header at offset 01C0
BootROM: Bad header at offset 01E0
BootROM: Bad header at offset 0200
BootROM: Bad header at offset 0220
BootROM: Bad header at offset 0240
BootROM: Bad header at offset 0260
BootROM: Bad header at offset 0280
BootROM: Bad header at offset 02A0
BootROM: Bad header at offset 02C0
BootROM: Bad header at offset 02E0

Valid offsets when booting from eMMC:

BootROM: Bad header at offset 
BootROM: Bad header at offset 0020
Switching BootPartitions.
BootROM: Bad header at offset 
BootROM: Bad header at offset 0020

Fixes: 2226ca17348 ("arm: mvebu: Load U-Boot proper binary in SPL code 
based on kwbimage header")


Signed-off-by: Josua Mayer 


Reviewed-by: Stefan Roese 


Applied to u-boot-marvell/master

Thanks,
Stefan



Thanks,
Stefan



---
  arch/arm/mach-mvebu/spl.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
index eaaa68a8564..79f8877745b 100644
--- a/arch/arm/mach-mvebu/spl.c
+++ b/arch/arm/mach-mvebu/spl.c
@@ -71,8 +71,9 @@
  #error CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR must be set to 0
  #endif
  #if !defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET) || \
-    CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET != 0
-#error CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET must be set 
to 0

+    (CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET != 0 && \
+ CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET != 4096)
+#error CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET must be set 
to either 0 or 4096

  #endif
  #endif


Viele Grüße,
Stefan Roese



Viele Grüße,
Stefan Roese

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


Re: [PATCH] arm: kirkwood: Enable bootstd for Pogo V4 board

2023-10-27 Thread Stefan Roese

On 10/26/23 09:08, Stefan Roese wrote:

On 10/25/23 01:17, Tony Dinh wrote:

Enable bootstd for Pogo V4 board, and remove distroboot.

Signed-off-by: Tony Dinh 


Reviewed-by: Stefan Roese 


Applied to u-boot-marvell/master

Thanks,
Stefan


Thanks,
Stefan


---

  configs/pogo_v4_defconfig |  3 ++-
  include/configs/pogo_v4.h | 35 ++-
  2 files changed, 4 insertions(+), 34 deletions(-)

diff --git a/configs/pogo_v4_defconfig b/configs/pogo_v4_defconfig
index 2747c3c72d..ff6411d894 100644
--- a/configs/pogo_v4_defconfig
+++ b/configs/pogo_v4_defconfig
@@ -17,7 +17,8 @@ CONFIG_IDENT_STRING="\nPogoplug V4"
  CONFIG_SYS_LOAD_ADDR=0x80
  CONFIG_PCI=y
  CONFIG_LTO=y
-CONFIG_DISTRO_DEFAULTS=y
+CONFIG_BOOTSTD_FULL=y
+CONFIG_BOOTSTD_DEFAULTS=y
  CONFIG_BOOTSTAGE=y
  CONFIG_SHOW_BOOT_PROGRESS=y
  CONFIG_BOOTDELAY=10
diff --git a/include/configs/pogo_v4.h b/include/configs/pogo_v4.h
index 3371579023..d5003538da 100644
--- a/include/configs/pogo_v4.h
+++ b/include/configs/pogo_v4.h
@@ -1,6 +1,6 @@
  /* SPDX-License-Identifier: GPL-2.0+ */
  /*
- * Copyright (C) 2014-2022 Tony Dinh 
+ * Copyright (C) 2014-2023 Tony Dinh 
   *
   * Based on
   * Copyright (C) 2012
@@ -21,33 +21,6 @@
   */
  #include "mv-common.h"
-/* Include the common distro boot environment */
-#ifndef CONFIG_SPL_BUILD
-
-#ifdef CONFIG_MMC
-#define BOOT_TARGET_DEVICES_MMC(func) func(MMC, mmc, 0)
-#else
-#define BOOT_TARGET_DEVICES_MMC(func)
-#endif
-
-#ifdef CONFIG_SATA
-#define BOOT_TARGET_DEVICES_SATA(func) func(SATA, sata, 0)
-#else
-#define BOOT_TARGET_DEVICES_SATA(func)
-#endif
-
-#ifdef CONFIG_USB_STORAGE
-#define BOOT_TARGET_DEVICES_USB(func) func(USB, usb, 0)
-#else
-#define BOOT_TARGET_DEVICES_USB(func)
-#endif
-
-#define BOOT_TARGET_DEVICES(func) \
-    BOOT_TARGET_DEVICES_MMC(func) \
-    BOOT_TARGET_DEVICES_USB(func) \
-    BOOT_TARGET_DEVICES_SATA(func) \
-    func(DHCP, dhcp, na)
-
  #define KERNEL_ADDR_R    __stringify(0x80)
  #define FDT_ADDR_R    __stringify(0x2c0)
  #define RAMDISK_ADDR_R    __stringify(0x0110)
@@ -59,14 +32,10 @@
  "ramdisk_addr_r=" RAMDISK_ADDR_R "\0" \
  "scriptaddr=" SCRIPT_ADDR_R "\0"
-#include 
-
  #define CFG_EXTRA_ENV_SETTINGS \
  LOAD_ADDRESS_ENV_SETTINGS \
  "fdtfile=" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \
  "mtdparts=" CONFIG_MTDPARTS_DEFAULT "\0" \
-    "console=ttyS0,115200\0" \
-    BOOTENV
-#endif /* CONFIG_SPL_BUILD */
+    "console=ttyS0,115200\0"
  #endif /* _CONFIG_POGO_V4_H */


Viele Grüße,
Stefan Roese



Viele Grüße,
Stefan Roese

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


Re: [PATCH] arm: kirkwood: Enable bootstd for Zyxel NSA310S board

2023-10-27 Thread Stefan Roese

On 10/26/23 09:09, Stefan Roese wrote:

On 10/26/23 00:38, Tony Dinh wrote:

Enable bootstd for Zyxel NSA310S board, and remove distroboot.

Signed-off-by: Tony Dinh 


Reviewed-by: Stefan Roese 


Applied to u-boot-marvell/master

Thanks,
Stefan


Thanks,
Stefan


---

  configs/nsa310s_defconfig |  3 ++-
  include/configs/nsa310s.h | 17 ++---
  2 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/configs/nsa310s_defconfig b/configs/nsa310s_defconfig
index ff4895622c..038ef42e9d 100644
--- a/configs/nsa310s_defconfig
+++ b/configs/nsa310s_defconfig
@@ -19,7 +19,8 @@ CONFIG_DEBUG_UART_CLOCK=16667
  CONFIG_IDENT_STRING="\nZyXEL NSA310S/320S 1/2-Bay Power Media Server"
  CONFIG_SYS_LOAD_ADDR=0x80
  CONFIG_DEBUG_UART=y
-CONFIG_DISTRO_DEFAULTS=y
+CONFIG_BOOTSTD_FULL=y
+CONFIG_BOOTSTD_DEFAULTS=y
  CONFIG_BOOTDELAY=3
  CONFIG_USE_PREBOOT=y
  # CONFIG_DISPLAY_BOARDINFO is not set
diff --git a/include/configs/nsa310s.h b/include/configs/nsa310s.h
index fa029a176b..8c4d03553d 100644
--- a/include/configs/nsa310s.h
+++ b/include/configs/nsa310s.h
@@ -1,6 +1,6 @@
  /* SPDX-License-Identifier: GPL-2.0+ */
  /*
- * Copyright (C) 2015, 2021-2022 Tony Dinh 
+ * Copyright (C) 2015, 2021-2023 Tony Dinh 
   * Copyright (C) 2015
   * Gerald Kerma 
   * Luka Perkov 
@@ -15,14 +15,6 @@
   */
  #include "mv-common.h"
-/* Include the common distro boot environment */
-#ifndef CONFIG_SPL_BUILD
-
-#define BOOT_TARGET_DEVICES(func) \
-    func(USB, usb, 0) \
-    func(SATA, sata, 0) \
-    func(DHCP, dhcp, na)
-
  #define KERNEL_ADDR_R    __stringify(0x80)
  #define FDT_ADDR_R    __stringify(0x2c0)
  #define RAMDISK_ADDR_R    __stringify(0x0110)
@@ -34,16 +26,11 @@
  "ramdisk_addr_r=" RAMDISK_ADDR_R "\0" \
  "scriptaddr=" SCRIPT_ADDR_R "\0"
-#include 
-
  #define CFG_EXTRA_ENV_SETTINGS \
  "console=console=ttyS0,115200\0" \
  "kernel=/boot/zImage\0" \
  "fdt=/boot/nsa310s.dtb\0" \
  "bootargs_root=ubi.mtd=3 root=ubi0:rootfs rootfstype=ubifs rw\0" \
-    LOAD_ADDRESS_ENV_SETTINGS \
-    BOOTENV
-
-#endif /* CONFIG_SPL_BUILD */
+    LOAD_ADDRESS_ENV_SETTINGS
  #endif /* _CONFIG_NSA310S_H */


Viele Grüße,
Stefan Roese



Viele Grüße,
Stefan Roese

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


Re: [PATCH u-boot-marvell] arm: mvebu: turris_mox: Extend to support RIPE Atlas Probe

2023-10-27 Thread Stefan Roese

On 10/26/23 09:10, Stefan Roese wrote:

On 10/20/23 16:29, Marek Behún wrote:

Extend Turris Mox board code to support CZ.NIC's RIPE Atlas Probe.

Signed-off-by: Marek Behún 


Reviewed-by: Stefan Roese 


Applied to u-boot-marvell/master

Thanks,
Stefan


Thanks,
Stefan



---
  arch/arm/dts/Makefile   |  1 +
  arch/arm/dts/armada-3720-ripe-atlas.dts | 91 +
  arch/arm/mach-mvebu/Kconfig |  6 +-
  board/CZ.NIC/turris_mox/mox_sp.c    | 12 +++-
  board/CZ.NIC/turris_mox/mox_sp.h    |  8 ++-
  board/CZ.NIC/turris_mox/turris_mox.c    | 72 +--
  configs/turris_mox_defconfig    |  3 +-
  7 files changed, 180 insertions(+), 13 deletions(-)
  create mode 100644 arch/arm/dts/armada-3720-ripe-atlas.dts

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 4569483d5f..e39a7647b4 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -319,6 +319,7 @@ else
  dtb-$(CONFIG_ARCH_MVEBU) +=    \
  armada-3720-db.dtb    \
  armada-3720-espressobin.dtb    \
+    armada-3720-ripe-atlas.dtb    \
  armada-3720-turris-mox.dtb    \
  armada-3720-eDPU.dtb    \
  armada-3720-uDPU.dtb    \
diff --git a/arch/arm/dts/armada-3720-ripe-atlas.dts 
b/arch/arm/dts/armada-3720-ripe-atlas.dts

new file mode 100644
index 00..4457845266
--- /dev/null
+++ b/arch/arm/dts/armada-3720-ripe-atlas.dts
@@ -0,0 +1,91 @@
+// SPDX-License-Identifier: GPL-2.0+ or X11
+/*
+ * Device Tree file for CZ.NIC' RIPE Atlas Probe
+ * 2021 by Marek Behún 
+ */
+
+/dts-v1/;
+
+#include 
+#include 
+#include "armada-372x.dtsi"
+
+/ {
+    model = "CZ.NIC's RIPE Atlas Probe";
+    compatible = "cznic,ripe-atlas", "marvell,armada3720",
+ "marvell,armada3710";
+
+    aliases {
+    ethernet0 = 
+    mmc0 = 
+    };
+
+    chosen {
+    stdout-path = "serial0:115200n8";
+    };
+
+    memory {
+    device_type = "memory";
+    reg = <0x 0x 0x 0x2000>;
+    };
+
+    leds {
+    compatible = "gpio-leds";
+
+    led {
+    gpios = < 21 GPIO_ACTIVE_LOW>;
+    color = ;
+    function = LED_FUNCTION_ACTIVITY;
+    };
+    };
+
+    vsdc_reg: vsdc-reg {
+    compatible = "regulator-gpio";
+    regulator-name = "vsdc";
+    regulator-min-microvolt = <180>;
+    regulator-max-microvolt = <330>;
+    regulator-boot-on;
+
+    gpios = < 23 GPIO_ACTIVE_HIGH>;
+    gpios-states = <0>;
+    states = <180 0x1
+  330 0x0>;
+    enable-active-high;
+    };
+};
+
+ {
+    status = "disabled";
+};
+
+ {
+    pinctrl-names = "default";
+    pinctrl-0 = <_pins>;
+    status = "okay";
+
+    phy1: ethernet-phy@1 {
+    reg = <1>;
+    };
+};
+
+ {
+    pinctrl-names = "default";
+    pinctrl-0 = <_pins>;
+    phy-mode = "rgmii";
+    phy-handle = <>;
+    status = "okay";
+};
+
+ {
+    bus-width = <8>;
+    non-removable;
+    vqmmc-supply = <_reg>;
+    marvell,pad-type = "sd";
+    status = "okay";
+};
+
+ {
+    pinctrl-names = "default";
+    pinctrl-0 = <_pins>;
+    status = "okay";
+};
diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index 5c7f4bf964..c80d8587b1 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -144,8 +144,12 @@ config TARGET_TURRIS_OMNIA
  select ATSHA204A
  config TARGET_TURRIS_MOX
-    bool "Support Turris Mox"
+    bool "Support CZ.NIC's Turris Mox / RIPE Atlas Probe"
  select ARMADA_3700
+    select BOARD_TYPES
+    select ENV_IS_IN_MMC
+    select ENV_IS_IN_SPI_FLASH
+    select MULTI_DTB_FIT
  config TARGET_MVEBU_ARMADA_8K
  bool "Support Armada 7k/8k platforms"
diff --git a/board/CZ.NIC/turris_mox/mox_sp.c 
b/board/CZ.NIC/turris_mox/mox_sp.c

index 87f67512fb..11d8756471 100644
--- a/board/CZ.NIC/turris_mox/mox_sp.c
+++ b/board/CZ.NIC/turris_mox/mox_sp.c
@@ -10,6 +10,8 @@
  #include 
  #include 
+#include "mox_sp.h"
+
  const char *mox_sp_get_ecdsa_public_key(void)
  {
  static char public_key[135];
@@ -42,12 +44,13 @@ static inline void res_to_mac(u8 *mac, u32 t1, u32 
t2)

  mac[5] = t2;
  }
-int mbox_sp_get_board_info(u64 *sn, u8 *mac1, u8 *mac2, int *bv, int 
*ram)
+int mbox_sp_get_board_info(u64 *sn, u8 *mac1, u8 *mac2, int *bv, int 
*ram,

+   enum cznic_a3720_board *board)
  {
-    u32 out[8];
+    u32 out[9];
  int res;
-    res = mbox_do_cmd(MBOX_CMD_BOARD_INFO, NULL, 0, out, 8);
+    res = mbox_do_cmd(MBOX_CMD_BOARD_INFO, NULL, 0, out, 9);
  if (res < 0)
  return res;
@@ -69,5 +72,8 @@ int mbox

Re: [PATCH v2 2/2] cmd: mvebu/bubt: move eMMC data-partition uboot from LBA-0 to 4096

2023-10-26 Thread Stefan Roese

On 10/25/23 10:22, Josua Mayer wrote:

A38x bootrom only searches 2 sectors when booting from eMMC,
irregardless of data or boot partition: 0 & 4096.

For eMMC boot partitions sector 0 is fine, but on data partition it
conflicts with MBR.

Change bubt command default to 4096 for eMMC data partition only, to
allow using an MBR partition table on the eMMC data partition while also
booting from it.

Signed-off-by: Josua Mayer 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---
V1 -> V2: fixed build without CONFIG_SUPPORT_EMMC_BOOT

  cmd/mvebu/bubt.c | 11 +--
  1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c
index ca24a5c1c4b..744b1c20aa8 100644
--- a/cmd/mvebu/bubt.c
+++ b/cmd/mvebu/bubt.c
@@ -240,9 +240,16 @@ static int mmc_burn_image(size_t image_size)
  #endif
  
  	/* SD reserves LBA-0 for MBR and boots from LBA-1,

-* MMC/eMMC boots from LBA-0
+* MMC/eMMC boots from LBA-0 and LBA-4096
 */
-   start_lba = IS_SD(mmc) ? 1 : 0;
+   if (IS_SD(mmc))
+   start_lba = 1;
+#ifdef CONFIG_SUPPORT_EMMC_BOOT
+   else if (part)
+   start_lba = 0;
+#endif
+   else
+   start_lba = 4096;
  #ifdef CONFIG_BLK
blk_count = image_size / mmc->write_bl_len;
if (image_size % mmc->write_bl_len)


Viele Grüße,
Stefan Roese

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


Re: [PATCH v2 1/2] arm: mvebu: allow additional 4096 offset for bootable mmc image

2023-10-26 Thread Stefan Roese

On 10/25/23 10:22, Josua Mayer wrote:

Disarm the error message forcing u-boot/spl image to be located at
sector 0 on eMMC data-partition and microSD.
Offset 0 makes sense on eMMC boot partitions only, data partition must
use 4096 to avoid conflicting with MBR.

Valid offsets when booting from microSD, reported by boot-rom v1.73:

BootROM: Bad header at offset 0200
BootROM: Bad header at offset 4400
BootROM: Bad header at offset 0020
BootROM: Bad header at offset 0040
BootROM: Bad header at offset 0060
BootROM: Bad header at offset 0080
BootROM: Bad header at offset 00A0
BootROM: Bad header at offset 00C0
BootROM: Bad header at offset 00E0
BootROM: Bad header at offset 0100
BootROM: Bad header at offset 0120
BootROM: Bad header at offset 0140
BootROM: Bad header at offset 0160
BootROM: Bad header at offset 0180
BootROM: Bad header at offset 01A0
BootROM: Bad header at offset 01C0
BootROM: Bad header at offset 01E0
BootROM: Bad header at offset 0200
BootROM: Bad header at offset 0220
BootROM: Bad header at offset 0240
BootROM: Bad header at offset 0260
BootROM: Bad header at offset 0280
BootROM: Bad header at offset 02A0
BootROM: Bad header at offset 02C0
BootROM: Bad header at offset 02E0

Valid offsets when booting from eMMC:

BootROM: Bad header at offset 
BootROM: Bad header at offset 0020
Switching BootPartitions.
BootROM: Bad header at offset 
BootROM: Bad header at offset 0020

Fixes: 2226ca17348 ("arm: mvebu: Load U-Boot proper binary in SPL code based on 
kwbimage header")

Signed-off-by: Josua Mayer 


Reviewed-by: Stefan Roese 

Thanks,
Stefan



---
  arch/arm/mach-mvebu/spl.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
index eaaa68a8564..79f8877745b 100644
--- a/arch/arm/mach-mvebu/spl.c
+++ b/arch/arm/mach-mvebu/spl.c
@@ -71,8 +71,9 @@
  #error CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR must be set to 0
  #endif
  #if !defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET) || \
-CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET != 0
-#error CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET must be set to 0
+(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET != 0 && \
+ CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET != 4096)
+#error CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET must be set to either 
0 or 4096
  #endif
  #endif
  


Viele Grüße,
Stefan Roese

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


Re: [PATCH u-boot-marvell] arm: mvebu: turris_mox: Extend to support RIPE Atlas Probe

2023-10-26 Thread Stefan Roese

On 10/20/23 16:29, Marek Behún wrote:

Extend Turris Mox board code to support CZ.NIC's RIPE Atlas Probe.

Signed-off-by: Marek Behún 


Reviewed-by: Stefan Roese 

Thanks,
Stefan



---
  arch/arm/dts/Makefile   |  1 +
  arch/arm/dts/armada-3720-ripe-atlas.dts | 91 +
  arch/arm/mach-mvebu/Kconfig |  6 +-
  board/CZ.NIC/turris_mox/mox_sp.c| 12 +++-
  board/CZ.NIC/turris_mox/mox_sp.h|  8 ++-
  board/CZ.NIC/turris_mox/turris_mox.c| 72 +--
  configs/turris_mox_defconfig|  3 +-
  7 files changed, 180 insertions(+), 13 deletions(-)
  create mode 100644 arch/arm/dts/armada-3720-ripe-atlas.dts

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 4569483d5f..e39a7647b4 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -319,6 +319,7 @@ else
  dtb-$(CONFIG_ARCH_MVEBU) +=   \
armada-3720-db.dtb  \
armada-3720-espressobin.dtb \
+   armada-3720-ripe-atlas.dtb  \
armada-3720-turris-mox.dtb  \
armada-3720-eDPU.dtb\
armada-3720-uDPU.dtb\
diff --git a/arch/arm/dts/armada-3720-ripe-atlas.dts 
b/arch/arm/dts/armada-3720-ripe-atlas.dts
new file mode 100644
index 00..4457845266
--- /dev/null
+++ b/arch/arm/dts/armada-3720-ripe-atlas.dts
@@ -0,0 +1,91 @@
+// SPDX-License-Identifier: GPL-2.0+ or X11
+/*
+ * Device Tree file for CZ.NIC' RIPE Atlas Probe
+ * 2021 by Marek Behún 
+ */
+
+/dts-v1/;
+
+#include 
+#include 
+#include "armada-372x.dtsi"
+
+/ {
+   model = "CZ.NIC's RIPE Atlas Probe";
+   compatible = "cznic,ripe-atlas", "marvell,armada3720",
+"marvell,armada3710";
+
+   aliases {
+   ethernet0 = 
+   mmc0 = 
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0x 0x 0x 0x2000>;
+   };
+
+   leds {
+   compatible = "gpio-leds";
+
+   led {
+   gpios = < 21 GPIO_ACTIVE_LOW>;
+   color = ;
+   function = LED_FUNCTION_ACTIVITY;
+   };
+   };
+
+   vsdc_reg: vsdc-reg {
+   compatible = "regulator-gpio";
+   regulator-name = "vsdc";
+   regulator-min-microvolt = <180>;
+   regulator-max-microvolt = <330>;
+   regulator-boot-on;
+
+   gpios = < 23 GPIO_ACTIVE_HIGH>;
+   gpios-states = <0>;
+   states = <180 0x1
+ 330 0x0>;
+   enable-active-high;
+   };
+};
+
+ {
+   status = "disabled";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>;
+   status = "okay";
+
+   phy1: ethernet-phy@1 {
+   reg = <1>;
+   };
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>;
+   phy-mode = "rgmii";
+   phy-handle = <>;
+   status = "okay";
+};
+
+ {
+   bus-width = <8>;
+   non-removable;
+   vqmmc-supply = <_reg>;
+   marvell,pad-type = "sd";
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>;
+   status = "okay";
+};
diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index 5c7f4bf964..c80d8587b1 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -144,8 +144,12 @@ config TARGET_TURRIS_OMNIA
select ATSHA204A
  
  config TARGET_TURRIS_MOX

-   bool "Support Turris Mox"
+   bool "Support CZ.NIC's Turris Mox / RIPE Atlas Probe"
select ARMADA_3700
+   select BOARD_TYPES
+   select ENV_IS_IN_MMC
+   select ENV_IS_IN_SPI_FLASH
+   select MULTI_DTB_FIT
  
  config TARGET_MVEBU_ARMADA_8K

bool "Support Armada 7k/8k platforms"
diff --git a/board/CZ.NIC/turris_mox/mox_sp.c b/board/CZ.NIC/turris_mox/mox_sp.c
index 87f67512fb..11d8756471 100644
--- a/board/CZ.NIC/turris_mox/mox_sp.c
+++ b/board/CZ.NIC/turris_mox/mox_sp.c
@@ -10,6 +10,8 @@
  #include 
  #include 
  
+#include "mox_sp.h"

+
  const char *mox_sp_get_ecdsa_public_key(void)
  {
static char public_key[135];
@@ -42,12 +44,13 @@ static inline void res_to_mac(u8 *mac, u32 t1, u32 t2)
mac[5] = t2;
  }
  
-int mbox_sp_get_board_info(u64 *sn, u8 *mac1, u8 *mac2, int *bv, int *ram)

+int mbox_sp_get_board_info(u64 *sn, u8 *mac1, u8 *mac2, int *bv, int *r

Re: [PATCH] arm: kirkwood: Enable bootstd for Zyxel NSA310S board

2023-10-26 Thread Stefan Roese

On 10/26/23 00:38, Tony Dinh wrote:

Enable bootstd for Zyxel NSA310S board, and remove distroboot.

Signed-off-by: Tony Dinh 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---

  configs/nsa310s_defconfig |  3 ++-
  include/configs/nsa310s.h | 17 ++---
  2 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/configs/nsa310s_defconfig b/configs/nsa310s_defconfig
index ff4895622c..038ef42e9d 100644
--- a/configs/nsa310s_defconfig
+++ b/configs/nsa310s_defconfig
@@ -19,7 +19,8 @@ CONFIG_DEBUG_UART_CLOCK=16667
  CONFIG_IDENT_STRING="\nZyXEL NSA310S/320S 1/2-Bay Power Media Server"
  CONFIG_SYS_LOAD_ADDR=0x80
  CONFIG_DEBUG_UART=y
-CONFIG_DISTRO_DEFAULTS=y
+CONFIG_BOOTSTD_FULL=y
+CONFIG_BOOTSTD_DEFAULTS=y
  CONFIG_BOOTDELAY=3
  CONFIG_USE_PREBOOT=y
  # CONFIG_DISPLAY_BOARDINFO is not set
diff --git a/include/configs/nsa310s.h b/include/configs/nsa310s.h
index fa029a176b..8c4d03553d 100644
--- a/include/configs/nsa310s.h
+++ b/include/configs/nsa310s.h
@@ -1,6 +1,6 @@
  /* SPDX-License-Identifier: GPL-2.0+ */
  /*
- * Copyright (C) 2015, 2021-2022 Tony Dinh 
+ * Copyright (C) 2015, 2021-2023 Tony Dinh 
   * Copyright (C) 2015
   * Gerald Kerma 
   * Luka Perkov 
@@ -15,14 +15,6 @@
   */
  #include "mv-common.h"
  
-/* Include the common distro boot environment */

-#ifndef CONFIG_SPL_BUILD
-
-#define BOOT_TARGET_DEVICES(func) \
-   func(USB, usb, 0) \
-   func(SATA, sata, 0) \
-   func(DHCP, dhcp, na)
-
  #define KERNEL_ADDR_R __stringify(0x80)
  #define FDT_ADDR_R__stringify(0x2c0)
  #define RAMDISK_ADDR_R__stringify(0x0110)
@@ -34,16 +26,11 @@
"ramdisk_addr_r=" RAMDISK_ADDR_R "\0" \
"scriptaddr=" SCRIPT_ADDR_R "\0"
  
-#include 

-
  #define CFG_EXTRA_ENV_SETTINGS \
"console=console=ttyS0,115200\0" \
"kernel=/boot/zImage\0" \
"fdt=/boot/nsa310s.dtb\0" \
"bootargs_root=ubi.mtd=3 root=ubi0:rootfs rootfstype=ubifs rw\0" \
-   LOAD_ADDRESS_ENV_SETTINGS \
-   BOOTENV
-
-#endif /* CONFIG_SPL_BUILD */
+   LOAD_ADDRESS_ENV_SETTINGS
  
  #endif /* _CONFIG_NSA310S_H */


Viele Grüße,
Stefan Roese

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


Re: [PATCH] arm: kirkwood: Enable bootstd for Pogo V4 board

2023-10-26 Thread Stefan Roese

On 10/25/23 01:17, Tony Dinh wrote:

Enable bootstd for Pogo V4 board, and remove distroboot.

Signed-off-by: Tony Dinh 


Reviewed-by: Stefan Roese 

Thanks,
Stefan


---

  configs/pogo_v4_defconfig |  3 ++-
  include/configs/pogo_v4.h | 35 ++-
  2 files changed, 4 insertions(+), 34 deletions(-)

diff --git a/configs/pogo_v4_defconfig b/configs/pogo_v4_defconfig
index 2747c3c72d..ff6411d894 100644
--- a/configs/pogo_v4_defconfig
+++ b/configs/pogo_v4_defconfig
@@ -17,7 +17,8 @@ CONFIG_IDENT_STRING="\nPogoplug V4"
  CONFIG_SYS_LOAD_ADDR=0x80
  CONFIG_PCI=y
  CONFIG_LTO=y
-CONFIG_DISTRO_DEFAULTS=y
+CONFIG_BOOTSTD_FULL=y
+CONFIG_BOOTSTD_DEFAULTS=y
  CONFIG_BOOTSTAGE=y
  CONFIG_SHOW_BOOT_PROGRESS=y
  CONFIG_BOOTDELAY=10
diff --git a/include/configs/pogo_v4.h b/include/configs/pogo_v4.h
index 3371579023..d5003538da 100644
--- a/include/configs/pogo_v4.h
+++ b/include/configs/pogo_v4.h
@@ -1,6 +1,6 @@
  /* SPDX-License-Identifier: GPL-2.0+ */
  /*
- * Copyright (C) 2014-2022 Tony Dinh 
+ * Copyright (C) 2014-2023 Tony Dinh 
   *
   * Based on
   * Copyright (C) 2012
@@ -21,33 +21,6 @@
   */
  #include "mv-common.h"
  
-/* Include the common distro boot environment */

-#ifndef CONFIG_SPL_BUILD
-
-#ifdef CONFIG_MMC
-#define BOOT_TARGET_DEVICES_MMC(func) func(MMC, mmc, 0)
-#else
-#define BOOT_TARGET_DEVICES_MMC(func)
-#endif
-
-#ifdef CONFIG_SATA
-#define BOOT_TARGET_DEVICES_SATA(func) func(SATA, sata, 0)
-#else
-#define BOOT_TARGET_DEVICES_SATA(func)
-#endif
-
-#ifdef CONFIG_USB_STORAGE
-#define BOOT_TARGET_DEVICES_USB(func) func(USB, usb, 0)
-#else
-#define BOOT_TARGET_DEVICES_USB(func)
-#endif
-
-#define BOOT_TARGET_DEVICES(func) \
-   BOOT_TARGET_DEVICES_MMC(func) \
-   BOOT_TARGET_DEVICES_USB(func) \
-   BOOT_TARGET_DEVICES_SATA(func) \
-   func(DHCP, dhcp, na)
-
  #define KERNEL_ADDR_R __stringify(0x80)
  #define FDT_ADDR_R__stringify(0x2c0)
  #define RAMDISK_ADDR_R__stringify(0x0110)
@@ -59,14 +32,10 @@
"ramdisk_addr_r=" RAMDISK_ADDR_R "\0" \
"scriptaddr=" SCRIPT_ADDR_R "\0"
  
-#include 

-
  #define CFG_EXTRA_ENV_SETTINGS \
LOAD_ADDRESS_ENV_SETTINGS \
"fdtfile=" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \
"mtdparts=" CONFIG_MTDPARTS_DEFAULT "\0" \
-   "console=ttyS0,115200\0" \
-   BOOTENV
-#endif /* CONFIG_SPL_BUILD */
+   "console=ttyS0,115200\0"
  
  #endif /* _CONFIG_POGO_V4_H */


Viele Grüße,
Stefan Roese

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


Re: Please pull u-boot-marvell/master

2023-10-20 Thread Stefan Roese

Hi Tom,

On 10/20/23 16:45, Tom Rini wrote:

On Fri, Oct 20, 2023 at 02:51:08PM +0200, Stefan Roese wrote:


Hi Tom,

please pull this next small batch of Marvell related patches:


- kirkwood: Pogo v4: Enable LTO (Tony)
- mvebu: AC5/AC5X: use fixed page table size (Chris)



Given Marc's request, can you please either respin this with a revert of
6cdf6b7a340d or I'll do that later, and drop the AC5 commit from here
instead.  Thanks.


I'm just now leaving for a longer weekend trip and will be back mid
of next week. Then I can take care of this, sure.

Thanks,
Stefan


Please pull u-boot-marvell/master

2023-10-20 Thread Stefan Roese

Hi Tom,

please pull this next small batch of Marvell related patches:


- kirkwood: Pogo v4: Enable LTO (Tony)
- mvebu: AC5/AC5X: use fixed page table size (Chris)


Here the Azure build, without any issues:

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

Thanks,
Stefan

The following changes since commit e463222cce0df86f05a117f06e1737f539841fe6:

  Merge branch 'master' of 
https://source.denx.de/u-boot/custodians/u-boot-riscv (2023-10-19 
09:40:04 -0400)


are available in the Git repository at:

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

for you to fetch changes up to 37047b4c378d7707ffb86295c6d24ca5240a07dc:

  arm: mvebu: AC5/AC5X: use fixed page table size (2023-10-20 11:57:26 
+0200)



Chris Packham (1):
  arm: mvebu: AC5/AC5X: use fixed page table size

Tony Dinh (1):
  arm: kirkwood: Pogo v4: Enable LTO

 arch/arm/mach-mvebu/alleycat5/cpu.c | 5 +
 configs/pogo_v4_defconfig   | 1 +
 2 files changed, 6 insertions(+)


Re: [RESEND PATCH] arm: kirkwood: Pogo v4: Enable LTO

2023-10-20 Thread Stefan Roese

On 10/20/23 08:14, Stefan Roese wrote:

On 10/16/23 22:01, Tony Dinh wrote:

Enable building Pogo V4 u-boot image with LTO, which results in about 30K
reduction in size.

Rebased to latest master and resend.


Nitpicking:

In such cases, please generate a v2 and put this description in the
patch history below the "---" line. No need to do this now, I'll fix
it up.


Signed-off-by: Tony Dinh 


Reviewed-by: Stefan Roese 


Applied to u-boot-marvell/master

Thanks,
Stefan



Thanks,
Stefan


---

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

diff --git a/configs/pogo_v4_defconfig b/configs/pogo_v4_defconfig
index cbbade3c0c..fd62146ed3 100644
--- a/configs/pogo_v4_defconfig
+++ b/configs/pogo_v4_defconfig
@@ -15,6 +15,7 @@ CONFIG_ENV_OFFSET=0xC
  CONFIG_DEFAULT_DEVICE_TREE="kirkwood-pogoplug-series-4"
  CONFIG_IDENT_STRING="\nPogoplug V4"
  CONFIG_SYS_LOAD_ADDR=0x80
+CONFIG_LTO=y
  CONFIG_PCI=y
  CONFIG_DISTRO_DEFAULTS=y
  CONFIG_BOOTSTAGE=y


Viele Grüße,
Stefan Roese



Viele Grüße,
Stefan Roese

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


Re: [PATCH] arm: mvebu: AC5/AC5X: use fixed page table size

2023-10-20 Thread Stefan Roese

On 10/20/23 10:21, Chris Packham wrote:



On Fri, 20 Oct 2023, 7:18 pm Stefan Roese, <mailto:s...@denx.de>> wrote:


Hi Chris,

On 10/18/23 22:53, Chris Packham wrote:
 > Since commit 6cdf6b7a340d ("arm64: Use FEAT_HAFDBS to track dirty
pages
 > when available") the default get_page_table_size() sets some
flags for
 > more efficient handling of dirty page table entries. This causes
 > problems on the AC5/AC5X SoC (specifically a lockup when calling
 > __asm_switch_ttbr() via mmu_set_region_dcache_behaviour()).
 >
 > The reason for the lockup isn't at all clear but it can be
avoided if we
 > provide our own get_page_table_size() which stops gd->arch.has_hafdbs
 > from being set to true effectively returning the AC5/AC5X to the
older
 > behaviour. This also opts for a simple fixed page table size
rather than
 > trying to duplicate the more complicated logic to optimise the table
 > size.
 >
 > Signed-off-by: Chris Packham mailto:judge.pack...@gmail.com>>

I'm not 100% happy with this approach / workaround - still it fixes an
issue on your board, so:

Reviewed-by: Stefan Roese mailto:s...@denx.de>>


Yeah I'm not super happy about this either. But this is about the best I 
could come up with.



Perhaps you (or someone else) can look into this in more depth to get
to the root of this issue at a later time.


I did spend a reasonable amount of time tracking down where things were 
going wrong, even if I couldn't figure out why. The commit message 
basically reflects what I found.


Applied to u-boot-marvell/master

Thanks,
Stefan




Thanks,
Stefan

 > ---
 >
 >   arch/arm/mach-mvebu/alleycat5/cpu.c | 5 +
 >   1 file changed, 5 insertions(+)
 >
 > diff --git a/arch/arm/mach-mvebu/alleycat5/cpu.c
b/arch/arm/mach-mvebu/alleycat5/cpu.c
 > index 8204d9627515..7ba57ae75e76 100644
 > --- a/arch/arm/mach-mvebu/alleycat5/cpu.c
 > +++ b/arch/arm/mach-mvebu/alleycat5/cpu.c
 > @@ -63,6 +63,11 @@ static struct mm_region ac5_mem_map[] = {
 >
 >   struct mm_region *mem_map = ac5_mem_map;
 >
 > +u64 get_page_table_size(void)
 > +{
 > +     return 0x8;
 > +}
 > +
 >   void reset_cpu(void)
 >   {
 >   }

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Erika Unter

HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email:
s...@denx.de <mailto:s...@denx.de>



Viele Grüße,
Stefan Roese

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


Re: [PATCH 2/3] cmd: mvebu/bubt: move eMMC data-partition uboot from LBA-0 to 4096

2023-10-20 Thread Stefan Roese

On 10/8/23 14:46, Josua Mayer wrote:

A38x bootrom only searches 2 sectors when booting from eMMC,
irregardless of data or boot partition: 0 & 4096.

For eMMC boot partitions sector 0 is fine, but on data partition it
conflicts with MBR.

Change bubt command default to 4096 for eMMC data partition only, to
allow using an MBR partition table on the eMMC data partition while also
booting from it.

Signed-off-by: Josua Mayer 
---
  cmd/mvebu/bubt.c | 9 +++--
  1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c
index ca24a5c1c4b..eb1fef9243d 100644
--- a/cmd/mvebu/bubt.c
+++ b/cmd/mvebu/bubt.c
@@ -240,9 +240,14 @@ static int mmc_burn_image(size_t image_size)
  #endif
  
  	/* SD reserves LBA-0 for MBR and boots from LBA-1,

-* MMC/eMMC boots from LBA-0
+* MMC/eMMC boots from LBA-0 and LBA-4096
 */
-   start_lba = IS_SD(mmc) ? 1 : 0;
+   if (IS_SD(mmc))
+   start_lba = 1;
+   else if (!part)
+   start_lba = 4096;
+   else
+   start_lba = 0;
  #ifdef CONFIG_BLK
blk_count = image_size / mmc->write_bl_len;
if (image_size % mmc->write_bl_len)


This patch leads to this error, e.g. for turris_mox_defconfig:

cmd/mvebu/bubt.c: In function 'mmc_burn_image':
cmd/mvebu/bubt.c:247:19: error: 'part' undeclared (first use in this 
function)

  247 | else if (!part)
  |   ^~~~
cmd/mvebu/bubt.c:247:19: note: each undeclared identifier is reported 
only once for each function it appears in


Could you please check and fix?

Thanks,
Stefan


  1   2   3   4   5   6   7   8   9   10   >