blob: ca0a42d29fb130613f030e46adf44f839dbcb851 [file] [log] [blame]
Googler25e92cf2023-12-13 10:05:01 +00001// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * Copyright (c) 2019 Amlogic, Inc. All rights reserved.
4 */
5
6#include <common.h>
7#include <asm/types.h>
8#include <asm/arch/romboot.h>
9#include <asm/arch/cpu_reset.h>
10#include <asm/arch/io.h>
11#include <asm/arch/timer.h>
12#include <dm.h>
13#include <wdt.h>
14
15/*
16 *GPIOE_0 VDDEE_PWM
17 *GPIOE_1 VDDCPU_PWM
18 * */
19void set_pwm_to_input(void)
20{
21 //hxbao, need fine tune
22 #if 0
23 unsigned int val;
24
25 val = readl(AO_RTI_PINMUX_REG1);
26 val &= ~(0xff << 16);
27 writel(val, AO_RTI_PINMUX_REG1);/* clear pinmux */
28 val = readl(AO_GPIO_O_EN_N);
29 val &= ~(0x3 << 16);
30 val |= 0x3 << 16;
31 writel(val, AO_GPIO_O_EN_N);/* set input mode */
32 val = readl(AO_RTI_PULL_UP_EN_REG);
33 val &= ~(0x3 << 16);
34 writel(val, AO_RTI_PULL_UP_EN_REG);/* disable pull up/down */
35 #endif
36}
37
38void reset_system(void)
39{
40 struct udevice *watchdog_devp;
41 int ret;
42
43 set_pwm_to_input();
44
45 _udelay(10000); //wait print
46
47 ret = uclass_get_device_by_name(UCLASS_WDT, "watchdog", &watchdog_devp);
48 if (ret < 0) {
49 printf("failed to reset system because can't get wdt device\n");
50 return;
51 }
52 wdt_start(watchdog_devp, 0, 0);
53 while (1);
54}
55
56/* uboot reset interface */
57void reset_cpu(unsigned long flag){
58 reset_system();
59}