1 // SPDX-License-Identifier: BSD-2-Clause 2 /* 3 * Copyright (C) 2017, Fuzhou Rockchip Electronics Co., Ltd. 4 */ 5 6 #include <initcall.h> 7 #include <io.h> 8 #include <mm/core_memprot.h> 9 #include <platform.h> 10 #include <platform_config.h> 11 #include <stdint.h> 12 13 int __weak platform_secure_init(void) 14 { 15 return 0; 16 } 17 18 int __weak platform_secure_ddr_region(int rgn __maybe_unused, 19 paddr_t st __maybe_unused, 20 size_t sz __maybe_unused) 21 { 22 MSG("Not protecting region %d: 0x%lx-0x%lx\n", rgn, st, st + sz); 23 24 return 0; 25 } 26 27 static TEE_Result platform_init(void) 28 { 29 int ret = 0; 30 31 platform_secure_init(); 32 33 /* 34 * Rockchip SoCs can protect multiple memory regions (mostly 8). 35 * Region 0 is assigned for Trusted-Firmware memory, so use 36 * regions 1 for OP-TEE memory, which leaves on all known SoCs 37 * at least 6 more regions available for other purposes. 38 */ 39 ret = platform_secure_ddr_region(1, CFG_TZDRAM_START, CFG_TZDRAM_SIZE); 40 if (ret < 0) 41 return TEE_ERROR_GENERIC; 42 43 return TEE_SUCCESS; 44 } 45 46 service_init(platform_init); 47