c3241bc21d2178b0d4e45e93b1db78ab3e201ee9
[platform/kernel/u-boot.git] / board / renesas / falcon / falcon.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * board/renesas/falcon/falcon.c
4  *     This file is Falcon board support.
5  *
6  * Copyright (C) 2020 Renesas Electronics Corp.
7  */
8
9 #include <common.h>
10 #include <asm/arch/rmobile.h>
11 #include <asm/arch/sys_proto.h>
12 #include <asm/global_data.h>
13 #include <asm/io.h>
14 #include <asm/mach-types.h>
15 #include <asm/processor.h>
16 #include <linux/errno.h>
17
18 DECLARE_GLOBAL_DATA_PTR;
19
20 #define CPGWPR          0xE6150000
21 #define CPGWPCR         0xE6150004
22
23 #define EXTAL_CLK       16666600u
24 #define CNTCR_BASE      0xE6080000
25 #define CNTFID0         (CNTCR_BASE + 0x020)
26 #define CNTCR_EN        BIT(0)
27
28 static void init_generic_timer(void)
29 {
30         u32 freq;
31
32         /* Set frequency data in CNTFID0 */
33         freq = EXTAL_CLK;
34
35         /* Update memory mapped and register based freqency */
36         asm volatile ("msr cntfrq_el0, %0" :: "r" (freq));
37         writel(freq, CNTFID0);
38
39         /* Enable counter */
40         setbits_le32(CNTCR_BASE, CNTCR_EN);
41 }
42
43 void s_init(void)
44 {
45         init_generic_timer();
46 }
47
48 int board_early_init_f(void)
49 {
50         /* Unlock CPG access */
51         writel(0x5A5AFFFF, CPGWPR);
52         writel(0xA5A50000, CPGWPCR);
53
54         return 0;
55 }
56
57 int board_init(void)
58 {
59         /* address of boot parameters */
60         gd->bd->bi_boot_params = CONFIG_SYS_TEXT_BASE + 0x50000;
61
62         return 0;
63 }
64
65 #define RST_BASE        0xE6160000 /* Domain0 */
66 #define RST_SRESCR0     (RST_BASE + 0x18)
67 #define RST_SPRES       0x5AA58000
68
69 void reset_cpu(void)
70 {
71         writel(RST_SPRES, RST_SRESCR0);
72 }