uniphier_bl31_setup.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <assert.h>
  7. #include <errno.h>
  8. #include <platform_def.h>
  9. #include <arch.h>
  10. #include <common/bl_common.h>
  11. #include <common/debug.h>
  12. #include <drivers/console.h>
  13. #include <lib/mmio.h>
  14. #include <plat/common/platform.h>
  15. #include "uniphier.h"
  16. static entry_point_info_t bl32_image_ep_info;
  17. static entry_point_info_t bl33_image_ep_info;
  18. static unsigned int uniphier_soc = UNIPHIER_SOC_UNKNOWN;
  19. entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type)
  20. {
  21. assert(sec_state_is_valid(type));
  22. return type == NON_SECURE ? &bl33_image_ep_info : &bl32_image_ep_info;
  23. }
  24. void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
  25. u_register_t arg2, u_register_t arg3)
  26. {
  27. void *from_bl2;
  28. from_bl2 = (void *)arg0;
  29. bl_params_node_t *bl_params = ((bl_params_t *)from_bl2)->head;
  30. uniphier_soc = uniphier_get_soc_id();
  31. if (uniphier_soc == UNIPHIER_SOC_UNKNOWN)
  32. plat_error_handler(-ENOTSUP);
  33. uniphier_console_setup(uniphier_soc);
  34. while (bl_params) {
  35. if (bl_params->image_id == BL32_IMAGE_ID)
  36. bl32_image_ep_info = *bl_params->ep_info;
  37. if (bl_params->image_id == BL33_IMAGE_ID)
  38. bl33_image_ep_info = *bl_params->ep_info;
  39. bl_params = bl_params->next_params_info;
  40. }
  41. if (bl33_image_ep_info.pc == 0)
  42. panic();
  43. }
  44. static const uintptr_t uniphier_cntctl_base[] = {
  45. [UNIPHIER_SOC_LD11] = 0x60e00000,
  46. [UNIPHIER_SOC_LD20] = 0x60e00000,
  47. [UNIPHIER_SOC_PXS3] = 0x60e00000,
  48. };
  49. void bl31_platform_setup(void)
  50. {
  51. uintptr_t cntctl_base;
  52. uniphier_cci_init(uniphier_soc);
  53. uniphier_cci_enable();
  54. /* Initialize the GIC driver, cpu and distributor interfaces */
  55. uniphier_gic_driver_init(uniphier_soc);
  56. uniphier_gic_init();
  57. assert(uniphier_soc < ARRAY_SIZE(uniphier_cntctl_base));
  58. cntctl_base = uniphier_cntctl_base[uniphier_soc];
  59. /* Enable and initialize the System level generic timer */
  60. mmio_write_32(cntctl_base + CNTCR_OFF, CNTCR_FCREQ(0U) | CNTCR_EN);
  61. uniphier_psci_init(uniphier_soc);
  62. }
  63. void bl31_plat_arch_setup(void)
  64. {
  65. uniphier_mmap_setup(uniphier_soc);
  66. }