uniphier_cci.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <stddef.h>
  7. #include <arch_helpers.h>
  8. #include <drivers/arm/cci.h>
  9. #include <lib/utils_def.h>
  10. #include "uniphier.h"
  11. #define UNIPHIER_CCI500_BASE 0x5FD00000
  12. static const int uniphier_cci_map[] = {1, 0};
  13. static void __uniphier_cci_init(void)
  14. {
  15. cci_init(UNIPHIER_CCI500_BASE, uniphier_cci_map,
  16. ARRAY_SIZE(uniphier_cci_map));
  17. }
  18. static void __uniphier_cci_enable(void)
  19. {
  20. cci_enable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(read_mpidr_el1()));
  21. }
  22. static void __uniphier_cci_disable(void)
  23. {
  24. cci_disable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(read_mpidr_el1()));
  25. }
  26. struct uniphier_cci_ops {
  27. void (*init)(void);
  28. void (*enable)(void);
  29. void (*disable)(void);
  30. };
  31. static const struct uniphier_cci_ops uniphier_cci_ops_table[] = {
  32. [UNIPHIER_SOC_LD11] = {
  33. .init = NULL,
  34. .enable = NULL,
  35. .disable = NULL,
  36. },
  37. [UNIPHIER_SOC_LD20] = {
  38. .init = __uniphier_cci_init,
  39. .enable = __uniphier_cci_enable,
  40. .disable = __uniphier_cci_disable,
  41. },
  42. [UNIPHIER_SOC_PXS3] = {
  43. .init = NULL,
  44. .enable = NULL,
  45. .disable = NULL,
  46. },
  47. };
  48. static struct uniphier_cci_ops uniphier_cci_ops;
  49. void uniphier_cci_init(unsigned int soc)
  50. {
  51. uniphier_cci_ops = uniphier_cci_ops_table[soc];
  52. flush_dcache_range((uint64_t)&uniphier_cci_ops,
  53. sizeof(uniphier_cci_ops));
  54. if (uniphier_cci_ops.init)
  55. uniphier_cci_ops.init();
  56. }
  57. void uniphier_cci_enable(void)
  58. {
  59. if (uniphier_cci_ops.enable)
  60. uniphier_cci_ops.enable();
  61. }
  62. void uniphier_cci_disable(void)
  63. {
  64. if (uniphier_cci_ops.disable)
  65. uniphier_cci_ops.disable();
  66. }