blob: 220a55ad84dae41baab7f97da4129a74a1ee277c [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glass82a5fa02013-03-05 14:39:40 +00002/*
3 * Copyright (c) 2011 The Chromium OS Authors.
Simon Glass82a5fa02013-03-05 14:39:40 +00004 */
5
Simon Glass5b668882017-03-28 10:27:17 -06006#ifndef __INITCALL_H
7#define __INITCALL_H
8
Simon Glass6b42d382023-08-21 21:16:54 -06009#include <asm/types.h>
10#include <event.h>
Jerome Forissier1fd58d42025-04-04 15:50:36 +020011#include <hang.h>
Simon Glass6b42d382023-08-21 21:16:54 -060012
13_Static_assert(EVT_COUNT < 256, "Can only support 256 event types with 8 bits");
14
Jerome Forissier1fd58d42025-04-04 15:50:36 +020015#define INITCALL(_call) \
16 do { \
17 if (_call()) { \
18 printf("%s(): initcall %s() failed\n", __func__, \
19 #_call); \
20 hang(); \
21 } \
22 } while (0)
23
24#define INITCALL_EVT(_evt) \
25 do { \
26 if (event_notify_null(_evt)) { \
27 printf("%s(): event %d/%s failed\n", __func__, _evt, \
28 event_type_name(_evt)) ; \
29 hang(); \
30 } \
31 } while (0)
32
33#if defined(CONFIG_WATCHDOG) || defined(CONFIG_HW_WATCHDOG)
34#define WATCHDOG_INIT() INITCALL(init_func_watchdog_init)
35#define WATCHDOG_RESET() INITCALL(init_func_watchdog_reset)
36#else
37#define WATCHDOG_INIT()
38#define WATCHDOG_RESET()
39#endif
40
Simon Glass5b668882017-03-28 10:27:17 -060041#endif