1 /* 2 * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <common/debug.h> 8 #include <lib/mmio.h> 9 10 #include <sunxi_ccu.h> 11 #include <sunxi_mmap.h> 12 #include <sunxi_private.h> 13 #include <sunxi_spc.h> 14 15 #define DMA_SEC_REG 0x20 16 17 /* 18 * Setup the peripherals to be accessible by non-secure world. 19 * This will not work for the Secure Peripherals Controller (SPC) unless 20 * a fuse it burnt (seems to be an erratum), but we do it nevertheless, 21 * to allow booting on boards using secure boot. 22 */ sunxi_security_setup(void)23void sunxi_security_setup(void) 24 { 25 int i; 26 27 INFO("Configuring SPC Controller\n"); 28 /* SPC setup: set all devices to non-secure */ 29 for (i = 0; i < SUNXI_SPC_NUM_PORTS; i++) 30 mmio_write_32(SUNXI_SPC_DECPORT_SET_REG(i), 0xffffffff); 31 32 /* set MBUS clocks, bus clocks (AXI/AHB/APB) and PLLs to non-secure */ 33 mmio_write_32(SUNXI_CCU_SEC_SWITCH_REG, 0x7); 34 35 /* Set R_PRCM bus clocks to non-secure */ 36 mmio_write_32(SUNXI_R_PRCM_SEC_SWITCH_REG, 0x1); 37 38 /* Set all DMA channels (16 max.) to non-secure */ 39 mmio_write_32(SUNXI_DMA_BASE + DMA_SEC_REG, 0xffff); 40 } 41