sunxi_security.c 1.1 KB

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