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_H_
9 #define ZEPHYR_DRIVERS_WATCHDOG_WDT_DW_H_
10
11 #include <zephyr/sys/util.h>
12
13 /**
14 * @file
15 * @brief Synopsys Designware Watchdog driver
16 *
17 * The DW_apb_wdt is an APB slave peripheral that can be used to prevent system lockup that may be
18 * caused by conflicting parts or programs in an SoC. This component can be configured, synthesized,
19 * and programmed based on user-defined options.
20 *
21 * The generated interrupt is passed to an interrupt controller. The generated reset is passed to a
22 * reset controller, which in turn generates a reset for the components in the system. The WDT may
23 * be reset independently to the other components.
24 *
25 * For more information about the specific IP capability, please refer to the DesignWare DW_apb_wdt
26 * Databook.
27 */
28
29 /*
30 * Control Register
31 */
32 #define WDT_CR 0x0
33
34 /*
35 * WDT enable
36 */
37 #define WDT_CR_WDT_EN BIT(0)
38
39 /* Watchdog timer disabled
40 */
41 #define WDT_EN_DISABLED 0x0
42
43 /* Watchdog timer enabled
44 */
45 #define WDT_EN_ENABLED 0x1
46
47 /*
48 * Response mode
49 */
50 #define WDT_CR_RMOD BIT(1)
51
52 /* Generate a system reset
53 */
54 #define RMOD_RESET 0x0
55
56 /* First generate an interrupt and even if it is cleared
57 * by the time a second timeout occurs then generate a system reset
58 */
59 #define RMOD_INTERRUPT 0x1
60
61 /*
62 * Reset pulse length
63 */
64 #define WDT_CR_RPL GENMASK(4, 2)
65
66 #define RPL_PCLK_CYCLES2 0x0 /* 2 pclk cycles */
67 #define RPL_PCLK_CYCLES4 0x1 /* 4 pclk cycles */
68 #define RPL_PCLK_CYCLES8 0x2 /* 8 pclk cycles */
69 #define RPL_PCLK_CYCLES16 0x3 /* 16 pclk cycles */
70 #define RPL_PCLK_CYCLES32 0x4 /* 32 pclk cycles */
71 #define RPL_PCLK_CYCLES64 0x5 /* 64 pclk cycles */
72 #define RPL_PCLK_CYCLES128 0x6 /* 128 pclk cycles */
73 #define RPL_PCLK_CYCLES256 0x7 /* 256 pclk cycles */
74
75 /*
76 * Redundant R/W bit.
77 */
78 #define WDT_CR_NO_NAME BIT(5)
79
80
81 /*
82 * Timeout Range Register
83 */
84 #define WDT_TORR 0x4
85
86 #define TORR_USER0_OR_64K 0x0 /* Time out of WDT_USER_TOP_0 or 64K Clocks */
87 #define TORR_USER1_OR_128K 0x1 /* Time out of WDT_USER_TOP_1 or 128K Clocks */
88 #define TORR_USER2_OR_256K 0x2 /* Time out of WDT_USER_TOP_2 or 256K Clocks */
89 #define TORR_USER3_OR_512K 0x3 /* Time out of WDT_USER_TOP_3 or 512K Clocks */
90 #define TORR_USER4_OR_1M 0x4 /* Time out of WDT_USER_TOP_4 or 1M Clocks */
91 #define TORR_USER5_OR_2M 0x5 /* Time out of WDT_USER_TOP_5 or 2M Clocks */
92 #define TORR_USER6_OR_4M 0x6 /* Time out of WDT_USER_TOP_6 or 4M Clocks */
93 #define TORR_USER7_OR_8M 0x7 /* Time out of WDT_USER_TOP_7 or 8M Clocks */
94 #define TORR_USER8_OR_16M 0x8 /* Time out of WDT_USER_TOP_8 or 16M Clocks */
95 #define TORR_USER9_OR_32M 0x9 /* Time out of WDT_USER_TOP_9 or 32M Clocks */
96 #define TORR_USER10_OR_64M 0xa /* Time out of WDT_USER_TOP_10 or 64M Clocks */
97 #define TORR_USER11_OR_128M 0xb /* Time out of WDT_USER_TOP_11 or 128M Clocks */
98 #define TORR_USER12_OR_256M 0xc /* Time out of WDT_USER_TOP_12 or 256M Clocks */
99 #define TORR_USER13_OR_512M 0xd /* Time out of WDT_USER_TOP_13 or 512M Clocks */
100 #define TORR_USER14_OR_1G 0xe /* Time out of WDT_USER_TOP_14 or 1G Clocks */
101 #define TORR_USER15_OR_2G 0xf /* Time out of WDT_USER_TOP_15 or 2G Clocks */
102
103 /*
104 * Timeout period
105 */
106 #define WDT_TORR_TOP GENMASK(3, 0)
107
108 /*
109 * Timeout period for initialization
110 */
111 #define WDT_TORR_TOP_INIT GENMASK(7, 4)
112
113
114 /*
115 * Current Counter Value Register.
116 * bits WDT_CNT_WIDTH - 1 to 0
117 */
118 #define WDT_CCVR 0x8
119
120 /*
121 * Counter Restart Register
122 */
123 #define WDT_CRR 0xc
124 #define WDT_CRR_MASK GENMASK(7, 0)
125
126 /*
127 * Watchdog timer restart command
128 */
129 #define WDT_CRR_RESTART_KEY 0x76
130
131
132 /*
133 * Interrupt Status Register
134 */
135 #define WDT_STAT 0x10
136 #define WDT_STAT_MASK BIT(0)
137
138
139 /*
140 * Interrupt Clear Register
141 */
142 #define WDT_EOI 0x14
143 #define WDT_EOI_MASK BIT(0)
144
145
146 /*
147 * WDT Protection level register
148 */
149 #define WDT_PROT_LEVEL 0x1c
150 #define WDT_PROT_LEVEL_MASK GENMASK(2, 0)
151
152
153 /*
154 * Component Parameters Register 5
155 * Upper limit of Timeout Period parameters
156 */
157 #define WDT_COMP_PARAM_5 0xe4
158 #define CP_WDT_USER_TOP_MAX WDT_COMP_PARAM_5
159
160
161 /*
162 * Component Parameters Register 4
163 * Upper limit of Initial Timeout Period parameters
164 */
165 #define WDT_COMP_PARAM_4 0xe8
166 #define CP_WDT_USER_TOP_INIT_MAX WDT_COMP_PARAM_4
167
168 /*
169 * Component Parameters Register 3
170 * The value of this register is derived from the WDT_TOP_RST core Consultant parameter.
171 */
172 #define WDT_COMP_PARAM_3 0xec
173 #define CD_WDT_TOP_RST WDT_COMP_PARAM_3
174
175
176 /*
177 * Component Parameters Register 2
178 * The value of this register is derived from the WDT_CNT_RST core Consultant parameter.
179 */
180 #define WDT_COMP_PARAM_2 0xf0
181 #define CP_WDT_CNT_RST WDT_COMP_PARAM_2
182
183
184 /*
185 * Component Parameters Register 1
186 */
187 #define WDT_COMP_PARAM_1 0xf4
188
189 /*
190 * The Watchdog Timer counter width.
191 */
192 #define WDT_CNT_WIDTH GENMASK(28, 24)
193
194 /*
195 * Describes the initial timeout period that is available directly after reset. It controls the
196 * reset value of the register. If WDT_HC_TOP is 1, then the default initial time period is the
197 * only possible period.
198 */
199 #define WDT_DFLT_TOP_INIT GENMASK(23, 20)
200
201 /*
202 * Selects the timeout period that is available directly after reset. It controls the reset value
203 * of the register. If WDT_HC_TOP is set to 1, then the default timeout period is the only possible
204 * timeout period. Can choose one of 16 values.
205 */
206 #define WDT_DFLT_TOP GENMASK(19, 16)
207
208 /*
209 * The reset pulse length that is available directly after reset.
210 */
211 #define WDT_DFLT_RPL GENMASK(12, 10)
212
213 /*
214 * Width of the APB Data Bus to which this component is attached.
215 */
216 #define APB_DATA_WIDTH GENMASK(9, 8)
217
218 /*
219 * APB data width is 8 bits
220 */
221 #define APB_8BITS 0x0
222
223 /*
224 * APB data width is 16 bits
225 */
226 #define APB_16BITS 0x1
227
228 /*
229 * APB data width is 32 bits
230 */
231 #define APB_32BITS 0x2
232
233 /*
234 * Configures the peripheral to have a pause enable signal (pause) on the interface that can be used
235 * to freeze the watchdog counter during pause mode.
236 */
237 #define WDT_PAUSE BIT(7)
238
239 /*
240 * When this parameter is set to 1, timeout period range is fixed. The range increments by the power
241 * of 2 from 2^16 to 2^(WDT_CNT_WIDTH-1). When this parameter is set to 0, the user must define the
242 * timeout period range (2^8 to 2^(WDT_CNT_WIDTH)-1) using the WDT_USER_TOP_(i) parameter.
243 */
244 #define WDT_USE_FIX_TOP BIT(6)
245
246 /*
247 * When set to 1, the selected timeout period(s)
248 */
249 #define WDT_HC_TOP BIT(5)
250
251 /*
252 * Configures the reset pulse length to be hard coded.
253 */
254 #define WDT_HC_RPL BIT(4)
255
256 /*
257 * Configures the output response mode to be hard coded.
258 */
259 #define WDT_HC_RMOD BIT(3)
260
261 /*
262 * When set to 1, includes a second timeout period that is used for initialization prior to the
263 * first kick.
264 */
265 #define WDT_DUAL_TOP BIT(2)
266
267 /*
268 * Describes the output response mode that is available directly after reset. Indicates the output
269 * response the WDT gives if a zero count is reached; that is, a system reset if equals 0 and
270 * an interrupt followed by a system reset, if equals 1. If WDT_HC_RMOD is 1, then default response
271 * mode is the only possible output response mode.
272 */
273 #define WDT_DFLT_RMOD BIT(1)
274
275 /*
276 * Configures the WDT to be enabled from reset. If this setting is 1, the WDT is always enabled and
277 * a write to the WDT_EN field (bit 0) of the Watchdog Timer Control Register (WDT_CR) to disable
278 * it has no effect.
279 */
280 #define WDT_ALWAYS_EN BIT(0)
281
282
283 /*
284 * Component Version Register
285 * ASCII value for each number in the version, followed by *.
286 * For example, 32_30_31_2A represents the version 2.01*.
287 */
288 #define WDT_COMP_VERSION 0xf8
289
290
291 /*
292 * Component Type Register
293 * Designware Component Type number = 0x44_57_01_20.
294 * This assigned unique hex value is constant, and is derived from the two ASCII letters "DW"
295 * followed by a 16-bit unsigned number.
296 */
297 #define WDT_COMP_TYPE 0xfc
298 #define WDT_COMP_TYPE_VALUE 0x44570120
299
300 /**
301 * @brief Enable watchdog
302 *
303 * @param base Device base address.
304 */
dw_wdt_enable(const uint32_t base)305 static inline void dw_wdt_enable(const uint32_t base)
306 {
307 uint32_t control = sys_read32(base + WDT_CR);
308
309 control |= WDT_CR_WDT_EN;
310 sys_write32(control, base + WDT_CR);
311 }
312
313 /**
314 * @brief Set response mode.
315 *
316 * Selects whether watchdog should generate interrupt on the first timeout (true) or reset system
317 * (false)
318 *
319 * @param base Device base address.
320 * @param mode Response mode.
321 * false = Generate a system reset,
322 * true = First generate an interrupt and even if it is cleared by the time a second
323 * timeout occurs then generate a system reset
324 */
dw_wdt_response_mode_set(const uint32_t base,const bool mode)325 static inline void dw_wdt_response_mode_set(const uint32_t base, const bool mode)
326 {
327 uint32_t control = sys_read32(base + WDT_CR);
328
329 if (mode) {
330 control |= WDT_CR_RMOD;
331 } else {
332 control &= ~WDT_CR_RMOD;
333 }
334
335 sys_write32(control, base + WDT_CR);
336 }
337
338 /**
339 * @brief Set reset pulse length.
340 *
341 * @param base Device base address.
342 * @param pclk_cycles Reset pulse length selector (2 to 256 pclk cycles)
343 */
dw_wdt_reset_pulse_length_set(const uint32_t base,const uint32_t pclk_cycles)344 static inline void dw_wdt_reset_pulse_length_set(const uint32_t base, const uint32_t pclk_cycles)
345 {
346 uint32_t control = sys_read32(base + WDT_CR);
347
348 control &= ~WDT_CR_RPL;
349 control |= FIELD_PREP(WDT_CR_RPL, pclk_cycles);
350
351 sys_write32(control, base + WDT_CR);
352 }
353
354 /**
355 * @brief Set timeout period.
356 *
357 * @param base Device base address.
358 * @param timeout_period Timeout period value selector
359 */
dw_wdt_timeout_period_set(const uint32_t base,const uint32_t timeout_period)360 static inline void dw_wdt_timeout_period_set(const uint32_t base, const uint32_t timeout_period)
361 {
362 uint32_t timeout = sys_read32(base + WDT_TORR);
363
364 timeout &= ~WDT_TORR_TOP;
365 timeout |= FIELD_PREP(WDT_TORR_TOP, timeout_period);
366 sys_write32(timeout, base + WDT_TORR);
367 }
368
369 /**
370 * @brief Get actual timeout period range.
371 *
372 * @param base Device base address.
373 * @return Actual timeout period range
374 */
dw_wdt_timeout_period_get(const uint32_t base)375 static inline uint32_t dw_wdt_timeout_period_get(const uint32_t base)
376 {
377 return FIELD_GET(WDT_TORR_TOP, sys_read32(base + WDT_TORR));
378 }
379
380 /**
381 * @brief Timeout period for initialization.
382 *
383 * @param base Device base address.
384 * @param timeout_period Timeout period value selector
385 */
dw_wdt_timeout_period_init_set(const uint32_t base,const uint32_t timeout_period)386 static inline void dw_wdt_timeout_period_init_set(const uint32_t base,
387 const uint32_t timeout_period)
388 {
389 uint32_t timeout = sys_read32(base + WDT_TORR);
390
391 timeout &= ~WDT_TORR_TOP_INIT;
392 timeout |= FIELD_PREP(WDT_TORR_TOP_INIT, timeout_period);
393 sys_write32(timeout, base + WDT_TORR);
394 }
395
396 /**
397 * @brief Get WDT Current Counter Value Register.
398 *
399 * @param base Device base address.
400 * @param wdt_counter_width Watchdog Timer counter width
401 * @return The current value of the internal counter
402 */
dw_wdt_current_counter_value_register_get(const uint32_t base,uint32_t wdt_counter_width)403 static inline uint32_t dw_wdt_current_counter_value_register_get(const uint32_t base,
404 uint32_t wdt_counter_width)
405 {
406 uint32_t current_counter_value = sys_read32(base + WDT_CCVR);
407
408 current_counter_value &= (1 << (wdt_counter_width - 1));
409 return current_counter_value;
410 }
411
412 /**
413 * @brief Counter Restart
414 *
415 * Restart the WDT counter. A restart also clears the WDT interrupt.
416 *
417 * @param base Device base address.
418 */
dw_wdt_counter_restart(const uint32_t base)419 static inline void dw_wdt_counter_restart(const uint32_t base)
420 {
421 sys_write32(WDT_CRR_RESTART_KEY, base + WDT_CRR);
422 }
423
424 /**
425 * @brief Get Interrupt status
426 *
427 * @param base Device base address.
428 * @return 0x0 (INACTIVE): Interrupt is inactive,
429 * 0x1 (ACTIVE): Interrupt is active regardless of polarity
430 */
dw_wdt_interrupt_status_register_get(const uint32_t base)431 static inline uint32_t dw_wdt_interrupt_status_register_get(const uint32_t base)
432 {
433 return sys_read32(base + WDT_STAT) & 1;
434 }
435
436 /**
437 * @brief Clears the watchdog interrupt.
438 *
439 * This can be used to clear the interrupt without restarting the watchdog counter.
440 *
441 * @param base Device base address.
442 */
dw_wdt_clear_interrupt(const uint32_t base)443 static inline void dw_wdt_clear_interrupt(const uint32_t base)
444 {
445 sys_read32(base + WDT_EOI);
446 }
447
448 /**
449 * @brief Gets the upper limit of Timeout Period parameters.
450 *
451 * @param base Device base address.
452 * @return Upper limit of Timeout Period parameters.
453 */
dw_wdt_user_top_max_get(const uint32_t base)454 static inline uint32_t dw_wdt_user_top_max_get(const uint32_t base)
455 {
456 return sys_read32(base + WDT_COMP_PARAM_5);
457 }
458
459 /**
460 * @brief Gets the Upper limit of Initial Timeout Period parameters.
461 *
462 * @param base Device base address.
463 * @return Upper limit of Initial Timeout Period parameters.
464 */
dw_wdt_user_top_init_max_get(const uint32_t base)465 static inline uint32_t dw_wdt_user_top_init_max_get(const uint32_t base)
466 {
467 return sys_read32(base + WDT_COMP_PARAM_4);
468 }
469
470 /**
471 * @brief Get the default value of the timeout range that is selected after reset.
472 *
473 * @param base Device base address.
474 * @return Default timeout range after reset
475 */
dw_wdt_timeout_period_rst_get(const uint32_t base)476 static inline uint32_t dw_wdt_timeout_period_rst_get(const uint32_t base)
477 {
478 return sys_read32(base + WDT_COMP_PARAM_3);
479 }
480
481 /**
482 * @brief Get the default value of the timeout counter that is set after reset.
483 *
484 * @param base Device base address.
485 * @return Default timeout counter value
486 */
dw_wdt_cnt_rst_get(const uint32_t base)487 static inline uint32_t dw_wdt_cnt_rst_get(const uint32_t base)
488 {
489 return sys_read32(base + WDT_COMP_PARAM_2);
490 }
491
492 /**
493 * @brief Get the Watchdog timer counter width.
494 *
495 * @param base Device base address.
496 * @return Width of the counter register
497 */
dw_wdt_cnt_width_get(const uint32_t base)498 static inline uint32_t dw_wdt_cnt_width_get(const uint32_t base)
499 {
500 return FIELD_GET(WDT_CNT_WIDTH, sys_read32(base + WDT_COMP_PARAM_1)) + 16;
501 }
502
503 /**
504 * @brief Describes the initial timeout period that is available directly after reset.
505 *
506 * It controls the reset value of the register. If WDT_HC_TOP is 1, then the default initial time
507 * period is the only possible period.
508 *
509 * @param base Device base address.
510 * @return Initial timeout period
511 */
dw_wdt_dflt_timeout_period_init_get(const uint32_t base)512 static inline uint32_t dw_wdt_dflt_timeout_period_init_get(const uint32_t base)
513 {
514 return FIELD_GET(WDT_DFLT_TOP_INIT, sys_read32(base + WDT_COMP_PARAM_1));
515 }
516
517 /**
518 * @brief Get default timeout period
519 *
520 * Selects the timeout period that is available directly after reset. It controls the reset value
521 * of the register. If WDT_HC_TOP is set to 1, then the default timeout period is the only possible
522 * timeout period. Can choose one of 16 values.
523 *
524 * @param base Device base address.
525 * @return Default timeout period
526 */
dw_wdt_dflt_timeout_period_get(const uint32_t base)527 static inline uint32_t dw_wdt_dflt_timeout_period_get(const uint32_t base)
528 {
529 return FIELD_GET(WDT_DFLT_TOP, sys_read32(base + WDT_COMP_PARAM_1));
530 }
531
532 /**
533 * @brief The reset pulse length that is available directly after reset.
534 *
535 * @param base Device base address.
536 * @return Reset pulse length
537 */
dw_wdt_dflt_rpl_get(const uint32_t base)538 static inline uint32_t dw_wdt_dflt_rpl_get(const uint32_t base)
539 {
540 return FIELD_GET(WDT_DFLT_RPL, sys_read32(base + WDT_COMP_PARAM_1));
541 }
542
543 /**
544 * @brief Width of the APB Data Bus to which this component is attached.
545 *
546 * @param base Device base address.
547 * @return APB data width
548 * 0x0 (APB_8BITS): APB data width is 8 bits
549 * 0x1 (APB_16BITS): APB data width is 16 bits
550 * 0x2 (APB_32BITS): APB data width is 32 bits
551 */
dw_wdt_apb_data_width_get(const uint32_t base)552 static inline uint32_t dw_wdt_apb_data_width_get(const uint32_t base)
553 {
554 return FIELD_GET(APB_DATA_WIDTH, sys_read32(base + WDT_COMP_PARAM_1));
555 }
556
557 /**
558 * @brief Get configuration status of a pause signal
559 *
560 * Check the peripheral is configured to have a pause enable signal (pause) on the interface that
561 * can be used to freeze the watchdog counter during pause mode.
562 *
563 * @param base Device base address.
564 * @return 0x0 (DISABLED): Pause enable signal is non existent
565 * 0x1 (ENABLED): Pause enable signal is included
566 */
dw_wdt_pause_get(const uint32_t base)567 static inline uint32_t dw_wdt_pause_get(const uint32_t base)
568 {
569 return FIELD_GET(WDT_PAUSE, sys_read32(base + WDT_COMP_PARAM_1));
570 }
571
572 /**
573 * @brief Get fixed period status
574 *
575 * When this parameter is set to 1, timeout period range is fixed. The range increments by the power
576 * of 2 from 2^16 to 2^(WDT_CNT_WIDTH-1). When this parameter is set to 0, the user must define the
577 * timeout period range (2^8 to 2^(WDT_CNT_WIDTH)-1) using the WDT_USER_TOP_(i) parameter.
578 *
579 * @param base Device base address.
580 * @return 0x0 (USERDEFINED): User must define timeout values
581 * 0x1 (PREDEFINED): Use predefined timeout values
582 */
dw_wdt_use_fix_timeout_period_get(const uint32_t base)583 static inline uint32_t dw_wdt_use_fix_timeout_period_get(const uint32_t base)
584 {
585 return FIELD_GET(WDT_USE_FIX_TOP, sys_read32(base + WDT_COMP_PARAM_1));
586 }
587
588 /**
589 * @brief Checks if period is hardcoded
590 *
591 * When set to 1, the selected timeout period(s) is set to be hard coded.
592 *
593 * @param base Device base address.
594 * @return 0x0 (PROGRAMMABLE): Timeout period is programmable
595 * 0x1 (HARDCODED): Timeout period is hard coded
596 */
dw_wdt_hc_timeout_period_get(const uint32_t base)597 static inline uint32_t dw_wdt_hc_timeout_period_get(const uint32_t base)
598 {
599 return FIELD_GET(WDT_HC_TOP, sys_read32(base + WDT_COMP_PARAM_1));
600 }
601
602 /**
603 * @brief Checks if reset pulse length is hardcoded.
604 *
605 * @param base Device base address.
606 * @return 0x0 (PROGRAMMABLE): Reset pulse length is programmable
607 * 0x1 (HARDCODED): Reset pulse length is hardcoded
608 */
dw_wdt_hc_reset_pulse_length_get(const uint32_t base)609 static inline uint32_t dw_wdt_hc_reset_pulse_length_get(const uint32_t base)
610 {
611 return FIELD_GET(WDT_HC_RPL, sys_read32(base + WDT_COMP_PARAM_1));
612 }
613
614 /**
615 * @brief Checks if the output response mode is hardcoded.
616 *
617 * @param base Device base address.
618 * @return 0x0 (PROGRAMMABLE): Output response mode is programmable
619 * 0x1 (HARDCODED): Output response mode is hard coded
620 */
dw_wdt_hc_response_mode_get(const uint32_t base)621 static inline uint32_t dw_wdt_hc_response_mode_get(const uint32_t base)
622 {
623 return FIELD_GET(WDT_HC_RMOD, sys_read32(base + WDT_COMP_PARAM_1));
624 }
625
626 /**
627 * @brief Checks if a second timeout period if supported.
628 *
629 * When set to 1, includes a second timeout period that is used for initialization prior to the
630 * first kick.
631 *
632 * @param base Device base address.
633 * @return 0x0 (DISABLED): Second timeout period is not present
634 * 0x1 (ENABLED): Second timeout period is present
635 */
dw_wdt_dual_timeout_period_get(const uint32_t base)636 static inline uint32_t dw_wdt_dual_timeout_period_get(const uint32_t base)
637 {
638 return FIELD_GET(WDT_DUAL_TOP, sys_read32(base + WDT_COMP_PARAM_1));
639 }
640
641 /**
642 * @brief Get default response mode
643 *
644 * Describes the output response mode that is available directly after reset. Indicates the output
645 * response the WDT gives if a zero count is reached; that is, a system reset if equals 0 and an
646 * interrupt followed by a system reset, if equals 1. If WDT_HC_RMOD is 1, then default response
647 * mode is the only possible output response mode.
648 *
649 * @param base Device base address.
650 * @return 0x0 (DISABLED): System reset only
651 * 0x1 (ENABLED): Interrupt and system reset
652 */
dw_wdt_dflt_response_mode_get(const uint32_t base)653 static inline uint32_t dw_wdt_dflt_response_mode_get(const uint32_t base)
654 {
655 return FIELD_GET(WDT_DFLT_RMOD, sys_read32(base + WDT_COMP_PARAM_1));
656 }
657
658 /**
659 * @brief Checks if watchdog is enabled from reset
660 *
661 * If this setting is 1, the WDT is always enabled and a write to the WDT_EN field (bit 0) of the
662 * Watchdog Timer Control Register (WDT_CR) to disable it has no effect.
663 *
664 * @param base Device base address.
665 * @return 0x0 (DISABLED): Watchdog timer disabled on reset
666 * 0x1 (ENABLED): Watchdog timer enabled on reset
667 */
dw_wdt_always_en_get(const uint32_t base)668 static inline uint32_t dw_wdt_always_en_get(const uint32_t base)
669 {
670 return FIELD_GET(WDT_ALWAYS_EN, sys_read32(base + WDT_COMP_PARAM_1));
671 }
672
673 /**
674 * @brief ASCII value for each number in the version
675 *
676 * For example, 32_30_31_2A represents the version 2.01s
677 *
678 * @param base Device base address.
679 * @return Component version code
680 */
dw_wdt_comp_version_get(const uint32_t base)681 static inline uint32_t dw_wdt_comp_version_get(const uint32_t base)
682 {
683 return sys_read32(base + WDT_COMP_VERSION);
684 }
685
686 /**
687 * @brief Get Component Type
688 *
689 * @param base Device base address.
690 * @return Components type code
691 */
dw_wdt_comp_type_get(const uint32_t base)692 static inline uint32_t dw_wdt_comp_type_get(const uint32_t base)
693 {
694 return sys_read32(base + WDT_COMP_TYPE);
695 }
696
697 #endif /* !ZEPHYR_DRIVERS_WATCHDOG_WDT_DW_H_ */
698