1 // SPDX-License-Identifier: GPL-2.0+
3 * board/renesas/falcon/falcon.c
4 * This file is Falcon board support.
6 * Copyright (C) 2020 Renesas Electronics Corp.
10 #include <asm/arch/rmobile.h>
11 #include <asm/arch/sys_proto.h>
12 #include <asm/global_data.h>
14 #include <asm/mach-types.h>
15 #include <asm/processor.h>
16 #include <linux/errno.h>
17 #include <asm/system.h>
19 DECLARE_GLOBAL_DATA_PTR;
21 #define CPGWPR 0xE6150000
22 #define CPGWPCR 0xE6150004
24 #define EXTAL_CLK 16666600u
25 #define CNTCR_BASE 0xE6080000
26 #define CNTFID0 (CNTCR_BASE + 0x020)
27 #define CNTCR_EN BIT(0)
29 static void init_generic_timer(void)
33 /* Set frequency data in CNTFID0 */
36 /* Update memory mapped and register based freqency */
37 asm volatile ("msr cntfrq_el0, %0" :: "r" (freq));
38 writel(freq, CNTFID0);
41 setbits_le32(CNTCR_BASE, CNTCR_EN);
44 /* Distributor Registers */
45 #define GICD_BASE 0xF1000000
47 /* ReDistributor Registers for Control and Physical LPIs */
48 #define GICR_LPI_BASE 0xF1060000
49 #define GICR_WAKER 0x0014
50 #define GICR_PWRR 0x0024
51 #define GICR_LPI_WAKER (GICR_LPI_BASE + GICR_WAKER)
52 #define GICR_LPI_PWRR (GICR_LPI_BASE + GICR_PWRR)
54 /* ReDistributor Registers for SGIs and PPIs */
55 #define GICR_SGI_BASE 0xF1070000
56 #define GICR_IGROUPR0 0x0080
58 static void init_gic_v3(void)
61 writel(0x00000002, (GICR_LPI_PWRR));
63 /* Wait till the WAKER_CA_BIT changes to 0 */
64 writel(readl(GICR_LPI_WAKER) & ~0x00000002, (GICR_LPI_WAKER));
65 while (readl(GICR_LPI_WAKER) & 0x00000004)
68 writel(0xffffffff, GICR_SGI_BASE + GICR_IGROUPR0);
73 if (current_el() == 3)
77 int board_early_init_f(void)
79 /* Unlock CPG access */
80 writel(0x5A5AFFFF, CPGWPR);
81 writel(0xA5A50000, CPGWPCR);
86 #define RST_BASE 0xE6160000 /* Domain0 */
87 #define RST_WDTRSTCR (RST_BASE + 0x10)
88 #define RST_RWDT 0xA55A8002
92 /* address of boot parameters */
93 gd->bd->bi_boot_params = CONFIG_TEXT_BASE + 0x50000;
95 if (current_el() == 3) {
98 /* Enable RWDT reset */
99 writel(RST_RWDT, RST_WDTRSTCR);