outercache.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * arch/arm/include/asm/outercache.h
  3. *
  4. * Copyright (C) 2010 ARM Ltd.
  5. * Written by Catalin Marinas <catalin.marinas@arm.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #ifndef __ASM_OUTERCACHE_H
  21. #define __ASM_OUTERCACHE_H
  22. #include <linux/types.h>
  23. struct outer_cache_fns {
  24. void (*inv_range)(unsigned long, unsigned long);
  25. void (*clean_range)(unsigned long, unsigned long);
  26. void (*flush_range)(unsigned long, unsigned long);
  27. void (*flush_all)(void);
  28. void (*disable)(void);
  29. #ifdef CONFIG_OUTER_CACHE_SYNC
  30. void (*sync)(void);
  31. #endif
  32. void (*set_debug)(unsigned long);
  33. void (*resume)(void);
  34. };
  35. extern struct outer_cache_fns outer_cache;
  36. #ifdef CONFIG_OUTER_CACHE
  37. /**
  38. * outer_inv_range - invalidate range of outer cache lines
  39. * @start: starting physical address, inclusive
  40. * @end: end physical address, exclusive
  41. */
  42. static inline void outer_inv_range(phys_addr_t start, phys_addr_t end)
  43. {
  44. if (outer_cache.inv_range)
  45. outer_cache.inv_range(start, end);
  46. }
  47. /**
  48. * outer_clean_range - clean dirty outer cache lines
  49. * @start: starting physical address, inclusive
  50. * @end: end physical address, exclusive
  51. */
  52. static inline void outer_clean_range(phys_addr_t start, phys_addr_t end)
  53. {
  54. if (outer_cache.clean_range)
  55. outer_cache.clean_range(start, end);
  56. }
  57. /**
  58. * outer_flush_range - clean and invalidate outer cache lines
  59. * @start: starting physical address, inclusive
  60. * @end: end physical address, exclusive
  61. */
  62. static inline void outer_flush_range(phys_addr_t start, phys_addr_t end)
  63. {
  64. if (outer_cache.flush_range)
  65. outer_cache.flush_range(start, end);
  66. }
  67. /**
  68. * outer_flush_all - clean and invalidate all cache lines in the outer cache
  69. *
  70. * Note: depending on implementation, this may not be atomic - it must
  71. * only be called with interrupts disabled and no other active outer
  72. * cache masters.
  73. *
  74. * It is intended that this function is only used by implementations
  75. * needing to override the outer_cache.disable() method due to security.
  76. * (Some implementations perform this as a clean followed by an invalidate.)
  77. */
  78. static inline void outer_flush_all(void)
  79. {
  80. if (outer_cache.flush_all)
  81. outer_cache.flush_all();
  82. }
  83. /**
  84. * outer_disable - clean, invalidate and disable the outer cache
  85. *
  86. * Disable the outer cache, ensuring that any data contained in the outer
  87. * cache is pushed out to lower levels of system memory. The note and
  88. * conditions above concerning outer_flush_all() applies here.
  89. */
  90. static inline void outer_disable(void)
  91. {
  92. if (outer_cache.disable)
  93. outer_cache.disable();
  94. }
  95. /**
  96. * outer_resume - restore the cache configuration and re-enable outer cache
  97. *
  98. * Restore any configuration that the cache had when previously enabled,
  99. * and re-enable the outer cache.
  100. */
  101. static inline void outer_resume(void)
  102. {
  103. if (outer_cache.resume)
  104. outer_cache.resume();
  105. }
  106. #else
  107. static inline void outer_inv_range(phys_addr_t start, phys_addr_t end)
  108. { }
  109. static inline void outer_clean_range(phys_addr_t start, phys_addr_t end)
  110. { }
  111. static inline void outer_flush_range(phys_addr_t start, phys_addr_t end)
  112. { }
  113. static inline void outer_flush_all(void) { }
  114. static inline void outer_disable(void) { }
  115. static inline void outer_resume(void) { }
  116. #endif
  117. #ifdef CONFIG_OUTER_CACHE_SYNC
  118. /**
  119. * outer_sync - perform a sync point for outer cache
  120. *
  121. * Ensure that all outer cache operations are complete and any store
  122. * buffers are drained.
  123. */
  124. static inline void outer_sync(void)
  125. {
  126. if (outer_cache.sync)
  127. outer_cache.sync();
  128. }
  129. #else
  130. static inline void outer_sync(void)
  131. { }
  132. #endif
  133. #endif /* __ASM_OUTERCACHE_H */