Hai Pham | ff3812c | 2023-02-28 22:37:08 +0100 | [diff] [blame] | 1 | // 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 | |
| 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 | #include <asm/system.h> |
| 18 | |
| 19 | DECLARE_GLOBAL_DATA_PTR; |
| 20 | |
| 21 | static void init_generic_timer(void) |
| 22 | { |
| 23 | const u32 freq = CONFIG_SYS_CLK_FREQ; |
| 24 | |
| 25 | /* Update memory mapped and register based freqency */ |
| 26 | asm volatile ("msr cntfrq_el0, %0" :: "r" (freq)); |
| 27 | writel(freq, CNTFID0); |
| 28 | |
| 29 | /* Enable counter */ |
| 30 | setbits_le32(CNTCR_BASE, CNTCR_EN); |
| 31 | } |
| 32 | |
| 33 | static void init_gic_v3(void) |
| 34 | { |
| 35 | /* GIC v3 power on */ |
| 36 | writel(BIT(1), GICR_LPI_PWRR); |
| 37 | |
| 38 | /* Wait till the WAKER_CA_BIT changes to 0 */ |
| 39 | clrbits_le32(GICR_LPI_WAKER, BIT(1)); |
| 40 | while (readl(GICR_LPI_WAKER) & BIT(2)) |
| 41 | ; |
| 42 | |
| 43 | writel(0xffffffff, GICR_SGI_BASE + GICR_IGROUPR0); |
| 44 | } |
| 45 | |
| 46 | void s_init(void) |
| 47 | { |
| 48 | if (current_el() == 3) |
| 49 | init_generic_timer(); |
| 50 | } |
| 51 | |
| 52 | int board_early_init_f(void) |
| 53 | { |
| 54 | /* Unlock CPG access */ |
| 55 | writel(0x5A5AFFFF, CPGWPR); |
| 56 | writel(0xA5A50000, CPGWPCR); |
| 57 | |
| 58 | return 0; |
| 59 | } |
| 60 | |
| 61 | int board_init(void) |
| 62 | { |
| 63 | if (current_el() == 3) |
| 64 | init_gic_v3(); |
| 65 | |
| 66 | return 0; |
| 67 | } |