cache.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. #include <asm/mmu.h> /* some of cache registers depend on MMU ver */
  11. /* In case $$ not config, setup a dummy number for rest of kernel */
  12. #ifndef CONFIG_ARC_CACHE_LINE_SHIFT
  13. #define L1_CACHE_SHIFT 6
  14. #else
  15. #define L1_CACHE_SHIFT CONFIG_ARC_CACHE_LINE_SHIFT
  16. #endif
  17. #define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
  18. #define ARC_ICACHE_WAYS 2
  19. #define ARC_DCACHE_WAYS 4
  20. /* Helpers */
  21. #define ARC_ICACHE_LINE_LEN L1_CACHE_BYTES
  22. #define ARC_DCACHE_LINE_LEN L1_CACHE_BYTES
  23. #define ICACHE_LINE_MASK (~(ARC_ICACHE_LINE_LEN - 1))
  24. #define DCACHE_LINE_MASK (~(ARC_DCACHE_LINE_LEN - 1))
  25. #if ARC_ICACHE_LINE_LEN != ARC_DCACHE_LINE_LEN
  26. #error "Need to fix some code as I/D cache lines not same"
  27. #else
  28. #define is_not_cache_aligned(p) ((unsigned long)p & (~DCACHE_LINE_MASK))
  29. #endif
  30. #ifndef __ASSEMBLY__
  31. /* Uncached access macros */
  32. #define arc_read_uncached_32(ptr) \
  33. ({ \
  34. unsigned int __ret; \
  35. __asm__ __volatile__( \
  36. " ld.di %0, [%1] \n" \
  37. : "=r"(__ret) \
  38. : "r"(ptr)); \
  39. __ret; \
  40. })
  41. #define arc_write_uncached_32(ptr, data)\
  42. ({ \
  43. __asm__ __volatile__( \
  44. " st.di %0, [%1] \n" \
  45. : \
  46. : "r"(data), "r"(ptr)); \
  47. })
  48. #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
  49. /*
  50. * ARC700 doesn't cache any access in top 256M.
  51. * Ideal for wiring memory mapped peripherals as we don't need to do
  52. * explicit uncached accesses (LD.di/ST.di) hence more portable drivers
  53. */
  54. #define ARC_UNCACHED_ADDR_SPACE 0xc0000000
  55. extern void arc_cache_init(void);
  56. extern char *arc_cache_mumbojumbo(int cpu_id, char *buf, int len);
  57. extern void __init read_decode_cache_bcr(void);
  58. #endif
  59. #endif /* _ASM_CACHE_H */