blob: 75a729a99d3960b643fb31328efdbb3e1674763e [file] [log] [blame]
Bryan O'Donoghue5c0c1e72018-05-25 16:45:27 +01001/*
2 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +00007#ifndef IMX_WDOG_H
8#define IMX_WDOG_H
Bryan O'Donoghue5c0c1e72018-05-25 16:45:27 +01009
Bryan O'Donoghue5c0c1e72018-05-25 16:45:27 +010010#include <stdint.h>
11
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000012#include <arch.h>
13
Bryan O'Donoghue5c0c1e72018-05-25 16:45:27 +010014struct wdog_regs {
15 uint16_t wcr;
16 uint16_t wsr;
17 uint16_t wrsr;
18 uint16_t wicr;
19 uint16_t wmcr;
20};
21
22/* WCR bits */
23#define WCR_WDZST BIT(0)
24#define WCR_WDBG BIT(1)
25#define WCR_WDE BIT(2)
26#define WCR_WDT BIT(3)
27#define WCR_SRS BIT(4)
28#define WCR_WDA BIT(5)
29#define WCR_SRE BIT(6)
30#define WCR_WDW BIT(7)
31#define WCR_WT(x) ((x) << 8)
32
33/* WSR bits */
34#define WSR_FIRST 0x5555
35#define WSR_SECOND 0xAAAA
36
37/* WRSR bits */
38#define WRSR_SFTW BIT(0)
39#define WRSR_TOUT BIT(1)
40#define WRSR_POR BIT(4)
41
42/* WICR bits */
43static inline int wicr_calc_wict(int sec, int half_sec)
44{
45 int wict_bits;
46
47 /* Represents WICR bits 7 - 0 */
48 wict_bits = ((sec << 1) | (half_sec ? 1 : 0));
49
50 return wict_bits;
51}
52
53#define WICR_WTIS BIT(14)
54#define WICR_WIE BIT(15)
55
56/* WMCR bits */
57#define WMCR_PDE BIT(0)
58
59/* External facing API */
60void imx_wdog_init(void);
61
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +000062#endif /* IMX_WDOG_H */