cache-j2.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * arch/sh/mm/cache-j2.c
  3. *
  4. * Copyright (C) 2015-2016 Smart Energy Instruments, Inc.
  5. *
  6. * Released under the terms of the GNU GPL v2.0.
  7. */
  8. #include <linux/init.h>
  9. #include <linux/mm.h>
  10. #include <linux/cpumask.h>
  11. #include <asm/cache.h>
  12. #include <asm/addrspace.h>
  13. #include <asm/processor.h>
  14. #include <asm/cacheflush.h>
  15. #include <asm/io.h>
  16. #define ICACHE_ENABLE 0x1
  17. #define DCACHE_ENABLE 0x2
  18. #define CACHE_ENABLE (ICACHE_ENABLE | DCACHE_ENABLE)
  19. #define ICACHE_FLUSH 0x100
  20. #define DCACHE_FLUSH 0x200
  21. #define CACHE_FLUSH (ICACHE_FLUSH | DCACHE_FLUSH)
  22. u32 __iomem *j2_ccr_base;
  23. static void j2_flush_icache(void *args)
  24. {
  25. unsigned cpu;
  26. for_each_possible_cpu(cpu)
  27. __raw_writel(CACHE_ENABLE | ICACHE_FLUSH, j2_ccr_base + cpu);
  28. }
  29. static void j2_flush_dcache(void *args)
  30. {
  31. unsigned cpu;
  32. for_each_possible_cpu(cpu)
  33. __raw_writel(CACHE_ENABLE | DCACHE_FLUSH, j2_ccr_base + cpu);
  34. }
  35. static void j2_flush_both(void *args)
  36. {
  37. unsigned cpu;
  38. for_each_possible_cpu(cpu)
  39. __raw_writel(CACHE_ENABLE | CACHE_FLUSH, j2_ccr_base + cpu);
  40. }
  41. void __init j2_cache_init(void)
  42. {
  43. if (!j2_ccr_base)
  44. return;
  45. local_flush_cache_all = j2_flush_both;
  46. local_flush_cache_mm = j2_flush_both;
  47. local_flush_cache_dup_mm = j2_flush_both;
  48. local_flush_cache_page = j2_flush_both;
  49. local_flush_cache_range = j2_flush_both;
  50. local_flush_dcache_page = j2_flush_dcache;
  51. local_flush_icache_range = j2_flush_icache;
  52. local_flush_icache_page = j2_flush_icache;
  53. local_flush_cache_sigtramp = j2_flush_icache;
  54. pr_info("Initial J2 CCR is %.8x\n", __raw_readl(j2_ccr_base));
  55. }