xref: /titanic_53/usr/src/uts/sun4u/sys/mc-us3i.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_SYS_MC_US3I_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_MC_US3I_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
33*7c478bd9Sstevel@tonic-gate extern "C" {
34*7c478bd9Sstevel@tonic-gate #endif
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #if defined(_KERNEL)
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate #define	NDGRPS_PER_MC		2		/* max dimm groups per mctrl */
39*7c478bd9Sstevel@tonic-gate #define	NDIMMS_PER_DGRP		2		/* max dimms in a group/pair */
40*7c478bd9Sstevel@tonic-gate #define	NLOGBANKS_PER_DGRP	2		/* max logical banks per grp */
41*7c478bd9Sstevel@tonic-gate #define	NLOGBANKS_PER_MC	16		/* max logical banks per mc */
42*7c478bd9Sstevel@tonic-gate #define	NLOGBANKS_PER_SEG	16		/* max logical banks per seg */
43*7c478bd9Sstevel@tonic-gate #define	MAX_DEVLEN		8
44*7c478bd9Sstevel@tonic-gate #define	TRANSFER_SIZE		64
45*7c478bd9Sstevel@tonic-gate 
46*7c478bd9Sstevel@tonic-gate #define	MC_SELECT_MASK		0x3000000000LL	/* upto 4 MCs at 64GB boundry */
47*7c478bd9Sstevel@tonic-gate #define	MC_SELECT_SHIFT		36
48*7c478bd9Sstevel@tonic-gate #define	DIMM_PAIR_SELECT_MASK	0x200000000LL	/* at 8GB boundry */
49*7c478bd9Sstevel@tonic-gate #define	DIMM_PAIR_SELECT_SHIFT	33
50*7c478bd9Sstevel@tonic-gate #define	LOG_BANK_SELECT_MASK	0x100000000LL	/* at 4GB boundry */
51*7c478bd9Sstevel@tonic-gate #define	LOG_BANK_SELECT_SHIFT	32
52*7c478bd9Sstevel@tonic-gate #define	XOR_DEVICE_SELECT_MASK	0x200000LL	/* at 2MB boundry */
53*7c478bd9Sstevel@tonic-gate #define	XOR_DEVICE_SELECT_SHIFT	21
54*7c478bd9Sstevel@tonic-gate #define	XOR_BANK_SELECT_MASK	0x100000LL	/* at 1MB boundry */
55*7c478bd9Sstevel@tonic-gate #define	XOR_BANK_SELECT_SHIFT	20
56*7c478bd9Sstevel@tonic-gate 
57*7c478bd9Sstevel@tonic-gate #define	MC_SIZE_MAX		0x1000000000LL	/* 64GB */
58*7c478bd9Sstevel@tonic-gate #define	DGRP_SIZE_MAX		0x200000000LL	/*  8GB */
59*7c478bd9Sstevel@tonic-gate #define	BANK_SIZE_MAX		0x100000000LL	/*  4GB */
60*7c478bd9Sstevel@tonic-gate 
61*7c478bd9Sstevel@tonic-gate #define	MC_BASE(id)		(id * MC_SIZE_MAX)
62*7c478bd9Sstevel@tonic-gate #define	DGRP_BASE(id)		((id & (NDGRPS_PER_MC - 1)) * DGRP_SIZE_MAX)
63*7c478bd9Sstevel@tonic-gate #define	LOGBANK_BASE(id)	((id & (NLOGBANKS_PER_SEG - 1)) * BANK_SIZE_MAX)
64*7c478bd9Sstevel@tonic-gate 
65*7c478bd9Sstevel@tonic-gate #define	ADDR_GEN_128Mb_X8_ROW_0	14
66*7c478bd9Sstevel@tonic-gate #define	ADDR_GEN_512Mb_X8_ROW_0	15
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate #ifndef	_ASM
69*7c478bd9Sstevel@tonic-gate 
70*7c478bd9Sstevel@tonic-gate struct mc_soft_state {
71*7c478bd9Sstevel@tonic-gate 	dev_info_t	*dip;	/* dev info of myself */
72*7c478bd9Sstevel@tonic-gate 	int		portid;
73*7c478bd9Sstevel@tonic-gate 	int		mcr_read_ok;
74*7c478bd9Sstevel@tonic-gate 	uint64_t	mcreg1;
75*7c478bd9Sstevel@tonic-gate 	int		reglen;
76*7c478bd9Sstevel@tonic-gate 	void		*reg;
77*7c478bd9Sstevel@tonic-gate 	int		memlayoutlen;
78*7c478bd9Sstevel@tonic-gate 	void		*memlayoutp;
79*7c478bd9Sstevel@tonic-gate };
80*7c478bd9Sstevel@tonic-gate 
81*7c478bd9Sstevel@tonic-gate struct memory_reg_info {
82*7c478bd9Sstevel@tonic-gate 	uint64_t base;
83*7c478bd9Sstevel@tonic-gate 	uint64_t size;
84*7c478bd9Sstevel@tonic-gate };
85*7c478bd9Sstevel@tonic-gate 
86*7c478bd9Sstevel@tonic-gate struct dimm_info {
87*7c478bd9Sstevel@tonic-gate 	char	label[NDGRPS_PER_MC * NDIMMS_PER_DGRP][MAX_DEVLEN];
88*7c478bd9Sstevel@tonic-gate 	char	table_width;	/* 1: symmetric 0: asymmetric */
89*7c478bd9Sstevel@tonic-gate 	char	data[1];
90*7c478bd9Sstevel@tonic-gate };
91*7c478bd9Sstevel@tonic-gate 
92*7c478bd9Sstevel@tonic-gate struct pin_info {
93*7c478bd9Sstevel@tonic-gate 	uchar_t	dimmtable[18];
94*7c478bd9Sstevel@tonic-gate 	uchar_t	pintable[144];
95*7c478bd9Sstevel@tonic-gate };
96*7c478bd9Sstevel@tonic-gate 
97*7c478bd9Sstevel@tonic-gate /* This struct is included at the following structs to set up list */
98*7c478bd9Sstevel@tonic-gate typedef struct mc_dlist {
99*7c478bd9Sstevel@tonic-gate 	struct mc_dlist *next;
100*7c478bd9Sstevel@tonic-gate 	struct mc_dlist *prev;
101*7c478bd9Sstevel@tonic-gate 	int id;
102*7c478bd9Sstevel@tonic-gate } mc_dlist_t;
103*7c478bd9Sstevel@tonic-gate 
104*7c478bd9Sstevel@tonic-gate /* unique segment id */
105*7c478bd9Sstevel@tonic-gate struct seg_info {
106*7c478bd9Sstevel@tonic-gate 	mc_dlist_t seg_node;
107*7c478bd9Sstevel@tonic-gate 	int nbanks;		/* The number of banks at this segment */
108*7c478bd9Sstevel@tonic-gate 	uint32_t ifactor;	/* Max interleave factor at this segment */
109*7c478bd9Sstevel@tonic-gate 	uint64_t base;
110*7c478bd9Sstevel@tonic-gate 	uint64_t size;		/* memory size per segment */
111*7c478bd9Sstevel@tonic-gate 	struct bank_info *head;	/* first bank at this segment */
112*7c478bd9Sstevel@tonic-gate 	struct bank_info *tail;	/* last bank at this segment */
113*7c478bd9Sstevel@tonic-gate };
114*7c478bd9Sstevel@tonic-gate 
115*7c478bd9Sstevel@tonic-gate /* id = mc_id * nbanks + bank_no */
116*7c478bd9Sstevel@tonic-gate struct bank_info {
117*7c478bd9Sstevel@tonic-gate 	mc_dlist_t bank_node;
118*7c478bd9Sstevel@tonic-gate 	int local_id;		/* unique local bank id per segment */
119*7c478bd9Sstevel@tonic-gate 	int seg_id;		/* unique segment id */
120*7c478bd9Sstevel@tonic-gate 	int devgrp_id;		/* unique device group id */
121*7c478bd9Sstevel@tonic-gate 	uint64_t mask;		/* If (Physical Address & MASK) == MATCH */
122*7c478bd9Sstevel@tonic-gate 	uint64_t match;		/* Physic Address is located at this bank. */
123*7c478bd9Sstevel@tonic-gate 	uint64_t base;		/* base address of the logical bank */
124*7c478bd9Sstevel@tonic-gate 	uint64_t size;		/* memory size per logical bank */
125*7c478bd9Sstevel@tonic-gate 	struct bank_info *next; /* next bank at the same segment */
126*7c478bd9Sstevel@tonic-gate };
127*7c478bd9Sstevel@tonic-gate 
128*7c478bd9Sstevel@tonic-gate /* id = id of dgrp_info * ndevices + device_no */
129*7c478bd9Sstevel@tonic-gate struct device_info {
130*7c478bd9Sstevel@tonic-gate 	mc_dlist_t dev_node;
131*7c478bd9Sstevel@tonic-gate 	char label[MAX_DEVLEN];
132*7c478bd9Sstevel@tonic-gate 	uint64_t size;		/* memory size per physical dimm */
133*7c478bd9Sstevel@tonic-gate };
134*7c478bd9Sstevel@tonic-gate 
135*7c478bd9Sstevel@tonic-gate /* id = mc_id * ndevgrps + devgrp_no */
136*7c478bd9Sstevel@tonic-gate struct dgrp_info {
137*7c478bd9Sstevel@tonic-gate 	mc_dlist_t dgrp_node;
138*7c478bd9Sstevel@tonic-gate 	int ndevices;		/* number of physical dimms - always a pair */
139*7c478bd9Sstevel@tonic-gate 	int nlogbanks;		/* number of logical banks - single or dual */
140*7c478bd9Sstevel@tonic-gate 	int base_device;	/* base density - 128Mb, 256Mb, 512Mb or 1Gb */
141*7c478bd9Sstevel@tonic-gate 	int part_type;		/* part type - x4, x8 */
142*7c478bd9Sstevel@tonic-gate 	uint64_t base;		/* physical memory base of the dev group */
143*7c478bd9Sstevel@tonic-gate 	uint64_t size;		/* total memory size of the dev group */
144*7c478bd9Sstevel@tonic-gate 	int deviceids[NDIMMS_PER_DGRP];	/* 2 dimms per group on Jalapeno */
145*7c478bd9Sstevel@tonic-gate };
146*7c478bd9Sstevel@tonic-gate 
147*7c478bd9Sstevel@tonic-gate /* id = portid */
148*7c478bd9Sstevel@tonic-gate struct mctrl_info {
149*7c478bd9Sstevel@tonic-gate 	mc_dlist_t mctrl_node;
150*7c478bd9Sstevel@tonic-gate 	int ndevgrps;		/* The number of dimm groups */
151*7c478bd9Sstevel@tonic-gate 	int devgrpids[NDGRPS_PER_MC];
152*7c478bd9Sstevel@tonic-gate 	struct dimm_info *dimminfop;
153*7c478bd9Sstevel@tonic-gate };
154*7c478bd9Sstevel@tonic-gate 
155*7c478bd9Sstevel@tonic-gate extern int (*p2get_mem_unum)(int, uint64_t, char *, int, int *);
156*7c478bd9Sstevel@tonic-gate extern int (*p2get_mem_info)(int, uint64_t, uint64_t *, uint64_t *,
157*7c478bd9Sstevel@tonic-gate     uint64_t *, int *, int *, int *);
158*7c478bd9Sstevel@tonic-gate extern int plat_add_mem_unum_label(char *, int, int, int);
159*7c478bd9Sstevel@tonic-gate 
160*7c478bd9Sstevel@tonic-gate uint64_t get_mcr(int);
161*7c478bd9Sstevel@tonic-gate 
162*7c478bd9Sstevel@tonic-gate /* #ifdef	DEBUG */
163*7c478bd9Sstevel@tonic-gate 
164*7c478bd9Sstevel@tonic-gate #include <sys/promif.h>
165*7c478bd9Sstevel@tonic-gate 
166*7c478bd9Sstevel@tonic-gate /* useful debugging level of DPRINTF */
167*7c478bd9Sstevel@tonic-gate #define	MC_ATTACH_DEBUG	0x00000001
168*7c478bd9Sstevel@tonic-gate #define	MC_DETACH_DEBUG	0x00000002
169*7c478bd9Sstevel@tonic-gate #define	MC_CMD_DEBUG	0x00000004
170*7c478bd9Sstevel@tonic-gate #define	MC_REG_DEBUG	0x00000008
171*7c478bd9Sstevel@tonic-gate #define	MC_GUNUM_DEBUG	0x00000010
172*7c478bd9Sstevel@tonic-gate #define	MC_CNSTRC_DEBUG	0x00000020
173*7c478bd9Sstevel@tonic-gate #define	MC_DESTRC_DEBUG	0x00000040
174*7c478bd9Sstevel@tonic-gate #define	MC_LIST_DEBUG	0x00000080
175*7c478bd9Sstevel@tonic-gate 
176*7c478bd9Sstevel@tonic-gate 
177*7c478bd9Sstevel@tonic-gate #define	_PRINTF printf
178*7c478bd9Sstevel@tonic-gate #define	DPRINTF(flag, args)	if (mc_debug & flag) _PRINTF args;
179*7c478bd9Sstevel@tonic-gate #else
180*7c478bd9Sstevel@tonic-gate #define	DPRINTF(flag, args)
181*7c478bd9Sstevel@tonic-gate 
182*7c478bd9Sstevel@tonic-gate /* #endif  DEBUG */
183*7c478bd9Sstevel@tonic-gate 
184*7c478bd9Sstevel@tonic-gate #endif	/* !_ASM */
185*7c478bd9Sstevel@tonic-gate 
186*7c478bd9Sstevel@tonic-gate /* Memory Control Registers */
187*7c478bd9Sstevel@tonic-gate #define	ASI_MCU_CTRL		0x72
188*7c478bd9Sstevel@tonic-gate #define	MCREG1OFFSET		0x00
189*7c478bd9Sstevel@tonic-gate 
190*7c478bd9Sstevel@tonic-gate /* Mask and shift constants for Memory Control Register I */
191*7c478bd9Sstevel@tonic-gate #define	MCREG1_DIMM2_BANK3	0x8000000000000000ULL	/* bit 63 */
192*7c478bd9Sstevel@tonic-gate #define	MCREG1_DIMM1_BANK1	0x4000000000000000ULL	/* bit 62 */
193*7c478bd9Sstevel@tonic-gate #define	MCREG1_DIMM2_BANK2	0x2000000000000000ULL	/* bit 61 */
194*7c478bd9Sstevel@tonic-gate #define	MCREG1_DIMM1_BANK0	0x1000000000000000ULL	/* bit 60 */
195*7c478bd9Sstevel@tonic-gate 
196*7c478bd9Sstevel@tonic-gate #define	MCREG1_XOR_ENABLE	0x10000000000LL		/* bit 40 */
197*7c478bd9Sstevel@tonic-gate #define	MCREG1_ADDRGEN2_MASK	0xE000000000LL		/* bits 39:37 */
198*7c478bd9Sstevel@tonic-gate #define	MCREG1_ADDRGEN2_SHIFT	37
199*7c478bd9Sstevel@tonic-gate #define	MCREG1_ADDRGEN1_MASK	0x1C00000000LL		/* bits 36:34 */
200*7c478bd9Sstevel@tonic-gate #define	MCREG1_ADDRGEN1_SHIFT	34
201*7c478bd9Sstevel@tonic-gate #define	BASE_DEVICE_128Mb	0
202*7c478bd9Sstevel@tonic-gate #define	BASE_DEVICE_256Mb	1
203*7c478bd9Sstevel@tonic-gate #define	BASE_DEVICE_512Mb	2
204*7c478bd9Sstevel@tonic-gate #define	BASE_DEVICE_1Gb		3
205*7c478bd9Sstevel@tonic-gate 
206*7c478bd9Sstevel@tonic-gate #define	MCREG1_INTERLEAVE_MASK			0x1800000LL	/* bits 24:23 */
207*7c478bd9Sstevel@tonic-gate #define	MCREG1_INTERLEAVE_SHIFT			23
208*7c478bd9Sstevel@tonic-gate #define	INTERLEAVE_DISABLE			0
209*7c478bd9Sstevel@tonic-gate #define	INTERLEAVE_INTEXT_SAME_DIMM_PAIR	1
210*7c478bd9Sstevel@tonic-gate #define	INTERLEAVE_INTERNAL			2
211*7c478bd9Sstevel@tonic-gate #define	INTERLEAVE_INTEXT_BOTH_DIMM_PAIR	3
212*7c478bd9Sstevel@tonic-gate 
213*7c478bd9Sstevel@tonic-gate #define	MCREG1_X4DIMM2_MASK	0x200000LL		/* bit 21 */
214*7c478bd9Sstevel@tonic-gate #define	MCREG1_X4DIMM2_SHIFT	21
215*7c478bd9Sstevel@tonic-gate #define	MCREG1_X4DIMM1_MASK	0x100000LL		/* bit 20 */
216*7c478bd9Sstevel@tonic-gate #define	MCREG1_X4DIMM1_SHIFT	20
217*7c478bd9Sstevel@tonic-gate #define	PART_TYPE_X4		1
218*7c478bd9Sstevel@tonic-gate #define	PART_TYPE_X8		0
219*7c478bd9Sstevel@tonic-gate 
220*7c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
221*7c478bd9Sstevel@tonic-gate 
222*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
223*7c478bd9Sstevel@tonic-gate }
224*7c478bd9Sstevel@tonic-gate #endif
225*7c478bd9Sstevel@tonic-gate 
226*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_MC_US3I_H */
227