blob: 3a10b0220d1bf24c873806c6459939bfcb5d6b35 [file] [log] [blame]
Hai Phamff3812c2023-02-28 22:37:08 +01001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * board/renesas/whitehawk/whitehawk.c
4 * This file is White Hawk board support.
5 *
6 * Copyright (C) 2021 Renesas Electronics Corp.
7 */
8
Marek Vasut97a070b2024-02-27 17:05:54 +01009#include <asm/arch/renesas.h>
Hai Phamff3812c2023-02-28 22:37:08 +010010#include <asm/arch/sys_proto.h>
11#include <asm/global_data.h>
12#include <asm/io.h>
13#include <asm/mach-types.h>
14#include <asm/processor.h>
15#include <linux/errno.h>
16#include <asm/system.h>
17
18DECLARE_GLOBAL_DATA_PTR;
19
20static void init_generic_timer(void)
21{
22 const u32 freq = CONFIG_SYS_CLK_FREQ;
23
24 /* Update memory mapped and register based freqency */
25 asm volatile ("msr cntfrq_el0, %0" :: "r" (freq));
26 writel(freq, CNTFID0);
27
28 /* Enable counter */
29 setbits_le32(CNTCR_BASE, CNTCR_EN);
30}
31
32static void init_gic_v3(void)
33{
Marek Vasut00eed1e2024-01-21 18:33:12 +010034 /* GIC v3 power on */
Hai Phamff3812c2023-02-28 22:37:08 +010035 writel(BIT(1), GICR_LPI_PWRR);
36
37 /* Wait till the WAKER_CA_BIT changes to 0 */
38 clrbits_le32(GICR_LPI_WAKER, BIT(1));
39 while (readl(GICR_LPI_WAKER) & BIT(2))
40 ;
41
42 writel(0xffffffff, GICR_SGI_BASE + GICR_IGROUPR0);
43}
44
45void s_init(void)
46{
47 if (current_el() == 3)
48 init_generic_timer();
49}
50
51int board_early_init_f(void)
52{
53 /* Unlock CPG access */
54 writel(0x5A5AFFFF, CPGWPR);
55 writel(0xA5A50000, CPGWPCR);
56
57 return 0;
58}
59
60int board_init(void)
61{
62 if (current_el() == 3)
63 init_gic_v3();
64
65 return 0;
66}