xref: /titanic_52/usr/src/uts/sun4u/sys/mc-us3.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_US3_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_MC_US3_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	NBANKS	4
39*7c478bd9Sstevel@tonic-gate #define	NDGRPS	2
40*7c478bd9Sstevel@tonic-gate #define	NDIMMS	4
41*7c478bd9Sstevel@tonic-gate #define	MAX_DEVLEN	8
42*7c478bd9Sstevel@tonic-gate #define	TRANSFER_SIZE	64
43*7c478bd9Sstevel@tonic-gate 
44*7c478bd9Sstevel@tonic-gate #ifndef	_ASM
45*7c478bd9Sstevel@tonic-gate 
46*7c478bd9Sstevel@tonic-gate struct mc_soft_state {
47*7c478bd9Sstevel@tonic-gate 	dev_info_t *dip;	/* dev info of myself */
48*7c478bd9Sstevel@tonic-gate 	int portid;
49*7c478bd9Sstevel@tonic-gate 	int size;
50*7c478bd9Sstevel@tonic-gate 	void *memlayoutp;
51*7c478bd9Sstevel@tonic-gate 	volatile uchar_t *mc_base; /* Mapped base address of MC registers */
52*7c478bd9Sstevel@tonic-gate };
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate struct dimm_info {
55*7c478bd9Sstevel@tonic-gate 	char	label[NDGRPS * NDIMMS][MAX_DEVLEN];	/* dimm lable */
56*7c478bd9Sstevel@tonic-gate 	char	sym_flag;	/* 1: symmetric 0: asymmetric */
57*7c478bd9Sstevel@tonic-gate 	char	data[1];
58*7c478bd9Sstevel@tonic-gate };
59*7c478bd9Sstevel@tonic-gate 
60*7c478bd9Sstevel@tonic-gate struct pin_info {
61*7c478bd9Sstevel@tonic-gate 	uchar_t	dimmtable[144];
62*7c478bd9Sstevel@tonic-gate 	uchar_t	pintable[576];
63*7c478bd9Sstevel@tonic-gate };
64*7c478bd9Sstevel@tonic-gate 
65*7c478bd9Sstevel@tonic-gate /* This struct is included at the following structs to set up list */
66*7c478bd9Sstevel@tonic-gate typedef struct mc_dlist {
67*7c478bd9Sstevel@tonic-gate 	struct mc_dlist *next;
68*7c478bd9Sstevel@tonic-gate 	struct mc_dlist *prev;
69*7c478bd9Sstevel@tonic-gate 	int id;
70*7c478bd9Sstevel@tonic-gate } mc_dlist_t;
71*7c478bd9Sstevel@tonic-gate 
72*7c478bd9Sstevel@tonic-gate /* unique segment id */
73*7c478bd9Sstevel@tonic-gate struct seg_info {
74*7c478bd9Sstevel@tonic-gate 	mc_dlist_t seg_node;
75*7c478bd9Sstevel@tonic-gate 	int nbanks;		/* The number of banks at this segment */
76*7c478bd9Sstevel@tonic-gate 	uint32_t ifactor;	/* Max interleave factor at this segment */
77*7c478bd9Sstevel@tonic-gate 	uint64_t base;
78*7c478bd9Sstevel@tonic-gate 	uint64_t size;		/* memory size per segment */
79*7c478bd9Sstevel@tonic-gate 	struct bank_info *hb_inseg;	/* first bank at this segment */
80*7c478bd9Sstevel@tonic-gate 	struct bank_info *tb_inseg;	/* last bank at this segment */
81*7c478bd9Sstevel@tonic-gate };
82*7c478bd9Sstevel@tonic-gate 
83*7c478bd9Sstevel@tonic-gate /* id = mc_id * nbanks + bank_no */
84*7c478bd9Sstevel@tonic-gate struct bank_info {
85*7c478bd9Sstevel@tonic-gate 	mc_dlist_t bank_node;
86*7c478bd9Sstevel@tonic-gate 	int local_id;		/* unique local bank id per segment */
87*7c478bd9Sstevel@tonic-gate 	int seg_id;		/* unique segment id */
88*7c478bd9Sstevel@tonic-gate 	int devgrp_id;		/* unique device group id */
89*7c478bd9Sstevel@tonic-gate 	ushort_t valid;		/* valid flag per logic bank */
90*7c478bd9Sstevel@tonic-gate 	ushort_t uk;		/* Upper Mask field to mask match 4 PA[37:26] */
91*7c478bd9Sstevel@tonic-gate 	uint_t um;		/* Upper Match field to match PA[42:26] */
92*7c478bd9Sstevel@tonic-gate 	uchar_t lk;		/* Lower Mask field to mask match 4 PA[9:6] */
93*7c478bd9Sstevel@tonic-gate 	uchar_t lm;		/* Lower Match field to match PA[9:6] */
94*7c478bd9Sstevel@tonic-gate 	uint64_t size;		/* memory size per logical bank */
95*7c478bd9Sstevel@tonic-gate 	struct bank_info *n_inseg; /* next bank at the same segment */
96*7c478bd9Sstevel@tonic-gate 	struct bank_info *p_inseg; /* previous bank at the same segment */
97*7c478bd9Sstevel@tonic-gate 	struct dimm_info *dimminfop;
98*7c478bd9Sstevel@tonic-gate };
99*7c478bd9Sstevel@tonic-gate 
100*7c478bd9Sstevel@tonic-gate /* id = mc_id * ndevgrps + devgrp_no */
101*7c478bd9Sstevel@tonic-gate struct dgrp_info {
102*7c478bd9Sstevel@tonic-gate 	mc_dlist_t dgrp_node;
103*7c478bd9Sstevel@tonic-gate 	int ndevices;	/* The number of available devices on this dev group */
104*7c478bd9Sstevel@tonic-gate 	uint64_t size;	/* memory size per physical dimm group */
105*7c478bd9Sstevel@tonic-gate 	int deviceids[NDIMMS];	/* 4 dimms per group on excalibur */
106*7c478bd9Sstevel@tonic-gate };
107*7c478bd9Sstevel@tonic-gate 
108*7c478bd9Sstevel@tonic-gate /* id = id of dgrp_info * ndevices + device_no */
109*7c478bd9Sstevel@tonic-gate struct device_info {
110*7c478bd9Sstevel@tonic-gate 	mc_dlist_t dev_node;
111*7c478bd9Sstevel@tonic-gate 	char label[MAX_DEVLEN];
112*7c478bd9Sstevel@tonic-gate 	uint64_t size;		/* memory size per physical dimm */
113*7c478bd9Sstevel@tonic-gate };
114*7c478bd9Sstevel@tonic-gate 
115*7c478bd9Sstevel@tonic-gate /* id = portid */
116*7c478bd9Sstevel@tonic-gate struct mctrl_info {
117*7c478bd9Sstevel@tonic-gate 	mc_dlist_t mctrl_node;
118*7c478bd9Sstevel@tonic-gate 	int ndevgrps;		/* The number of dimm groups */
119*7c478bd9Sstevel@tonic-gate 	int devgrpids[NDGRPS];
120*7c478bd9Sstevel@tonic-gate };
121*7c478bd9Sstevel@tonic-gate 
122*7c478bd9Sstevel@tonic-gate extern int (*p2get_mem_unum)(int, uint64_t, char *, int, int *);
123*7c478bd9Sstevel@tonic-gate extern int (*p2get_mem_info)(int, uint64_t, uint64_t *, uint64_t *,
124*7c478bd9Sstevel@tonic-gate     uint64_t *, int *, int *, int *);
125*7c478bd9Sstevel@tonic-gate extern int plat_add_mem_unum_label(char *, int, int, int);
126*7c478bd9Sstevel@tonic-gate 
127*7c478bd9Sstevel@tonic-gate uint64_t get_mcr(int);
128*7c478bd9Sstevel@tonic-gate 
129*7c478bd9Sstevel@tonic-gate #ifdef	DEBUG
130*7c478bd9Sstevel@tonic-gate 
131*7c478bd9Sstevel@tonic-gate #include <sys/promif.h>
132*7c478bd9Sstevel@tonic-gate 
133*7c478bd9Sstevel@tonic-gate /* useful debugging level of DPRINTF */
134*7c478bd9Sstevel@tonic-gate #define	MC_ATTACH_DEBUG	0x00000001
135*7c478bd9Sstevel@tonic-gate #define	MC_DETACH_DEBUG	0x00000002
136*7c478bd9Sstevel@tonic-gate #define	MC_CMD_DEBUG	0x00000004
137*7c478bd9Sstevel@tonic-gate #define	MC_REG_DEBUG	0x00000008
138*7c478bd9Sstevel@tonic-gate #define	MC_GUNUM_DEBUG	0x00000010
139*7c478bd9Sstevel@tonic-gate #define	MC_CNSTRC_DEBUG	0x00000020
140*7c478bd9Sstevel@tonic-gate #define	MC_DESTRC_DEBUG	0x00000040
141*7c478bd9Sstevel@tonic-gate #define	MC_LIST_DEBUG	0x00000080
142*7c478bd9Sstevel@tonic-gate 
143*7c478bd9Sstevel@tonic-gate static uint_t mc_debug = 0;
144*7c478bd9Sstevel@tonic-gate 
145*7c478bd9Sstevel@tonic-gate #define	_PRINTF prom_printf
146*7c478bd9Sstevel@tonic-gate #define	DPRINTF(flag, args)	if (mc_debug & flag) _PRINTF args;
147*7c478bd9Sstevel@tonic-gate #else
148*7c478bd9Sstevel@tonic-gate #define	DPRINTF(flag, args)
149*7c478bd9Sstevel@tonic-gate 
150*7c478bd9Sstevel@tonic-gate #endif /* DEBUG */
151*7c478bd9Sstevel@tonic-gate 
152*7c478bd9Sstevel@tonic-gate #endif	/* !_ASM */
153*7c478bd9Sstevel@tonic-gate 
154*7c478bd9Sstevel@tonic-gate /* Memory Address Decoding Registers */
155*7c478bd9Sstevel@tonic-gate #define	ASI_MCU_CTRL	0x72
156*7c478bd9Sstevel@tonic-gate #define	REGOFFSET	8
157*7c478bd9Sstevel@tonic-gate #define	MADR0OFFSET	0x10
158*7c478bd9Sstevel@tonic-gate 
159*7c478bd9Sstevel@tonic-gate /* Mask and shift constants for Memory Address Decoding */
160*7c478bd9Sstevel@tonic-gate #define	MADR_UPA_MASK	0x7fffc000000LL		/* 17 bits */
161*7c478bd9Sstevel@tonic-gate #define	MADR_LPA_MASK	0x000000003c0LL		/* 4 bits */
162*7c478bd9Sstevel@tonic-gate #define	MADR_LK_MASK	0x0000003c000LL		/* 4 bits */
163*7c478bd9Sstevel@tonic-gate 
164*7c478bd9Sstevel@tonic-gate #define	MADR_UPA_SHIFT	26
165*7c478bd9Sstevel@tonic-gate #define	MADR_LPA_SHIFT	6
166*7c478bd9Sstevel@tonic-gate #define	MADR_LK_SHIFT	14
167*7c478bd9Sstevel@tonic-gate 
168*7c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
169*7c478bd9Sstevel@tonic-gate 
170*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
171*7c478bd9Sstevel@tonic-gate }
172*7c478bd9Sstevel@tonic-gate #endif
173*7c478bd9Sstevel@tonic-gate 
174*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_MC_US3_H */
175