common: Move reset_cpu() to the CPU header
[oweals/u-boot.git] / board / renesas / grpeach / grpeach.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2017 Renesas Electronics
4  * Copyright (C) Chris Brandt
5  */
6
7 #include <common.h>
8 #include <cpu_func.h>
9 #include <asm/io.h>
10 #include <asm/arch/sys_proto.h>
11
12 #define RZA1_WDT_BASE   0xfcfe0000
13 #define WTCSR           0x00
14 #define WTCNT           0x02
15 #define WRCSR           0x04
16
17 DECLARE_GLOBAL_DATA_PTR;
18
19 int board_init(void)
20 {
21         gd->bd->bi_boot_params = (CONFIG_SYS_SDRAM_BASE + 0x100);
22
23         return 0;
24 }
25
26 int dram_init(void)
27 {
28         if (fdtdec_setup_mem_size_base() != 0)
29                 return -EINVAL;
30
31         return 0;
32 }
33
34 int dram_init_banksize(void)
35 {
36         fdtdec_setup_memory_banksize();
37
38         return 0;
39 }
40
41 void reset_cpu(ulong addr)
42 {
43         /* Dummy read (must read WRCSR:WOVF at least once before clearing) */
44         readb(RZA1_WDT_BASE + WRCSR);
45
46         writew(0xa500, RZA1_WDT_BASE + WRCSR);
47         writew(0x5a5f, RZA1_WDT_BASE + WRCSR);
48         writew(0x5a00, RZA1_WDT_BASE + WTCNT);
49         writew(0xa578, RZA1_WDT_BASE + WTCSR);
50
51         for (;;)
52                 asm volatile("wfi");
53 }