Hi Simon,

On 16.08.22 13:48, Simon Glass wrote:
Hi Stefan,

On Tue, 16 Aug 2022 at 04:28, Stefan Roese <s...@denx.de> wrote:

This patch enables the cyclic infrastructure on sandbox and also adds
one simple example/demo functions using this cyclic functionality.

Signed-off-by: Stefan Roese <s...@denx.de>
---
v4:
- Rename cyclic_struct to cyclic_info

v3:
- No change

v2:
- Extend CONFIG_CYCLIC_MAX_CPU_TIME_US to 10000ms as running this
   in CI might take a bit longer

  board/sandbox/sandbox.c   | 15 +++++++++++++++
  configs/sandbox_defconfig |  3 +++
  2 files changed, 18 insertions(+)

Now that we have the test, do we need this?

Frankly, I did not think about this before.

Or perhaps it should be a
'cyclic demo' command?

Yes, this could make sense, if we drop this sandbox implementation.
Let me think a bit about it...

Thanks,
Stefan


diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c
index ca9a2ca5b17c..f633b8e63768 100644
--- a/board/sandbox/sandbox.c
+++ b/board/sandbox/sandbox.c
@@ -7,6 +7,7 @@
  #include <addr_map.h>
  #include <cpu_func.h>
  #include <cros_ec.h>
+#include <cyclic.h>
  #include <dm.h>
  #include <efi.h>
  #include <efi_loader.h>
@@ -17,6 +18,7 @@
  #include <asm/global_data.h>
  #include <asm/test.h>
  #include <asm/u-boot-sandbox.h>
+#include <linux/delay.h>
  #include <linux/kernel.h>
  #include <malloc.h>

@@ -106,8 +108,21 @@ int dram_init(void)
         return 0;
  }

+static void cyclic_demo(void *ctx)
+{
+       /* Just a small dummy delay here */
+       udelay(10);
+}
+
  int board_init(void)
  {
+       struct cyclic_info *cyclic;
+
+       /* Register demo cyclic function */
+       cyclic = cyclic_register(cyclic_demo, 10 * 1000, "cyclic_demo", NULL);
+       if (!cyclic)
+               printf("Registering of cyclic_demo failed\n");
+
         return 0;
  }

diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index eba7bcbb483b..8b6c003760f2 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -34,6 +34,8 @@ CONFIG_LOG=y
  CONFIG_LOG_MAX_LEVEL=9
  CONFIG_LOG_DEFAULT_LEVEL=6
  CONFIG_DISPLAY_BOARDINFO_LATE=y
+CONFIG_CYCLIC=y
+CONFIG_CYCLIC_MAX_CPU_TIME_US=10000
  CONFIG_STACKPROTECTOR=y
  CONFIG_ANDROID_AB=y
  CONFIG_CMD_CPU=y
@@ -114,6 +116,7 @@ CONFIG_CMD_EROFS=y
  CONFIG_CMD_EXT4_WRITE=y
  CONFIG_CMD_SQUASHFS=y
  CONFIG_CMD_MTDPARTS=y
+CONFIG_CMD_CYCLIC=y
  CONFIG_CMD_STACKPROTECTOR_TEST=y
  CONFIG_MAC_PARTITION=y
  CONFIG_AMIGA_PARTITION=y
--
2.37.2


Regards,
Simon

Viele Grüße,
Stefan Roese

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

Reply via email to