handoff.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2016 - 2017 Xilinx, Inc.
  4. *
  5. * Michal Simek <michal.simek@xilinx.com>
  6. */
  7. #include <common.h>
  8. #include <asm/io.h>
  9. #include <asm/arch/hardware.h>
  10. #include <asm/arch/sys_proto.h>
  11. /*
  12. * atfhandoffparams
  13. * Parameter bitfield encoding
  14. * -----------------------------------------------------------------------------
  15. * Exec State 0 0 -> Aarch64, 1-> Aarch32
  16. * endianness 1 0 -> LE, 1 -> BE
  17. * secure (TZ) 2 0 -> Non secure, 1 -> secure
  18. * EL 3:4 00 -> EL0, 01 -> EL1, 10 -> EL2, 11 -> EL3
  19. * CPU# 5:6 00 -> A53_0, 01 -> A53_1, 10 -> A53_2, 11 -> A53_3
  20. */
  21. #define FSBL_FLAGS_ESTATE_SHIFT 0
  22. #define FSBL_FLAGS_ESTATE_MASK (1 << FSBL_FLAGS_ESTATE_SHIFT)
  23. #define FSBL_FLAGS_ESTATE_A64 0
  24. #define FSBL_FLAGS_ESTATE_A32 1
  25. #define FSBL_FLAGS_ENDIAN_SHIFT 1
  26. #define FSBL_FLAGS_ENDIAN_MASK (1 << FSBL_FLAGS_ENDIAN_SHIFT)
  27. #define FSBL_FLAGS_ENDIAN_LE 0
  28. #define FSBL_FLAGS_ENDIAN_BE 1
  29. #define FSBL_FLAGS_TZ_SHIFT 2
  30. #define FSBL_FLAGS_TZ_MASK (1 << FSBL_FLAGS_TZ_SHIFT)
  31. #define FSBL_FLAGS_NON_SECURE 0
  32. #define FSBL_FLAGS_SECURE 1
  33. #define FSBL_FLAGS_EL_SHIFT 3
  34. #define FSBL_FLAGS_EL_MASK (3 << FSBL_FLAGS_EL_SHIFT)
  35. #define FSBL_FLAGS_EL0 0
  36. #define FSBL_FLAGS_EL1 1
  37. #define FSBL_FLAGS_EL2 2
  38. #define FSBL_FLAGS_EL3 3
  39. #define FSBL_FLAGS_CPU_SHIFT 5
  40. #define FSBL_FLAGS_CPU_MASK (3 << FSBL_FLAGS_CPU_SHIFT)
  41. #define FSBL_FLAGS_A53_0 0
  42. #define FSBL_FLAGS_A53_1 1
  43. #define FSBL_FLAGS_A53_2 2
  44. #define FSBL_FLAGS_A53_3 3
  45. #define FSBL_MAX_PARTITIONS 8
  46. /* Structure corresponding to each partition entry */
  47. struct xfsbl_partition {
  48. uint64_t entry_point;
  49. uint64_t flags;
  50. };
  51. /* Structure for handoff parameters to ARM Trusted Firmware (ATF) */
  52. struct xfsbl_atf_handoff_params {
  53. uint8_t magic[4];
  54. uint32_t num_entries;
  55. struct xfsbl_partition partition[FSBL_MAX_PARTITIONS];
  56. };
  57. #ifdef CONFIG_SPL_ATF
  58. struct bl31_params *bl2_plat_get_bl31_params(uintptr_t bl32_entry,
  59. uintptr_t bl33_entry,
  60. uintptr_t fdt_addr)
  61. {
  62. struct xfsbl_atf_handoff_params *atfhandoffparams;
  63. atfhandoffparams = (void *)CONFIG_SPL_TEXT_BASE;
  64. atfhandoffparams->magic[0] = 'X';
  65. atfhandoffparams->magic[1] = 'L';
  66. atfhandoffparams->magic[2] = 'N';
  67. atfhandoffparams->magic[3] = 'X';
  68. atfhandoffparams->num_entries = 0;
  69. if (bl33_entry) {
  70. atfhandoffparams->partition[0].entry_point = bl33_entry;
  71. atfhandoffparams->partition[0].flags = FSBL_FLAGS_EL2 <<
  72. FSBL_FLAGS_EL_SHIFT;
  73. atfhandoffparams->num_entries++;
  74. }
  75. writel(CONFIG_SPL_TEXT_BASE, &pmu_base->gen_storage6);
  76. return NULL;
  77. }
  78. #endif