]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
cyclic: Introduce schedule() function
authorStefan Roese <sr@denx.de>
Fri, 2 Sep 2022 12:10:45 +0000 (14:10 +0200)
committerStefan Roese <sr@denx.de>
Sun, 18 Sep 2022 08:26:28 +0000 (10:26 +0200)
This patch introduces a schedule() function, which shall be used instead
of the old WATCHDOG_RESET. Follow-up patches will make sure, that this
new function is used.

Signed-off-by: Stefan Roese <sr@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Rini <trini@konsulko.com> [am335x_evm, mx6cuboxi, rpi_3,dra7xx_evm, pine64_plus, am65x_evm, j721e_evm]
common/cyclic.c
include/cyclic.h

index cd5dcb1f2b948724bce74bff9982ded74166fe4d..b3c180bd1a62c14835f7e81d266f296ae98399fa 100644 (file)
@@ -18,6 +18,8 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+void hw_watchdog_reset(void);
+
 struct list_head *cyclic_get_list(void)
 {
        return &gd->cyclic->cyclic_list;
@@ -96,6 +98,20 @@ void cyclic_run(void)
        gd->cyclic->cyclic_running = false;
 }
 
+void schedule(void)
+{
+       /* The HW watchdog is not integrated into the cyclic IF (yet) */
+       if (IS_ENABLED(CONFIG_HW_WATCHDOG))
+               hw_watchdog_reset();
+
+       /*
+        * schedule() might get called very early before the cyclic IF is
+        * ready. Make sure to only call cyclic_run() when it's initalized.
+        */
+       if (gd && gd->cyclic && gd->cyclic->cyclic_ready)
+               cyclic_run();
+}
+
 int cyclic_uninit(void)
 {
        struct cyclic_info *cyclic, *tmp;
index 23902234cc877cea0a83b6da413e570e871e6ec3..760163643345cd6869d31bf66ad81f78a320a059 100644 (file)
@@ -106,6 +106,14 @@ struct list_head *cyclic_get_list(void);
  * needs to be executed, then call into these registered functions.
  */
 void cyclic_run(void);
+
+/**
+ * schedule() - Schedule all potentially waiting tasks
+ *
+ * Basically a wrapper for cyclic_run(), pontentially enhanced by some
+ * other parts, that need to get handled periodically.
+ */
+void schedule(void);
 #else
 static inline struct cyclic_info *cyclic_register(cyclic_func_t func,
                                                  uint64_t delay_us,
@@ -124,6 +132,10 @@ static inline void cyclic_run(void)
 {
 }
 
+static inline void schedule(void)
+{
+}
+
 static inline int cyclic_init(void)
 {
        return 0;