126ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson#ifndef _ASM_POWERPC_CACHE_H 226ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson#define _ASM_POWERPC_CACHE_H 326ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson 426ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson#ifdef __KERNEL__ 526ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson 69678cdaae93932473f696fdea5debf3eee1e1260Stewart Smith#include <asm/reg.h> 726ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson 826ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson/* bytes per L1 cache line */ 926ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson#if defined(CONFIG_8xx) || defined(CONFIG_403GCX) 1026ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson#define L1_CACHE_SHIFT 4 1126ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson#define MAX_COPY_PREFETCH 1 123dfa8773674e16f95f70a0e631e80c69390d04d7Kumar Gala#elif defined(CONFIG_PPC_E500MC) 133dfa8773674e16f95f70a0e631e80c69390d04d7Kumar Gala#define L1_CACHE_SHIFT 6 143dfa8773674e16f95f70a0e631e80c69390d04d7Kumar Gala#define MAX_COPY_PREFETCH 4 1526ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson#elif defined(CONFIG_PPC32) 1626ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson#define MAX_COPY_PREFETCH 4 17e7f75ad01d590243904c2d95ab47e6b2e9ef6dadDave Kleikamp#if defined(CONFIG_PPC_47x) 18e7f75ad01d590243904c2d95ab47e6b2e9ef6dadDave Kleikamp#define L1_CACHE_SHIFT 7 19e7f75ad01d590243904c2d95ab47e6b2e9ef6dadDave Kleikamp#else 20e7f75ad01d590243904c2d95ab47e6b2e9ef6dadDave Kleikamp#define L1_CACHE_SHIFT 5 21e7f75ad01d590243904c2d95ab47e6b2e9ef6dadDave Kleikamp#endif 2226ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson#else /* CONFIG_PPC64 */ 2326ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson#define L1_CACHE_SHIFT 7 2426ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson#endif 2526ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson 2626ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) 2726ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson 2826ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson#define SMP_CACHE_BYTES L1_CACHE_BYTES 2926ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson 3026ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson#if defined(__powerpc64__) && !defined(__ASSEMBLY__) 3126ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibsonstruct ppc64_caches { 3226ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson u32 dsize; /* L1 d-cache size */ 3326ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson u32 dline_size; /* L1 d-cache line size */ 3426ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson u32 log_dline_size; 3526ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson u32 dlines_per_page; 3626ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson u32 isize; /* L1 i-cache size */ 3726ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson u32 iline_size; /* L1 i-cache line size */ 3826ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson u32 log_iline_size; 3926ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson u32 ilines_per_page; 4026ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson}; 4126ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson 4226ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibsonextern struct ppc64_caches ppc64_caches; 439678cdaae93932473f696fdea5debf3eee1e1260Stewart Smith 449678cdaae93932473f696fdea5debf3eee1e1260Stewart Smithstatic inline void logmpp(u64 x) 459678cdaae93932473f696fdea5debf3eee1e1260Stewart Smith{ 469678cdaae93932473f696fdea5debf3eee1e1260Stewart Smith asm volatile(PPC_LOGMPP(R1) : : "r" (x)); 479678cdaae93932473f696fdea5debf3eee1e1260Stewart Smith} 489678cdaae93932473f696fdea5debf3eee1e1260Stewart Smith 4926ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson#endif /* __powerpc64__ && ! __ASSEMBLY__ */ 5026ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson 510ce636700c5bad54eda0e62903a1803f6d67b31dKevin Hao#if defined(__ASSEMBLY__) 520ce636700c5bad54eda0e62903a1803f6d67b31dKevin Hao/* 530ce636700c5bad54eda0e62903a1803f6d67b31dKevin Hao * For a snooping icache, we still need a dummy icbi to purge all the 540ce636700c5bad54eda0e62903a1803f6d67b31dKevin Hao * prefetched instructions from the ifetch buffers. We also need a sync 550ce636700c5bad54eda0e62903a1803f6d67b31dKevin Hao * before the icbi to order the the actual stores to memory that might 560ce636700c5bad54eda0e62903a1803f6d67b31dKevin Hao * have modified instructions with the icbi. 570ce636700c5bad54eda0e62903a1803f6d67b31dKevin Hao */ 580ce636700c5bad54eda0e62903a1803f6d67b31dKevin Hao#define PURGE_PREFETCHED_INS \ 590ce636700c5bad54eda0e62903a1803f6d67b31dKevin Hao sync; \ 600ce636700c5bad54eda0e62903a1803f6d67b31dKevin Hao icbi 0,r3; \ 610ce636700c5bad54eda0e62903a1803f6d67b31dKevin Hao sync; \ 620ce636700c5bad54eda0e62903a1803f6d67b31dKevin Hao isync 63ae3a197e3d0bfe3f4bf1693723e82dc018c096f3David Howells 640ce636700c5bad54eda0e62903a1803f6d67b31dKevin Hao#else 6554cb27a71f51d304342c79e62fd7667f2171062bDenys Vlasenko#define __read_mostly __attribute__((__section__(".data..read_mostly"))) 66ae3a197e3d0bfe3f4bf1693723e82dc018c096f3David Howells 67ae3a197e3d0bfe3f4bf1693723e82dc018c096f3David Howells#ifdef CONFIG_6xx 68ae3a197e3d0bfe3f4bf1693723e82dc018c096f3David Howellsextern long _get_L2CR(void); 69ae3a197e3d0bfe3f4bf1693723e82dc018c096f3David Howellsextern long _get_L3CR(void); 70ae3a197e3d0bfe3f4bf1693723e82dc018c096f3David Howellsextern void _set_L2CR(unsigned long); 71ae3a197e3d0bfe3f4bf1693723e82dc018c096f3David Howellsextern void _set_L3CR(unsigned long); 72ae3a197e3d0bfe3f4bf1693723e82dc018c096f3David Howells#else 73ae3a197e3d0bfe3f4bf1693723e82dc018c096f3David Howells#define _get_L2CR() 0L 74ae3a197e3d0bfe3f4bf1693723e82dc018c096f3David Howells#define _get_L3CR() 0L 75ae3a197e3d0bfe3f4bf1693723e82dc018c096f3David Howells#define _set_L2CR(val) do { } while(0) 76ae3a197e3d0bfe3f4bf1693723e82dc018c096f3David Howells#define _set_L3CR(val) do { } while(0) 77bd67fcf9ba8474e8eef649a79aba5b3479b01272Tony Breeds#endif 78bd67fcf9ba8474e8eef649a79aba5b3479b01272Tony Breeds 79ae3a197e3d0bfe3f4bf1693723e82dc018c096f3David Howellsextern void cacheable_memzero(void *p, unsigned int nb); 80ae3a197e3d0bfe3f4bf1693723e82dc018c096f3David Howellsextern void *cacheable_memcpy(void *, const void *, unsigned int); 81ae3a197e3d0bfe3f4bf1693723e82dc018c096f3David Howells 82ae3a197e3d0bfe3f4bf1693723e82dc018c096f3David Howells#endif /* !__ASSEMBLY__ */ 8326ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson#endif /* __KERNEL__ */ 8426ef5c09576496dfd08d2b36ec1d08a6f917a0ebDavid Gibson#endif /* _ASM_POWERPC_CACHE_H */ 85