qemu-options: Remove the deprecated -no-acpi option
[qemu/kevin.git] / tests / qtest / sifive-e-aon-watchdog-test.c
blob1f313d16ad82d876b8b4ddd1aee7c6ca7b40f145
1 /*
2 * QTest testcase for the watchdog timer of HiFive 1 rev b.
4 * Copyright (c) 2023 SiFive, Inc.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2 or later, as published by the Free Software Foundation.
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
15 * You should have received a copy of the GNU General Public License along with
16 * this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "qemu/osdep.h"
20 #include "qemu/timer.h"
21 #include "qemu/bitops.h"
22 #include "libqtest.h"
23 #include "hw/registerfields.h"
24 #include "hw/misc/sifive_e_aon.h"
26 FIELD(AON_WDT_WDOGCFG, SCALE, 0, 4)
27 FIELD(AON_WDT_WDOGCFG, RSVD0, 4, 4)
28 FIELD(AON_WDT_WDOGCFG, RSTEN, 8, 1)
29 FIELD(AON_WDT_WDOGCFG, ZEROCMP, 9, 1)
30 FIELD(AON_WDT_WDOGCFG, RSVD1, 10, 2)
31 FIELD(AON_WDT_WDOGCFG, EN_ALWAYS, 12, 1)
32 FIELD(AON_WDT_WDOGCFG, EN_CORE_AWAKE, 13, 1)
33 FIELD(AON_WDT_WDOGCFG, RSVD2, 14, 14)
34 FIELD(AON_WDT_WDOGCFG, IP0, 28, 1)
35 FIELD(AON_WDT_WDOGCFG, RSVD3, 29, 3)
37 #define WDOG_BASE (0x10000000)
38 #define WDOGCFG (0x0)
39 #define WDOGCOUNT (0x8)
40 #define WDOGS (0x10)
41 #define WDOGFEED (0x18)
42 #define WDOGKEY (0x1c)
43 #define WDOGCMP0 (0x20)
45 #define SIFIVE_E_AON_WDOGKEY (0x51F15E)
46 #define SIFIVE_E_AON_WDOGFEED (0xD09F00D)
47 #define SIFIVE_E_LFCLK_DEFAULT_FREQ (32768)
49 static void test_init(QTestState *qts)
51 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
52 qtest_writel(qts, WDOG_BASE + WDOGCOUNT, 0);
54 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
55 qtest_writel(qts, WDOG_BASE + WDOGCFG, 0);
57 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
58 qtest_writel(qts, WDOG_BASE + WDOGCMP0, 0xBEEF);
61 static void test_wdogcount(void)
63 uint64_t tmp;
64 QTestState *qts = qtest_init("-machine sifive_e");
66 test_init(qts);
68 tmp = qtest_readl(qts, WDOG_BASE + WDOGCOUNT);
69 qtest_writel(qts, WDOG_BASE + WDOGCOUNT, 0xBEEF);
70 g_assert(qtest_readl(qts, WDOG_BASE + WDOGCOUNT) == tmp);
72 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
73 qtest_writel(qts, WDOG_BASE + WDOGCOUNT, 0xBEEF);
74 g_assert(0xBEEF == qtest_readl(qts, WDOG_BASE + WDOGCOUNT));
76 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
77 qtest_writel(qts, WDOG_BASE + WDOGCOUNT, 0xAAAAAAAA);
78 g_assert(0x2AAAAAAA == qtest_readl(qts, WDOG_BASE + WDOGCOUNT));
80 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
81 qtest_writel(qts, WDOG_BASE + WDOGFEED, 0xAAAAAAAA);
82 g_assert(0x2AAAAAAA == qtest_readl(qts, WDOG_BASE + WDOGCOUNT));
84 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
85 qtest_writel(qts, WDOG_BASE + WDOGFEED, SIFIVE_E_AON_WDOGFEED);
86 g_assert(0 == qtest_readl(qts, WDOG_BASE + WDOGCOUNT));
88 qtest_quit(qts);
91 static void test_wdogcfg(void)
93 uint32_t tmp_cfg;
94 QTestState *qts = qtest_init("-machine sifive_e");
96 test_init(qts);
98 tmp_cfg = qtest_readl(qts, WDOG_BASE + WDOGCFG);
99 qtest_writel(qts, WDOG_BASE + WDOGCFG, 0xFFFFFFFF);
100 g_assert(qtest_readl(qts, WDOG_BASE + WDOGCFG) == tmp_cfg);
102 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
103 qtest_writel(qts, WDOG_BASE + WDOGCFG, 0xFFFFFFFF);
104 g_assert(0xFFFFFFFF == qtest_readl(qts, WDOG_BASE + WDOGCFG));
106 tmp_cfg = qtest_readl(qts, WDOG_BASE + WDOGCFG);
107 g_assert(15 == FIELD_EX32(tmp_cfg, AON_WDT_WDOGCFG, SCALE));
108 g_assert(1 == FIELD_EX32(tmp_cfg, AON_WDT_WDOGCFG, RSTEN));
109 g_assert(1 == FIELD_EX32(tmp_cfg, AON_WDT_WDOGCFG, ZEROCMP));
110 g_assert(1 == FIELD_EX32(tmp_cfg, AON_WDT_WDOGCFG, EN_ALWAYS));
111 g_assert(1 == FIELD_EX32(tmp_cfg, AON_WDT_WDOGCFG, EN_CORE_AWAKE));
112 g_assert(1 == FIELD_EX32(tmp_cfg, AON_WDT_WDOGCFG, IP0));
114 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
115 qtest_writel(qts, WDOG_BASE + WDOGCFG, 0);
116 tmp_cfg = qtest_readl(qts, WDOG_BASE + WDOGCFG);
117 g_assert(0 == FIELD_EX32(tmp_cfg, AON_WDT_WDOGCFG, SCALE));
118 g_assert(0 == FIELD_EX32(tmp_cfg, AON_WDT_WDOGCFG, RSTEN));
119 g_assert(0 == FIELD_EX32(tmp_cfg, AON_WDT_WDOGCFG, ZEROCMP));
120 g_assert(0 == FIELD_EX32(tmp_cfg, AON_WDT_WDOGCFG, EN_ALWAYS));
121 g_assert(0 == FIELD_EX32(tmp_cfg, AON_WDT_WDOGCFG, EN_CORE_AWAKE));
122 g_assert(0 == FIELD_EX32(tmp_cfg, AON_WDT_WDOGCFG, IP0));
123 g_assert(0 == qtest_readl(qts, WDOG_BASE + WDOGCFG));
125 qtest_quit(qts);
128 static void test_wdogcmp0(void)
130 uint32_t tmp;
131 QTestState *qts = qtest_init("-machine sifive_e");
133 test_init(qts);
135 tmp = qtest_readl(qts, WDOG_BASE + WDOGCMP0);
136 qtest_writel(qts, WDOG_BASE + WDOGCMP0, 0xBEEF);
137 g_assert(qtest_readl(qts, WDOG_BASE + WDOGCMP0) == tmp);
139 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
140 qtest_writel(qts, WDOG_BASE + WDOGCMP0, 0xBEEF);
141 g_assert(0xBEEF == qtest_readl(qts, WDOG_BASE + WDOGCMP0));
143 qtest_quit(qts);
146 static void test_wdogkey(void)
148 QTestState *qts = qtest_init("-machine sifive_e");
150 test_init(qts);
152 g_assert(0 == qtest_readl(qts, WDOG_BASE + WDOGKEY));
154 qtest_writel(qts, WDOG_BASE + WDOGKEY, 0xFFFF);
155 g_assert(0 == qtest_readl(qts, WDOG_BASE + WDOGKEY));
157 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
158 g_assert(1 == qtest_readl(qts, WDOG_BASE + WDOGKEY));
160 qtest_writel(qts, WDOG_BASE + WDOGFEED, 0xAAAAAAAA);
161 g_assert(0 == qtest_readl(qts, WDOG_BASE + WDOGKEY));
163 qtest_quit(qts);
166 static void test_wdogfeed(void)
168 QTestState *qts = qtest_init("-machine sifive_e");
170 test_init(qts);
172 g_assert(0 == qtest_readl(qts, WDOG_BASE + WDOGFEED));
174 qtest_writel(qts, WDOG_BASE + WDOGFEED, 0xFFFF);
175 g_assert(0 == qtest_readl(qts, WDOG_BASE + WDOGFEED));
177 qtest_quit(qts);
180 static void test_scaled_wdogs(void)
182 uint32_t cfg;
183 uint32_t fake_count = 0x12345678;
184 QTestState *qts = qtest_init("-machine sifive_e");
186 test_init(qts);
188 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
189 qtest_writel(qts, WDOG_BASE + WDOGCOUNT, fake_count);
190 g_assert(qtest_readl(qts, WDOG_BASE + WDOGCOUNT) == fake_count);
191 g_assert((uint16_t)qtest_readl(qts, WDOG_BASE + WDOGS) ==
192 (uint16_t)fake_count);
194 for (int i = 0; i < 16; i++) {
195 cfg = qtest_readl(qts, WDOG_BASE + WDOGCFG);
196 cfg = FIELD_DP32(cfg, AON_WDT_WDOGCFG, SCALE, i);
197 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
198 qtest_writel(qts, WDOG_BASE + WDOGCFG, cfg);
199 g_assert((uint16_t)qtest_readl(qts, WDOG_BASE + WDOGS) ==
200 (uint16_t)(fake_count >>
201 FIELD_EX32(cfg, AON_WDT_WDOGCFG, SCALE)));
204 qtest_quit(qts);
207 static void test_watchdog(void)
209 uint32_t cfg;
210 QTestState *qts = qtest_init("-machine sifive_e");
212 test_init(qts);
214 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
215 qtest_writel(qts, WDOG_BASE + WDOGCMP0, SIFIVE_E_LFCLK_DEFAULT_FREQ);
217 cfg = qtest_readl(qts, WDOG_BASE + WDOGCFG);
218 cfg = FIELD_DP32(cfg, AON_WDT_WDOGCFG, SCALE, 0);
219 cfg = FIELD_DP32(cfg, AON_WDT_WDOGCFG, EN_ALWAYS, 1);
220 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
221 qtest_writel(qts, WDOG_BASE + WDOGCFG, cfg);
223 qtest_clock_step(qts, NANOSECONDS_PER_SECOND);
225 g_assert(qtest_readl(qts, WDOG_BASE + WDOGCOUNT) ==
226 SIFIVE_E_LFCLK_DEFAULT_FREQ);
227 g_assert(qtest_readl(qts, WDOG_BASE + WDOGS) ==
228 SIFIVE_E_LFCLK_DEFAULT_FREQ);
230 cfg = qtest_readl(qts, WDOG_BASE + WDOGCFG);
231 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, SCALE));
232 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, RSTEN));
233 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, ZEROCMP));
234 g_assert(1 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, EN_ALWAYS));
235 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, EN_CORE_AWAKE));
236 g_assert(1 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, IP0));
238 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
239 qtest_writel(qts, WDOG_BASE + WDOGCOUNT, 0);
240 cfg = FIELD_DP32(cfg, AON_WDT_WDOGCFG, IP0, 0);
241 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
242 qtest_writel(qts, WDOG_BASE + WDOGCFG, cfg);
243 cfg = qtest_readl(qts, WDOG_BASE + WDOGCFG);
244 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, IP0));
246 qtest_quit(qts);
249 static void test_scaled_watchdog(void)
251 uint32_t cfg;
252 QTestState *qts = qtest_init("-machine sifive_e");
254 test_init(qts);
256 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
257 qtest_writel(qts, WDOG_BASE + WDOGCMP0, 10);
259 cfg = qtest_readl(qts, WDOG_BASE + WDOGCFG);
260 cfg = FIELD_DP32(cfg, AON_WDT_WDOGCFG, SCALE, 15);
261 cfg = FIELD_DP32(cfg, AON_WDT_WDOGCFG, EN_ALWAYS, 1);
262 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
263 qtest_writel(qts, WDOG_BASE + WDOGCFG, cfg);
265 qtest_clock_step(qts, NANOSECONDS_PER_SECOND * 10);
267 g_assert(qtest_readl(qts, WDOG_BASE + WDOGCOUNT) ==
268 SIFIVE_E_LFCLK_DEFAULT_FREQ * 10);
270 g_assert(10 == qtest_readl(qts, WDOG_BASE + WDOGS));
272 cfg = qtest_readl(qts, WDOG_BASE + WDOGCFG);
273 g_assert(15 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, SCALE));
274 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, RSTEN));
275 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, ZEROCMP));
276 g_assert(1 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, EN_ALWAYS));
277 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, EN_CORE_AWAKE));
278 g_assert(1 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, IP0));
280 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
281 qtest_writel(qts, WDOG_BASE + WDOGCOUNT, 0);
282 cfg = FIELD_DP32(cfg, AON_WDT_WDOGCFG, IP0, 0);
283 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
284 qtest_writel(qts, WDOG_BASE + WDOGCFG, cfg);
285 cfg = qtest_readl(qts, WDOG_BASE + WDOGCFG);
286 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, IP0));
288 qtest_quit(qts);
291 static void test_periodic_int(void)
293 uint32_t cfg;
294 QTestState *qts = qtest_init("-machine sifive_e");
296 test_init(qts);
298 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
299 qtest_writel(qts, WDOG_BASE + WDOGCMP0, SIFIVE_E_LFCLK_DEFAULT_FREQ);
301 cfg = qtest_readl(qts, WDOG_BASE + WDOGCFG);
302 cfg = FIELD_DP32(cfg, AON_WDT_WDOGCFG, SCALE, 0);
303 cfg = FIELD_DP32(cfg, AON_WDT_WDOGCFG, ZEROCMP, 1);
304 cfg = FIELD_DP32(cfg, AON_WDT_WDOGCFG, EN_ALWAYS, 1);
305 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
306 qtest_writel(qts, WDOG_BASE + WDOGCFG, cfg);
308 qtest_clock_step(qts, NANOSECONDS_PER_SECOND);
310 g_assert(0 == qtest_readl(qts, WDOG_BASE + WDOGCOUNT));
311 g_assert(0 == qtest_readl(qts, WDOG_BASE + WDOGS));
313 cfg = qtest_readl(qts, WDOG_BASE + WDOGCFG);
314 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, SCALE));
315 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, RSTEN));
316 g_assert(1 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, ZEROCMP));
317 g_assert(1 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, EN_ALWAYS));
318 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, EN_CORE_AWAKE));
319 g_assert(1 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, IP0));
321 cfg = FIELD_DP32(cfg, AON_WDT_WDOGCFG, IP0, 0);
322 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
323 qtest_writel(qts, WDOG_BASE + WDOGCFG, cfg);
324 cfg = qtest_readl(qts, WDOG_BASE + WDOGCFG);
325 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, IP0));
327 qtest_clock_step(qts, NANOSECONDS_PER_SECOND);
329 g_assert(0 == qtest_readl(qts, WDOG_BASE + WDOGCOUNT));
330 g_assert(0 == qtest_readl(qts, WDOG_BASE + WDOGS));
332 cfg = qtest_readl(qts, WDOG_BASE + WDOGCFG);
333 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, SCALE));
334 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, RSTEN));
335 g_assert(1 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, ZEROCMP));
336 g_assert(1 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, EN_ALWAYS));
337 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, EN_CORE_AWAKE));
338 g_assert(1 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, IP0));
340 cfg = FIELD_DP32(cfg, AON_WDT_WDOGCFG, IP0, 0);
341 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
342 qtest_writel(qts, WDOG_BASE + WDOGCFG, cfg);
343 cfg = qtest_readl(qts, WDOG_BASE + WDOGCFG);
344 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, IP0));
346 qtest_quit(qts);
349 static void test_enable_disable(void)
351 uint32_t cfg;
352 QTestState *qts = qtest_init("-machine sifive_e");
354 test_init(qts);
356 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
357 qtest_writel(qts, WDOG_BASE + WDOGCMP0, 10);
359 cfg = qtest_readl(qts, WDOG_BASE + WDOGCFG);
360 cfg = FIELD_DP32(cfg, AON_WDT_WDOGCFG, SCALE, 15);
361 cfg = FIELD_DP32(cfg, AON_WDT_WDOGCFG, EN_ALWAYS, 1);
362 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
363 qtest_writel(qts, WDOG_BASE + WDOGCFG, cfg);
365 qtest_clock_step(qts, NANOSECONDS_PER_SECOND * 2);
367 g_assert(qtest_readl(qts, WDOG_BASE + WDOGCOUNT) ==
368 SIFIVE_E_LFCLK_DEFAULT_FREQ * 2);
369 g_assert(2 == qtest_readl(qts, WDOG_BASE + WDOGS));
371 cfg = qtest_readl(qts, WDOG_BASE + WDOGCFG);
372 g_assert(15 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, SCALE));
373 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, RSTEN));
374 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, ZEROCMP));
375 g_assert(1 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, EN_ALWAYS));
376 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, EN_CORE_AWAKE));
377 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, IP0));
379 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
380 cfg = FIELD_DP32(cfg, AON_WDT_WDOGCFG, EN_ALWAYS, 0);
381 qtest_writel(qts, WDOG_BASE + WDOGCFG, cfg);
383 qtest_clock_step(qts, NANOSECONDS_PER_SECOND * 8);
385 g_assert(qtest_readl(qts, WDOG_BASE + WDOGCOUNT) ==
386 SIFIVE_E_LFCLK_DEFAULT_FREQ * 2);
387 g_assert(2 == qtest_readl(qts, WDOG_BASE + WDOGS));
389 cfg = qtest_readl(qts, WDOG_BASE + WDOGCFG);
390 g_assert(15 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, SCALE));
391 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, RSTEN));
392 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, ZEROCMP));
393 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, EN_ALWAYS));
394 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, EN_CORE_AWAKE));
395 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, IP0));
397 cfg = FIELD_DP32(cfg, AON_WDT_WDOGCFG, EN_ALWAYS, 1);
398 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
399 qtest_writel(qts, WDOG_BASE + WDOGCFG, cfg);
401 qtest_clock_step(qts, NANOSECONDS_PER_SECOND * 8);
403 g_assert(qtest_readl(qts, WDOG_BASE + WDOGCOUNT) ==
404 SIFIVE_E_LFCLK_DEFAULT_FREQ * 10);
405 g_assert(10 == qtest_readl(qts, WDOG_BASE + WDOGS));
407 cfg = qtest_readl(qts, WDOG_BASE + WDOGCFG);
408 g_assert(15 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, SCALE));
409 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, RSTEN));
410 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, ZEROCMP));
411 g_assert(1 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, EN_ALWAYS));
412 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, EN_CORE_AWAKE));
413 g_assert(1 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, IP0));
415 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
416 qtest_writel(qts, WDOG_BASE + WDOGCOUNT, 0);
417 cfg = FIELD_DP32(cfg, AON_WDT_WDOGCFG, IP0, 0);
418 qtest_writel(qts, WDOG_BASE + WDOGKEY, SIFIVE_E_AON_WDOGKEY);
419 qtest_writel(qts, WDOG_BASE + WDOGCFG, cfg);
420 cfg = qtest_readl(qts, WDOG_BASE + WDOGCFG);
421 g_assert(0 == FIELD_EX32(cfg, AON_WDT_WDOGCFG, IP0));
423 qtest_quit(qts);
426 int main(int argc, char *argv[])
428 g_test_init(&argc, &argv, NULL);
429 qtest_add_func("/sifive-e-aon-watchdog-test/wdogcount",
430 test_wdogcount);
431 qtest_add_func("/sifive-e-aon-watchdog-test/wdogcfg",
432 test_wdogcfg);
433 qtest_add_func("/sifive-e-aon-watchdog-test/wdogcmp0",
434 test_wdogcmp0);
435 qtest_add_func("/sifive-e-aon-watchdog-test/wdogkey",
436 test_wdogkey);
437 qtest_add_func("/sifive-e-aon-watchdog-test/wdogfeed",
438 test_wdogfeed);
439 qtest_add_func("/sifive-e-aon-watchdog-test/scaled_wdogs",
440 test_scaled_wdogs);
441 qtest_add_func("/sifive-e-aon-watchdog-test/watchdog",
442 test_watchdog);
443 qtest_add_func("/sifive-e-aon-watchdog-test/scaled_watchdog",
444 test_scaled_watchdog);
445 qtest_add_func("/sifive-e-aon-watchdog-test/periodic_int",
446 test_periodic_int);
447 qtest_add_func("/sifive-e-aon-watchdog-test/enable_disable",
448 test_enable_disable);
449 return g_test_run();