cyclic: Add a symbol for SPL
authorSimon Glass <sjg@chromium.org>
Wed, 31 Jul 2024 14:44:08 +0000 (08:44 -0600)
committerAnatolij Gustschin <agust@denx.de>
Wed, 31 Jul 2024 14:51:54 +0000 (16:51 +0200)
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.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Devarsh Thakkar <devarsht@ti.com>
Reviewed-by: Stefan Roese <sr@denx.de>
common/Kconfig
common/Makefile
drivers/watchdog/Kconfig
include/asm-generic/global_data.h
include/cyclic.h

index 4bb9f08..87b0ec3 100644 (file)
@@ -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 5000
index e983547..d871113 100644 (file)
@@ -79,7 +79,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
index 8318fd7..0c3e991 100644 (file)
@@ -4,6 +4,7 @@ config WATCHDOG
        bool "Enable U-Boot watchdog reset"
        depends on !HW_WATCHDOG
        select CYCLIC
+       imply SPL_CYCLIC if SPL
        help
          This option enables U-Boot watchdog support where U-Boot is using
          watchdog_reset function to service watchdog device in U-Boot. Enable
@@ -408,6 +409,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.
index aa336d6..27aa75e 100644 (file)
@@ -481,7 +481,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
         */
index 2c3d383..cd95b69 100644 (file)
@@ -46,7 +46,8 @@ struct cyclic_info {
 /** Function type for cyclic functions */
 typedef void (*cyclic_func_t)(struct cyclic_info *c);
 
-#if defined(CONFIG_CYCLIC)
+#if CONFIG_IS_ENABLED(CYCLIC)
+
 /**
  * cyclic_register - Register a new cyclic function
  *
@@ -123,6 +124,6 @@ static inline int cyclic_unregister_all(void)
 {
        return 0;
 }
-#endif
+#endif /* CYCLIC */
 
 #endif