cache.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #ifndef __ARC_ASM_CACHE_H
  9. #define __ARC_ASM_CACHE_H
  10. /* In case $$ not config, setup a dummy number for rest of kernel */
  11. #ifndef CONFIG_ARC_CACHE_LINE_SHIFT
  12. #define L1_CACHE_SHIFT 6
  13. #else
  14. #define L1_CACHE_SHIFT CONFIG_ARC_CACHE_LINE_SHIFT
  15. #endif
  16. #define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
  17. #define ARC_ICACHE_WAYS 2
  18. #define ARC_DCACHE_WAYS 4
  19. /* Helpers */
  20. #define ARC_ICACHE_LINE_LEN L1_CACHE_BYTES
  21. #define ARC_DCACHE_LINE_LEN L1_CACHE_BYTES
  22. #define ICACHE_LINE_MASK (~(ARC_ICACHE_LINE_LEN - 1))
  23. #define DCACHE_LINE_MASK (~(ARC_DCACHE_LINE_LEN - 1))
  24. #if ARC_ICACHE_LINE_LEN != ARC_DCACHE_LINE_LEN
  25. #error "Need to fix some code as I/D cache lines not same"
  26. #else
  27. #define is_not_cache_aligned(p) ((unsigned long)p & (~DCACHE_LINE_MASK))
  28. #endif
  29. #ifndef __ASSEMBLY__
  30. /* Uncached access macros */
  31. #define arc_read_uncached_32(ptr) \
  32. ({ \
  33. unsigned int __ret; \
  34. __asm__ __volatile__( \
  35. " ld.di %0, [%1] \n" \
  36. : "=r"(__ret) \
  37. : "r"(ptr)); \
  38. __ret; \
  39. })
  40. #define arc_write_uncached_32(ptr, data)\
  41. ({ \
  42. __asm__ __volatile__( \
  43. " st.di %0, [%1] \n" \
  44. : \
  45. : "r"(data), "r"(ptr)); \
  46. })
  47. /* used to give SHMLBA a value to avoid Cache Aliasing */
  48. extern unsigned int ARC_shmlba;
  49. #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
  50. /*
  51. * ARC700 doesn't cache any access in top 256M.
  52. * Ideal for wiring memory mapped peripherals as we don't need to do
  53. * explicit uncached accesses (LD.di/ST.di) hence more portable drivers
  54. */
  55. #define ARC_UNCACHED_ADDR_SPACE 0xc0000000
  56. extern void arc_cache_init(void);
  57. extern char *arc_cache_mumbojumbo(int cpu_id, char *buf, int len);
  58. extern void __init read_decode_cache_bcr(void);
  59. #endif
  60. #endif /* _ASM_CACHE_H */