xref: /titanic_50/usr/src/uts/intel/sys/mc_amd.h (revision 5667185bc023b9742cb2480659d7673fa9ac8050)
17aec1d6eScindi /*
27aec1d6eScindi  * CDDL HEADER START
37aec1d6eScindi  *
47aec1d6eScindi  * The contents of this file are subject to the terms of the
58a40a695Sgavinm  * Common Development and Distribution License (the "License").
68a40a695Sgavinm  * You may not use this file except in compliance with the License.
77aec1d6eScindi  *
87aec1d6eScindi  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97aec1d6eScindi  * or http://www.opensolaris.org/os/licensing.
107aec1d6eScindi  * See the License for the specific language governing permissions
117aec1d6eScindi  * and limitations under the License.
127aec1d6eScindi  *
137aec1d6eScindi  * When distributing Covered Code, include this CDDL HEADER in each
147aec1d6eScindi  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157aec1d6eScindi  * If applicable, add the following below this CDDL HEADER, with the
167aec1d6eScindi  * fields enclosed by brackets "[]" replaced with your own identifying
177aec1d6eScindi  * information: Portions Copyright [yyyy] [name of copyright owner]
187aec1d6eScindi  *
197aec1d6eScindi  * CDDL HEADER END
207aec1d6eScindi  *
21*5667185bSSrihari Venkatesan  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
227aec1d6eScindi  * Use is subject to license terms.
237aec1d6eScindi  */
247aec1d6eScindi 
257aec1d6eScindi #ifndef _MC_AMD_H
267aec1d6eScindi #define	_MC_AMD_H
277aec1d6eScindi 
288a40a695Sgavinm #include <sys/mc.h>
2920c794b3Sgavinm #include <sys/isa_defs.h>
308a40a695Sgavinm #include <sys/x86_archext.h>
318a40a695Sgavinm 
329dd0f810Scindi #ifdef __cplusplus
339dd0f810Scindi extern "C" {
349dd0f810Scindi #endif
359dd0f810Scindi 
368a40a695Sgavinm /*
37bb86c342Sgavinm  * Definitions, register offsets, register structure etc pertaining to
38bb86c342Sgavinm  * the memory controller on AMD64 systems.  These are used by both the
39bb86c342Sgavinm  * AMD cpu module and the mc-amd driver.
40bb86c342Sgavinm  */
41bb86c342Sgavinm 
42bb86c342Sgavinm /*
438a40a695Sgavinm  * The mc-amd driver exports an nvlist to userland, where the primary
448a40a695Sgavinm  * consumer is the "chip" topology enumerator for this platform type which
458a40a695Sgavinm  * builds a full topology subtree from this information.  Others can use
464156fc34Sgavinm  * it, too, but don't depend on it not changing without an ARC contract
474156fc34Sgavinm  * (and the contract should probably concern the topology, not this nvlist).
488a40a695Sgavinm  *
498a40a695Sgavinm  * In the initial mc-amd implementation this nvlist was not versioned;
508a40a695Sgavinm  * we'll think of that as version 0 and it may be recognised by the absence
518a40a695Sgavinm  * of a "mcamd-nvlist-version member.
528a40a695Sgavinm  *
538a40a695Sgavinm  * Version 1 is defined as follows.  A name in square brackets indicates
548a40a695Sgavinm  * that member is optional (only present if the actual value is valid).
558a40a695Sgavinm  *
568a40a695Sgavinm  * Name			Type		Description
578a40a695Sgavinm  * -------------------- --------------- ---------------------------------------
588a40a695Sgavinm  * mcamd-nvlist-version	uint8		Exported nvlist version number
598a40a695Sgavinm  * num			uint64		Chip id of this memory controller
608a40a695Sgavinm  * revision		uint64		cpuid_getchiprev() result
618a40a695Sgavinm  * revname		string		cpuid_getchiprevstr() result
628a40a695Sgavinm  * socket		string		"Socket 755|939|940|AM2|F(1207)|S1g1"
638a40a695Sgavinm  * ecc-type		string		"ChipKill 128/16" or "Normal 64/8"
648a40a695Sgavinm  * base-addr		uint64		Node base address
658a40a695Sgavinm  * lim-addr		uint64		Node limit address
668a40a695Sgavinm  * node-ilen		uint64		0|1|3|7 for 0/2/4/8 way node interleave
678a40a695Sgavinm  * node-ilsel		uint64		Node interleave position of this node
688a40a695Sgavinm  * cs-intlv-factor	uint64		chip-select interleave: 1/2/4/8
698a40a695Sgavinm  * dram-hole-size	uint64		size in bytes from dram hole addr reg
708a40a695Sgavinm  * access-width		uint64		MC mode, 64 or 128 bit
718a40a695Sgavinm  * bank-mapping		uint64		Raw DRAM Bank Address Mapping Register
728a40a695Sgavinm  * bankswizzle		uint64		1 if bank swizzling enabled; else 0
738a40a695Sgavinm  * mismatched-dimm-support uint64	1 if active; else 0
748a40a695Sgavinm  * [spare-csnum]	uint64		Chip-select pair number of any spare
758a40a695Sgavinm  * [bad-csnum]		uint64		Chip-select pair number of swapped cs
768a40a695Sgavinm  * cslist		nvlist array	See below; may have 0 members
778a40a695Sgavinm  * dimmlist		nvlist array	See below; may have 0 members
788a40a695Sgavinm  *
798a40a695Sgavinm  * cslist is an array of nvlist, each as follows:
808a40a695Sgavinm  *
818a40a695Sgavinm  * Name			Type		Description
828a40a695Sgavinm  * -------------------- --------------- ---------------------------------------
838a40a695Sgavinm  * num			uint64		Chip-select base/mask pair number
848a40a695Sgavinm  * base-addr		uint64		Chip-select base address (rel to node)
858a40a695Sgavinm  * mask			uint64		Chip-select mask
868a40a695Sgavinm  * size			uint64		Chip-select size in bytes
878a40a695Sgavinm  * dimm1-num		uint64		First dimm (lodimm if a pair)
888a40a695Sgavinm  * dimm1-csname		string		Socket cs# line name for 1st dimm rank
898a40a695Sgavinm  * [dimm2-num]		uint64		Second dimm if applicable (updimm)
908a40a695Sgavinm  * [dimm2-csname]	string		Socket cs# line name for 2nd dimm rank
918a40a695Sgavinm  *
928a40a695Sgavinm  * dimmlist is an array of nvlist, each as follows:
938a40a695Sgavinm  *
948a40a695Sgavinm  * Name			Type		Description
958a40a695Sgavinm  * -------------------- --------------- ---------------------------------------
968a40a695Sgavinm  * num			uint64		DIMM instance number
978a40a695Sgavinm  * size			uint64		DIMM size in bytes
988a40a695Sgavinm  * csnums		uint64 array	CS base/mask pair(s) on this DIMM
998a40a695Sgavinm  * csnames		string array	Socket cs# line name(s) on this DIMM
1008a40a695Sgavinm  *
1018a40a695Sgavinm  *	The n'th csnums entry corresponds to the n'th csnames entry
1028a40a695Sgavinm  */
1038a40a695Sgavinm #define	MC_NVLIST_VERSTR	"mcamd-nvlist-version"
1048a40a695Sgavinm #define	MC_NVLIST_VERS0		0
1058a40a695Sgavinm #define	MC_NVLIST_VERS1		1
1068a40a695Sgavinm #define	MC_NVLIST_VERS		MC_NVLIST_VERS1
1078a40a695Sgavinm 
1087aec1d6eScindi /*
1098a40a695Sgavinm  * Constants and feature/revision test macros that are not expected to vary
1108a40a695Sgavinm  * among different AMD family 0xf processor revisions.
1118a40a695Sgavinm  */
1128a40a695Sgavinm 
1138a40a695Sgavinm /*
1147aec1d6eScindi  * Configuration constants
1157aec1d6eScindi  */
1168a40a695Sgavinm #define	MC_CHIP_MAXNODES	8	/* max number of MCs in system */
1177aec1d6eScindi #define	MC_CHIP_NDIMM		8	/* max dimms per MC */
1187aec1d6eScindi #define	MC_CHIP_NCS		8	/* number of chip-selects per MC */
1198a40a695Sgavinm #define	MC_CHIP_NDRAMCHAN	2	/* maximum number of dram channels */
1207aec1d6eScindi #define	MC_CHIP_DIMMRANKMAX	4	/* largest number of ranks per dimm */
1217aec1d6eScindi #define	MC_CHIP_DIMMPERCS	2	/* max number of dimms per cs */
1227aec1d6eScindi #define	MC_CHIP_DIMMPAIR(csnum)	(csnum / MC_CHIP_DIMMPERCS)
1237aec1d6eScindi 
1248a40a695Sgavinm /*
1258a40a695Sgavinm  * Memory controller registers are read via PCI config space accesses on
12620c794b3Sgavinm  * bus 0, device 0x18 + NodeId, and function as follows:
1277aec1d6eScindi  *
1288a40a695Sgavinm  * Function 0: HyperTransport Technology Configuration
1298a40a695Sgavinm  * Function 1: Address Map
1308a40a695Sgavinm  * Function 2: DRAM Controller & HyperTransport Technology Trace Mode
1318a40a695Sgavinm  * Function 3: Miscellaneous Control
132bb86c342Sgavinm  */
13320c794b3Sgavinm 
13420c794b3Sgavinm #define	MC_AMD_DEV_OFFSET	0x18	/* node ID + offset == PCI dev num */
13520c794b3Sgavinm 
136bb86c342Sgavinm enum mc_funcnum {
137bb86c342Sgavinm 	MC_FUNC_HTCONFIG = 0,
138bb86c342Sgavinm 	MC_FUNC_ADDRMAP	= 1,
139bb86c342Sgavinm 	MC_FUNC_DRAMCTL = 2,
140bb86c342Sgavinm 	MC_FUNC_MISCCTL = 3
141bb86c342Sgavinm };
142bb86c342Sgavinm 
143bb86c342Sgavinm /*
1448a40a695Sgavinm  * For a given (bus, device, function) a particular offset selects the
1458a40a695Sgavinm  * desired register.  All registers are 32-bits wide.
1468a40a695Sgavinm  *
1478a40a695Sgavinm  * Different family 0xf processor revisions vary slightly in the content
1488a40a695Sgavinm  * of these configuration registers.  The biggest change is with rev F
1498a40a695Sgavinm  * where DDR2 support has been introduced along with some hardware-controlled
1508a40a695Sgavinm  * correctable memory error thresholding.  Fortunately most of the config info
1518a40a695Sgavinm  * required by the mc-amd driver is similar across revisions.
1528a40a695Sgavinm  *
1538a40a695Sgavinm  * We will try to insulate most of the driver code from config register
1548a40a695Sgavinm  * details by reading all memory-controller PCI config registers that we
1558a40a695Sgavinm  * will need at driver attach time for each of functions 0 through 3, and
1568a40a695Sgavinm  * storing them in a "cooked" form as memory controller properties.
1578a40a695Sgavinm  * These are to be accessed directly where we have an mc_t to hand, otherwise
1588a40a695Sgavinm  * through mcamd_get_numprop.  As such we expect most/all use of the
1598a40a695Sgavinm  * structures and macros defined below to be in those attach codepaths.
1607aec1d6eScindi  */
1617aec1d6eScindi 
1627aec1d6eScindi /*
163bb86c342Sgavinm  * Function 0 (HT Config) offsets
164bb86c342Sgavinm  */
165bb86c342Sgavinm #define	MC_HT_REG_RTBL_NODE_0	0x40
166bb86c342Sgavinm #define	MC_HT_REG_RTBL_INCR	4
167bb86c342Sgavinm #define	MC_HT_REG_NODEID	0x60
168bb86c342Sgavinm #define	MC_HT_REG_UNITID	0x64
169bb86c342Sgavinm 
170bb86c342Sgavinm /*
171bb86c342Sgavinm  * Function 1 (address map) offsets for DRAM base, DRAM limit, DRAM hole
172bb86c342Sgavinm  * registers.
173bb86c342Sgavinm  */
174bb86c342Sgavinm #define	MC_AM_REG_DRAMBASE_0	0x40	/* Offset for DRAM Base 0 */
175bb86c342Sgavinm #define	MC_AM_REG_DRAMLIM_0	0x44	/* Offset for DRAM Limit 0 */
176bb86c342Sgavinm #define	MC_AM_REG_DRAM_INCR	8	/* incr between base/limit pairs */
177bb86c342Sgavinm #define	MC_AM_REG_HOLEADDR	0xf0	/* DRAM Hole Address Register */
178bb86c342Sgavinm 
179bb86c342Sgavinm /*
180bb86c342Sgavinm  * Function 2 (dram controller) offsets for chip-select base, chip-select mask,
181bb86c342Sgavinm  * DRAM bank address mapping, DRAM configuration registers.
182bb86c342Sgavinm  */
183bb86c342Sgavinm #define	MC_DC_REG_CS_INCR	4	/* incr for CS base and mask */
184bb86c342Sgavinm #define	MC_DC_REG_CSBASE_0	0x40	/* 0x40 - 0x5c */
185bb86c342Sgavinm #define	MC_DC_REG_CSMASK_0	0x60	/* 0x60 - 0x7c */
186bb86c342Sgavinm #define	MC_DC_REG_BANKADDRMAP	0x80	/* DRAM Bank Address Mapping */
187bb86c342Sgavinm #define	MC_DC_REG_DRAMCFGLO	0x90	/* DRAM Configuration Low */
188bb86c342Sgavinm #define	MC_DC_REG_DRAMCFGHI	0x94	/* DRAM Configuration High */
189bb86c342Sgavinm #define	MC_DC_REG_DRAMMISC	0xa0	/* DRAM Miscellaneous */
190bb86c342Sgavinm 
191bb86c342Sgavinm /*
19225f47677Sgavinm  * Function 3 (misc control) offset for NB MCA config, scrubber control,
19325f47677Sgavinm  * online spare control and NB capabilities.
194bb86c342Sgavinm  */
195bb86c342Sgavinm #define	MC_CTL_REG_NBCFG	0x44	/* MCA NB configuration register */
196bb86c342Sgavinm #define	MC_CTL_REG_SCRUBCTL	0x58	/* Scrub control register */
197bb86c342Sgavinm #define	MC_CTL_REG_SCRUBADDR_LO	0x5c	/* DRAM Scrub Address Low */
198bb86c342Sgavinm #define	MC_CTL_REG_SCRUBADDR_HI	0x60	/* DRAM Scrub Address High */
199bb86c342Sgavinm #define	MC_CTL_REG_SPARECTL	0xb0	/* On-line spare control register */
20025f47677Sgavinm #define	MC_CTL_REG_NBCAP	0xe8	/* NB Capabilities */
201*5667185bSSrihari Venkatesan #define	MC_CTL_REG_EXTNBCFG	0x180	/* Ext. MCA NB configuration register */
20225f47677Sgavinm 
203a24e89c4SKuriakose Kuruvilla #define	MC_NBCAP_L3CAPABLE	(1U << 25)
204a24e89c4SKuriakose Kuruvilla #define	MC_NBCAP_MULTINODECPU	(1U << 29)
205*5667185bSSrihari Venkatesan #define	MC_EXTNBCFG_ECCSYMSZ	(1U << 25)
206bb86c342Sgavinm 
207bb86c342Sgavinm /*
20820c794b3Sgavinm  * MC4_MISC MSR and MC4_MISCj MSRs
20920c794b3Sgavinm  */
21020c794b3Sgavinm #define	MC_MSR_NB_MISC0		0x413
21120c794b3Sgavinm #define	MC_MSR_NB_MISC1		0xc0000408
21220c794b3Sgavinm #define	MC_MSR_NB_MISC2		0xc0000409
21320c794b3Sgavinm #define	MC_MSR_NB_MISC3		0xc000040a
21420c794b3Sgavinm #define	MC_MSR_NB_MISC(j) \
21520c794b3Sgavinm 	((j) == 0 ? MC_MSR_NB_MISC0 : MC_MSR_NB_MISC1 + (j) - 1)
21620c794b3Sgavinm 
21720c794b3Sgavinm /*
21820c794b3Sgavinm  * PCI registers will be represented as unions, with one fixed-width unsigned
2198a40a695Sgavinm  * integer member providing access to the raw register value and one or more
2208a40a695Sgavinm  * structs breaking the register out into bitfields (more than one struct if
2218a40a695Sgavinm  * the register definitions varies across processor revisions).
2228a40a695Sgavinm  *
2238a40a695Sgavinm  * The "raw" union member will always be '_val32'.  Use MCREG_VAL32 to
2248a40a695Sgavinm  * access this member.
2258a40a695Sgavinm  *
2268a40a695Sgavinm  * The bitfield structs are all named _fmt_xxx where xxx identifies the
2278a40a695Sgavinm  * processor revision to which it applies.  At this point the only xxx
2288a40a695Sgavinm  * values in use are:
2298a40a695Sgavinm  *			'cmn' - applies to all revisions
23020c794b3Sgavinm  *			'f_preF' - applies to revisions E and earlier
23120c794b3Sgavinm  *			'f_revFG' - applies to revisions F and G
23220c794b3Sgavinm  *
2338a40a695Sgavinm  * Variants such as 'preD', 'revDE', 'postCG' etc should be introduced
2348a40a695Sgavinm  * as requirements arise.  The MC_REV_* and MC_REV_MATCH etc macros
2358a40a695Sgavinm  * will also need to grow to match.  Use MCREG_FIELD_* to access the
2368a40a695Sgavinm  * individual bitfields of a register, perhaps using MC_REV_* and MC_REV_MATCH
2378a40a695Sgavinm  * to decide which revision suffix to provide.  Where a bitfield appears
2388a40a695Sgavinm  * in different revisions but has the same use it should be named identically
2398a40a695Sgavinm  * (even if the BKDG varies a little) so that the MC_REG_FIELD_* macros
2408a40a695Sgavinm  * can lookup that member based on revision only.
2417aec1d6eScindi  */
2428a40a695Sgavinm 
243bb86c342Sgavinm #define	MC_REV_UNKNOWN	X86_CHIPREV_UNKNOWN
24420c794b3Sgavinm 
24520c794b3Sgavinm #define	MC_F_REV_B	X86_CHIPREV_AMD_F_REV_B
24620c794b3Sgavinm #define	MC_F_REV_C	(X86_CHIPREV_AMD_F_REV_C0 | X86_CHIPREV_AMD_F_REV_CG)
24720c794b3Sgavinm #define	MC_F_REV_D	X86_CHIPREV_AMD_F_REV_D
24820c794b3Sgavinm #define	MC_F_REV_E	X86_CHIPREV_AMD_F_REV_E
24920c794b3Sgavinm #define	MC_F_REV_F	X86_CHIPREV_AMD_F_REV_F
25020c794b3Sgavinm #define	MC_F_REV_G	X86_CHIPREV_AMD_F_REV_G
25120c794b3Sgavinm 
25220c794b3Sgavinm #define	MC_10_REV_A	X86_CHIPREV_AMD_10_REV_A
25320c794b3Sgavinm #define	MC_10_REV_B	X86_CHIPREV_AMD_10_REV_B
254bb86c342Sgavinm 
255bb86c342Sgavinm /*
256bb86c342Sgavinm  * The most common groupings for memory controller features.
257bb86c342Sgavinm  */
25820c794b3Sgavinm #define	MC_F_REVS_BC	(MC_F_REV_B | MC_F_REV_C)
25920c794b3Sgavinm #define	MC_F_REVS_DE	(MC_F_REV_D | MC_F_REV_E)
26020c794b3Sgavinm #define	MC_F_REVS_BCDE	(MC_F_REVS_BC | MC_F_REVS_DE)
26120c794b3Sgavinm #define	MC_F_REVS_FG	(MC_F_REV_F | MC_F_REV_G)
26220c794b3Sgavinm 
26320c794b3Sgavinm #define	MC_10_REVS_AB	(MC_10_REV_A | MC_10_REV_B)
264bb86c342Sgavinm 
265bb86c342Sgavinm /*
266bb86c342Sgavinm  * Is 'rev' included in the 'revmask' bitmask?
267bb86c342Sgavinm  */
268bb86c342Sgavinm #define	MC_REV_MATCH(rev, revmask)	X86_CHIPREV_MATCH(rev, revmask)
269bb86c342Sgavinm 
270bb86c342Sgavinm /*
271bb86c342Sgavinm  * Is 'rev' at least revision 'revmin' or greater
272bb86c342Sgavinm  */
273bb86c342Sgavinm #define	MC_REV_ATLEAST(rev, minrev)	X86_CHIPREV_ATLEAST(rev, minrev)
274bb86c342Sgavinm 
2758a40a695Sgavinm #define	_MCREG_FIELD(up, revsuffix, field) ((up)->_fmt_##revsuffix.field)
2768a40a695Sgavinm 
2778a40a695Sgavinm #define	MCREG_VAL32(up) ((up)->_val32)
2788a40a695Sgavinm 
27920c794b3Sgavinm /*
28020c794b3Sgavinm  * Access a field that has the same structure in all families and revisions
28120c794b3Sgavinm  */
2828a40a695Sgavinm #define	MCREG_FIELD_CMN(up, field)	_MCREG_FIELD(up, cmn, field)
28320c794b3Sgavinm 
28420c794b3Sgavinm /*
28520c794b3Sgavinm  * Access a field as defined for family 0xf prior to revision F
28620c794b3Sgavinm  */
28720c794b3Sgavinm #define	MCREG_FIELD_F_preF(up, field)	_MCREG_FIELD(up, f_preF, field)
28820c794b3Sgavinm 
28920c794b3Sgavinm /*
29020c794b3Sgavinm  * Access a field as defined for family 0xf revisions F and G
29120c794b3Sgavinm  */
29220c794b3Sgavinm #define	MCREG_FIELD_F_revFG(up, field)	_MCREG_FIELD(up, f_revFG, field)
29320c794b3Sgavinm 
29420c794b3Sgavinm /*
29520c794b3Sgavinm  * Access a field as defined for family 0x10 revisions A and
29620c794b3Sgavinm  */
29720c794b3Sgavinm #define	MCREG_FIELD_10_revAB(up, field)	_MCREG_FIELD(up, 10_revAB, field)
29820c794b3Sgavinm 
29920c794b3Sgavinm /*
30020c794b3Sgavinm  * We will only define the register bitfields for little-endian order
30120c794b3Sgavinm  */
30220c794b3Sgavinm #ifdef	_BIT_FIELDS_LTOH
3038a40a695Sgavinm 
3048a40a695Sgavinm /*
3059dd0f810Scindi  * Function 0 - HT Configuration: Routing Table Node Register
3069dd0f810Scindi  */
3079dd0f810Scindi union mcreg_htroute {
3089dd0f810Scindi 	uint32_t	_val32;
3099dd0f810Scindi 	struct {
3109dd0f810Scindi 		uint32_t	RQRte:4;	/*  3:0 */
3119dd0f810Scindi 		uint32_t	reserved1:4;	/*  7:4 */
3129dd0f810Scindi 		uint32_t	RPRte:4;	/* 11:8 */
3139dd0f810Scindi 		uint32_t	reserved2:4;	/* 15:12 */
3149dd0f810Scindi 		uint32_t	BCRte:4;	/* 19:16 */
3159dd0f810Scindi 		uint32_t	reserved3:12;	/* 31:20 */
3169dd0f810Scindi 	} _fmt_cmn;
3179dd0f810Scindi };
3189dd0f810Scindi 
3199dd0f810Scindi /*
3209dd0f810Scindi  * Function 0 - HT Configuration: Node ID Register
3219dd0f810Scindi  */
3229dd0f810Scindi union mcreg_nodeid {
3239dd0f810Scindi 	uint32_t	_val32;
3249dd0f810Scindi 	struct {
3259dd0f810Scindi 		uint32_t	NodeId:3;	/*  2:0 */
3269dd0f810Scindi 		uint32_t	reserved1:1;	/*  3:3 */
3279dd0f810Scindi 		uint32_t	NodeCnt:3;	/*  6:4 */
3289dd0f810Scindi 		uint32_t	reserved2:1;	/*  7:7 */
3299dd0f810Scindi 		uint32_t	SbNode:3;	/* 10:8 */
3309dd0f810Scindi 		uint32_t	reserved3:1;	/* 11:11 */
3319dd0f810Scindi 		uint32_t	LkNode:3;	/* 14:12 */
3329dd0f810Scindi 		uint32_t	reserved4:1;	/* 15:15 */
3339dd0f810Scindi 		uint32_t	CpuCnt:4;	/* 19:16 */
3349dd0f810Scindi 		uint32_t	reserved:12;	/* 31:20 */
3359dd0f810Scindi 	} _fmt_cmn;
3369dd0f810Scindi };
3379dd0f810Scindi 
3389dd0f810Scindi #define	HT_COHERENTNODES(up)	(MCREG_FIELD_CMN(up, NodeCnt) + 1)
3399dd0f810Scindi #define	HT_SYSTEMCORECOUNT(up)	(MCREG_FIELD_CMN(up, CpuCnt) + 1)
3409dd0f810Scindi 
3419dd0f810Scindi /*
3429dd0f810Scindi  * Function 0 - HT Configuration: Unit ID Register
3439dd0f810Scindi  */
3449dd0f810Scindi union mcreg_unitid {
3459dd0f810Scindi 	uint32_t	_val32;
3469dd0f810Scindi 	struct {
3479dd0f810Scindi 		uint32_t	C0Unit:2;	/*  1:0 */
3489dd0f810Scindi 		uint32_t	C1Unit:2;	/*  3:2 */
3499dd0f810Scindi 		uint32_t	McUnit:2;	/*  5:4 */
3509dd0f810Scindi 		uint32_t	HbUnit:2;	/*  7:6 */
3519dd0f810Scindi 		uint32_t	SbLink:2;	/*  9:8 */
3529dd0f810Scindi 		uint32_t	reserved:22;	/* 31:10 */
3539dd0f810Scindi 	} _fmt_cmn;
3549dd0f810Scindi };
3559dd0f810Scindi 
3569dd0f810Scindi /*
3578a40a695Sgavinm  * Function 1 - DRAM Address Map: DRAM Base i Registers
3588a40a695Sgavinm  *
3598a40a695Sgavinm  */
3608a40a695Sgavinm 
3618a40a695Sgavinm union mcreg_drambase {
3628a40a695Sgavinm 	uint32_t	_val32;
3638a40a695Sgavinm 	struct {
3648a40a695Sgavinm 		uint32_t	RE:1;		/*  0:0  - Read Enable */
3658a40a695Sgavinm 		uint32_t	WE:1;		/*  1:1  - Write Enable */
3668a40a695Sgavinm 		uint32_t	reserved1:6;	/*  7:2 */
3678a40a695Sgavinm 		uint32_t	IntlvEn:3;	/* 10:8  - Interleave Enable */
3688a40a695Sgavinm 		uint32_t	reserved2:5;	/* 15:11 */
3698a40a695Sgavinm 		uint32_t	DRAMBasei:16;	/* 31:16 - Base Addr 39:24 */
3708a40a695Sgavinm 	} _fmt_cmn;
3718a40a695Sgavinm };
3728a40a695Sgavinm 
3738a40a695Sgavinm #define	MC_DRAMBASE(up)	((uint64_t)MCREG_FIELD_CMN(up, DRAMBasei) << 24)
3748a40a695Sgavinm 
3758a40a695Sgavinm /*
3768a40a695Sgavinm  * Function 1 - DRAM Address Map: DRAM Limit i Registers
3778a40a695Sgavinm  *
3788a40a695Sgavinm  */
3798a40a695Sgavinm 
3808a40a695Sgavinm union mcreg_dramlimit {
3818a40a695Sgavinm 	uint32_t	_val32;
3828a40a695Sgavinm 	struct {
3838a40a695Sgavinm 		uint32_t	DstNode:3;	/*  2:0  - Destination Node */
3848a40a695Sgavinm 		uint32_t	reserved1:5;	/*  7:3 */
3858a40a695Sgavinm 		uint32_t	IntlvSel:3;	/* 10:8  - Interleave Select */
3868a40a695Sgavinm 		uint32_t	reserved2:5;	/* 15:11 */
3878a40a695Sgavinm 		uint32_t	DRAMLimiti:16;	/* 31:16 - Limit Addr 39:24 */
3888a40a695Sgavinm 	} _fmt_cmn;
3898a40a695Sgavinm };
3908a40a695Sgavinm 
3918a40a695Sgavinm #define	MC_DRAMLIM(up) \
3928a40a695Sgavinm 	((uint64_t)MCREG_FIELD_CMN(up, DRAMLimiti) << 24 |		\
3938a40a695Sgavinm 	(MCREG_FIELD_CMN(up, DRAMLimiti) ?  ((1 << 24) - 1) : 0))
3948a40a695Sgavinm 
3958a40a695Sgavinm /*
3968a40a695Sgavinm  * Function 1 - DRAM Address Map: DRAM Hole Address Register
3978a40a695Sgavinm  */
3988a40a695Sgavinm 
3998a40a695Sgavinm union mcreg_dramhole {
4008a40a695Sgavinm 	uint32_t	_val32;
4018a40a695Sgavinm 	struct {
4028a40a695Sgavinm 		uint32_t	DramHoleValid:1;	/*  0:0 */
4038a40a695Sgavinm 		uint32_t	reserved1:7;		/*  7:1 */
4048a40a695Sgavinm 		uint32_t	DramHoleOffset:8;	/* 15:8 */
4058a40a695Sgavinm 		uint32_t	reserved2:8;		/* 23:16 */
4068a40a695Sgavinm 		uint32_t	DramHoleBase:8;		/* 31:24 */
4078a40a695Sgavinm 	} _fmt_cmn;
4088a40a695Sgavinm };
4098a40a695Sgavinm 
4108a40a695Sgavinm #define	MC_DRAMHOLE_SIZE(up) (MCREG_FIELD_CMN(up, DramHoleOffset) << 24)
4118a40a695Sgavinm 
4128a40a695Sgavinm /*
4138a40a695Sgavinm  * Function 2 - DRAM Controller: DRAM CS Base Address Registers
4148a40a695Sgavinm  */
4158a40a695Sgavinm 
4168a40a695Sgavinm union mcreg_csbase {
4178a40a695Sgavinm 	uint32_t	_val32;
4188a40a695Sgavinm 	/*
41920c794b3Sgavinm 	 * Register format in family 0xf revisions E and earlier
4208a40a695Sgavinm 	 */
4218a40a695Sgavinm 	struct {
4228a40a695Sgavinm 		uint32_t	CSEnable:1;	/*  0:0  - CS Bank Enable */
4238a40a695Sgavinm 		uint32_t	reserved1:8;	/*  8:1 */
4248a40a695Sgavinm 		uint32_t	BaseAddrLo:7;	/* 15:9  - Base Addr 19:13 */
4258a40a695Sgavinm 		uint32_t	reserved2:5;	/* 20:16 */
4268a40a695Sgavinm 		uint32_t	BaseAddrHi:11;	/* 31:21 - Base Addr 35:25 */
42720c794b3Sgavinm 	} _fmt_f_preF;
4288a40a695Sgavinm 	/*
42920c794b3Sgavinm 	 * Register format in family 0xf revisions F and G
4308a40a695Sgavinm 	 */
4318a40a695Sgavinm 	struct {
4328a40a695Sgavinm 		uint32_t	CSEnable:1;	/*  0:0  - CS Bank Enable */
4338a40a695Sgavinm 		uint32_t	Spare:1;	/*  1:1  - Spare Rank */
4348a40a695Sgavinm 		uint32_t	TestFail:1;	/*  2:2  - Memory Test Failed */
4358a40a695Sgavinm 		uint32_t	reserved1:2;	/*  4:3 */
4368a40a695Sgavinm 		uint32_t	BaseAddrLo:9;	/* 13:5  - Base Addr 21:13 */
4378a40a695Sgavinm 		uint32_t	reserved2:5;	/* 18:14 */
4388a40a695Sgavinm 		uint32_t	BaseAddrHi:10;	/* 28:19 - Base Addr 36:27 */
4398a40a695Sgavinm 		uint32_t	reserved3:3;	/* 31:39 */
44020c794b3Sgavinm 	} _fmt_f_revFG;
4418a40a695Sgavinm };
4428a40a695Sgavinm 
44320c794b3Sgavinm #define	MC_CSBASE(up, rev) (MC_REV_MATCH(rev, MC_F_REVS_FG) ?	\
44420c794b3Sgavinm 	(uint64_t)MCREG_FIELD_F_revFG(up, BaseAddrHi) << 27 |		\
44520c794b3Sgavinm 	(uint64_t)MCREG_FIELD_F_revFG(up, BaseAddrLo) << 13 :		\
44620c794b3Sgavinm 	(uint64_t)MCREG_FIELD_F_preF(up, BaseAddrHi) << 25 |		\
44720c794b3Sgavinm 	(uint64_t)MCREG_FIELD_F_preF(up, BaseAddrLo) << 13)
4488a40a695Sgavinm 
4498a40a695Sgavinm /*
4508a40a695Sgavinm  * Function 2 - DRAM Controller: DRAM CS Mask Registers
4518a40a695Sgavinm  */
4528a40a695Sgavinm 
4538a40a695Sgavinm union mcreg_csmask {
4548a40a695Sgavinm 	uint32_t	_val32;
4558a40a695Sgavinm 	/*
45620c794b3Sgavinm 	 * Register format in family 0xf revisions E and earlier
4578a40a695Sgavinm 	 */
4588a40a695Sgavinm 	struct {
4598a40a695Sgavinm 		uint32_t	reserved1:9;	/*  8:0 */
4608a40a695Sgavinm 		uint32_t	AddrMaskLo:7;	/* 15:9  - Addr Mask 19:13 */
4618a40a695Sgavinm 		uint32_t	reserved2:5;	/* 20:16 */
4628a40a695Sgavinm 		uint32_t	AddrMaskHi:9;	/* 29:21 - Addr Mask 33:25 */
4638a40a695Sgavinm 		uint32_t	reserved3:2;	/* 31:30 */
46420c794b3Sgavinm 	} _fmt_f_preF;
4658a40a695Sgavinm 	/*
46620c794b3Sgavinm 	 * Register format in family 0xf revisions F and G
4678a40a695Sgavinm 	 */
4688a40a695Sgavinm 	struct {
4698a40a695Sgavinm 		uint32_t	reserved1:5;	/*  4:0 */
4708a40a695Sgavinm 		uint32_t	AddrMaskLo:9;	/* 13:5  - Addr Mask 21:13 */
4718a40a695Sgavinm 		uint32_t	reserved2:5;	/* 18:14 */
4728a40a695Sgavinm 		uint32_t	AddrMaskHi:10;	/* 28:19 - Addr Mask 36:27 */
4738a40a695Sgavinm 		uint32_t	reserved3:3;	/* 31:29 */
47420c794b3Sgavinm 	} _fmt_f_revFG;
4758a40a695Sgavinm };
4768a40a695Sgavinm 
47720c794b3Sgavinm #define	MC_CSMASKLO_LOBIT(rev) (MC_REV_MATCH(rev, MC_F_REVS_FG) ? 13 : 13)
47820c794b3Sgavinm #define	MC_CSMASKLO_HIBIT(rev) (MC_REV_MATCH(rev, MC_F_REVS_FG) ? 21 : 19)
4798a40a695Sgavinm 
48020c794b3Sgavinm #define	MC_CSMASKHI_LOBIT(rev) (MC_REV_MATCH(rev, MC_F_REVS_FG) ? 27 : 25)
48120c794b3Sgavinm #define	MC_CSMASKHI_HIBIT(rev) (MC_REV_MATCH(rev, MC_F_REVS_FG) ? 36 : 33)
4828a40a695Sgavinm 
48320c794b3Sgavinm #define	MC_CSMASK_UNMASKABLE(rev) (MC_REV_MATCH(rev, MC_F_REVS_FG) ? 0 : 2)
4848a40a695Sgavinm 
48520c794b3Sgavinm #define	MC_CSMASK(up, rev) (MC_REV_MATCH(rev, MC_F_REVS_FG) ? \
48620c794b3Sgavinm 	(uint64_t)MCREG_FIELD_F_revFG(up, AddrMaskHi) << 27 | \
48720c794b3Sgavinm 	(uint64_t)MCREG_FIELD_F_revFG(up, AddrMaskLo) << 13 | 0x7c01fff : \
48820c794b3Sgavinm 	(uint64_t)MCREG_FIELD_F_preF(up, AddrMaskHi) << 25 | \
48920c794b3Sgavinm 	(uint64_t)MCREG_FIELD_F_preF(up, AddrMaskLo) << 13 | 0x1f01fff)
4908a40a695Sgavinm 
4918a40a695Sgavinm /*
4928a40a695Sgavinm  * Function 2 - DRAM Controller: DRAM Bank Address Mapping Registers
4938a40a695Sgavinm  */
4948a40a695Sgavinm 
4958a40a695Sgavinm union mcreg_bankaddrmap {
4968a40a695Sgavinm 	uint32_t	_val32;
4978a40a695Sgavinm 	/*
49820c794b3Sgavinm 	 * Register format in family 0xf revisions E and earlier
4998a40a695Sgavinm 	 */
5008a40a695Sgavinm 	struct {
5018a40a695Sgavinm 		uint32_t	cs10:4;			/*  3:0  - CS1/0 */
5028a40a695Sgavinm 		uint32_t	cs32:4;			/*  7:4  - CS3/2 */
5038a40a695Sgavinm 		uint32_t	cs54:4;			/* 11:8  - CS5/4 */
5048a40a695Sgavinm 		uint32_t	cs76:4;			/* 15:12 - CS7/6 */
5058a40a695Sgavinm 		uint32_t	reserved1:14;		/* 29:16 */
5068a40a695Sgavinm 		uint32_t	BankSwizzleMode:1;	/* 30:30 */
5078a40a695Sgavinm 		uint32_t	reserved2:1;		/* 31:31 */
50820c794b3Sgavinm 	} _fmt_f_preF;
5098a40a695Sgavinm 	/*
51020c794b3Sgavinm 	 * Register format in family 0xf revisions F and G
5118a40a695Sgavinm 	 */
5128a40a695Sgavinm 	struct {
5138a40a695Sgavinm 		uint32_t	cs10:4;			/*  3:0  - CS1/0 */
5148a40a695Sgavinm 		uint32_t	cs32:4;			/*  7:4  - CS3/2 */
5158a40a695Sgavinm 		uint32_t	cs54:4;			/* 11:8  - CS5/4 */
5168a40a695Sgavinm 		uint32_t	cs76:4;			/* 15:12 - CS7/6 */
5178a40a695Sgavinm 		uint32_t	reserved1:16;		/* 31:16 */
51820c794b3Sgavinm 	} _fmt_f_revFG;
5198a40a695Sgavinm 	/*
5208a40a695Sgavinm 	 * Accessing all mode encodings as one uint16
5218a40a695Sgavinm 	 */
5228a40a695Sgavinm 	struct {
5238a40a695Sgavinm 		uint32_t	allcsmodes:16;		/* 15:0 */
5248a40a695Sgavinm 		uint32_t	pad:16;			/* 31:16 */
5258a40a695Sgavinm 	} _fmt_bankmodes;
5268a40a695Sgavinm };
5278a40a695Sgavinm 
5287aec1d6eScindi #define	MC_DC_BAM_CSBANK_MASK	0x0000000f
5297aec1d6eScindi #define	MC_DC_BAM_CSBANK_SHIFT	4
5308a40a695Sgavinm 
5318a40a695Sgavinm #define	MC_CSBANKMODE(up, csnum) ((up)->_fmt_bankmodes.allcsmodes >>	\
5328a40a695Sgavinm     MC_DC_BAM_CSBANK_SHIFT * MC_CHIP_DIMMPAIR(csnum) & MC_DC_BAM_CSBANK_MASK)
5337aec1d6eScindi 
5347aec1d6eScindi /*
5358a40a695Sgavinm  * Function 2 - DRAM Controller: DRAM Configuration Low and High
5367aec1d6eScindi  */
5378a40a695Sgavinm 
5388a40a695Sgavinm union mcreg_dramcfg_lo {
5398a40a695Sgavinm 	uint32_t _val32;
5408a40a695Sgavinm 	/*
54120c794b3Sgavinm 	 * Register format in family 0xf revisions E and earlier.
5428a40a695Sgavinm 	 * Bit 7 is a BIOS ScratchBit in revs D and earlier,
5438a40a695Sgavinm 	 * PwrDwnTriEn in revision E;  we don't use it so
5448a40a695Sgavinm 	 * we'll call it ambig1.
5458a40a695Sgavinm 	 */
5468a40a695Sgavinm 	struct {
5478a40a695Sgavinm 		uint32_t	DLL_Dis:1;	/* 0 */
5488a40a695Sgavinm 		uint32_t	D_DRV:1;	/* 1 */
5498a40a695Sgavinm 		uint32_t	QFC_EN:1;	/* 2 */
5508a40a695Sgavinm 		uint32_t	DisDqsHys:1;	/* 3 */
5518a40a695Sgavinm 		uint32_t	reserved1:1;	/* 4 */
5528a40a695Sgavinm 		uint32_t	Burst2Opt:1;	/* 5 */
5538a40a695Sgavinm 		uint32_t	Mod64BitMux:1;	/* 6 */
5548a40a695Sgavinm 		uint32_t	ambig1:1;	/* 7 */
5558a40a695Sgavinm 		uint32_t	DramInit:1;	/* 8 */
5568a40a695Sgavinm 		uint32_t	DualDimmEn:1;	/* 9 */
5578a40a695Sgavinm 		uint32_t	DramEnable:1;	/* 10 */
5588a40a695Sgavinm 		uint32_t	MemClrStatus:1;	/* 11 */
5598a40a695Sgavinm 		uint32_t	ESR:1;		/* 12 */
5608a40a695Sgavinm 		uint32_t	SR_S:1;		/* 13 */
5618a40a695Sgavinm 		uint32_t	RdWrQByp:2;	/* 15:14 */
5628a40a695Sgavinm 		uint32_t	Width128:1;	/* 16 */
5638a40a695Sgavinm 		uint32_t	DimmEcEn:1;	/* 17 */
5648a40a695Sgavinm 		uint32_t	UnBufDimm:1;	/* 18 */
5658a40a695Sgavinm 		uint32_t	ByteEn32:1;	/* 19 */
5668a40a695Sgavinm 		uint32_t	x4DIMMs:4;	/* 23:20 */
5678a40a695Sgavinm 		uint32_t	DisInRcvrs:1;	/* 24 */
5688a40a695Sgavinm 		uint32_t	BypMax:3;	/* 27:25 */
5698a40a695Sgavinm 		uint32_t	En2T:1;		/* 28 */
5708a40a695Sgavinm 		uint32_t	UpperCSMap:1;	/* 29 */
5718a40a695Sgavinm 		uint32_t	PwrDownCtl:2;	/* 31:30 */
57220c794b3Sgavinm 	} _fmt_f_preF;
5738a40a695Sgavinm 	/*
57420c794b3Sgavinm 	 * Register format in family 0xf revisions F and G
5758a40a695Sgavinm 	 */
5768a40a695Sgavinm 	struct {
5778a40a695Sgavinm 		uint32_t	InitDram:1;		/* 0 */
5788a40a695Sgavinm 		uint32_t	ExitSelfRef:1;		/* 1 */
5798a40a695Sgavinm 		uint32_t	reserved1:2;		/* 3:2 */
5808a40a695Sgavinm 		uint32_t	DramTerm:2;		/* 5:4 */
5818a40a695Sgavinm 		uint32_t	reserved2:1;		/* 6 */
5828a40a695Sgavinm 		uint32_t	DramDrvWeak:1;		/* 7 */
5838a40a695Sgavinm 		uint32_t	ParEn:1;		/* 8 */
5848a40a695Sgavinm 		uint32_t	SelRefRateEn:1;		/* 9 */
5858a40a695Sgavinm 		uint32_t	BurstLength32:1;	/* 10 */
5868a40a695Sgavinm 		uint32_t	Width128:1;		/* 11 */
5878a40a695Sgavinm 		uint32_t	x4DIMMs:4;		/* 15:12 */
5888a40a695Sgavinm 		uint32_t	UnBuffDimm:1;		/* 16 */
5898a40a695Sgavinm 		uint32_t	reserved3:2;		/* 18:17 */
5908a40a695Sgavinm 		uint32_t	DimmEccEn:1;		/* 19 */
5918a40a695Sgavinm 		uint32_t	reserved4:12;		/* 31:20 */
59220c794b3Sgavinm 	} _fmt_f_revFG;
5938a40a695Sgavinm };
5947aec1d6eScindi 
5957aec1d6eScindi /*
5968a40a695Sgavinm  * Function 2 - DRAM Controller: DRAM Controller Miscellaneous Data
5977aec1d6eScindi  */
5988a40a695Sgavinm 
5998a40a695Sgavinm union mcreg_drammisc {
6008a40a695Sgavinm 	uint32_t _val32;
6018a40a695Sgavinm 	/*
60220c794b3Sgavinm 	 * Register format in family 0xf revisions F and G
6038a40a695Sgavinm 	 */
6048a40a695Sgavinm 	struct {
6058a40a695Sgavinm 		uint32_t	reserved2:1;		/* 0 */
6068a40a695Sgavinm 		uint32_t	DisableJitter:1;	/* 1 */
6078a40a695Sgavinm 		uint32_t	RdWrQByp:2;		/* 3:2 */
6088a40a695Sgavinm 		uint32_t	Mod64Mux:1;		/* 4 */
6098a40a695Sgavinm 		uint32_t	DCC_EN:1;		/* 5 */
6108a40a695Sgavinm 		uint32_t	ILD_lmt:3;		/* 8:6 */
6118a40a695Sgavinm 		uint32_t	DramEnabled:1;		/* 9 */
6128a40a695Sgavinm 		uint32_t	PwrSavingsEn:1;		/* 10 */
6138a40a695Sgavinm 		uint32_t	reserved1:13;		/* 23:11 */
6148a40a695Sgavinm 		uint32_t	MemClkDis:8;		/* 31:24 */
61520c794b3Sgavinm 	} _fmt_f_revFG;
6168a40a695Sgavinm };
6178a40a695Sgavinm 
6188a40a695Sgavinm union mcreg_dramcfg_hi {
6198a40a695Sgavinm 	uint32_t _val32;
6208a40a695Sgavinm 	/*
62120c794b3Sgavinm 	 * Register format in family 0xf revisions E and earlier.
6228a40a695Sgavinm 	 */
6238a40a695Sgavinm 	struct {
6248a40a695Sgavinm 		uint32_t	AsyncLat:4;		/* 3:0 */
6258a40a695Sgavinm 		uint32_t	reserved1:4;		/* 7:4 */
6268a40a695Sgavinm 		uint32_t	RdPreamble:4;		/* 11:8 */
6278a40a695Sgavinm 		uint32_t	reserved2:1;		/* 12 */
6288a40a695Sgavinm 		uint32_t	MemDQDrvStren:2;	/* 14:13 */
6298a40a695Sgavinm 		uint32_t	DisableJitter:1;	/* 15 */
6308a40a695Sgavinm 		uint32_t	ILD_lmt:3;		/* 18:16 */
6318a40a695Sgavinm 		uint32_t	DCC_EN:1;		/* 19 */
6328a40a695Sgavinm 		uint32_t	MemClk:3;		/* 22:20 */
6338a40a695Sgavinm 		uint32_t	reserved3:2;		/* 24:23 */
6348a40a695Sgavinm 		uint32_t	MCR:1;			/* 25 */
6358a40a695Sgavinm 		uint32_t	MC0_EN:1;		/* 26 */
6368a40a695Sgavinm 		uint32_t	MC1_EN:1;		/* 27 */
6378a40a695Sgavinm 		uint32_t	MC2_EN:1;		/* 28 */
6388a40a695Sgavinm 		uint32_t	MC3_EN:1;		/* 29 */
6398a40a695Sgavinm 		uint32_t	reserved4:1;		/* 30 */
6408a40a695Sgavinm 		uint32_t	OddDivisorCorrect:1;	/* 31 */
64120c794b3Sgavinm 	} _fmt_f_preF;
6428a40a695Sgavinm 	/*
64320c794b3Sgavinm 	 * Register format in family 0xf revisions F and G
6448a40a695Sgavinm 	 */
6458a40a695Sgavinm 	struct {
6468a40a695Sgavinm 		uint32_t	MemClkFreq:3;		/* 2:0 */
6478a40a695Sgavinm 		uint32_t	MemClkFreqVal:1;	/* 3 */
6488a40a695Sgavinm 		uint32_t	MaxAsyncLat:4;		/* 7:4 */
6498a40a695Sgavinm 		uint32_t	reserved1:4;		/* 11:8 */
6508a40a695Sgavinm 		uint32_t	RDqsEn:1;		/* 12 */
6518a40a695Sgavinm 		uint32_t	reserved2:1;		/* 13 */
6528a40a695Sgavinm 		uint32_t	DisDramInterface:1;	/* 14 */
6538a40a695Sgavinm 		uint32_t	PowerDownEn:1;		/* 15 */
6548a40a695Sgavinm 		uint32_t	PowerDownMode:1;	/* 16 */
6558a40a695Sgavinm 		uint32_t	FourRankSODimm:1;	/* 17 */
6568a40a695Sgavinm 		uint32_t	FourRankRDimm:1;	/* 18 */
6578a40a695Sgavinm 		uint32_t	reserved3:1;		/* 19 */
6588a40a695Sgavinm 		uint32_t	SlowAccessMode:1;	/* 20 */
6598a40a695Sgavinm 		uint32_t	reserved4:1;		/* 21 */
6608a40a695Sgavinm 		uint32_t	BankSwizzleMode:1;	/* 22 */
6618a40a695Sgavinm 		uint32_t	undocumented1:1;	/* 23 */
6628a40a695Sgavinm 		uint32_t	DcqBypassMax:4;		/* 27:24 */
6638a40a695Sgavinm 		uint32_t	FourActWindow:4;	/* 31:28 */
66420c794b3Sgavinm 	} _fmt_f_revFG;
6658a40a695Sgavinm };
6668a40a695Sgavinm 
6678a40a695Sgavinm /*
6688a40a695Sgavinm  * Function 3 - Miscellaneous Control: Scrub Control Register
6698a40a695Sgavinm  */
6708a40a695Sgavinm 
6718a40a695Sgavinm union mcreg_scrubctl {
6728a40a695Sgavinm 	uint32_t _val32;
6738a40a695Sgavinm 	struct {
6748a40a695Sgavinm 		uint32_t	DramScrub:5;		/* 4:0 */
6758a40a695Sgavinm 		uint32_t	reserved3:3;		/* 7:5 */
6768a40a695Sgavinm 		uint32_t	L2Scrub:5;		/* 12:8 */
6778a40a695Sgavinm 		uint32_t	reserved2:3;		/* 15:13 */
6788a40a695Sgavinm 		uint32_t	DcacheScrub:5;		/* 20:16 */
6798a40a695Sgavinm 		uint32_t	reserved1:11;		/* 31:21 */
6808a40a695Sgavinm 	} _fmt_cmn;
6818a40a695Sgavinm };
6828a40a695Sgavinm 
68320c794b3Sgavinm union mcreg_dramscrublo {
68420c794b3Sgavinm 	uint32_t _val32;
68520c794b3Sgavinm 	struct {
68620c794b3Sgavinm 		uint32_t	ScrubReDirEn:1;		/* 0 */
68720c794b3Sgavinm 		uint32_t	reserved:5;		/* 5:1 */
68820c794b3Sgavinm 		uint32_t	ScrubAddrLo:26;		/* 31:6 */
68920c794b3Sgavinm 	} _fmt_cmn;
69020c794b3Sgavinm };
69120c794b3Sgavinm 
69220c794b3Sgavinm union mcreg_dramscrubhi {
69320c794b3Sgavinm 	uint32_t _val32;
69420c794b3Sgavinm 	struct {
69520c794b3Sgavinm 		uint32_t	ScrubAddrHi:8;		/* 7:0 */
69620c794b3Sgavinm 		uint32_t	reserved:24;		/* 31:8 */
69720c794b3Sgavinm 	} _fmt_cmn;
69820c794b3Sgavinm };
69920c794b3Sgavinm 
7008a40a695Sgavinm /*
7018a40a695Sgavinm  * Function 3 - Miscellaneous Control: On-Line Spare Control Register
7028a40a695Sgavinm  */
7038a40a695Sgavinm 
7048a40a695Sgavinm union mcreg_nbcfg {
7058a40a695Sgavinm 	uint32_t _val32;
7068a40a695Sgavinm 	/*
70720c794b3Sgavinm 	 * Register format in family 0xf revisions E and earlier.
7088a40a695Sgavinm 	 */
7098a40a695Sgavinm 	struct {
7108a40a695Sgavinm 		uint32_t	CpuEccErrEn:1;			/* 0 */
7118a40a695Sgavinm 		uint32_t	CpuRdDatErrEn:1;		/* 1 */
7128a40a695Sgavinm 		uint32_t	SyncOnUcEccEn:1;		/* 2 */
7138a40a695Sgavinm 		uint32_t	SyncPktGenDis:1;		/* 3 */
7148a40a695Sgavinm 		uint32_t	SyncPktPropDis:1;		/* 4 */
7158a40a695Sgavinm 		uint32_t	IoMstAbortDis:1;		/* 5 */
7168a40a695Sgavinm 		uint32_t	CpuErrDis:1;			/* 6 */
7178a40a695Sgavinm 		uint32_t	IoErrDis:1;			/* 7 */
7188a40a695Sgavinm 		uint32_t	WdogTmrDis:1;			/* 8 */
7198a40a695Sgavinm 		uint32_t	WdogTmrCntSel:3;		/* 11:9 */
7208a40a695Sgavinm 		uint32_t	WdogTmrBaseSel:2;		/* 13:12 */
7218a40a695Sgavinm 		uint32_t	LdtLinkSel:2;			/* 15:14 */
7228a40a695Sgavinm 		uint32_t	GenCrcErrByte0:1;		/* 16 */
7238a40a695Sgavinm 		uint32_t	GenCrcErrByte1:1;		/* 17 */
7248a40a695Sgavinm 		uint32_t	reserved1:2;			/* 19:18 */
7258a40a695Sgavinm 		uint32_t	SyncOnWdogEn:1;			/* 20 */
7268a40a695Sgavinm 		uint32_t	SyncOnAnyErrEn:1;		/* 21 */
7278a40a695Sgavinm 		uint32_t	EccEn:1;			/* 22 */
7288a40a695Sgavinm 		uint32_t	ChipKillEccEn:1;		/* 23 */
7298a40a695Sgavinm 		uint32_t	IoRdDatErrEn:1;			/* 24 */
7308a40a695Sgavinm 		uint32_t	DisPciCfgCpuErrRsp:1;		/* 25 */
7318a40a695Sgavinm 		uint32_t	reserved2:1;			/* 26 */
7328a40a695Sgavinm 		uint32_t	NbMcaToMstCpuEn:1;		/* 27 */
7338a40a695Sgavinm 		uint32_t	reserved3:4;			/* 31:28 */
73420c794b3Sgavinm 	} _fmt_f_preF;
7358a40a695Sgavinm 	/*
73620c794b3Sgavinm 	 * Register format in family 0xf revisions F and G
7378a40a695Sgavinm 	 */
7388a40a695Sgavinm 	struct {
7398a40a695Sgavinm 		uint32_t	CpuEccErrEn:1;			/* 0 */
7408a40a695Sgavinm 		uint32_t	CpuRdDatErrEn:1;		/* 1 */
7418a40a695Sgavinm 		uint32_t	SyncOnUcEccEn:1;		/* 2 */
7428a40a695Sgavinm 		uint32_t	SyncPktGenDis:1;		/* 3 */
7438a40a695Sgavinm 		uint32_t	SyncPktPropDis:1;		/* 4 */
7448a40a695Sgavinm 		uint32_t	IoMstAbortDis:1;		/* 5 */
7458a40a695Sgavinm 		uint32_t	CpuErrDis:1;			/* 6 */
7468a40a695Sgavinm 		uint32_t	IoErrDis:1;			/* 7 */
7478a40a695Sgavinm 		uint32_t	WdogTmrDis:1;			/* 8 */
7488a40a695Sgavinm 		uint32_t	WdogTmrCntSel:3;		/* 11:9 */
7498a40a695Sgavinm 		uint32_t	WdogTmrBaseSel:2;		/* 13:12 */
7508a40a695Sgavinm 		uint32_t	LdtLinkSel:2;			/* 15:14 */
7518a40a695Sgavinm 		uint32_t	GenCrcErrByte0:1;		/* 16 */
7528a40a695Sgavinm 		uint32_t	GenCrcErrByte1:1;		/* 17 */
7538a40a695Sgavinm 		uint32_t	reserved1:2;			/* 19:18 */
7548a40a695Sgavinm 		uint32_t	SyncOnWdogEn:1;			/* 20 */
7558a40a695Sgavinm 		uint32_t	SyncOnAnyErrEn:1;		/* 21 */
7568a40a695Sgavinm 		uint32_t	EccEn:1;			/* 22 */
7578a40a695Sgavinm 		uint32_t	ChipKillEccEn:1;		/* 23 */
7588a40a695Sgavinm 		uint32_t	IoRdDatErrEn:1;			/* 24 */
7598a40a695Sgavinm 		uint32_t	DisPciCfgCpuErrRsp:1;		/* 25 */
7608a40a695Sgavinm 		uint32_t	reserved2:1;			/* 26 */
7618a40a695Sgavinm 		uint32_t	NbMcaToMstCpuEn:1;		/* 27 */
7628a40a695Sgavinm 		uint32_t	DisTgtAbtCpuErrRsp:1;		/* 28 */
7638a40a695Sgavinm 		uint32_t	DisMstAbtCpuErrRsp:1;		/* 29 */
7648a40a695Sgavinm 		uint32_t	SyncOnDramAdrParErrEn:1;	/* 30 */
7658a40a695Sgavinm 		uint32_t	reserved3:1;			/* 31 */
7668a40a695Sgavinm 
76720c794b3Sgavinm 	} _fmt_f_revFG;
7688a40a695Sgavinm };
7698a40a695Sgavinm 
7708a40a695Sgavinm /*
7718a40a695Sgavinm  * Function 3 - Miscellaneous Control: On-Line Spare Control Register
7728a40a695Sgavinm  */
7738a40a695Sgavinm 
7748a40a695Sgavinm union mcreg_sparectl {
7758a40a695Sgavinm 	uint32_t _val32;
7768a40a695Sgavinm 	/*
77720c794b3Sgavinm 	 * Register format in family 0xf revisions F and G
7788a40a695Sgavinm 	 */
7798a40a695Sgavinm 	struct {
7808a40a695Sgavinm 		uint32_t	SwapEn:1;		/* 0 */
7818a40a695Sgavinm 		uint32_t	SwapDone:1;		/* 1 */
7828a40a695Sgavinm 		uint32_t	reserved1:2;		/* 3:2 */
7838a40a695Sgavinm 		uint32_t	BadDramCs:3;		/* 6:4 */
7848a40a695Sgavinm 		uint32_t	reserved2:5;		/* 11:7 */
7858a40a695Sgavinm 		uint32_t	SwapDoneInt:2;		/* 13:12 */
7868a40a695Sgavinm 		uint32_t	EccErrInt:2;		/* 15:14 */
7878a40a695Sgavinm 		uint32_t	EccErrCntDramCs:3;	/* 18:16 */
7888a40a695Sgavinm 		uint32_t	reserved3:1;		/* 19 */
7898a40a695Sgavinm 		uint32_t	EccErrCntDramChan:1;	/* 20 */
7908a40a695Sgavinm 		uint32_t	reserved4:2;		/* 22:21 */
7918a40a695Sgavinm 		uint32_t	EccErrCntWrEn:1;	/* 23 */
7928a40a695Sgavinm 		uint32_t	EccErrCnt:4;		/* 27:24 */
7938a40a695Sgavinm 		uint32_t	reserved5:4;		/* 31:28 */
79420c794b3Sgavinm 	} _fmt_f_revFG;
79520c794b3Sgavinm 	/*
79620c794b3Sgavinm 	 * Regiser format in family 0x10 revisions A and B
79720c794b3Sgavinm 	 */
79820c794b3Sgavinm 	struct {
79920c794b3Sgavinm 		uint32_t	SwapEn0:1;		/* 0 */
80020c794b3Sgavinm 		uint32_t	SwapDone0:1;		/* 1 */
80120c794b3Sgavinm 		uint32_t	SwapEn1:1;		/* 2 */
80220c794b3Sgavinm 		uint32_t	SwapDone1:1;		/* 3 */
80320c794b3Sgavinm 		uint32_t	BadDramCs0:3;		/* 6:4 */
80420c794b3Sgavinm 		uint32_t	reserved1:1;		/* 7 */
80520c794b3Sgavinm 		uint32_t	BadDramCs1:3;		/* 10:8 */
80620c794b3Sgavinm 		uint32_t	reserved2:1;		/* 11 */
80720c794b3Sgavinm 		uint32_t	SwapDoneInt:2;		/* 13:12 */
80820c794b3Sgavinm 		uint32_t	EccErrInt:2;		/* 15:14 */
80920c794b3Sgavinm 		uint32_t	EccErrCntDramCs:4;	/* 19:16 */
81020c794b3Sgavinm 		uint32_t	EccErrCntDramChan:2;	/* 21:20 */
81120c794b3Sgavinm 		uint32_t	reserved4:1;		/* 22 */
81220c794b3Sgavinm 		uint32_t	EccErrCntWrEn:1;	/* 23 */
81320c794b3Sgavinm 		uint32_t	EccErrCnt:4;		/* 27:24 */
81420c794b3Sgavinm 		uint32_t	LvtOffset:4;		/* 31:28 */
81520c794b3Sgavinm 	} _fmt_10_revAB;
8168a40a695Sgavinm };
8177aec1d6eScindi 
81820c794b3Sgavinm /*
81920c794b3Sgavinm  * Since the NB is on-chip some registers are also accessible as MSRs.
82020c794b3Sgavinm  * We will represent such registers as bitfields as in the 32-bit PCI
82120c794b3Sgavinm  * registers above, with the restriction that we must compile for 32-bit
82220c794b3Sgavinm  * kernels and so 64-bit bitfields cannot be used.
82320c794b3Sgavinm  */
82420c794b3Sgavinm 
82520c794b3Sgavinm #define	_MCMSR_FIELD(up, revsuffix, field) ((up)->_fmt_##revsuffix.field)
82620c794b3Sgavinm 
82720c794b3Sgavinm #define	MCMSR_VAL(up) ((up)->_val64)
82820c794b3Sgavinm 
82920c794b3Sgavinm #define	MCMSR_FIELD_CMN(up, field)	_MCMSR_FIELD(up, cmn, field)
83020c794b3Sgavinm #define	MCMSR_FIELD_F_preF(up, field)	_MCMSR_FIELD(up, f_preF, field)
83120c794b3Sgavinm #define	MCMSR_FIELD_F_revFG(up, field)	_MCMSR_FIELD(up, f_revFG, field)
83220c794b3Sgavinm #define	MCMSR_FIELD_10_revAB(up, field)	_MCMSR_FIELD(up, 10_revAB, field)
83320c794b3Sgavinm 
83420c794b3Sgavinm /*
83520c794b3Sgavinm  * The NB MISC registers.  On family 0xf rev F this was introduced with
83620c794b3Sgavinm  * a 12-bit ECC error count of all ECC errors observed on this memory-
83720c794b3Sgavinm  * controller (regardless of channel or chip-select) and the ability to
83820c794b3Sgavinm  * raise an interrupt or SMI on overflow.  In family 0x10 it has a similar
83920c794b3Sgavinm  * purpose, but the register is is split into 4 misc registers
84020c794b3Sgavinm  * MC4_MISC{0,1,2,3} accessible via both MSRs and PCI config space;
84120c794b3Sgavinm  * they perform thresholding for dram, l3, HT errors.
84220c794b3Sgavinm  */
84320c794b3Sgavinm 
84420c794b3Sgavinm union mcmsr_nbmisc {
84520c794b3Sgavinm 	uint64_t _val64;
84620c794b3Sgavinm 	/*
84720c794b3Sgavinm 	 * MSR format in family 0xf revision F and later
84820c794b3Sgavinm 	 */
84920c794b3Sgavinm 	struct {
85020c794b3Sgavinm 		/*
85120c794b3Sgavinm 		 * Lower 32 bits
85220c794b3Sgavinm 		 */
85320c794b3Sgavinm 		struct {
85420c794b3Sgavinm 			uint32_t _reserved;			/* 31:0 */
85520c794b3Sgavinm 		} _mcimisc_lo;
85620c794b3Sgavinm 		/*
85720c794b3Sgavinm 		 * Upper 32 bits
85820c794b3Sgavinm 		 */
85920c794b3Sgavinm 		struct {
86020c794b3Sgavinm 			uint32_t _ErrCount:12;			/* 43:32 */
86120c794b3Sgavinm 			uint32_t _reserved1:4;			/* 47:44 */
86220c794b3Sgavinm 			uint32_t _Ovrflw:1;			/* 48 */
86320c794b3Sgavinm 			uint32_t _IntType:2;			/* 50:49 */
86420c794b3Sgavinm 			uint32_t _CntEn:1;			/* 51 */
86520c794b3Sgavinm 			uint32_t _LvtOff:4;			/* 55:52 */
86620c794b3Sgavinm 			uint32_t _reserved2:5;			/* 60:56 */
86720c794b3Sgavinm 			uint32_t _Locked:1;			/* 61 */
86820c794b3Sgavinm 			uint32_t _CntP:1;			/* 62 */
86920c794b3Sgavinm 			uint32_t _Valid:1;			/* 63 */
87020c794b3Sgavinm 		} _mcimisc_hi;
87120c794b3Sgavinm 	} _fmt_f_revFG;
87220c794b3Sgavinm 	/*
87320c794b3Sgavinm 	 * MSR format in family 0x10 revisions A and B
87420c794b3Sgavinm 	 */
87520c794b3Sgavinm 	struct {
87620c794b3Sgavinm 		/*
87720c794b3Sgavinm 		 * Lower 32 bits
87820c794b3Sgavinm 		 */
87920c794b3Sgavinm 		struct {
88020c794b3Sgavinm 			uint32_t _reserved:24;			/* 23:0 */
88120c794b3Sgavinm 			uint32_t _BlkPtr:8;			/* 31:24 */
88220c794b3Sgavinm 		} _mcimisc_lo;
88320c794b3Sgavinm 		/*
88420c794b3Sgavinm 		 * Upper 32 bits
88520c794b3Sgavinm 		 */
88620c794b3Sgavinm 		struct {
88720c794b3Sgavinm 			uint32_t _ErrCnt:12;			/* 43:32 */
88820c794b3Sgavinm 			uint32_t _reserved1:4;			/* 47:44 */
88920c794b3Sgavinm 			uint32_t _Ovrflw:1;			/* 48 */
89020c794b3Sgavinm 			uint32_t _IntType:2;			/* 50:49 */
89120c794b3Sgavinm 			uint32_t _CntEn:1;			/* 51 */
89220c794b3Sgavinm 			uint32_t _LvtOff:4;			/* 55:52 */
89320c794b3Sgavinm 			uint32_t _reserved2:5;			/* 60:56 */
89420c794b3Sgavinm 			uint32_t _Locked:1;			/* 61 */
89520c794b3Sgavinm 			uint32_t _CntP:1;			/* 62 */
89620c794b3Sgavinm 			uint32_t _Valid:1;			/* 63 */
89720c794b3Sgavinm 
89820c794b3Sgavinm 		} _mcimisc_hi;
89920c794b3Sgavinm 	} _fmt_10_revAB;
90020c794b3Sgavinm };
90120c794b3Sgavinm 
90220c794b3Sgavinm #define	mcmisc_BlkPtr	_mcimisc_lo._BlkPtr
90320c794b3Sgavinm #define	mcmisc_ErrCount	_mcimisc_hi._ErrCount
90420c794b3Sgavinm #define	mcmisc_Ovrflw	_mcimisc_hi._Ovrflw
90520c794b3Sgavinm #define	mcmisc_IntType	_mcimisc_hi._IntType
90620c794b3Sgavinm #define	mcmisc_CntEn	_mcimisc_hi._CntEn
90720c794b3Sgavinm #define	mcmisc_LvtOff	_mcimisc_hi._LvtOff
90820c794b3Sgavinm #define	mcmisc_Locked	_mcimisc_hi._Locked
90920c794b3Sgavinm #define	mcmisc_CntP	_mcimisc_hi._CntP
91020c794b3Sgavinm #define	mcmisc_Valid	_mcimisc_hi._Valid
91120c794b3Sgavinm 
91220c794b3Sgavinm #endif /* _BIT_FIELDS_LTOH */
91320c794b3Sgavinm 
9147aec1d6eScindi #ifdef __cplusplus
9157aec1d6eScindi }
9167aec1d6eScindi #endif
9177aec1d6eScindi 
9187aec1d6eScindi #endif /* _MC_AMD_H */
919