soc_css_security.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <platform_def.h>
  7. #include <drivers/arm/nic_400.h>
  8. #include <lib/mmio.h>
  9. #include <plat/arm/soc/common/soc_css.h>
  10. void soc_css_init_nic400(void)
  11. {
  12. /*
  13. * NIC-400 Access Control Initialization
  14. *
  15. * Define access privileges by setting each corresponding bit to:
  16. * 0 = Secure access only
  17. * 1 = Non-secure access allowed
  18. */
  19. /*
  20. * Allow non-secure access to some SOC regions, excluding UART1, which
  21. * remains secure (unless CSS_NON_SECURE_UART is set).
  22. * Note: This is the NIC-400 device on the SOC
  23. */
  24. mmio_write_32(SOC_CSS_NIC400_BASE +
  25. NIC400_ADDR_CTRL_SECURITY_REG(SOC_CSS_NIC400_USB_EHCI), ~0);
  26. mmio_write_32(SOC_CSS_NIC400_BASE +
  27. NIC400_ADDR_CTRL_SECURITY_REG(SOC_CSS_NIC400_TLX_MASTER), ~0);
  28. mmio_write_32(SOC_CSS_NIC400_BASE +
  29. NIC400_ADDR_CTRL_SECURITY_REG(SOC_CSS_NIC400_USB_OHCI), ~0);
  30. mmio_write_32(SOC_CSS_NIC400_BASE +
  31. NIC400_ADDR_CTRL_SECURITY_REG(SOC_CSS_NIC400_PL354_SMC), ~0);
  32. mmio_write_32(SOC_CSS_NIC400_BASE +
  33. NIC400_ADDR_CTRL_SECURITY_REG(SOC_CSS_NIC400_APB4_BRIDGE), ~0);
  34. #if CSS_NON_SECURE_UART
  35. /* Configure UART for non-secure access */
  36. mmio_write_32(SOC_CSS_NIC400_BASE +
  37. NIC400_ADDR_CTRL_SECURITY_REG(SOC_CSS_NIC400_BOOTSEC_BRIDGE), ~0);
  38. #else
  39. mmio_write_32(SOC_CSS_NIC400_BASE +
  40. NIC400_ADDR_CTRL_SECURITY_REG(SOC_CSS_NIC400_BOOTSEC_BRIDGE),
  41. ~SOC_CSS_NIC400_BOOTSEC_BRIDGE_UART1);
  42. #endif /* CSS_NON_SECURE_UART */
  43. }
  44. #define PCIE_SECURE_REG 0x3000
  45. /* Mask uses REG and MEM access bits */
  46. #define PCIE_SEC_ACCESS_MASK ((1 << 0) | (1 << 1))
  47. void soc_css_init_pcie(void)
  48. {
  49. #if !PLAT_juno
  50. /*
  51. * Do not initialize PCIe in emulator environment.
  52. * Platform ID register not supported on Juno
  53. */
  54. if (BOARD_CSS_GET_PLAT_TYPE(BOARD_CSS_PLAT_ID_REG_ADDR) ==
  55. BOARD_CSS_PLAT_TYPE_EMULATOR)
  56. return;
  57. #endif /* PLAT_juno */
  58. /*
  59. * PCIE Root Complex Security settings to enable non-secure
  60. * access to config registers.
  61. */
  62. mmio_write_32(SOC_CSS_PCIE_CONTROL_BASE + PCIE_SECURE_REG,
  63. PCIE_SEC_ACCESS_MASK);
  64. }