xref: /titanic_44/usr/src/uts/sun4u/serengeti/sys/serengeti.h (revision 03831d35f7499c87d51205817c93e9a8d42c4bae)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_SERENGETI_H
28 #define	_SYS_SERENGETI_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * serengeti.h - Serengeti/WildCat common header file
38  *
39  * This header file contains the common definitions and macros for the
40  * Serengeti and WildCat platforms. We define them all here to avoid them
41  * being redefined in numerous different drivers.
42  */
43 
44 #include <sys/dditypes.h>
45 
46 /*
47  * Definitions
48  * ===========
49  */
50 
51 #ifndef	TRUE
52 #define	TRUE	1
53 #endif
54 
55 #ifndef	FALSE
56 #define	FALSE	0
57 #endif
58 
59 
60 #define	SG_MAX_IO_PER_BD		5	/* 4 pci buses + cpci */
61 #define	SG_MAX_CMPS_PER_BD		4
62 #define	SG_MAX_CPUS_PER_BD		8
63 #define	SG_MAX_MEM_PER_BD		1
64 #define	SG_MAX_CPU_BDS			6
65 #define	SG_MAX_IO_BDS			4
66 #define	SG_MAX_POWER_SUPPLIES		6
67 #define	SG_MAX_FAN_TRAYS		6
68 #define	SG_MAX_REPEATER_BDS		4
69 #define	SG_MAX_BDS			(SG_MAX_CPU_BDS + SG_MAX_IO_BDS)
70 #define	SG_MAX_CPUS			(SG_MAX_CPUS_PER_BD * SG_MAX_CPU_BDS)
71 
72 #define	SG_MAX_SLOTS_PER_IO_BD		8
73 #define	SG_SCHIZO_PER_IO_BD		2
74 
75 #define	SSM_MAX_INSTANCES		16
76 #define	SSM_MAX_BDS			(SSM_MAX_INSTANCES * SG_MAX_BDS)
77 
78 #define	SG_MIN_CPU_SAFARI_ID		0	/* 0x00 */
79 #define	SG_MAX_CPU_SAFARI_ID		23	/* 0x17 */
80 #define	SG_MIN_IO_SAFARI_ID		24	/* 0x18 */
81 #define	SG_MAX_IO_SAFARI_ID		31	/* 0x1F */
82 
83 
84 /*
85  * possible states for the Keyswitch Position.
86  */
87 #define	SG_KEYSWITCH_POSN_UNKNOWN	(-1)
88 #define	SG_KEYSWITCH_POSN_ON		2
89 #define	SG_KEYSWITCH_POSN_DIAG		3
90 #define	SG_KEYSWITCH_POSN_SECURE	4
91 
92 
93 
94 /*
95  * Macros
96  * ======
97  */
98 
99 /* we only need the 5 LSB of the portid to calculate the board number */
100 #define	SG_SAFARI_ID_MASK		0x1F	/* 5 bits */
101 #define	SG_CPU_ID_MASK			0x21F	/* bit 9 and bits 0-4 */
102 #define	SG_CORE_ID_MASK			0x200	/* bit 9 */
103 #define	SG_NODE_MASK			0x0F	/* 4 bits */
104 #define	SG_PORTID_NODE_SHIFT		5
105 
106 /*
107  * For Serengeti and WildCat the portid consists of 10 bits.
108  *
109  * [9] [8 -------- 5][4 --------- 0]
110  *  ^      NodeID        AgentID
111  *  |___ Used in CMP to identify core 1.  Unused with non-CMP.
112  *
113  * For CPU boards:
114  *	Aid <4:2>			: Board ID/Number
115  *	Aid <1:0>			: CPU ID
116  * For IO boards:
117  *	(Aid <4:0> - 24) / 2 + 6	: Board ID/Number
118  * 	(Aid <4:0> - 24) % 2		: Schizo ID
119  */
120 
121 /*
122  * For Jaguar there are two CPU IDs the can be derived from portid
123  * and coreid.  On Serengeti, bit 9 is set for core 1, resulting in
124  * the cpuid for core 1 being 512 off from the one for core 0.
125  */
126 #define	SG_JG_CORE1_SHIFT		9
127 #define	SG_JG_CORE1_OFFSET		(1 << SG_JG_CORE1_SHIFT)
128 #define	SG_PORTID_TO_CPUID(p, c)	((p) + ((c) << SG_JG_CORE1_SHIFT))
129 #define	SG_PORTID_TO_CPU_UNIT(p, c)	((p % SG_MAX_CMPS_PER_BD) | \
130 					    ((c) * SG_MAX_CMPS_PER_BD))
131 #define	SG_CPUID_TO_PORTID(c)		((c) & SG_SAFARI_ID_MASK)
132 #define	SG_CPUID_TO_COREID(c)		(((c) & SG_CORE_ID_MASK) >> \
133 					    SG_JG_CORE1_SHIFT)
134 #define	SG_CPUID_TO_CPU_UNIT(c)		SG_PORTID_TO_CPU_UNIT( \
135 					    SG_CPUID_TO_PORTID(c), \
136 					    SG_CPUID_TO_COREID(c))
137 
138 /*
139  * SG_PORTID_TO_NODEID
140  *
141  * Calculates the SSM NodeID from the portid
142  */
143 #define	SG_PORTID_TO_NODEID(portid)	(((portid) >> SG_PORTID_NODE_SHIFT) & \
144 						SG_NODE_MASK)
145 
146 /*
147  * SG_PORTID_TO_SAFARI_ID
148  *
149  * Calculates the Safari Agent ID from the portid.
150  */
151 #define	SG_PORTID_TO_SAFARI_ID(portid)	((portid) & SG_SAFARI_ID_MASK)
152 
153 
154 /*
155  * SG_PORTID_TO_BOARD_NUM
156  *
157  * If a valid portid is passed in, this macro returns the board number
158  * associated with it, otherwise it returns -1.
159  */
160 #define	SG_PORTID_TO_BOARD_NUM(portid) \
161 	((SG_PORTID_IS_CPU_TYPE(portid)) ? \
162 		(SG_CPU_BD_PORTID_TO_BD_NUM(portid)) : \
163 	((SG_PORTID_IS_IO_TYPE(portid)) ? \
164 		SG_IO_BD_PORTID_TO_BD_NUM(portid) : (-1)))
165 
166 /*
167  * SG_BOARD_IS_CPU_TYPE
168  *
169  * If the board number of a board of CPU type is passed in, TRUE is returned,
170  * otherwise FALSE.
171  */
172 #define	SG_BOARD_IS_CPU_TYPE(board_num) \
173 	((((board_num) >= 0) && ((board_num) < SG_MAX_CPU_BDS)) ? TRUE: FALSE)
174 
175 /*
176  * SG_BOARD_IS_IO_TYPE
177  *
178  * If the board number of a board of IO type is passed in, TRUE is returned,
179  * otherwise FALSE.
180  */
181 #define	SG_BOARD_IS_IO_TYPE(board_num) \
182 	((((board_num) >= SG_MAX_CPU_BDS) && \
183 		((board_num) < SG_MAX_BDS)) ? TRUE: FALSE)
184 
185 /*
186  * SG_PORTID_IS_CPU_TYPE
187  *
188  * If the portid associated with a CPU board is passed in, TRUE is returned,
189  * otherwise FALSE.
190  */
191 #define	SG_PORTID_IS_CPU_TYPE(portid) \
192 	(((((portid) & SG_SAFARI_ID_MASK) >= SG_MIN_CPU_SAFARI_ID) && \
193 	(((portid) & SG_SAFARI_ID_MASK) <= SG_MAX_CPU_SAFARI_ID)) ? TRUE: FALSE)
194 
195 /*
196  * SG_PORTID_IS_IO_TYPE
197  *
198  * If the portid associated with an IO board is passed in, TRUE is returned,
199  * otherwise FALSE.
200  */
201 #define	SG_PORTID_IS_IO_TYPE(portid) \
202 	(((((portid) & SG_SAFARI_ID_MASK) >= SG_MIN_IO_SAFARI_ID) && \
203 	(((portid) & SG_SAFARI_ID_MASK) <= SG_MAX_IO_SAFARI_ID)) ? TRUE: FALSE)
204 
205 /*
206  * SG_CPU_BD_PORTID_TO_BD_NUM
207  *
208  * If the portid associated with a CPU board is passed in, the board number
209  * associated with this portid is returned, otherwise -1.
210  */
211 #define	SG_CPU_BD_PORTID_TO_BD_NUM(portid) \
212 	((SG_PORTID_IS_CPU_TYPE(portid)) ? \
213 		(((portid) & SG_SAFARI_ID_MASK) / 4) : (-1))
214 
215 /*
216  * SG_IO_BD_PORTID_TO_BD_NUM
217  *
218  * If the portid associated with an IO board is passed in, the board number
219  * associated with this portid is returned, otherwise -1.
220  */
221 #define	SG_IO_BD_PORTID_TO_BD_NUM(portid) \
222 	(SG_PORTID_IS_IO_TYPE(portid) ? \
223 		(((((portid) & SG_SAFARI_ID_MASK) - 24) / 2) + 6) : (-1))
224 
225 /*
226  * SG_PORTID_TO_CPU_POSN
227  *
228  * If the portid associated with a CPU board is passed in, the position
229  * of the CPU module for this portid is returned, otherwise -1.
230  */
231 #define	SG_PORTID_TO_CPU_POSN(portid) \
232 	((SG_PORTID_IS_CPU_TYPE(portid)) ? \
233 		(((portid) & SG_SAFARI_ID_MASK) % 4) : (-1))
234 
235 /*
236  * Serengeti slices are defined by bits 34..41 of the physical address
237  * space, and can contain Safari agent ID bits depending upon the SC
238  * firmware being used.
239  */
240 
241 #define	PA_SLICE_SHIFT		(34)
242 #define	PFN_SLICE_SHIFT		(PA_SLICE_SHIFT - MMU_PAGESHIFT)
243 #define	PA_2_SLICE(pa)		(((pa) >> PA_SLICE_SHIFT) & SG_SLICE_MASK)
244 #define	PFN_2_SLICE(pfn)	(((pfn) >> PFN_SLICE_SHIFT) & SG_SLICE_MASK)
245 
246 /* Define the max memory banks per CPU board */
247 #define	SG_MAX_BANKS_PER_MC	(4)
248 
249 /* Define the number of possible slices for the span of slice bits */
250 #define	SG_SLICE_MASK		(0xff)
251 #define	SG_MAX_SLICE		(SG_SLICE_MASK + 1)
252 
253 /*
254  * b represents the SB and c represents the processor (P)
255  * in relation to the SB.
256  */
257 #define	MAKE_CPUID(b, c)	((b*4) + c)
258 
259 /* Each physical CPU has 2 ecache DIMMs */
260 #define	SG_NUM_ECACHE_DIMMS_PER_CPU	2
261 
262 /* Bit 4 of the physical address indicates ecache dimm 0 or 1 */
263 #define	SG_ECACHE_DIMM_SHIFT	4
264 #define	SG_ECACHE_DIMM_MASK	0x10
265 
266 extern	dev_info_t	*find_chosen_dip(void);
267 
268 extern int sg_get_prom_version(int *sysp, int *intfp, int *bldp);
269 extern int sg_prom_sb_dr_check(void);
270 extern int sg_prom_cpci_dr_check(void);
271 extern int sg_get_ecacheunum(int cpuid, uint64_t physaddr, char *buf,
272     uint_t buflen, int *lenp);
273 
274 #ifdef	__cplusplus
275 }
276 #endif
277 
278 #endif	/* _SYS_SERENGETI_H */
279