arm_ccn.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <platform_def.h>
  7. #include <arch.h>
  8. #include <drivers/arm/ccn.h>
  9. #include <plat/arm/common/plat_arm.h>
  10. static const unsigned char master_to_rn_id_map[] = {
  11. PLAT_ARM_CLUSTER_TO_CCN_ID_MAP
  12. };
  13. static const ccn_desc_t arm_ccn_desc = {
  14. .periphbase = PLAT_ARM_CCN_BASE,
  15. .num_masters = ARRAY_SIZE(master_to_rn_id_map),
  16. .master_to_rn_id_map = master_to_rn_id_map
  17. };
  18. CASSERT(PLAT_ARM_CLUSTER_COUNT == ARRAY_SIZE(master_to_rn_id_map),
  19. assert_invalid_cluster_count_for_ccn_variant);
  20. /******************************************************************************
  21. * The following functions are defined as weak to allow a platform to override
  22. * the way ARM CCN driver is initialised and used.
  23. *****************************************************************************/
  24. #pragma weak plat_arm_interconnect_init
  25. #pragma weak plat_arm_interconnect_enter_coherency
  26. #pragma weak plat_arm_interconnect_exit_coherency
  27. /******************************************************************************
  28. * Helper function to initialize ARM CCN driver.
  29. *****************************************************************************/
  30. void __init plat_arm_interconnect_init(void)
  31. {
  32. ccn_init(&arm_ccn_desc);
  33. }
  34. /******************************************************************************
  35. * Helper function to place current master into coherency
  36. *****************************************************************************/
  37. void plat_arm_interconnect_enter_coherency(void)
  38. {
  39. ccn_enter_snoop_dvm_domain(1 << MPIDR_AFFLVL1_VAL(read_mpidr_el1()));
  40. }
  41. /******************************************************************************
  42. * Helper function to remove current master from coherency
  43. *****************************************************************************/
  44. void plat_arm_interconnect_exit_coherency(void)
  45. {
  46. ccn_exit_snoop_dvm_domain(1 << MPIDR_AFFLVL1_VAL(read_mpidr_el1()));
  47. }