vexpress_tc2.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * (C) Copyright 2016 Linaro
  3. * Jon Medhurst <tixy@linaro.org>
  4. *
  5. * TC2 specific code for Versatile Express.
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #include <asm/armv7.h>
  10. #include <asm/io.h>
  11. #include <asm/u-boot.h>
  12. #include <common.h>
  13. #include <libfdt.h>
  14. #define SCC_BASE 0x7fff0000
  15. bool armv7_boot_nonsec_default(void)
  16. {
  17. #ifdef CONFIG_ARMV7_BOOT_SEC_DEFAULT
  18. return false
  19. #else
  20. /*
  21. * The Serial Configuration Controller (SCC) register at address 0x700
  22. * contains flags for configuring the behaviour of the Boot Monitor
  23. * (which CPUs execute from reset). Two of these bits are of interest:
  24. *
  25. * bit 12 = Use per-cpu mailboxes for power management
  26. * bit 13 = Power down the non-boot cluster
  27. *
  28. * It is only when both of these are false that U-Boot's current
  29. * implementation of 'nonsec' mode can work as expected because we
  30. * rely on getting all CPUs to execute _nonsec_init, so let's check that.
  31. */
  32. return (readl((u32 *)(SCC_BASE + 0x700)) & ((1 << 12) | (1 << 13))) == 0;
  33. #endif
  34. }
  35. #ifdef CONFIG_OF_BOARD_SETUP
  36. int ft_board_setup(void *fdt, bd_t *bd)
  37. {
  38. int offset, tmp, len;
  39. const struct fdt_property *prop;
  40. const char *cci_compatible = "arm,cci-400-ctrl-if";
  41. #ifdef CONFIG_ARMV7_NONSEC
  42. if (!armv7_boot_nonsec())
  43. return 0;
  44. #else
  45. return 0;
  46. #endif
  47. /* Booting in nonsec mode, disable CCI access */
  48. offset = fdt_path_offset(fdt, "/cpus");
  49. if (offset < 0) {
  50. printf("couldn't find /cpus\n");
  51. return offset;
  52. }
  53. /* delete cci-control-port in each cpu node */
  54. for (tmp = fdt_first_subnode(fdt, offset); tmp >= 0;
  55. tmp = fdt_next_subnode(fdt, tmp))
  56. fdt_delprop(fdt, tmp, "cci-control-port");
  57. /* disable all ace cci slave ports */
  58. offset = fdt_node_offset_by_prop_value(fdt, offset, "compatible",
  59. cci_compatible, 20);
  60. while (offset > 0) {
  61. prop = fdt_get_property(fdt, offset, "interface-type",
  62. &len);
  63. if (!prop)
  64. continue;
  65. if (len < 4)
  66. continue;
  67. if (strcmp(prop->data, "ace"))
  68. continue;
  69. fdt_setprop_string(fdt, offset, "status", "disabled");
  70. offset = fdt_node_offset_by_prop_value(fdt, offset, "compatible",
  71. cci_compatible, 20);
  72. }
  73. return 0;
  74. }
  75. #endif /* CONFIG_OF_BOARD_SETUP */