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>
---
 board/sandbox/sandbox.c   | 15 +++++++++++++++
 configs/sandbox_defconfig |  2 ++
 2 files changed, 17 insertions(+)

diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c
index e054f300c4a5..3b48c9bf8cbb 100644
--- a/board/sandbox/sandbox.c
+++ b/board/sandbox/sandbox.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <cpu_func.h>
 #include <cros_ec.h>
+#include <cyclic.h>
 #include <dm.h>
 #include <efi.h>
 #include <efi_loader.h>
@@ -16,6 +17,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>
 
@@ -105,8 +107,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_struct *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 c509a924e6b3..601c5dfe5a51 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -32,6 +32,7 @@ CONFIG_CONSOLE_RECORD_OUT_SIZE=0x6000
 CONFIG_PRE_CONSOLE_BUFFER=y
 CONFIG_LOG=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
+CONFIG_CYCLIC=y
 CONFIG_STACKPROTECTOR=y
 CONFIG_ANDROID_AB=y
 CONFIG_CMD_CPU=y
@@ -111,6 +112,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.36.1

Reply via email to