blob: 445adf94cd3341d0d846017dbcd01c67376aa709 [file] [log] [blame]
bangzheng.liu5e691382023-01-10 16:20:10 +08001/*
2 * Copyright (c) 2021-2022 Amlogic, Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: MIT
5 */
6
7#ifndef __WAKEUP_H__
8#define __WAKEUP_H__
9
10/*use timerB to wakeup AP FSM*/
11static inline void wakeup_ap(void)
12{
13 uint32_t value;
14 //uint32_t time_out = 20;
15
16 /*set alarm timer*/
17 REG32(FSM_TRIGER_SRC) = 1000; /*1ms*/
18
19 value = REG32(FSM_TRIGER_CTRL);
20 value &= ~((1 << 7) | (0x3) | (1 << 6));
21 value |= ((1 << 7) | (0 << 6) | (0x3));
22 REG32(FSM_TRIGER_CTRL) = value;
23 vTaskDelay(1);
24}
25
26static inline void clear_wakeup_trigger(void)
27{
28 REG32(FSM_TRIGER_SRC) = 0;
29 REG32(FSM_TRIGER_CTRL) = 0;
30}
31
32static inline void watchdog_reset_system(void)
33{
34 int i = 0;
35
36 printf("enter %s\n", __func__);
37 while (1) {
38 REG32(RESETCTRL_WATCHDOG_CTRL0) = 1 << 27 | 0 << 18;
39 /* Device GCC for waiting some cycles */
40 for (i = 0; i < 100; i++)
41 REG32(RESETCTRL_WATCHDOG_CTRL0);
42 }
43}
44#endif