vexpress_tc2.c 2.1 KB

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