1 /* 2 * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <platform_def.h> 8 9 #include <arch.h> 10 #include <arch_helpers.h> 11 #include <common/bl_common.h> 12 #include <common/debug.h> 13 #include <lib/xlat_tables/xlat_mmu_helpers.h> 14 #include <lib/xlat_tables/xlat_tables_defs.h> 15 16 #include "rpi3_private.h" 17 18 /* Data structure which holds the extents of the trusted SRAM for BL1 */ 19 static meminfo_t bl1_tzram_layout; 20 21 meminfo_t *bl1_plat_sec_mem_layout(void) 22 { 23 return &bl1_tzram_layout; 24 } 25 26 /******************************************************************************* 27 * Perform any BL1 specific platform actions. 28 ******************************************************************************/ 29 void bl1_early_platform_setup(void) 30 { 31 /* Initialize the console to provide early debug support */ 32 rpi3_console_init(); 33 34 /* Allow BL1 to see the whole Trusted RAM */ 35 bl1_tzram_layout.total_base = BL_RAM_BASE; 36 bl1_tzram_layout.total_size = BL_RAM_SIZE; 37 } 38 39 /****************************************************************************** 40 * Perform the very early platform specific architecture setup. This only 41 * does basic initialization. Later architectural setup (bl1_arch_setup()) 42 * does not do anything platform specific. 43 *****************************************************************************/ 44 void bl1_plat_arch_setup(void) 45 { 46 rpi3_setup_page_tables(bl1_tzram_layout.total_base, 47 bl1_tzram_layout.total_size, 48 BL_CODE_BASE, BL1_CODE_END, 49 BL1_RO_DATA_BASE, BL1_RO_DATA_END 50 #if USE_COHERENT_MEM 51 , BL_COHERENT_RAM_BASE, BL_COHERENT_RAM_END 52 #endif 53 ); 54 55 enable_mmu_el3(0); 56 } 57 58 void bl1_platform_setup(void) 59 { 60 uint32_t __unused rev; 61 int __unused rc; 62 63 rc = rpi3_vc_hardware_get_board_revision(&rev); 64 65 if (rc == 0) { 66 const char __unused *model, __unused *info; 67 68 switch (rev) { 69 case 0xA02082: 70 model = "Raspberry Pi 3 Model B"; 71 info = "(1GB, Sony, UK)"; 72 break; 73 case 0xA22082: 74 model = "Raspberry Pi 3 Model B"; 75 info = "(1GB, Embest, China)"; 76 break; 77 case 0xA020D3: 78 model = "Raspberry Pi 3 Model B+"; 79 info = "(1GB, Sony, UK)"; 80 break; 81 default: 82 model = "Unknown"; 83 info = "(Unknown)"; 84 ERROR("rpi3: Unknown board revision 0x%08x\n", rev); 85 break; 86 } 87 88 NOTICE("rpi3: Detected: %s %s [0x%08x]\n", model, info, rev); 89 } else { 90 ERROR("rpi3: Unable to detect board revision\n"); 91 } 92 93 /* Initialise the IO layer and register platform IO devices */ 94 plat_rpi3_io_setup(); 95 } 96