bcache.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (c) 1997, 1999 by Ralf Baechle
  7. * Copyright (c) 1999 Silicon Graphics, Inc.
  8. */
  9. #ifndef _ASM_BCACHE_H
  10. #define _ASM_BCACHE_H
  11. #include <linux/types.h>
  12. /* Some R4000 / R4400 / R4600 / R5000 machines may have a non-dma-coherent,
  13. chipset implemented caches. On machines with other CPUs the CPU does the
  14. cache thing itself. */
  15. struct bcache_ops {
  16. void (*bc_enable)(void);
  17. void (*bc_disable)(void);
  18. void (*bc_wback_inv)(unsigned long page, unsigned long size);
  19. void (*bc_inv)(unsigned long page, unsigned long size);
  20. void (*bc_prefetch_enable)(void);
  21. void (*bc_prefetch_disable)(void);
  22. bool (*bc_prefetch_is_enabled)(void);
  23. };
  24. extern void indy_sc_init(void);
  25. #ifdef CONFIG_BOARD_SCACHE
  26. extern struct bcache_ops *bcops;
  27. static inline void bc_enable(void)
  28. {
  29. bcops->bc_enable();
  30. }
  31. static inline void bc_disable(void)
  32. {
  33. bcops->bc_disable();
  34. }
  35. static inline void bc_wback_inv(unsigned long page, unsigned long size)
  36. {
  37. bcops->bc_wback_inv(page, size);
  38. }
  39. static inline void bc_inv(unsigned long page, unsigned long size)
  40. {
  41. bcops->bc_inv(page, size);
  42. }
  43. static inline void bc_prefetch_enable(void)
  44. {
  45. if (bcops->bc_prefetch_enable)
  46. bcops->bc_prefetch_enable();
  47. }
  48. static inline void bc_prefetch_disable(void)
  49. {
  50. if (bcops->bc_prefetch_disable)
  51. bcops->bc_prefetch_disable();
  52. }
  53. static inline bool bc_prefetch_is_enabled(void)
  54. {
  55. if (bcops->bc_prefetch_is_enabled)
  56. return bcops->bc_prefetch_is_enabled();
  57. return false;
  58. }
  59. #else /* !defined(CONFIG_BOARD_SCACHE) */
  60. /* Not R4000 / R4400 / R4600 / R5000. */
  61. #define bc_enable() do { } while (0)
  62. #define bc_disable() do { } while (0)
  63. #define bc_wback_inv(page, size) do { } while (0)
  64. #define bc_inv(page, size) do { } while (0)
  65. #define bc_prefetch_enable() do { } while (0)
  66. #define bc_prefetch_disable() do { } while (0)
  67. #define bc_prefetch_is_enabled() 0
  68. #endif /* !defined(CONFIG_BOARD_SCACHE) */
  69. #endif /* _ASM_BCACHE_H */