outercache.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * arch/arm/include/asm/outercache.h
  4. *
  5. * Copyright (C) 2010 ARM Ltd.
  6. * Written by Catalin Marinas <[email protected]>
  7. */
  8. #ifndef __ASM_OUTERCACHE_H
  9. #define __ASM_OUTERCACHE_H
  10. #include <linux/types.h>
  11. struct l2x0_regs;
  12. struct outer_cache_fns {
  13. void (*inv_range)(unsigned long, unsigned long);
  14. void (*clean_range)(unsigned long, unsigned long);
  15. void (*flush_range)(unsigned long, unsigned long);
  16. void (*flush_all)(void);
  17. void (*disable)(void);
  18. #ifdef CONFIG_OUTER_CACHE_SYNC
  19. void (*sync)(void);
  20. #endif
  21. void (*resume)(void);
  22. /* This is an ARM L2C thing */
  23. void (*write_sec)(unsigned long, unsigned);
  24. void (*configure)(const struct l2x0_regs *);
  25. };
  26. extern struct outer_cache_fns outer_cache;
  27. #ifdef CONFIG_OUTER_CACHE
  28. /**
  29. * outer_inv_range - invalidate range of outer cache lines
  30. * @start: starting physical address, inclusive
  31. * @end: end physical address, exclusive
  32. */
  33. static inline void outer_inv_range(phys_addr_t start, phys_addr_t end)
  34. {
  35. if (outer_cache.inv_range)
  36. outer_cache.inv_range(start, end);
  37. }
  38. /**
  39. * outer_clean_range - clean dirty outer cache lines
  40. * @start: starting physical address, inclusive
  41. * @end: end physical address, exclusive
  42. */
  43. static inline void outer_clean_range(phys_addr_t start, phys_addr_t end)
  44. {
  45. if (outer_cache.clean_range)
  46. outer_cache.clean_range(start, end);
  47. }
  48. /**
  49. * outer_flush_range - clean and invalidate outer cache lines
  50. * @start: starting physical address, inclusive
  51. * @end: end physical address, exclusive
  52. */
  53. static inline void outer_flush_range(phys_addr_t start, phys_addr_t end)
  54. {
  55. if (outer_cache.flush_range)
  56. outer_cache.flush_range(start, end);
  57. }
  58. /**
  59. * outer_flush_all - clean and invalidate all cache lines in the outer cache
  60. *
  61. * Note: depending on implementation, this may not be atomic - it must
  62. * only be called with interrupts disabled and no other active outer
  63. * cache masters.
  64. *
  65. * It is intended that this function is only used by implementations
  66. * needing to override the outer_cache.disable() method due to security.
  67. * (Some implementations perform this as a clean followed by an invalidate.)
  68. */
  69. static inline void outer_flush_all(void)
  70. {
  71. if (outer_cache.flush_all)
  72. outer_cache.flush_all();
  73. }
  74. /**
  75. * outer_disable - clean, invalidate and disable the outer cache
  76. *
  77. * Disable the outer cache, ensuring that any data contained in the outer
  78. * cache is pushed out to lower levels of system memory. The note and
  79. * conditions above concerning outer_flush_all() applies here.
  80. */
  81. extern void outer_disable(void);
  82. /**
  83. * outer_resume - restore the cache configuration and re-enable outer cache
  84. *
  85. * Restore any configuration that the cache had when previously enabled,
  86. * and re-enable the outer cache.
  87. */
  88. static inline void outer_resume(void)
  89. {
  90. if (outer_cache.resume)
  91. outer_cache.resume();
  92. }
  93. #else
  94. static inline void outer_inv_range(phys_addr_t start, phys_addr_t end)
  95. { }
  96. static inline void outer_clean_range(phys_addr_t start, phys_addr_t end)
  97. { }
  98. static inline void outer_flush_range(phys_addr_t start, phys_addr_t end)
  99. { }
  100. static inline void outer_flush_all(void) { }
  101. static inline void outer_disable(void) { }
  102. static inline void outer_resume(void) { }
  103. #endif
  104. #endif /* __ASM_OUTERCACHE_H */