outercache.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 l2x0_regs;
  24. struct outer_cache_fns {
  25. void (*inv_range)(unsigned long, unsigned long);
  26. void (*clean_range)(unsigned long, unsigned long);
  27. void (*flush_range)(unsigned long, unsigned long);
  28. void (*flush_all)(void);
  29. void (*disable)(void);
  30. #ifdef CONFIG_OUTER_CACHE_SYNC
  31. void (*sync)(void);
  32. #endif
  33. void (*resume)(void);
  34. /* This is an ARM L2C thing */
  35. void (*write_sec)(unsigned long, unsigned);
  36. void (*configure)(const struct l2x0_regs *);
  37. };
  38. extern struct outer_cache_fns outer_cache;
  39. #ifdef CONFIG_OUTER_CACHE
  40. /**
  41. * outer_inv_range - invalidate range of outer cache lines
  42. * @start: starting physical address, inclusive
  43. * @end: end physical address, exclusive
  44. */
  45. static inline void outer_inv_range(phys_addr_t start, phys_addr_t end)
  46. {
  47. if (outer_cache.inv_range)
  48. outer_cache.inv_range(start, end);
  49. }
  50. /**
  51. * outer_clean_range - clean dirty outer cache lines
  52. * @start: starting physical address, inclusive
  53. * @end: end physical address, exclusive
  54. */
  55. static inline void outer_clean_range(phys_addr_t start, phys_addr_t end)
  56. {
  57. if (outer_cache.clean_range)
  58. outer_cache.clean_range(start, end);
  59. }
  60. /**
  61. * outer_flush_range - clean and invalidate outer cache lines
  62. * @start: starting physical address, inclusive
  63. * @end: end physical address, exclusive
  64. */
  65. static inline void outer_flush_range(phys_addr_t start, phys_addr_t end)
  66. {
  67. if (outer_cache.flush_range)
  68. outer_cache.flush_range(start, end);
  69. }
  70. /**
  71. * outer_flush_all - clean and invalidate all cache lines in the outer cache
  72. *
  73. * Note: depending on implementation, this may not be atomic - it must
  74. * only be called with interrupts disabled and no other active outer
  75. * cache masters.
  76. *
  77. * It is intended that this function is only used by implementations
  78. * needing to override the outer_cache.disable() method due to security.
  79. * (Some implementations perform this as a clean followed by an invalidate.)
  80. */
  81. static inline void outer_flush_all(void)
  82. {
  83. if (outer_cache.flush_all)
  84. outer_cache.flush_all();
  85. }
  86. /**
  87. * outer_disable - clean, invalidate and disable the outer cache
  88. *
  89. * Disable the outer cache, ensuring that any data contained in the outer
  90. * cache is pushed out to lower levels of system memory. The note and
  91. * conditions above concerning outer_flush_all() applies here.
  92. */
  93. extern void outer_disable(void);
  94. /**
  95. * outer_resume - restore the cache configuration and re-enable outer cache
  96. *
  97. * Restore any configuration that the cache had when previously enabled,
  98. * and re-enable the outer cache.
  99. */
  100. static inline void outer_resume(void)
  101. {
  102. if (outer_cache.resume)
  103. outer_cache.resume();
  104. }
  105. #else
  106. static inline void outer_inv_range(phys_addr_t start, phys_addr_t end)
  107. { }
  108. static inline void outer_clean_range(phys_addr_t start, phys_addr_t end)
  109. { }
  110. static inline void outer_flush_range(phys_addr_t start, phys_addr_t end)
  111. { }
  112. static inline void outer_flush_all(void) { }
  113. static inline void outer_disable(void) { }
  114. static inline void outer_resume(void) { }
  115. #endif
  116. #endif /* __ASM_OUTERCACHE_H */