1 /* SPDX-License-Identifier: Apache-2.0 */
2 /*
3  * Copyright (c) 2023 Intel Corporation
4  *
5  * Author: Adrian Warecki <adrian.warecki@intel.com>
6  */
7 
8 #ifndef ZEPHYR_DRIVERS_WATCHDOG_WDT_DW_COMMON_H_
9 #define ZEPHYR_DRIVERS_WATCHDOG_WDT_DW_COMMON_H_
10 
11 #include <stdint.h>
12 
13 /**
14  * @brief Check watchdog configuration options
15  *
16  * Check options value passed to a watchdog setup function. Returns error if unsupported option
17  * is used.
18  *
19  * @param options options value passed to a watchdog setup function.
20  * @return Error code, 0 on success.
21  */
22 int dw_wdt_check_options(const uint8_t options);
23 
24 /**
25  * @brief Configure watchdog device
26  *
27  * @param base Device base address.
28  * @param config device configuration word
29  * @return Error code, 0 on success.
30  */
31 int dw_wdt_configure(const uint32_t base, const uint32_t config);
32 
33 /**
34  * @brief Calculate period
35  *
36  * @param [in]base Device base address.
37  * @param [in]clk_freq frequency of a clock used by watchdog device
38  * @param [in]config pointer to a watchdog configuration structure
39  * @param [out]period_out pointer to a variable in which the period configuration word will be
40  *        placed
41  * @return Error code, 0 on success.
42  */
43 int dw_wdt_calc_period(const uint32_t base, const uint32_t clk_freq,
44 		       const struct wdt_timeout_cfg *config, uint32_t *period_out);
45 
46 /**
47  * @brief Watchdog probe
48  *
49  * Checks device id register and configure a reset pulse length.
50  *
51  * @param base Device base address.
52  * @param reset_pulse_length Length of a reset pulse produced by watchdog
53  * @return Error code, 0 on success.
54  */
55 int dw_wdt_probe(const uint32_t base, const uint32_t reset_pulse_length);
56 
57 /**
58  * @brief Watchdog disable function
59  *
60  * @param dev Device structure.
61  * @return -ENOTSUP. The hardware does not support disabling.
62  */
63 int dw_wdt_disable(const struct device *dev);
64 
65 #endif /* ZEPHYR_DRIVERS_WATCHDOG_WDT_DW_COMMON_H_ */
66