cm.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * MIPS Coherence Manager (CM) Register Definitions
  3. *
  4. * Copyright (c) 2016 Imagination Technologies Ltd.
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #ifndef __MIPS_ASM_CM_H__
  9. #define __MIPS_ASM_CM_H__
  10. /* Global Control Register (GCR) offsets */
  11. #define GCR_BASE 0x0008
  12. #define GCR_BASE_UPPER 0x000c
  13. #define GCR_REV 0x0030
  14. #define GCR_L2_CONFIG 0x0130
  15. #define GCR_L2_TAG_ADDR 0x0600
  16. #define GCR_L2_TAG_ADDR_UPPER 0x0604
  17. #define GCR_L2_TAG_STATE 0x0608
  18. #define GCR_L2_TAG_STATE_UPPER 0x060c
  19. #define GCR_L2_DATA 0x0610
  20. #define GCR_L2_DATA_UPPER 0x0614
  21. #define GCR_Cx_COHERENCE 0x2008
  22. /* GCR_REV CM versions */
  23. #define GCR_REV_CM3 0x0800
  24. /* GCR_L2_CONFIG fields */
  25. #define GCR_L2_CONFIG_ASSOC_SHIFT 0
  26. #define GCR_L2_CONFIG_ASSOC_BITS 8
  27. #define GCR_L2_CONFIG_LINESZ_SHIFT 8
  28. #define GCR_L2_CONFIG_LINESZ_BITS 4
  29. #define GCR_L2_CONFIG_SETSZ_SHIFT 12
  30. #define GCR_L2_CONFIG_SETSZ_BITS 4
  31. #define GCR_L2_CONFIG_BYPASS (1 << 20)
  32. /* GCR_Cx_COHERENCE */
  33. #define GCR_Cx_COHERENCE_DOM_EN (0xff << 0)
  34. #define GCR_Cx_COHERENCE_EN (0x1 << 0)
  35. #ifndef __ASSEMBLY__
  36. #include <asm/io.h>
  37. static inline void *mips_cm_base(void)
  38. {
  39. return (void *)CKSEG1ADDR(CONFIG_MIPS_CM_BASE);
  40. }
  41. static inline unsigned long mips_cm_l2_line_size(void)
  42. {
  43. unsigned long l2conf, line_sz;
  44. l2conf = __raw_readl(mips_cm_base() + GCR_L2_CONFIG);
  45. line_sz = l2conf >> GCR_L2_CONFIG_LINESZ_SHIFT;
  46. line_sz &= GENMASK(GCR_L2_CONFIG_LINESZ_BITS - 1, 0);
  47. return line_sz ? (2 << line_sz) : 0;
  48. }
  49. #endif /* !__ASSEMBLY__ */
  50. #endif /* __MIPS_ASM_CM_H__ */