cache.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
  4. */
  5. #ifndef __ARC_ASM_CACHE_H
  6. #define __ARC_ASM_CACHE_H
  7. /* In case $$ not config, setup a dummy number for rest of kernel */
  8. #ifndef CONFIG_ARC_CACHE_LINE_SHIFT
  9. #define L1_CACHE_SHIFT 6
  10. #else
  11. #define L1_CACHE_SHIFT CONFIG_ARC_CACHE_LINE_SHIFT
  12. #endif
  13. #define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
  14. #define CACHE_LINE_MASK (~(L1_CACHE_BYTES - 1))
  15. /*
  16. * ARC700 doesn't cache any access in top 1G (0xc000_0000 to 0xFFFF_FFFF)
  17. * Ideal for wiring memory mapped peripherals as we don't need to do
  18. * explicit uncached accesses (LD.di/ST.di) hence more portable drivers
  19. */
  20. #define ARC_UNCACHED_ADDR_SPACE 0xc0000000
  21. #ifndef __ASSEMBLY__
  22. #include <linux/build_bug.h>
  23. /* Uncached access macros */
  24. #define arc_read_uncached_32(ptr) \
  25. ({ \
  26. unsigned int __ret; \
  27. __asm__ __volatile__( \
  28. " ld.di %0, [%1] \n" \
  29. : "=r"(__ret) \
  30. : "r"(ptr)); \
  31. __ret; \
  32. })
  33. #define arc_write_uncached_32(ptr, data)\
  34. ({ \
  35. __asm__ __volatile__( \
  36. " st.di %0, [%1] \n" \
  37. : \
  38. : "r"(data), "r"(ptr)); \
  39. })
  40. /* Largest line length for either L1 or L2 is 128 bytes */
  41. #define SMP_CACHE_BYTES 128
  42. #define cache_line_size() SMP_CACHE_BYTES
  43. #define ARCH_DMA_MINALIGN SMP_CACHE_BYTES
  44. /*
  45. * Make sure slab-allocated buffers are 64-bit aligned when atomic64_t uses
  46. * ARCv2 64-bit atomics (LLOCKD/SCONDD). This guarantess runtime 64-bit
  47. * alignment for any atomic64_t embedded in buffer.
  48. * Default ARCH_SLAB_MINALIGN is __alignof__(long long) which has a relaxed
  49. * value of 4 (and not 8) in ARC ABI.
  50. */
  51. #if defined(CONFIG_ARC_HAS_LL64) && defined(CONFIG_ARC_HAS_LLSC)
  52. #define ARCH_SLAB_MINALIGN 8
  53. #endif
  54. extern int ioc_enable;
  55. extern unsigned long perip_base, perip_end;
  56. #endif /* !__ASSEMBLY__ */
  57. /* Instruction cache related Auxiliary registers */
  58. #define ARC_REG_IC_BCR 0x77 /* Build Config reg */
  59. #define ARC_REG_IC_IVIC 0x10
  60. #define ARC_REG_IC_CTRL 0x11
  61. #define ARC_REG_IC_IVIR 0x16
  62. #define ARC_REG_IC_ENDR 0x17
  63. #define ARC_REG_IC_IVIL 0x19
  64. #define ARC_REG_IC_PTAG 0x1E
  65. #define ARC_REG_IC_PTAG_HI 0x1F
  66. /* Bit val in IC_CTRL */
  67. #define IC_CTRL_DIS 0x1
  68. /* Data cache related Auxiliary registers */
  69. #define ARC_REG_DC_BCR 0x72 /* Build Config reg */
  70. #define ARC_REG_DC_IVDC 0x47
  71. #define ARC_REG_DC_CTRL 0x48
  72. #define ARC_REG_DC_IVDL 0x4A
  73. #define ARC_REG_DC_FLSH 0x4B
  74. #define ARC_REG_DC_FLDL 0x4C
  75. #define ARC_REG_DC_STARTR 0x4D
  76. #define ARC_REG_DC_ENDR 0x4E
  77. #define ARC_REG_DC_PTAG 0x5C
  78. #define ARC_REG_DC_PTAG_HI 0x5F
  79. /* Bit val in DC_CTRL */
  80. #define DC_CTRL_DIS 0x001
  81. #define DC_CTRL_INV_MODE_FLUSH 0x040
  82. #define DC_CTRL_FLUSH_STATUS 0x100
  83. #define DC_CTRL_RGN_OP_INV 0x200
  84. #define DC_CTRL_RGN_OP_MSK 0x200
  85. /*System-level cache (L2 cache) related Auxiliary registers */
  86. #define ARC_REG_SLC_CFG 0x901
  87. #define ARC_REG_SLC_CTRL 0x903
  88. #define ARC_REG_SLC_FLUSH 0x904
  89. #define ARC_REG_SLC_INVALIDATE 0x905
  90. #define ARC_AUX_SLC_IVDL 0x910
  91. #define ARC_AUX_SLC_FLDL 0x912
  92. #define ARC_REG_SLC_RGN_START 0x914
  93. #define ARC_REG_SLC_RGN_START1 0x915
  94. #define ARC_REG_SLC_RGN_END 0x916
  95. #define ARC_REG_SLC_RGN_END1 0x917
  96. /* Bit val in SLC_CONTROL */
  97. #define SLC_CTRL_DIS 0x001
  98. #define SLC_CTRL_IM 0x040
  99. #define SLC_CTRL_BUSY 0x100
  100. #define SLC_CTRL_RGN_OP_INV 0x200
  101. /* IO coherency related Auxiliary registers */
  102. #define ARC_REG_IO_COH_ENABLE 0x500
  103. #define ARC_IO_COH_ENABLE_BIT BIT(0)
  104. #define ARC_REG_IO_COH_PARTIAL 0x501
  105. #define ARC_IO_COH_PARTIAL_BIT BIT(0)
  106. #define ARC_REG_IO_COH_AP0_BASE 0x508
  107. #define ARC_REG_IO_COH_AP0_SIZE 0x509
  108. #endif /* _ASM_CACHE_H */