From 64536e6028348c20cc5bb4491a9ee8bc267f1d47 Mon Sep 17 00:00:00 2001 From: Andre Przywara Date: Wed, 9 Nov 2016 23:52:15 +0000 Subject: sunxi: print SoC ID on startup Each Allwinner SoC contains a SoC ID, which can be used to identify a chip. Add a function to retrieve this value and print it upon initializing ATF. --- plat/sun50iw1p1/aarch64/sunxi_common.c | 13 +++++++++++++ plat/sun50iw1p1/bl31_sunxi_setup.c | 13 ++++++++++++- plat/sun50iw1p1/sunxi_private.h | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/plat/sun50iw1p1/aarch64/sunxi_common.c b/plat/sun50iw1p1/aarch64/sunxi_common.c index 20d185a..a2fa37a 100644 --- a/plat/sun50iw1p1/aarch64/sunxi_common.c +++ b/plat/sun50iw1p1/aarch64/sunxi_common.c @@ -137,3 +137,16 @@ uint32_t sunxi_get_spsr_for_bl33_entry(int aarch) return spsr; } + +#define SRAM_VER_REG 0x01c00024 + +uint16_t sunxi_get_socid(void) +{ + uint32_t reg; + + reg = mmio_read_32(SRAM_VER_REG); + mmio_write_32(SRAM_VER_REG, reg | (1 << 15)); + reg = mmio_read_32(SRAM_VER_REG); + mmio_write_32(0x01c00024, reg & ~(1 << 15)); + return reg >> 16; +} diff --git a/plat/sun50iw1p1/bl31_sunxi_setup.c b/plat/sun50iw1p1/bl31_sunxi_setup.c index 16b27d7..473438a 100644 --- a/plat/sun50iw1p1/bl31_sunxi_setup.c +++ b/plat/sun50iw1p1/bl31_sunxi_setup.c @@ -144,6 +144,8 @@ void bl31_early_platform_setup(bl31_params_t *from_bl2, { unsigned long load_addr; const char *mem_name = "unknown memory region"; + const char *soc_name = "unknown SoC"; + uint16_t soc_id; /* Initialize the console to provide early debug support */ console_init(SUNXI_UART0_BASE, UART0_CLK_IN_HZ, UART0_BAUDRATE); @@ -157,7 +159,16 @@ void bl31_early_platform_setup(bl31_params_t *from_bl2, } else if (load_addr >= 0x40000000) mem_name = "DRAM"; - NOTICE("BL3-1: Running in %s (@0x%lx)\n", mem_name, load_addr); + soc_id = sunxi_get_socid(); + + switch (soc_id) { + case 0x1689: + soc_name = "A64/H64"; + break; + } + + NOTICE("BL3-1: Running on %s (%x) in %s (@0x%lx)\n", + soc_name, soc_id, mem_name, load_addr); #if 0 #if RESET_TO_BL31 diff --git a/plat/sun50iw1p1/sunxi_private.h b/plat/sun50iw1p1/sunxi_private.h index c41c431..6f1f637 100644 --- a/plat/sun50iw1p1/sunxi_private.h +++ b/plat/sun50iw1p1/sunxi_private.h @@ -56,6 +56,8 @@ void sunxi_configure_mmu_el3(unsigned long total_base, unsigned long); int sunxi_config_setup(void); +uint16_t sunxi_get_socid(void); + /* Declarations for sunxi_topology.c */ int plat_setup_topology(void); -- cgit v1.2.3