18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public
38c2ecf20Sopenharmony_ci * License.  See the file "COPYING" in the main directory of this archive
48c2ecf20Sopenharmony_ci * for more details.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Derived from IRIX <sys/SN/SN0/hubmd.h>, revision 1.59.
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * Copyright (C) 1992 - 1997, 1999 Silicon Graphics, Inc.
98c2ecf20Sopenharmony_ci * Copyright (C) 1999 by Ralf Baechle
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci#ifndef _ASM_SN_SN0_HUBMD_H
128c2ecf20Sopenharmony_ci#define _ASM_SN_SN0_HUBMD_H
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci/*
168c2ecf20Sopenharmony_ci * Hub Memory/Directory interface registers
178c2ecf20Sopenharmony_ci */
188c2ecf20Sopenharmony_ci#define CACHE_SLINE_SIZE	128	/* Secondary cache line size on SN0 */
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#define MAX_REGIONS		64
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci/* Hardware page size and shift */
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#define MD_PAGE_SIZE		4096	 /* Page size in bytes		    */
258c2ecf20Sopenharmony_ci#define MD_PAGE_NUM_SHFT	12	 /* Address to page number shift    */
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci/* Register offsets from LOCAL_HUB or REMOTE_HUB */
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci#define MD_BASE			0x200000
308c2ecf20Sopenharmony_ci#define MD_BASE_PERF		0x210000
318c2ecf20Sopenharmony_ci#define MD_BASE_JUNK		0x220000
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#define MD_IO_PROTECT		0x200000 /* MD and core register protection */
348c2ecf20Sopenharmony_ci#define MD_IO_PROT_OVRRD	0x200008 /* Clear my bit in MD_IO_PROTECT   */
358c2ecf20Sopenharmony_ci#define MD_HSPEC_PROTECT	0x200010 /* BDDIR, LBOOT, RBOOT protection  */
368c2ecf20Sopenharmony_ci#define MD_MEMORY_CONFIG	0x200018 /* Memory/Directory DIMM control   */
378c2ecf20Sopenharmony_ci#define MD_REFRESH_CONTROL	0x200020 /* Memory/Directory refresh ctrl   */
388c2ecf20Sopenharmony_ci#define MD_FANDOP_CAC_STAT	0x200028 /* Fetch-and-op cache status	    */
398c2ecf20Sopenharmony_ci#define MD_MIG_DIFF_THRESH	0x200030 /* Page migr. count diff thresh.   */
408c2ecf20Sopenharmony_ci#define MD_MIG_VALUE_THRESH	0x200038 /* Page migr. count abs. thresh.   */
418c2ecf20Sopenharmony_ci#define MD_MIG_CANDIDATE	0x200040 /* Latest page migration candidate */
428c2ecf20Sopenharmony_ci#define MD_MIG_CANDIDATE_CLR	0x200048 /* Clear page migration candidate  */
438c2ecf20Sopenharmony_ci#define MD_DIR_ERROR		0x200050 /* Directory DIMM error	    */
448c2ecf20Sopenharmony_ci#define MD_DIR_ERROR_CLR	0x200058 /* Directory DIMM error clear	    */
458c2ecf20Sopenharmony_ci#define MD_PROTOCOL_ERROR	0x200060 /* Directory protocol error	    */
468c2ecf20Sopenharmony_ci#define MD_PROTOCOL_ERROR_CLR	0x200068 /* Directory protocol error clear  */
478c2ecf20Sopenharmony_ci#define MD_MEM_ERROR		0x200070 /* Memory DIMM error		    */
488c2ecf20Sopenharmony_ci#define MD_MEM_ERROR_CLR	0x200078 /* Memory DIMM error clear	    */
498c2ecf20Sopenharmony_ci#define MD_MISC_ERROR		0x200080 /* Miscellaneous MD error	    */
508c2ecf20Sopenharmony_ci#define MD_MISC_ERROR_CLR	0x200088 /* Miscellaneous MD error clear    */
518c2ecf20Sopenharmony_ci#define MD_MEM_DIMM_INIT	0x200090 /* Memory DIMM mode initization.   */
528c2ecf20Sopenharmony_ci#define MD_DIR_DIMM_INIT	0x200098 /* Directory DIMM mode init.	    */
538c2ecf20Sopenharmony_ci#define MD_MOQ_SIZE		0x2000a0 /* MD outgoing queue size	    */
548c2ecf20Sopenharmony_ci#define MD_MLAN_CTL		0x2000a8 /* NIC (Microlan) control register */
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci#define MD_PERF_SEL		0x210000 /* Select perf monitor events	    */
578c2ecf20Sopenharmony_ci#define MD_PERF_CNT0		0x210010 /* Performance counter 0	    */
588c2ecf20Sopenharmony_ci#define MD_PERF_CNT1		0x210018 /* Performance counter 1	    */
598c2ecf20Sopenharmony_ci#define MD_PERF_CNT2		0x210020 /* Performance counter 2	    */
608c2ecf20Sopenharmony_ci#define MD_PERF_CNT3		0x210028 /* Performance counter 3	    */
618c2ecf20Sopenharmony_ci#define MD_PERF_CNT4		0x210030 /* Performance counter 4	    */
628c2ecf20Sopenharmony_ci#define MD_PERF_CNT5		0x210038 /* Performance counter 5	    */
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci#define MD_UREG0_0		0x220000 /* uController/UART 0 register	    */
658c2ecf20Sopenharmony_ci#define MD_UREG0_1		0x220008 /* uController/UART 0 register	    */
668c2ecf20Sopenharmony_ci#define MD_UREG0_2		0x220010 /* uController/UART 0 register	    */
678c2ecf20Sopenharmony_ci#define MD_UREG0_3		0x220018 /* uController/UART 0 register	    */
688c2ecf20Sopenharmony_ci#define MD_UREG0_4		0x220020 /* uController/UART 0 register	    */
698c2ecf20Sopenharmony_ci#define MD_UREG0_5		0x220028 /* uController/UART 0 register	    */
708c2ecf20Sopenharmony_ci#define MD_UREG0_6		0x220030 /* uController/UART 0 register	    */
718c2ecf20Sopenharmony_ci#define MD_UREG0_7		0x220038 /* uController/UART 0 register	    */
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci#define MD_SLOTID_USTAT		0x220048 /* Hub slot ID & UART/uCtlr status */
748c2ecf20Sopenharmony_ci#define MD_LED0			0x220050 /* Eight-bit LED for CPU A	    */
758c2ecf20Sopenharmony_ci#define MD_LED1			0x220058 /* Eight-bit LED for CPU B	    */
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci#define MD_UREG1_0		0x220080 /* uController/UART 1 register	    */
788c2ecf20Sopenharmony_ci#define MD_UREG1_1		0x220088 /* uController/UART 1 register	    */
798c2ecf20Sopenharmony_ci#define MD_UREG1_2		0x220090 /* uController/UART 1 register	    */
808c2ecf20Sopenharmony_ci#define MD_UREG1_3		0x220098 /* uController/UART 1 register	    */
818c2ecf20Sopenharmony_ci#define MD_UREG1_4		0x2200a0 /* uController/UART 1 register	    */
828c2ecf20Sopenharmony_ci#define MD_UREG1_5		0x2200a8 /* uController/UART 1 register	    */
838c2ecf20Sopenharmony_ci#define MD_UREG1_6		0x2200b0 /* uController/UART 1 register	    */
848c2ecf20Sopenharmony_ci#define MD_UREG1_7		0x2200b8 /* uController/UART 1 register	    */
858c2ecf20Sopenharmony_ci#define MD_UREG1_8		0x2200c0 /* uController/UART 1 register	    */
868c2ecf20Sopenharmony_ci#define MD_UREG1_9		0x2200c8 /* uController/UART 1 register	    */
878c2ecf20Sopenharmony_ci#define MD_UREG1_10		0x2200d0 /* uController/UART 1 register	    */
888c2ecf20Sopenharmony_ci#define MD_UREG1_11		0x2200d8 /* uController/UART 1 register	    */
898c2ecf20Sopenharmony_ci#define MD_UREG1_12		0x2200e0 /* uController/UART 1 register	    */
908c2ecf20Sopenharmony_ci#define MD_UREG1_13		0x2200e8 /* uController/UART 1 register	    */
918c2ecf20Sopenharmony_ci#define MD_UREG1_14		0x2200f0 /* uController/UART 1 register	    */
928c2ecf20Sopenharmony_ci#define MD_UREG1_15		0x2200f8 /* uController/UART 1 register	    */
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci#ifdef CONFIG_SGI_SN_N_MODE
958c2ecf20Sopenharmony_ci#define MD_MEM_BANKS		4	 /* 4 banks of memory max in N mode */
968c2ecf20Sopenharmony_ci#else
978c2ecf20Sopenharmony_ci#define MD_MEM_BANKS		8	 /* 8 banks of memory max in M mode */
988c2ecf20Sopenharmony_ci#endif
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci/*
1018c2ecf20Sopenharmony_ci * MD_MEMORY_CONFIG fields
1028c2ecf20Sopenharmony_ci *
1038c2ecf20Sopenharmony_ci *   MD_SIZE_xxx are useful for representing the size of a SIMM or bank
1048c2ecf20Sopenharmony_ci *   (SIMM pair).  They correspond to the values needed for the bit
1058c2ecf20Sopenharmony_ci *   triplets (MMC_BANK_MASK) in the MD_MEMORY_CONFIG register for bank size.
1068c2ecf20Sopenharmony_ci *   Bits not used by the MD are used by software.
1078c2ecf20Sopenharmony_ci */
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci#define MD_SIZE_EMPTY		0	/* Valid in MEMORY_CONFIG	    */
1108c2ecf20Sopenharmony_ci#define MD_SIZE_8MB		1
1118c2ecf20Sopenharmony_ci#define MD_SIZE_16MB		2
1128c2ecf20Sopenharmony_ci#define MD_SIZE_32MB		3	/* Broken in Hub 1		    */
1138c2ecf20Sopenharmony_ci#define MD_SIZE_64MB		4	/* Valid in MEMORY_CONFIG	    */
1148c2ecf20Sopenharmony_ci#define MD_SIZE_128MB		5	/* Valid in MEMORY_CONFIG	    */
1158c2ecf20Sopenharmony_ci#define MD_SIZE_256MB		6
1168c2ecf20Sopenharmony_ci#define MD_SIZE_512MB		7	/* Valid in MEMORY_CONFIG	    */
1178c2ecf20Sopenharmony_ci#define MD_SIZE_1GB		8
1188c2ecf20Sopenharmony_ci#define MD_SIZE_2GB		9
1198c2ecf20Sopenharmony_ci#define MD_SIZE_4GB		10
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci#define MD_SIZE_BYTES(size)	((size) == 0 ? 0 : 0x400000L << (size))
1228c2ecf20Sopenharmony_ci#define MD_SIZE_MBYTES(size)	((size) == 0 ? 0 :   4	     << (size))
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci#define MMC_FPROM_CYC_SHFT	49	/* Have to use UINT64_CAST, instead */
1258c2ecf20Sopenharmony_ci#define MMC_FPROM_CYC_MASK	(UINT64_CAST 31 << 49)	/* of 'L' suffix,   */
1268c2ecf20Sopenharmony_ci#define MMC_FPROM_WR_SHFT	44			/* for assembler    */
1278c2ecf20Sopenharmony_ci#define MMC_FPROM_WR_MASK	(UINT64_CAST 31 << 44)
1288c2ecf20Sopenharmony_ci#define MMC_UCTLR_CYC_SHFT	39
1298c2ecf20Sopenharmony_ci#define MMC_UCTLR_CYC_MASK	(UINT64_CAST 31 << 39)
1308c2ecf20Sopenharmony_ci#define MMC_UCTLR_WR_SHFT	34
1318c2ecf20Sopenharmony_ci#define MMC_UCTLR_WR_MASK	(UINT64_CAST 31 << 34)
1328c2ecf20Sopenharmony_ci#define MMC_DIMM0_SEL_SHFT	32
1338c2ecf20Sopenharmony_ci#define MMC_DIMM0_SEL_MASK	(UINT64_CAST 3 << 32)
1348c2ecf20Sopenharmony_ci#define MMC_IO_PROT_EN_SHFT	31
1358c2ecf20Sopenharmony_ci#define MMC_IO_PROT_EN_MASK	(UINT64_CAST 1 << 31)
1368c2ecf20Sopenharmony_ci#define MMC_IO_PROT		(UINT64_CAST 1 << 31)
1378c2ecf20Sopenharmony_ci#define MMC_ARB_MLSS_SHFT	30
1388c2ecf20Sopenharmony_ci#define MMC_ARB_MLSS_MASK	(UINT64_CAST 1 << 30)
1398c2ecf20Sopenharmony_ci#define MMC_ARB_MLSS		(UINT64_CAST 1 << 30)
1408c2ecf20Sopenharmony_ci#define MMC_IGNORE_ECC_SHFT	29
1418c2ecf20Sopenharmony_ci#define MMC_IGNORE_ECC_MASK	(UINT64_CAST 1 << 29)
1428c2ecf20Sopenharmony_ci#define MMC_IGNORE_ECC		(UINT64_CAST 1 << 29)
1438c2ecf20Sopenharmony_ci#define MMC_DIR_PREMIUM_SHFT	28
1448c2ecf20Sopenharmony_ci#define MMC_DIR_PREMIUM_MASK	(UINT64_CAST 1 << 28)
1458c2ecf20Sopenharmony_ci#define MMC_DIR_PREMIUM		(UINT64_CAST 1 << 28)
1468c2ecf20Sopenharmony_ci#define MMC_REPLY_GUAR_SHFT	24
1478c2ecf20Sopenharmony_ci#define MMC_REPLY_GUAR_MASK	(UINT64_CAST 15 << 24)
1488c2ecf20Sopenharmony_ci#define MMC_BANK_SHFT(_b)	((_b) * 3)
1498c2ecf20Sopenharmony_ci#define MMC_BANK_MASK(_b)	(UINT64_CAST 7 << MMC_BANK_SHFT(_b))
1508c2ecf20Sopenharmony_ci#define MMC_BANK_ALL_MASK	0xffffff
1518c2ecf20Sopenharmony_ci#define MMC_RESET_DEFAULTS	(UINT64_CAST 0x0f << MMC_FPROM_CYC_SHFT | \
1528c2ecf20Sopenharmony_ci				 UINT64_CAST 0x07 << MMC_FPROM_WR_SHFT | \
1538c2ecf20Sopenharmony_ci				 UINT64_CAST 0x1f << MMC_UCTLR_CYC_SHFT | \
1548c2ecf20Sopenharmony_ci				 UINT64_CAST 0x0f << MMC_UCTLR_WR_SHFT | \
1558c2ecf20Sopenharmony_ci				 MMC_IGNORE_ECC | MMC_DIR_PREMIUM | \
1568c2ecf20Sopenharmony_ci				 UINT64_CAST 0x0f << MMC_REPLY_GUAR_SHFT | \
1578c2ecf20Sopenharmony_ci				 MMC_BANK_ALL_MASK)
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci/* MD_REFRESH_CONTROL fields */
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ci#define MRC_ENABLE_SHFT		63
1628c2ecf20Sopenharmony_ci#define MRC_ENABLE_MASK		(UINT64_CAST 1 << 63)
1638c2ecf20Sopenharmony_ci#define MRC_ENABLE		(UINT64_CAST 1 << 63)
1648c2ecf20Sopenharmony_ci#define MRC_COUNTER_SHFT	12
1658c2ecf20Sopenharmony_ci#define MRC_COUNTER_MASK	(UINT64_CAST 0xfff << 12)
1668c2ecf20Sopenharmony_ci#define MRC_CNT_THRESH_MASK	0xfff
1678c2ecf20Sopenharmony_ci#define MRC_RESET_DEFAULTS	(UINT64_CAST 0x400)
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci/* MD_MEM_DIMM_INIT and MD_DIR_DIMM_INIT fields */
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci#define MDI_SELECT_SHFT		32
1728c2ecf20Sopenharmony_ci#define MDI_SELECT_MASK		(UINT64_CAST 0x0f << 32)
1738c2ecf20Sopenharmony_ci#define MDI_DIMM_MODE_MASK	(UINT64_CAST 0xfff)
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_ci/* MD_MOQ_SIZE fields */
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ci#define MMS_RP_SIZE_SHFT	8
1788c2ecf20Sopenharmony_ci#define MMS_RP_SIZE_MASK	(UINT64_CAST 0x3f << 8)
1798c2ecf20Sopenharmony_ci#define MMS_RQ_SIZE_SHFT	0
1808c2ecf20Sopenharmony_ci#define MMS_RQ_SIZE_MASK	(UINT64_CAST 0x1f)
1818c2ecf20Sopenharmony_ci#define MMS_RESET_DEFAULTS	(0x32 << 8 | 0x12)
1828c2ecf20Sopenharmony_ci
1838c2ecf20Sopenharmony_ci/* MD_FANDOP_CAC_STAT fields */
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci#define MFC_VALID_SHFT		63
1868c2ecf20Sopenharmony_ci#define MFC_VALID_MASK		(UINT64_CAST 1 << 63)
1878c2ecf20Sopenharmony_ci#define MFC_VALID		(UINT64_CAST 1 << 63)
1888c2ecf20Sopenharmony_ci#define MFC_ADDR_SHFT		6
1898c2ecf20Sopenharmony_ci#define MFC_ADDR_MASK		(UINT64_CAST 0x3ffffff)
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_ci/* MD_MLAN_CTL fields */
1928c2ecf20Sopenharmony_ci
1938c2ecf20Sopenharmony_ci#define MLAN_PHI1_SHFT		27
1948c2ecf20Sopenharmony_ci#define MLAN_PHI1_MASK		(UINT64_CAST 0x7f << 27)
1958c2ecf20Sopenharmony_ci#define MLAN_PHI0_SHFT		20
1968c2ecf20Sopenharmony_ci#define MLAN_PHI0_MASK		(UINT64_CAST 0x7f << 27)
1978c2ecf20Sopenharmony_ci#define MLAN_PULSE_SHFT		10
1988c2ecf20Sopenharmony_ci#define MLAN_PULSE_MASK		(UINT64_CAST 0x3ff << 10)
1998c2ecf20Sopenharmony_ci#define MLAN_SAMPLE_SHFT	2
2008c2ecf20Sopenharmony_ci#define MLAN_SAMPLE_MASK	(UINT64_CAST 0xff << 2)
2018c2ecf20Sopenharmony_ci#define MLAN_DONE_SHFT		1
2028c2ecf20Sopenharmony_ci#define MLAN_DONE_MASK		2
2038c2ecf20Sopenharmony_ci#define MLAN_DONE		(UINT64_CAST 0x02)
2048c2ecf20Sopenharmony_ci#define MLAN_RD_DATA		(UINT64_CAST 0x01)
2058c2ecf20Sopenharmony_ci#define MLAN_RESET_DEFAULTS	(UINT64_CAST 0x31 << MLAN_PHI1_SHFT | \
2068c2ecf20Sopenharmony_ci				 UINT64_CAST 0x31 << MLAN_PHI0_SHFT)
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_ci/* MD_SLOTID_USTAT bit definitions */
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_ci#define MSU_CORECLK_TST_SHFT	7	/* You don't wanna know		    */
2118c2ecf20Sopenharmony_ci#define MSU_CORECLK_TST_MASK	(UINT64_CAST 1 << 7)
2128c2ecf20Sopenharmony_ci#define MSU_CORECLK_TST		(UINT64_CAST 1 << 7)
2138c2ecf20Sopenharmony_ci#define MSU_CORECLK_SHFT	6	/* You don't wanna know		    */
2148c2ecf20Sopenharmony_ci#define MSU_CORECLK_MASK	(UINT64_CAST 1 << 6)
2158c2ecf20Sopenharmony_ci#define MSU_CORECLK		(UINT64_CAST 1 << 6)
2168c2ecf20Sopenharmony_ci#define MSU_NETSYNC_SHFT	5	/* You don't wanna know		    */
2178c2ecf20Sopenharmony_ci#define MSU_NETSYNC_MASK	(UINT64_CAST 1 << 5)
2188c2ecf20Sopenharmony_ci#define MSU_NETSYNC		(UINT64_CAST 1 << 5)
2198c2ecf20Sopenharmony_ci#define MSU_FPROMRDY_SHFT	4	/* Flash PROM ready bit		    */
2208c2ecf20Sopenharmony_ci#define MSU_FPROMRDY_MASK	(UINT64_CAST 1 << 4)
2218c2ecf20Sopenharmony_ci#define MSU_FPROMRDY		(UINT64_CAST 1 << 4)
2228c2ecf20Sopenharmony_ci#define MSU_I2CINTR_SHFT		3	/* I2C interrupt bit   */
2238c2ecf20Sopenharmony_ci#define MSU_I2CINTR_MASK		(UINT64_CAST 1 << 3)
2248c2ecf20Sopenharmony_ci#define MSU_I2CINTR		(UINT64_CAST 1 << 3)
2258c2ecf20Sopenharmony_ci#define MSU_SLOTID_MASK		0xff
2268c2ecf20Sopenharmony_ci#define MSU_SN0_SLOTID_SHFT	0	/* Slot ID			    */
2278c2ecf20Sopenharmony_ci#define MSU_SN0_SLOTID_MASK	(UINT64_CAST 7)
2288c2ecf20Sopenharmony_ci#define MSU_SN00_SLOTID_SHFT	7
2298c2ecf20Sopenharmony_ci#define MSU_SN00_SLOTID_MASK	(UINT64_CAST 0x80)
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_ci#define MSU_PIMM_PSC_SHFT	4
2328c2ecf20Sopenharmony_ci#define MSU_PIMM_PSC_MASK	(0xf << MSU_PIMM_PSC_SHFT)
2338c2ecf20Sopenharmony_ci
2348c2ecf20Sopenharmony_ci/* MD_MIG_DIFF_THRESH bit definitions */
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_ci#define MD_MIG_DIFF_THRES_VALID_MASK (UINT64_CAST 0x1 << 63)
2378c2ecf20Sopenharmony_ci#define MD_MIG_DIFF_THRES_VALID_SHFT 63
2388c2ecf20Sopenharmony_ci#define MD_MIG_DIFF_THRES_VALUE_MASK (UINT64_CAST 0xfffff)
2398c2ecf20Sopenharmony_ci
2408c2ecf20Sopenharmony_ci/* MD_MIG_VALUE_THRESH bit definitions */
2418c2ecf20Sopenharmony_ci
2428c2ecf20Sopenharmony_ci#define MD_MIG_VALUE_THRES_VALID_MASK (UINT64_CAST 0x1 << 63)
2438c2ecf20Sopenharmony_ci#define MD_MIG_VALUE_THRES_VALID_SHFT 63
2448c2ecf20Sopenharmony_ci#define MD_MIG_VALUE_THRES_VALUE_MASK (UINT64_CAST 0xfffff)
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_ci/* MD_MIG_CANDIDATE bit definitions */
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_ci#define MD_MIG_CANDIDATE_VALID_MASK (UINT64_CAST 0x1 << 63)
2498c2ecf20Sopenharmony_ci#define MD_MIG_CANDIDATE_VALID_SHFT 63
2508c2ecf20Sopenharmony_ci#define MD_MIG_CANDIDATE_TYPE_MASK (UINT64_CAST 0x1 << 30)
2518c2ecf20Sopenharmony_ci#define MD_MIG_CANDIDATE_TYPE_SHFT 30
2528c2ecf20Sopenharmony_ci#define MD_MIG_CANDIDATE_OVERRUN_MASK (UINT64_CAST 0x1 << 29)
2538c2ecf20Sopenharmony_ci#define MD_MIG_CANDIDATE_OVERRUN_SHFT 29
2548c2ecf20Sopenharmony_ci#define MD_MIG_CANDIDATE_INITIATOR_MASK (UINT64_CAST 0x7ff << 18)
2558c2ecf20Sopenharmony_ci#define MD_MIG_CANDIDATE_INITIATOR_SHFT 18
2568c2ecf20Sopenharmony_ci#define MD_MIG_CANDIDATE_NODEID_MASK (UINT64_CAST 0x1ff << 20)
2578c2ecf20Sopenharmony_ci#define MD_MIG_CANDIDATE_NODEID_SHFT 20
2588c2ecf20Sopenharmony_ci#define MD_MIG_CANDIDATE_ADDR_MASK (UINT64_CAST 0x3ffff)
2598c2ecf20Sopenharmony_ci#define MD_MIG_CANDIDATE_ADDR_SHFT 14  /* The address starts at bit 14 */
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_ci/* Other MD definitions */
2628c2ecf20Sopenharmony_ci
2638c2ecf20Sopenharmony_ci#define MD_BANK_SHFT		29			/* log2(512 MB)	    */
2648c2ecf20Sopenharmony_ci#define MD_BANK_MASK		(UINT64_CAST 7 << 29)
2658c2ecf20Sopenharmony_ci#define MD_BANK_SIZE		(UINT64_CAST 1 << MD_BANK_SHFT)	  /* 512 MB */
2668c2ecf20Sopenharmony_ci#define MD_BANK_OFFSET(_b)	(UINT64_CAST (_b) << MD_BANK_SHFT)
2678c2ecf20Sopenharmony_ci
2688c2ecf20Sopenharmony_ci/*
2698c2ecf20Sopenharmony_ci * The following definitions cover the bit field definitions for the
2708c2ecf20Sopenharmony_ci * various MD registers.  For multi-bit registers, we define both
2718c2ecf20Sopenharmony_ci * a shift amount and a mask value.  By convention, if you want to
2728c2ecf20Sopenharmony_ci * isolate a field, you should mask the field and then shift it down,
2738c2ecf20Sopenharmony_ci * since this makes the masks useful without a shift.
2748c2ecf20Sopenharmony_ci */
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ci/* Directory entry states for both premium and standard SIMMs. */
2778c2ecf20Sopenharmony_ci
2788c2ecf20Sopenharmony_ci#define MD_DIR_SHARED		(UINT64_CAST 0x0)	/* 000 */
2798c2ecf20Sopenharmony_ci#define MD_DIR_POISONED		(UINT64_CAST 0x1)	/* 001 */
2808c2ecf20Sopenharmony_ci#define MD_DIR_EXCLUSIVE	(UINT64_CAST 0x2)	/* 010 */
2818c2ecf20Sopenharmony_ci#define MD_DIR_BUSY_SHARED	(UINT64_CAST 0x3)	/* 011 */
2828c2ecf20Sopenharmony_ci#define MD_DIR_BUSY_EXCL	(UINT64_CAST 0x4)	/* 100 */
2838c2ecf20Sopenharmony_ci#define MD_DIR_WAIT		(UINT64_CAST 0x5)	/* 101 */
2848c2ecf20Sopenharmony_ci#define MD_DIR_UNOWNED		(UINT64_CAST 0x7)	/* 111 */
2858c2ecf20Sopenharmony_ci
2868c2ecf20Sopenharmony_ci/*
2878c2ecf20Sopenharmony_ci * The MD_DIR_FORCE_ECC bit can be added directory entry write data
2888c2ecf20Sopenharmony_ci * to forcing the ECC to be written as-is instead of recalculated.
2898c2ecf20Sopenharmony_ci */
2908c2ecf20Sopenharmony_ci
2918c2ecf20Sopenharmony_ci#define MD_DIR_FORCE_ECC	(UINT64_CAST 1 << 63)
2928c2ecf20Sopenharmony_ci
2938c2ecf20Sopenharmony_ci/*
2948c2ecf20Sopenharmony_ci * Premium SIMM directory entry shifts and masks.  Each is valid only in the
2958c2ecf20Sopenharmony_ci * context(s) indicated, where A, B, and C indicate the directory entry format
2968c2ecf20Sopenharmony_ci * as shown, and low and/or high indicates which double-word of the entry.
2978c2ecf20Sopenharmony_ci *
2988c2ecf20Sopenharmony_ci * Format A:  STATE = shared, FINE = 1
2998c2ecf20Sopenharmony_ci * Format B:  STATE = shared, FINE = 0
3008c2ecf20Sopenharmony_ci * Format C:  STATE != shared (FINE must be 0)
3018c2ecf20Sopenharmony_ci */
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_ci#define MD_PDIR_MASK		0xffffffffffff		/* Whole entry	    */
3048c2ecf20Sopenharmony_ci#define MD_PDIR_ECC_SHFT	0			/* ABC low or high  */
3058c2ecf20Sopenharmony_ci#define MD_PDIR_ECC_MASK	0x7f
3068c2ecf20Sopenharmony_ci#define MD_PDIR_PRIO_SHFT	8			/* ABC low	    */
3078c2ecf20Sopenharmony_ci#define MD_PDIR_PRIO_MASK	(0xf << 8)
3088c2ecf20Sopenharmony_ci#define MD_PDIR_AX_SHFT		7			/* ABC low	    */
3098c2ecf20Sopenharmony_ci#define MD_PDIR_AX_MASK		(1 << 7)
3108c2ecf20Sopenharmony_ci#define MD_PDIR_AX		(1 << 7)
3118c2ecf20Sopenharmony_ci#define MD_PDIR_FINE_SHFT	12			/* ABC low	    */
3128c2ecf20Sopenharmony_ci#define MD_PDIR_FINE_MASK	(1 << 12)
3138c2ecf20Sopenharmony_ci#define MD_PDIR_FINE		(1 << 12)
3148c2ecf20Sopenharmony_ci#define MD_PDIR_OCT_SHFT	13			/* A low	    */
3158c2ecf20Sopenharmony_ci#define MD_PDIR_OCT_MASK	(7 << 13)
3168c2ecf20Sopenharmony_ci#define MD_PDIR_STATE_SHFT	13			/* BC low	    */
3178c2ecf20Sopenharmony_ci#define MD_PDIR_STATE_MASK	(7 << 13)
3188c2ecf20Sopenharmony_ci#define MD_PDIR_ONECNT_SHFT	16			/* BC low	    */
3198c2ecf20Sopenharmony_ci#define MD_PDIR_ONECNT_MASK	(0x3f << 16)
3208c2ecf20Sopenharmony_ci#define MD_PDIR_PTR_SHFT	22			/* C low	    */
3218c2ecf20Sopenharmony_ci#define MD_PDIR_PTR_MASK	(UINT64_CAST 0x7ff << 22)
3228c2ecf20Sopenharmony_ci#define MD_PDIR_VECMSB_SHFT	22			/* AB low	    */
3238c2ecf20Sopenharmony_ci#define MD_PDIR_VECMSB_BITMASK	0x3ffffff
3248c2ecf20Sopenharmony_ci#define MD_PDIR_VECMSB_BITSHFT	27
3258c2ecf20Sopenharmony_ci#define MD_PDIR_VECMSB_MASK	(UINT64_CAST MD_PDIR_VECMSB_BITMASK << 22)
3268c2ecf20Sopenharmony_ci#define MD_PDIR_CWOFF_SHFT	7			/* C high	    */
3278c2ecf20Sopenharmony_ci#define MD_PDIR_CWOFF_MASK	(7 << 7)
3288c2ecf20Sopenharmony_ci#define MD_PDIR_VECLSB_SHFT	10			/* AB high	    */
3298c2ecf20Sopenharmony_ci#define MD_PDIR_VECLSB_BITMASK	(UINT64_CAST 0x3fffffffff)
3308c2ecf20Sopenharmony_ci#define MD_PDIR_VECLSB_BITSHFT	0
3318c2ecf20Sopenharmony_ci#define MD_PDIR_VECLSB_MASK	(MD_PDIR_VECLSB_BITMASK << 10)
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_ci/*
3348c2ecf20Sopenharmony_ci * Directory initialization values
3358c2ecf20Sopenharmony_ci */
3368c2ecf20Sopenharmony_ci
3378c2ecf20Sopenharmony_ci#define MD_PDIR_INIT_LO		(MD_DIR_UNOWNED << MD_PDIR_STATE_SHFT | \
3388c2ecf20Sopenharmony_ci				 MD_PDIR_AX)
3398c2ecf20Sopenharmony_ci#define MD_PDIR_INIT_HI		0
3408c2ecf20Sopenharmony_ci#define MD_PDIR_INIT_PROT	(MD_PROT_RW << MD_PPROT_IO_SHFT | \
3418c2ecf20Sopenharmony_ci				 MD_PROT_RW << MD_PPROT_SHFT)
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_ci/*
3448c2ecf20Sopenharmony_ci * Standard SIMM directory entry shifts and masks.  Each is valid only in the
3458c2ecf20Sopenharmony_ci * context(s) indicated, where A and C indicate the directory entry format
3468c2ecf20Sopenharmony_ci * as shown, and low and/or high indicates which double-word of the entry.
3478c2ecf20Sopenharmony_ci *
3488c2ecf20Sopenharmony_ci * Format A:  STATE == shared
3498c2ecf20Sopenharmony_ci * Format C:  STATE != shared
3508c2ecf20Sopenharmony_ci */
3518c2ecf20Sopenharmony_ci
3528c2ecf20Sopenharmony_ci#define MD_SDIR_MASK		0xffff			/* Whole entry	    */
3538c2ecf20Sopenharmony_ci#define MD_SDIR_ECC_SHFT	0			/* AC low or high   */
3548c2ecf20Sopenharmony_ci#define MD_SDIR_ECC_MASK	0x1f
3558c2ecf20Sopenharmony_ci#define MD_SDIR_PRIO_SHFT	6			/* AC low	    */
3568c2ecf20Sopenharmony_ci#define MD_SDIR_PRIO_MASK	(1 << 6)
3578c2ecf20Sopenharmony_ci#define MD_SDIR_AX_SHFT		5			/* AC low	    */
3588c2ecf20Sopenharmony_ci#define MD_SDIR_AX_MASK		(1 << 5)
3598c2ecf20Sopenharmony_ci#define MD_SDIR_AX		(1 << 5)
3608c2ecf20Sopenharmony_ci#define MD_SDIR_STATE_SHFT	7			/* AC low	    */
3618c2ecf20Sopenharmony_ci#define MD_SDIR_STATE_MASK	(7 << 7)
3628c2ecf20Sopenharmony_ci#define MD_SDIR_PTR_SHFT	10			/* C low	    */
3638c2ecf20Sopenharmony_ci#define MD_SDIR_PTR_MASK	(0x3f << 10)
3648c2ecf20Sopenharmony_ci#define MD_SDIR_CWOFF_SHFT	5			/* C high	    */
3658c2ecf20Sopenharmony_ci#define MD_SDIR_CWOFF_MASK	(7 << 5)
3668c2ecf20Sopenharmony_ci#define MD_SDIR_VECMSB_SHFT	11			/* A low	    */
3678c2ecf20Sopenharmony_ci#define MD_SDIR_VECMSB_BITMASK	0x1f
3688c2ecf20Sopenharmony_ci#define MD_SDIR_VECMSB_BITSHFT	7
3698c2ecf20Sopenharmony_ci#define MD_SDIR_VECMSB_MASK	(MD_SDIR_VECMSB_BITMASK << 11)
3708c2ecf20Sopenharmony_ci#define MD_SDIR_VECLSB_SHFT	5			/* A high	    */
3718c2ecf20Sopenharmony_ci#define MD_SDIR_VECLSB_BITMASK	0x7ff
3728c2ecf20Sopenharmony_ci#define MD_SDIR_VECLSB_BITSHFT	0
3738c2ecf20Sopenharmony_ci#define MD_SDIR_VECLSB_MASK	(MD_SDIR_VECLSB_BITMASK << 5)
3748c2ecf20Sopenharmony_ci
3758c2ecf20Sopenharmony_ci/*
3768c2ecf20Sopenharmony_ci * Directory initialization values
3778c2ecf20Sopenharmony_ci */
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_ci#define MD_SDIR_INIT_LO		(MD_DIR_UNOWNED << MD_SDIR_STATE_SHFT | \
3808c2ecf20Sopenharmony_ci				 MD_SDIR_AX)
3818c2ecf20Sopenharmony_ci#define MD_SDIR_INIT_HI		0
3828c2ecf20Sopenharmony_ci#define MD_SDIR_INIT_PROT	(MD_PROT_RW << MD_SPROT_SHFT)
3838c2ecf20Sopenharmony_ci
3848c2ecf20Sopenharmony_ci/* Protection and migration field values */
3858c2ecf20Sopenharmony_ci
3868c2ecf20Sopenharmony_ci#define MD_PROT_RW		(UINT64_CAST 0x6)
3878c2ecf20Sopenharmony_ci#define MD_PROT_RO		(UINT64_CAST 0x3)
3888c2ecf20Sopenharmony_ci#define MD_PROT_NO		(UINT64_CAST 0x0)
3898c2ecf20Sopenharmony_ci#define MD_PROT_BAD		(UINT64_CAST 0x5)
3908c2ecf20Sopenharmony_ci
3918c2ecf20Sopenharmony_ci/* Premium SIMM protection entry shifts and masks. */
3928c2ecf20Sopenharmony_ci
3938c2ecf20Sopenharmony_ci#define MD_PPROT_SHFT		0			/* Prot. field	    */
3948c2ecf20Sopenharmony_ci#define MD_PPROT_MASK		7
3958c2ecf20Sopenharmony_ci#define MD_PPROT_MIGMD_SHFT	3			/* Migration mode   */
3968c2ecf20Sopenharmony_ci#define MD_PPROT_MIGMD_MASK	(3 << 3)
3978c2ecf20Sopenharmony_ci#define MD_PPROT_REFCNT_SHFT	5			/* Reference count  */
3988c2ecf20Sopenharmony_ci#define MD_PPROT_REFCNT_WIDTH	0x7ffff
3998c2ecf20Sopenharmony_ci#define MD_PPROT_REFCNT_MASK	(MD_PPROT_REFCNT_WIDTH << 5)
4008c2ecf20Sopenharmony_ci
4018c2ecf20Sopenharmony_ci#define MD_PPROT_IO_SHFT	45			/* I/O Prot field   */
4028c2ecf20Sopenharmony_ci#define MD_PPROT_IO_MASK	(UINT64_CAST 7 << 45)
4038c2ecf20Sopenharmony_ci
4048c2ecf20Sopenharmony_ci/* Standard SIMM protection entry shifts and masks. */
4058c2ecf20Sopenharmony_ci
4068c2ecf20Sopenharmony_ci#define MD_SPROT_SHFT		0			/* Prot. field	    */
4078c2ecf20Sopenharmony_ci#define MD_SPROT_MASK		7
4088c2ecf20Sopenharmony_ci#define MD_SPROT_MIGMD_SHFT	3			/* Migration mode   */
4098c2ecf20Sopenharmony_ci#define MD_SPROT_MIGMD_MASK	(3 << 3)
4108c2ecf20Sopenharmony_ci#define MD_SPROT_REFCNT_SHFT	5			/* Reference count  */
4118c2ecf20Sopenharmony_ci#define MD_SPROT_REFCNT_WIDTH	0x7ff
4128c2ecf20Sopenharmony_ci#define MD_SPROT_REFCNT_MASK	(MD_SPROT_REFCNT_WIDTH << 5)
4138c2ecf20Sopenharmony_ci
4148c2ecf20Sopenharmony_ci/* Migration modes used in protection entries */
4158c2ecf20Sopenharmony_ci
4168c2ecf20Sopenharmony_ci#define MD_PROT_MIGMD_IREL	(UINT64_CAST 0x3 << 3)
4178c2ecf20Sopenharmony_ci#define MD_PROT_MIGMD_IABS	(UINT64_CAST 0x2 << 3)
4188c2ecf20Sopenharmony_ci#define MD_PROT_MIGMD_PREL	(UINT64_CAST 0x1 << 3)
4198c2ecf20Sopenharmony_ci#define MD_PROT_MIGMD_OFF	(UINT64_CAST 0x0 << 3)
4208c2ecf20Sopenharmony_ci
4218c2ecf20Sopenharmony_ci
4228c2ecf20Sopenharmony_ci/*
4238c2ecf20Sopenharmony_ci * Operations on page migration threshold register
4248c2ecf20Sopenharmony_ci */
4258c2ecf20Sopenharmony_ci
4268c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
4278c2ecf20Sopenharmony_ci
4288c2ecf20Sopenharmony_ci/*
4298c2ecf20Sopenharmony_ci * LED register macros
4308c2ecf20Sopenharmony_ci */
4318c2ecf20Sopenharmony_ci
4328c2ecf20Sopenharmony_ci#define CPU_LED_ADDR(_nasid, _slice)					   \
4338c2ecf20Sopenharmony_ci	(private.p_sn00 ?						   \
4348c2ecf20Sopenharmony_ci	 REMOTE_HUB_ADDR((_nasid), MD_UREG1_0 + ((_slice) << 5)) :	   \
4358c2ecf20Sopenharmony_ci	 REMOTE_HUB_ADDR((_nasid), MD_LED0    + ((_slice) << 3)))
4368c2ecf20Sopenharmony_ci
4378c2ecf20Sopenharmony_ci#define SET_CPU_LEDS(_nasid, _slice,  _val)				   \
4388c2ecf20Sopenharmony_ci	(HUB_S(CPU_LED_ADDR(_nasid, _slice), (_val)))
4398c2ecf20Sopenharmony_ci
4408c2ecf20Sopenharmony_ci#define SET_MY_LEDS(_v)							   \
4418c2ecf20Sopenharmony_ci	SET_CPU_LEDS(get_nasid(), get_slice(), (_v))
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_ci/*
4448c2ecf20Sopenharmony_ci * Operations on Memory/Directory DIMM control register
4458c2ecf20Sopenharmony_ci */
4468c2ecf20Sopenharmony_ci
4478c2ecf20Sopenharmony_ci#define DIRTYPE_PREMIUM 1
4488c2ecf20Sopenharmony_ci#define DIRTYPE_STANDARD 0
4498c2ecf20Sopenharmony_ci#define MD_MEMORY_CONFIG_DIR_TYPE_GET(region) (\
4508c2ecf20Sopenharmony_ci	(REMOTE_HUB_L(region, MD_MEMORY_CONFIG) & MMC_DIR_PREMIUM_MASK) >> \
4518c2ecf20Sopenharmony_ci	MMC_DIR_PREMIUM_SHFT)
4528c2ecf20Sopenharmony_ci
4538c2ecf20Sopenharmony_ci
4548c2ecf20Sopenharmony_ci/*
4558c2ecf20Sopenharmony_ci * Operations on page migration count difference and absolute threshold
4568c2ecf20Sopenharmony_ci * registers
4578c2ecf20Sopenharmony_ci */
4588c2ecf20Sopenharmony_ci
4598c2ecf20Sopenharmony_ci#define MD_MIG_DIFF_THRESH_GET(region) ( \
4608c2ecf20Sopenharmony_ci	REMOTE_HUB_L((region), MD_MIG_DIFF_THRESH) & \
4618c2ecf20Sopenharmony_ci	MD_MIG_DIFF_THRES_VALUE_MASK)
4628c2ecf20Sopenharmony_ci
4638c2ecf20Sopenharmony_ci#define MD_MIG_DIFF_THRESH_SET(region, value) (				\
4648c2ecf20Sopenharmony_ci	REMOTE_HUB_S((region), MD_MIG_DIFF_THRESH,			\
4658c2ecf20Sopenharmony_ci		MD_MIG_DIFF_THRES_VALID_MASK | (value)))
4668c2ecf20Sopenharmony_ci
4678c2ecf20Sopenharmony_ci#define MD_MIG_DIFF_THRESH_DISABLE(region) (			\
4688c2ecf20Sopenharmony_ci	REMOTE_HUB_S((region), MD_MIG_DIFF_THRESH,			\
4698c2ecf20Sopenharmony_ci		REMOTE_HUB_L((region), MD_MIG_DIFF_THRESH)		\
4708c2ecf20Sopenharmony_ci			     & ~MD_MIG_DIFF_THRES_VALID_MASK))
4718c2ecf20Sopenharmony_ci
4728c2ecf20Sopenharmony_ci#define MD_MIG_DIFF_THRESH_ENABLE(region) (			\
4738c2ecf20Sopenharmony_ci	REMOTE_HUB_S((region), MD_MIG_DIFF_THRESH,			\
4748c2ecf20Sopenharmony_ci		REMOTE_HUB_L((region), MD_MIG_DIFF_THRESH)		\
4758c2ecf20Sopenharmony_ci			     | MD_MIG_DIFF_THRES_VALID_MASK))
4768c2ecf20Sopenharmony_ci
4778c2ecf20Sopenharmony_ci#define MD_MIG_DIFF_THRESH_IS_ENABLED(region) (				\
4788c2ecf20Sopenharmony_ci	REMOTE_HUB_L((region), MD_MIG_DIFF_THRESH) &			\
4798c2ecf20Sopenharmony_ci	       MD_MIG_DIFF_THRES_VALID_MASK)
4808c2ecf20Sopenharmony_ci
4818c2ecf20Sopenharmony_ci#define MD_MIG_VALUE_THRESH_GET(region) (				\
4828c2ecf20Sopenharmony_ci	REMOTE_HUB_L((region), MD_MIG_VALUE_THRESH) &  \
4838c2ecf20Sopenharmony_ci	MD_MIG_VALUE_THRES_VALUE_MASK)
4848c2ecf20Sopenharmony_ci
4858c2ecf20Sopenharmony_ci#define MD_MIG_VALUE_THRESH_SET(region, value) (			\
4868c2ecf20Sopenharmony_ci	REMOTE_HUB_S((region), MD_MIG_VALUE_THRESH,			\
4878c2ecf20Sopenharmony_ci		MD_MIG_VALUE_THRES_VALID_MASK | (value)))
4888c2ecf20Sopenharmony_ci
4898c2ecf20Sopenharmony_ci#define MD_MIG_VALUE_THRESH_DISABLE(region) (			\
4908c2ecf20Sopenharmony_ci	REMOTE_HUB_S((region), MD_MIG_VALUE_THRESH,			\
4918c2ecf20Sopenharmony_ci		REMOTE_HUB_L(region, MD_MIG_VALUE_THRESH)		\
4928c2ecf20Sopenharmony_ci			     & ~MD_MIG_VALUE_THRES_VALID_MASK))
4938c2ecf20Sopenharmony_ci
4948c2ecf20Sopenharmony_ci#define MD_MIG_VALUE_THRESH_ENABLE(region) (			\
4958c2ecf20Sopenharmony_ci	REMOTE_HUB_S((region), MD_MIG_VALUE_THRESH,			\
4968c2ecf20Sopenharmony_ci		REMOTE_HUB_L((region), MD_MIG_VALUE_THRESH)		\
4978c2ecf20Sopenharmony_ci			     | MD_MIG_VALUE_THRES_VALID_MASK))
4988c2ecf20Sopenharmony_ci
4998c2ecf20Sopenharmony_ci#define MD_MIG_VALUE_THRESH_IS_ENABLED(region) (			\
5008c2ecf20Sopenharmony_ci	REMOTE_HUB_L((region), MD_MIG_VALUE_THRESH) &			 \
5018c2ecf20Sopenharmony_ci	       MD_MIG_VALUE_THRES_VALID_MASK)
5028c2ecf20Sopenharmony_ci
5038c2ecf20Sopenharmony_ci/*
5048c2ecf20Sopenharmony_ci * Operations on page migration candidate register
5058c2ecf20Sopenharmony_ci */
5068c2ecf20Sopenharmony_ci
5078c2ecf20Sopenharmony_ci#define MD_MIG_CANDIDATE_GET(my_region_id) ( \
5088c2ecf20Sopenharmony_ci	REMOTE_HUB_L((my_region_id), MD_MIG_CANDIDATE_CLR))
5098c2ecf20Sopenharmony_ci
5108c2ecf20Sopenharmony_ci#define MD_MIG_CANDIDATE_HWPFN(value) ((value) & MD_MIG_CANDIDATE_ADDR_MASK)
5118c2ecf20Sopenharmony_ci
5128c2ecf20Sopenharmony_ci#define MD_MIG_CANDIDATE_NODEID(value) ( \
5138c2ecf20Sopenharmony_ci	((value) & MD_MIG_CANDIDATE_NODEID_MASK) >> MD_MIG_CANDIDATE_NODEID_SHFT)
5148c2ecf20Sopenharmony_ci
5158c2ecf20Sopenharmony_ci#define MD_MIG_CANDIDATE_TYPE(value) ( \
5168c2ecf20Sopenharmony_ci	((value) & MD_MIG_CANDIDATE_TYPE_MASK) >> MD_MIG_CANDIDATE_TYPE_SHFT)
5178c2ecf20Sopenharmony_ci
5188c2ecf20Sopenharmony_ci#define MD_MIG_CANDIDATE_VALID(value) ( \
5198c2ecf20Sopenharmony_ci	((value) & MD_MIG_CANDIDATE_VALID_MASK) >> MD_MIG_CANDIDATE_VALID_SHFT)
5208c2ecf20Sopenharmony_ci
5218c2ecf20Sopenharmony_ci/*
5228c2ecf20Sopenharmony_ci * Macros to retrieve fields in the protection entry
5238c2ecf20Sopenharmony_ci */
5248c2ecf20Sopenharmony_ci
5258c2ecf20Sopenharmony_ci/* for Premium SIMM */
5268c2ecf20Sopenharmony_ci#define MD_PPROT_REFCNT_GET(value) ( \
5278c2ecf20Sopenharmony_ci	((value) & MD_PPROT_REFCNT_MASK) >> MD_PPROT_REFCNT_SHFT)
5288c2ecf20Sopenharmony_ci
5298c2ecf20Sopenharmony_ci#define MD_PPROT_MIGMD_GET(value) ( \
5308c2ecf20Sopenharmony_ci	((value) & MD_PPROT_MIGMD_MASK) >> MD_PPROT_MIGMD_SHFT)
5318c2ecf20Sopenharmony_ci
5328c2ecf20Sopenharmony_ci/* for Standard SIMM */
5338c2ecf20Sopenharmony_ci#define MD_SPROT_REFCNT_GET(value) ( \
5348c2ecf20Sopenharmony_ci	((value) & MD_SPROT_REFCNT_MASK) >> MD_SPROT_REFCNT_SHFT)
5358c2ecf20Sopenharmony_ci
5368c2ecf20Sopenharmony_ci#define MD_SPROT_MIGMD_GET(value) ( \
5378c2ecf20Sopenharmony_ci	((value) & MD_SPROT_MIGMD_MASK) >> MD_SPROT_MIGMD_SHFT)
5388c2ecf20Sopenharmony_ci
5398c2ecf20Sopenharmony_ci/*
5408c2ecf20Sopenharmony_ci * Format of dir_error, mem_error, protocol_error and misc_error registers
5418c2ecf20Sopenharmony_ci */
5428c2ecf20Sopenharmony_ci
5438c2ecf20Sopenharmony_cistruct dir_error_reg {
5448c2ecf20Sopenharmony_ci	u64	uce_vld:   1,	/*    63: valid directory uce	*/
5458c2ecf20Sopenharmony_ci		ae_vld:	   1,	/*    62: valid dir prot ecc error */
5468c2ecf20Sopenharmony_ci		ce_vld:	   1,	/*    61: valid correctable ECC err*/
5478c2ecf20Sopenharmony_ci		rsvd1:	  19,	/* 60-42: reserved		*/
5488c2ecf20Sopenharmony_ci		bad_prot:  3,	/* 41-39: encoding, bad access rights*/
5498c2ecf20Sopenharmony_ci		bad_syn:   7,	/* 38-32: bad dir syndrome	*/
5508c2ecf20Sopenharmony_ci		rsvd2:	   2,	/* 31-30: reserved		*/
5518c2ecf20Sopenharmony_ci		hspec_addr:27,	/* 29-03: bddir space bad entry */
5528c2ecf20Sopenharmony_ci		uce_ovr:   1,	/*     2: multiple dir uce's	*/
5538c2ecf20Sopenharmony_ci		ae_ovr:	   1,	/*     1: multiple prot ecc errs*/
5548c2ecf20Sopenharmony_ci		ce_ovr:	   1;	/*     0: multiple correctable errs */
5558c2ecf20Sopenharmony_ci};
5568c2ecf20Sopenharmony_ci
5578c2ecf20Sopenharmony_citypedef union md_dir_error {
5588c2ecf20Sopenharmony_ci	u64	derr_reg;	/* the entire register		*/
5598c2ecf20Sopenharmony_ci	struct dir_error_reg derr_fmt;	/* the register format		*/
5608c2ecf20Sopenharmony_ci} md_dir_error_t;
5618c2ecf20Sopenharmony_ci
5628c2ecf20Sopenharmony_ci
5638c2ecf20Sopenharmony_cistruct mem_error_reg {
5648c2ecf20Sopenharmony_ci	u64	uce_vld:   1,	/*    63: valid memory uce	*/
5658c2ecf20Sopenharmony_ci		ce_vld:	   1,	/*    62: valid correctable ECC err*/
5668c2ecf20Sopenharmony_ci		rsvd1:	  22,	/* 61-40: reserved		*/
5678c2ecf20Sopenharmony_ci		bad_syn:   8,	/* 39-32: bad mem ecc syndrome	*/
5688c2ecf20Sopenharmony_ci		address:  29,	/* 31-03: bad entry pointer	*/
5698c2ecf20Sopenharmony_ci		rsvd2:	   1,	/*     2: reserved		*/
5708c2ecf20Sopenharmony_ci		uce_ovr:   1,	/*     1: multiple mem uce's	*/
5718c2ecf20Sopenharmony_ci		ce_ovr:	   1;	/*     0: multiple correctable errs */
5728c2ecf20Sopenharmony_ci};
5738c2ecf20Sopenharmony_ci
5748c2ecf20Sopenharmony_ci
5758c2ecf20Sopenharmony_citypedef union md_mem_error {
5768c2ecf20Sopenharmony_ci	u64	merr_reg;	/* the entire register		*/
5778c2ecf20Sopenharmony_ci	struct mem_error_reg  merr_fmt; /* format of the mem_error reg	*/
5788c2ecf20Sopenharmony_ci} md_mem_error_t;
5798c2ecf20Sopenharmony_ci
5808c2ecf20Sopenharmony_ci
5818c2ecf20Sopenharmony_cistruct proto_error_reg {
5828c2ecf20Sopenharmony_ci	u64	valid:	   1,	/*    63: valid protocol error	*/
5838c2ecf20Sopenharmony_ci		rsvd1:	   2,	/* 62-61: reserved		*/
5848c2ecf20Sopenharmony_ci		initiator:11,	/* 60-50: id of request initiator*/
5858c2ecf20Sopenharmony_ci		backoff:   2,	/* 49-48: backoff control	*/
5868c2ecf20Sopenharmony_ci		msg_type:  8,	/* 47-40: type of request	*/
5878c2ecf20Sopenharmony_ci		access:	   2,	/* 39-38: access rights of initiator*/
5888c2ecf20Sopenharmony_ci		priority:  1,	/*    37: priority level of requestor*/
5898c2ecf20Sopenharmony_ci		dir_state: 4,	/* 36-33: state of directory	*/
5908c2ecf20Sopenharmony_ci		pointer_me:1,	/*    32: initiator same as dir ptr */
5918c2ecf20Sopenharmony_ci		address:  29,	/* 31-03: request address	*/
5928c2ecf20Sopenharmony_ci		rsvd2:	   2,	/* 02-01: reserved		*/
5938c2ecf20Sopenharmony_ci		overrun:   1;	/*     0: multiple protocol errs */
5948c2ecf20Sopenharmony_ci};
5958c2ecf20Sopenharmony_ci
5968c2ecf20Sopenharmony_citypedef union md_proto_error {
5978c2ecf20Sopenharmony_ci	u64	perr_reg;	/* the entire register		*/
5988c2ecf20Sopenharmony_ci	struct proto_error_reg	perr_fmt; /* format of the register	*/
5998c2ecf20Sopenharmony_ci} md_proto_error_t;
6008c2ecf20Sopenharmony_ci
6018c2ecf20Sopenharmony_ci
6028c2ecf20Sopenharmony_cistruct md_sdir_high_fmt {
6038c2ecf20Sopenharmony_ci	unsigned short sd_hi_bvec : 11,
6048c2ecf20Sopenharmony_ci		       sd_hi_ecc  : 5;
6058c2ecf20Sopenharmony_ci};
6068c2ecf20Sopenharmony_ci
6078c2ecf20Sopenharmony_ci
6088c2ecf20Sopenharmony_citypedef union md_sdir_high {
6098c2ecf20Sopenharmony_ci	/* The 16 bits of standard directory, upper word */
6108c2ecf20Sopenharmony_ci	unsigned short sd_hi_val;
6118c2ecf20Sopenharmony_ci	struct	md_sdir_high_fmt sd_hi_fmt;
6128c2ecf20Sopenharmony_ci}md_sdir_high_t;
6138c2ecf20Sopenharmony_ci
6148c2ecf20Sopenharmony_ci
6158c2ecf20Sopenharmony_cistruct md_sdir_low_shared_fmt {
6168c2ecf20Sopenharmony_ci	/* The meaning of lower directory, shared */
6178c2ecf20Sopenharmony_ci	unsigned short	sds_lo_bvec  : 5,
6188c2ecf20Sopenharmony_ci			sds_lo_unused: 1,
6198c2ecf20Sopenharmony_ci			sds_lo_state : 3,
6208c2ecf20Sopenharmony_ci			sds_lo_prio  : 1,
6218c2ecf20Sopenharmony_ci			sds_lo_ax    : 1,
6228c2ecf20Sopenharmony_ci			sds_lo_ecc   : 5;
6238c2ecf20Sopenharmony_ci};
6248c2ecf20Sopenharmony_ci
6258c2ecf20Sopenharmony_cistruct md_sdir_low_exclusive_fmt {
6268c2ecf20Sopenharmony_ci	/* The meaning of lower directory, exclusive */
6278c2ecf20Sopenharmony_ci	unsigned short	sde_lo_ptr   : 6,
6288c2ecf20Sopenharmony_ci			sde_lo_state : 3,
6298c2ecf20Sopenharmony_ci			sde_lo_prio  : 1,
6308c2ecf20Sopenharmony_ci			sde_lo_ax    : 1,
6318c2ecf20Sopenharmony_ci			sde_lo_ecc   : 5;
6328c2ecf20Sopenharmony_ci};
6338c2ecf20Sopenharmony_ci
6348c2ecf20Sopenharmony_ci
6358c2ecf20Sopenharmony_citypedef union md_sdir_low {
6368c2ecf20Sopenharmony_ci	/* The 16 bits of standard directory, lower word */
6378c2ecf20Sopenharmony_ci	unsigned short	sd_lo_val;
6388c2ecf20Sopenharmony_ci	struct	md_sdir_low_exclusive_fmt sde_lo_fmt;
6398c2ecf20Sopenharmony_ci	struct	md_sdir_low_shared_fmt sds_lo_fmt;
6408c2ecf20Sopenharmony_ci}md_sdir_low_t;
6418c2ecf20Sopenharmony_ci
6428c2ecf20Sopenharmony_ci
6438c2ecf20Sopenharmony_ci
6448c2ecf20Sopenharmony_cistruct md_pdir_high_fmt {
6458c2ecf20Sopenharmony_ci	u64	pd_hi_unused   : 16,
6468c2ecf20Sopenharmony_ci		pd_hi_bvec     : 38,
6478c2ecf20Sopenharmony_ci		pd_hi_unused1  : 3,
6488c2ecf20Sopenharmony_ci		pd_hi_ecc      : 7;
6498c2ecf20Sopenharmony_ci};
6508c2ecf20Sopenharmony_ci
6518c2ecf20Sopenharmony_ci
6528c2ecf20Sopenharmony_citypedef union md_pdir_high {
6538c2ecf20Sopenharmony_ci	/* The 48 bits of standard directory, upper word */
6548c2ecf20Sopenharmony_ci	u64	pd_hi_val;
6558c2ecf20Sopenharmony_ci	struct md_pdir_high_fmt pd_hi_fmt;
6568c2ecf20Sopenharmony_ci}md_pdir_high_t;
6578c2ecf20Sopenharmony_ci
6588c2ecf20Sopenharmony_ci
6598c2ecf20Sopenharmony_cistruct md_pdir_low_shared_fmt {
6608c2ecf20Sopenharmony_ci	/* The meaning of lower directory, shared */
6618c2ecf20Sopenharmony_ci	u64	pds_lo_unused	: 16,
6628c2ecf20Sopenharmony_ci		pds_lo_bvec	: 26,
6638c2ecf20Sopenharmony_ci		pds_lo_cnt	:  6,
6648c2ecf20Sopenharmony_ci		pds_lo_state	:  3,
6658c2ecf20Sopenharmony_ci		pds_lo_ste	:  1,
6668c2ecf20Sopenharmony_ci		pds_lo_prio	:  4,
6678c2ecf20Sopenharmony_ci		pds_lo_ax	:  1,
6688c2ecf20Sopenharmony_ci		pds_lo_ecc	:  7;
6698c2ecf20Sopenharmony_ci};
6708c2ecf20Sopenharmony_ci
6718c2ecf20Sopenharmony_cistruct md_pdir_low_exclusive_fmt {
6728c2ecf20Sopenharmony_ci	/* The meaning of lower directory, exclusive */
6738c2ecf20Sopenharmony_ci	u64	pde_lo_unused	: 31,
6748c2ecf20Sopenharmony_ci		pde_lo_ptr	: 11,
6758c2ecf20Sopenharmony_ci		pde_lo_unused1	:  6,
6768c2ecf20Sopenharmony_ci		pde_lo_state	:  3,
6778c2ecf20Sopenharmony_ci		pde_lo_ste	:  1,
6788c2ecf20Sopenharmony_ci		pde_lo_prio	:  4,
6798c2ecf20Sopenharmony_ci		pde_lo_ax	:  1,
6808c2ecf20Sopenharmony_ci		pde_lo_ecc	:  7;
6818c2ecf20Sopenharmony_ci};
6828c2ecf20Sopenharmony_ci
6838c2ecf20Sopenharmony_ci
6848c2ecf20Sopenharmony_citypedef union md_pdir_loent {
6858c2ecf20Sopenharmony_ci	/* The 48 bits of premium directory, lower word */
6868c2ecf20Sopenharmony_ci	u64	pd_lo_val;
6878c2ecf20Sopenharmony_ci	struct md_pdir_low_exclusive_fmt pde_lo_fmt;
6888c2ecf20Sopenharmony_ci	struct md_pdir_low_shared_fmt	pds_lo_fmt;
6898c2ecf20Sopenharmony_ci}md_pdir_low_t;
6908c2ecf20Sopenharmony_ci
6918c2ecf20Sopenharmony_ci
6928c2ecf20Sopenharmony_ci/*
6938c2ecf20Sopenharmony_ci *   the following two "union" definitions and two
6948c2ecf20Sopenharmony_ci *   "struct" definitions are used in vmdump.c to
6958c2ecf20Sopenharmony_ci *   represent directory memory information.
6968c2ecf20Sopenharmony_ci */
6978c2ecf20Sopenharmony_ci
6988c2ecf20Sopenharmony_citypedef union	md_dir_high	{
6998c2ecf20Sopenharmony_ci	md_sdir_high_t	md_sdir_high;
7008c2ecf20Sopenharmony_ci	md_pdir_high_t	md_pdir_high;
7018c2ecf20Sopenharmony_ci} md_dir_high_t;
7028c2ecf20Sopenharmony_ci
7038c2ecf20Sopenharmony_citypedef union	md_dir_low	{
7048c2ecf20Sopenharmony_ci	md_sdir_low_t	md_sdir_low;
7058c2ecf20Sopenharmony_ci	md_pdir_low_t	md_pdir_low;
7068c2ecf20Sopenharmony_ci} md_dir_low_t;
7078c2ecf20Sopenharmony_ci
7088c2ecf20Sopenharmony_citypedef struct	bddir_entry	{
7098c2ecf20Sopenharmony_ci	md_dir_low_t	md_dir_low;
7108c2ecf20Sopenharmony_ci	md_dir_high_t	md_dir_high;
7118c2ecf20Sopenharmony_ci} bddir_entry_t;
7128c2ecf20Sopenharmony_ci
7138c2ecf20Sopenharmony_citypedef struct	dir_mem_entry	{
7148c2ecf20Sopenharmony_ci	u64		prcpf[MAX_REGIONS];
7158c2ecf20Sopenharmony_ci	bddir_entry_t	directory_words[MD_PAGE_SIZE/CACHE_SLINE_SIZE];
7168c2ecf20Sopenharmony_ci} dir_mem_entry_t;
7178c2ecf20Sopenharmony_ci
7188c2ecf20Sopenharmony_ci
7198c2ecf20Sopenharmony_ci
7208c2ecf20Sopenharmony_citypedef union md_perf_sel {
7218c2ecf20Sopenharmony_ci	u64	perf_sel_reg;
7228c2ecf20Sopenharmony_ci	struct	{
7238c2ecf20Sopenharmony_ci		u64	perf_rsvd : 60,
7248c2ecf20Sopenharmony_ci			perf_en	  :  1,
7258c2ecf20Sopenharmony_ci			perf_sel  :  3;
7268c2ecf20Sopenharmony_ci	} perf_sel_bits;
7278c2ecf20Sopenharmony_ci} md_perf_sel_t;
7288c2ecf20Sopenharmony_ci
7298c2ecf20Sopenharmony_citypedef union md_perf_cnt {
7308c2ecf20Sopenharmony_ci	u64	perf_cnt;
7318c2ecf20Sopenharmony_ci	struct	{
7328c2ecf20Sopenharmony_ci		u64	perf_rsvd : 44,
7338c2ecf20Sopenharmony_ci			perf_cnt  : 20;
7348c2ecf20Sopenharmony_ci	} perf_cnt_bits;
7358c2ecf20Sopenharmony_ci} md_perf_cnt_t;
7368c2ecf20Sopenharmony_ci
7378c2ecf20Sopenharmony_ci
7388c2ecf20Sopenharmony_ci#endif /* !__ASSEMBLY__ */
7398c2ecf20Sopenharmony_ci
7408c2ecf20Sopenharmony_ci
7418c2ecf20Sopenharmony_ci#define DIR_ERROR_VALID_MASK	0xe000000000000000
7428c2ecf20Sopenharmony_ci#define DIR_ERROR_VALID_SHFT	61
7438c2ecf20Sopenharmony_ci#define DIR_ERROR_VALID_UCE	0x8000000000000000
7448c2ecf20Sopenharmony_ci#define DIR_ERROR_VALID_AE	0x4000000000000000
7458c2ecf20Sopenharmony_ci#define DIR_ERROR_VALID_CE	0x2000000000000000
7468c2ecf20Sopenharmony_ci
7478c2ecf20Sopenharmony_ci#define MEM_ERROR_VALID_MASK	0xc000000000000000
7488c2ecf20Sopenharmony_ci#define MEM_ERROR_VALID_SHFT	62
7498c2ecf20Sopenharmony_ci#define MEM_ERROR_VALID_UCE	0x8000000000000000
7508c2ecf20Sopenharmony_ci#define MEM_ERROR_VALID_CE	0x4000000000000000
7518c2ecf20Sopenharmony_ci
7528c2ecf20Sopenharmony_ci#define PROTO_ERROR_VALID_MASK	0x8000000000000000
7538c2ecf20Sopenharmony_ci
7548c2ecf20Sopenharmony_ci#define MISC_ERROR_VALID_MASK	0x3ff
7558c2ecf20Sopenharmony_ci
7568c2ecf20Sopenharmony_ci/*
7578c2ecf20Sopenharmony_ci * Mask for hspec address that is stored in the dir error register.
7588c2ecf20Sopenharmony_ci * This represents bits 29 through 3.
7598c2ecf20Sopenharmony_ci */
7608c2ecf20Sopenharmony_ci#define DIR_ERR_HSPEC_MASK	0x3ffffff8
7618c2ecf20Sopenharmony_ci#define ERROR_HSPEC_MASK	0x3ffffff8
7628c2ecf20Sopenharmony_ci#define ERROR_HSPEC_SHFT	3
7638c2ecf20Sopenharmony_ci#define ERROR_ADDR_MASK		0xfffffff8
7648c2ecf20Sopenharmony_ci#define ERROR_ADDR_SHFT		3
7658c2ecf20Sopenharmony_ci
7668c2ecf20Sopenharmony_ci/*
7678c2ecf20Sopenharmony_ci * MD_MISC_ERROR register defines.
7688c2ecf20Sopenharmony_ci */
7698c2ecf20Sopenharmony_ci
7708c2ecf20Sopenharmony_ci#define MMCE_VALID_MASK		0x3ff
7718c2ecf20Sopenharmony_ci#define MMCE_ILL_MSG_SHFT	8
7728c2ecf20Sopenharmony_ci#define MMCE_ILL_MSG_MASK	(UINT64_CAST 0x03 << MMCE_ILL_MSG_SHFT)
7738c2ecf20Sopenharmony_ci#define MMCE_ILL_REV_SHFT	6
7748c2ecf20Sopenharmony_ci#define MMCE_ILL_REV_MASK	(UINT64_CAST 0x03 << MMCE_ILL_REV_SHFT)
7758c2ecf20Sopenharmony_ci#define MMCE_LONG_PACK_SHFT	4
7768c2ecf20Sopenharmony_ci#define MMCE_LONG_PACK_MASK	(UINT64_CAST 0x03 << MMCE_lONG_PACK_SHFT)
7778c2ecf20Sopenharmony_ci#define MMCE_SHORT_PACK_SHFT	2
7788c2ecf20Sopenharmony_ci#define MMCE_SHORT_PACK_MASK	(UINT64_CAST 0x03 << MMCE_SHORT_PACK_SHFT)
7798c2ecf20Sopenharmony_ci#define MMCE_BAD_DATA_SHFT	0
7808c2ecf20Sopenharmony_ci#define MMCE_BAD_DATA_MASK	(UINT64_CAST 0x03 << MMCE_BAD_DATA_SHFT)
7818c2ecf20Sopenharmony_ci
7828c2ecf20Sopenharmony_ci
7838c2ecf20Sopenharmony_ci#define MD_PERF_COUNTERS	6
7848c2ecf20Sopenharmony_ci#define MD_PERF_SETS		6
7858c2ecf20Sopenharmony_ci
7868c2ecf20Sopenharmony_ci#define MEM_DIMM_MASK				0xe0000000
7878c2ecf20Sopenharmony_ci#define MEM_DIMM_SHFT				29
7888c2ecf20Sopenharmony_ci
7898c2ecf20Sopenharmony_ci#endif /* _ASM_SN_SN0_HUBMD_H */
790