cacheflush.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Blackfin low-level cache routines
  3. *
  4. * Copyright 2004-2009 Analog Devices Inc.
  5. *
  6. * Licensed under the GPL-2 or later.
  7. */
  8. #ifndef _BLACKFIN_CACHEFLUSH_H
  9. #define _BLACKFIN_CACHEFLUSH_H
  10. #include <asm/blackfin.h> /* for SSYNC() */
  11. #include <asm/sections.h> /* for _ramend */
  12. #ifdef CONFIG_SMP
  13. #include <asm/smp.h>
  14. #endif
  15. extern void blackfin_icache_flush_range(unsigned long start_address, unsigned long end_address);
  16. extern void blackfin_dcache_flush_range(unsigned long start_address, unsigned long end_address);
  17. extern void blackfin_dcache_invalidate_range(unsigned long start_address, unsigned long end_address);
  18. extern void blackfin_dflush_page(void *page);
  19. extern void blackfin_invalidate_entire_dcache(void);
  20. extern void blackfin_invalidate_entire_icache(void);
  21. #define flush_dcache_mmap_lock(mapping) do { } while (0)
  22. #define flush_dcache_mmap_unlock(mapping) do { } while (0)
  23. #define flush_cache_mm(mm) do { } while (0)
  24. #define flush_cache_range(vma, start, end) do { } while (0)
  25. #define flush_cache_page(vma, vmaddr) do { } while (0)
  26. #define flush_cache_vmap(start, end) do { } while (0)
  27. #define flush_cache_vunmap(start, end) do { } while (0)
  28. #ifdef CONFIG_SMP
  29. #define flush_icache_range_others(start, end) \
  30. smp_icache_flush_range_others((start), (end))
  31. #else
  32. #define flush_icache_range_others(start, end) do { } while (0)
  33. #endif
  34. static inline void flush_icache_range(unsigned start, unsigned end)
  35. {
  36. #if defined(CONFIG_BFIN_EXTMEM_WRITEBACK) || defined(CONFIG_BFIN_L2_WRITEBACK)
  37. blackfin_dcache_flush_range(start, end);
  38. #endif
  39. /* Make sure all write buffers in the data side of the core
  40. * are flushed before trying to invalidate the icache. This
  41. * needs to be after the data flush and before the icache
  42. * flush so that the SSYNC does the right thing in preventing
  43. * the instruction prefetcher from hitting things in cached
  44. * memory at the wrong time -- it runs much further ahead than
  45. * the pipeline.
  46. */
  47. SSYNC();
  48. #if defined(CONFIG_BFIN_ICACHE)
  49. blackfin_icache_flush_range(start, end);
  50. flush_icache_range_others(start, end);
  51. #endif
  52. }
  53. #define copy_to_user_page(vma, page, vaddr, dst, src, len) \
  54. do { memcpy(dst, src, len); \
  55. flush_icache_range((unsigned) (dst), (unsigned) (dst) + (len)); \
  56. } while (0)
  57. #define copy_from_user_page(vma, page, vaddr, dst, src, len) memcpy(dst, src, len)
  58. #if defined(CONFIG_BFIN_DCACHE)
  59. # define invalidate_dcache_range(start,end) blackfin_dcache_invalidate_range((start), (end))
  60. #else
  61. # define invalidate_dcache_range(start,end) do { } while (0)
  62. #endif
  63. #if defined(CONFIG_BFIN_EXTMEM_WRITEBACK) || defined(CONFIG_BFIN_L2_WRITEBACK)
  64. # define flush_dcache_range(start,end) blackfin_dcache_flush_range((start), (end))
  65. #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1
  66. # define flush_dcache_page(page) blackfin_dflush_page(page_address(page))
  67. #else
  68. # define flush_dcache_range(start,end) do { } while (0)
  69. #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
  70. # define flush_dcache_page(page) do { } while (0)
  71. #endif
  72. extern unsigned long reserved_mem_dcache_on;
  73. extern unsigned long reserved_mem_icache_on;
  74. static inline int bfin_addr_dcacheable(unsigned long addr)
  75. {
  76. #ifdef CONFIG_BFIN_EXTMEM_DCACHEABLE
  77. if (addr < (_ramend - DMA_UNCACHED_REGION))
  78. return 1;
  79. #endif
  80. if (reserved_mem_dcache_on &&
  81. addr >= _ramend && addr < physical_mem_end)
  82. return 1;
  83. #ifdef CONFIG_BFIN_L2_DCACHEABLE
  84. if (addr >= L2_START && addr < L2_START + L2_LENGTH)
  85. return 1;
  86. #endif
  87. return 0;
  88. }
  89. #endif /* _BLACKFIN_ICACHEFLUSH_H */