1 // SPDX-License-Identifier: GPL-2.0+ 2 /* 3 * board/renesas/spider/spider.c 4 * This file is Spider 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 <asm/system.h> 17 #include <linux/errno.h> 18 19 DECLARE_GLOBAL_DATA_PTR; 20 init_generic_timer(void)21static 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 init_gic_v3(void)33static 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 s_init(void)46void s_init(void) 47 { 48 if (current_el() == 3) 49 init_generic_timer(); 50 } 51 board_early_init_f(void)52int board_early_init_f(void) 53 { 54 /* Unlock CPG access */ 55 writel(0x5A5AFFFF, CPGWPR); 56 writel(0xA5A50000, CPGWPCR); 57 58 return 0; 59 } 60 board_init(void)61int board_init(void) 62 { 63 if (current_el() == 3) 64 init_gic_v3(); 65 66 return 0; 67 } 68 reset_cpu(void)69void reset_cpu(void) 70 { 71 writel(RST_SPRES, RST_SRESCR0); 72 } 73