cm.h 1.5 KB

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