cache-j2.c 1.5 KB

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