1*83d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */ 2b2b135d9SPaul Burton /* 3b2b135d9SPaul Burton * MIPS Coherence Manager (CM) Register Definitions 4b2b135d9SPaul Burton * 5b2b135d9SPaul Burton * Copyright (c) 2016 Imagination Technologies Ltd. 6b2b135d9SPaul Burton */ 7b2b135d9SPaul Burton #ifndef __MIPS_ASM_CM_H__ 8b2b135d9SPaul Burton #define __MIPS_ASM_CM_H__ 9b2b135d9SPaul Burton 10b2b135d9SPaul Burton /* Global Control Register (GCR) offsets */ 11b2b135d9SPaul Burton #define GCR_BASE 0x0008 12b2b135d9SPaul Burton #define GCR_BASE_UPPER 0x000c 13b2b135d9SPaul Burton #define GCR_REV 0x0030 144baa0ab6SPaul Burton #define GCR_L2_CONFIG 0x0130 154baa0ab6SPaul Burton #define GCR_L2_TAG_ADDR 0x0600 164baa0ab6SPaul Burton #define GCR_L2_TAG_ADDR_UPPER 0x0604 174baa0ab6SPaul Burton #define GCR_L2_TAG_STATE 0x0608 184baa0ab6SPaul Burton #define GCR_L2_TAG_STATE_UPPER 0x060c 194baa0ab6SPaul Burton #define GCR_L2_DATA 0x0610 204baa0ab6SPaul Burton #define GCR_L2_DATA_UPPER 0x0614 217953354bSPaul Burton #define GCR_Cx_COHERENCE 0x2008 22b2b135d9SPaul Burton 23b2b135d9SPaul Burton /* GCR_REV CM versions */ 24b2b135d9SPaul Burton #define GCR_REV_CM3 0x0800 25b2b135d9SPaul Burton 264baa0ab6SPaul Burton /* GCR_L2_CONFIG fields */ 274baa0ab6SPaul Burton #define GCR_L2_CONFIG_ASSOC_SHIFT 0 284baa0ab6SPaul Burton #define GCR_L2_CONFIG_ASSOC_BITS 8 294baa0ab6SPaul Burton #define GCR_L2_CONFIG_LINESZ_SHIFT 8 304baa0ab6SPaul Burton #define GCR_L2_CONFIG_LINESZ_BITS 4 314baa0ab6SPaul Burton #define GCR_L2_CONFIG_SETSZ_SHIFT 12 324baa0ab6SPaul Burton #define GCR_L2_CONFIG_SETSZ_BITS 4 334baa0ab6SPaul Burton #define GCR_L2_CONFIG_BYPASS (1 << 20) 344baa0ab6SPaul Burton 357953354bSPaul Burton /* GCR_Cx_COHERENCE */ 367953354bSPaul Burton #define GCR_Cx_COHERENCE_DOM_EN (0xff << 0) 377953354bSPaul Burton #define GCR_Cx_COHERENCE_EN (0x1 << 0) 387953354bSPaul Burton 394baa0ab6SPaul Burton #ifndef __ASSEMBLY__ 404baa0ab6SPaul Burton 414baa0ab6SPaul Burton #include <asm/io.h> 424baa0ab6SPaul Burton mips_cm_base(void)434baa0ab6SPaul Burtonstatic inline void *mips_cm_base(void) 444baa0ab6SPaul Burton { 454baa0ab6SPaul Burton return (void *)CKSEG1ADDR(CONFIG_MIPS_CM_BASE); 464baa0ab6SPaul Burton } 474baa0ab6SPaul Burton mips_cm_l2_line_size(void)484baa0ab6SPaul Burtonstatic inline unsigned long mips_cm_l2_line_size(void) 494baa0ab6SPaul Burton { 504baa0ab6SPaul Burton unsigned long l2conf, line_sz; 514baa0ab6SPaul Burton 524baa0ab6SPaul Burton l2conf = __raw_readl(mips_cm_base() + GCR_L2_CONFIG); 534baa0ab6SPaul Burton 544baa0ab6SPaul Burton line_sz = l2conf >> GCR_L2_CONFIG_LINESZ_SHIFT; 554baa0ab6SPaul Burton line_sz &= GENMASK(GCR_L2_CONFIG_LINESZ_BITS - 1, 0); 564baa0ab6SPaul Burton return line_sz ? (2 << line_sz) : 0; 574baa0ab6SPaul Burton } 584baa0ab6SPaul Burton 594baa0ab6SPaul Burton #endif /* !__ASSEMBLY__ */ 604baa0ab6SPaul Burton 61b2b135d9SPaul Burton #endif /* __MIPS_ASM_CM_H__ */ 62