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_config.h> 10 #include <stdint.h> 11 12 #if defined(PLATFORM_FLAVOR_rk322x) 13 14 #define SGRF_SOC_CON(n) ((n) * 4) 15 #define DDR_SGRF_DDR_CON(n) ((n) * 4) 16 #define DDR_RGN0_NS BIT32(30) 17 #define SLAVE_ALL_NS 0xffff0000 18 19 static TEE_Result platform_init(void) 20 { 21 vaddr_t sgrf_base = (vaddr_t)phys_to_virt_io(SGRF_BASE); 22 vaddr_t ddrsgrf_base = (vaddr_t)phys_to_virt_io(DDRSGRF_BASE); 23 24 /* Set rgn0 non-secure */ 25 io_write32(ddrsgrf_base + DDR_SGRF_DDR_CON(0), DDR_RGN0_NS); 26 27 /* Initialize all slave non-secure */ 28 io_write32(sgrf_base + SGRF_SOC_CON(7), SLAVE_ALL_NS); 29 io_write32(sgrf_base + SGRF_SOC_CON(8), SLAVE_ALL_NS); 30 io_write32(sgrf_base + SGRF_SOC_CON(9), SLAVE_ALL_NS); 31 io_write32(sgrf_base + SGRF_SOC_CON(10), SLAVE_ALL_NS); 32 33 return TEE_SUCCESS; 34 } 35 36 #endif 37 38 service_init(platform_init); 39