xref: /onnv-gate/usr/src/uts/sun4u/sys/mc-us3.h (revision 1186:7791ded250f8)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
50Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
70Sstevel@tonic-gate  * with the License.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate  * See the License for the specific language governing permissions
120Sstevel@tonic-gate  * and limitations under the License.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * CDDL HEADER END
210Sstevel@tonic-gate  */
220Sstevel@tonic-gate /*
23*1186Sayznaga  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #ifndef	_SYS_MC_US3_H
280Sstevel@tonic-gate #define	_SYS_MC_US3_H
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #ifdef	__cplusplus
330Sstevel@tonic-gate extern "C" {
340Sstevel@tonic-gate #endif
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #if defined(_KERNEL)
370Sstevel@tonic-gate 
380Sstevel@tonic-gate #define	NBANKS	4
390Sstevel@tonic-gate #define	NDGRPS	2
400Sstevel@tonic-gate #define	NDIMMS	4
410Sstevel@tonic-gate #define	MAX_DEVLEN	8
420Sstevel@tonic-gate #define	TRANSFER_SIZE	64
430Sstevel@tonic-gate 
440Sstevel@tonic-gate #ifndef	_ASM
450Sstevel@tonic-gate 
460Sstevel@tonic-gate struct mc_soft_state {
470Sstevel@tonic-gate 	dev_info_t *dip;	/* dev info of myself */
480Sstevel@tonic-gate 	int portid;
490Sstevel@tonic-gate 	int size;
500Sstevel@tonic-gate 	void *memlayoutp;
510Sstevel@tonic-gate 	volatile uchar_t *mc_base; /* Mapped base address of MC registers */
520Sstevel@tonic-gate };
530Sstevel@tonic-gate 
540Sstevel@tonic-gate struct dimm_info {
55*1186Sayznaga 	char	label[NDGRPS * NDIMMS][MAX_DEVLEN];	/* dimm label */
560Sstevel@tonic-gate 	char	sym_flag;	/* 1: symmetric 0: asymmetric */
570Sstevel@tonic-gate 	char	data[1];
580Sstevel@tonic-gate };
590Sstevel@tonic-gate 
60*1186Sayznaga typedef char dimm_sid_t[DIMM_SERIAL_ID_LEN];
61*1186Sayznaga 
620Sstevel@tonic-gate struct pin_info {
630Sstevel@tonic-gate 	uchar_t	dimmtable[144];
640Sstevel@tonic-gate 	uchar_t	pintable[576];
650Sstevel@tonic-gate };
660Sstevel@tonic-gate 
670Sstevel@tonic-gate /* This struct is included at the following structs to set up list */
680Sstevel@tonic-gate typedef struct mc_dlist {
690Sstevel@tonic-gate 	struct mc_dlist *next;
700Sstevel@tonic-gate 	struct mc_dlist *prev;
710Sstevel@tonic-gate 	int id;
720Sstevel@tonic-gate } mc_dlist_t;
730Sstevel@tonic-gate 
740Sstevel@tonic-gate /* unique segment id */
750Sstevel@tonic-gate struct seg_info {
760Sstevel@tonic-gate 	mc_dlist_t seg_node;
770Sstevel@tonic-gate 	int nbanks;		/* The number of banks at this segment */
780Sstevel@tonic-gate 	uint32_t ifactor;	/* Max interleave factor at this segment */
790Sstevel@tonic-gate 	uint64_t base;
800Sstevel@tonic-gate 	uint64_t size;		/* memory size per segment */
810Sstevel@tonic-gate 	struct bank_info *hb_inseg;	/* first bank at this segment */
820Sstevel@tonic-gate 	struct bank_info *tb_inseg;	/* last bank at this segment */
830Sstevel@tonic-gate };
840Sstevel@tonic-gate 
850Sstevel@tonic-gate /* id = mc_id * nbanks + bank_no */
860Sstevel@tonic-gate struct bank_info {
870Sstevel@tonic-gate 	mc_dlist_t bank_node;
880Sstevel@tonic-gate 	int local_id;		/* unique local bank id per segment */
890Sstevel@tonic-gate 	int seg_id;		/* unique segment id */
900Sstevel@tonic-gate 	int devgrp_id;		/* unique device group id */
910Sstevel@tonic-gate 	ushort_t valid;		/* valid flag per logic bank */
920Sstevel@tonic-gate 	ushort_t uk;		/* Upper Mask field to mask match 4 PA[37:26] */
930Sstevel@tonic-gate 	uint_t um;		/* Upper Match field to match PA[42:26] */
940Sstevel@tonic-gate 	uchar_t lk;		/* Lower Mask field to mask match 4 PA[9:6] */
950Sstevel@tonic-gate 	uchar_t lm;		/* Lower Match field to match PA[9:6] */
96*1186Sayznaga 	uchar_t pos;		/* front=0, back=1 */
970Sstevel@tonic-gate 	uint64_t size;		/* memory size per logical bank */
980Sstevel@tonic-gate 	struct bank_info *n_inseg; /* next bank at the same segment */
990Sstevel@tonic-gate 	struct bank_info *p_inseg; /* previous bank at the same segment */
1000Sstevel@tonic-gate 	struct dimm_info *dimminfop;
101*1186Sayznaga 	dimm_sid_t *dimmsidp[NDIMMS];
1020Sstevel@tonic-gate };
1030Sstevel@tonic-gate 
1040Sstevel@tonic-gate /* id = mc_id * ndevgrps + devgrp_no */
1050Sstevel@tonic-gate struct dgrp_info {
1060Sstevel@tonic-gate 	mc_dlist_t dgrp_node;
1070Sstevel@tonic-gate 	int ndevices;	/* The number of available devices on this dev group */
1080Sstevel@tonic-gate 	uint64_t size;	/* memory size per physical dimm group */
1090Sstevel@tonic-gate 	int deviceids[NDIMMS];	/* 4 dimms per group on excalibur */
1100Sstevel@tonic-gate };
1110Sstevel@tonic-gate 
1120Sstevel@tonic-gate /* id = id of dgrp_info * ndevices + device_no */
1130Sstevel@tonic-gate struct device_info {
1140Sstevel@tonic-gate 	mc_dlist_t dev_node;
1150Sstevel@tonic-gate 	char label[MAX_DEVLEN];
1160Sstevel@tonic-gate 	uint64_t size;		/* memory size per physical dimm */
1170Sstevel@tonic-gate };
1180Sstevel@tonic-gate 
1190Sstevel@tonic-gate /* id = portid */
1200Sstevel@tonic-gate struct mctrl_info {
1210Sstevel@tonic-gate 	mc_dlist_t mctrl_node;
1220Sstevel@tonic-gate 	int ndevgrps;		/* The number of dimm groups */
1230Sstevel@tonic-gate 	int devgrpids[NDGRPS];
1240Sstevel@tonic-gate };
1250Sstevel@tonic-gate 
126*1186Sayznaga typedef struct dimm_sid_cache {
127*1186Sayznaga 	int	mcid;	/* mc portid */
128*1186Sayznaga 	int	seg_id;	/* segment these DIMMs are in */
129*1186Sayznaga 	int	state;	/* state of cache for this mc */
130*1186Sayznaga 	dimm_sid_t	*sids;  /* ptr to array of serial ids */
131*1186Sayznaga } dimm_sid_cache_t;
132*1186Sayznaga 
133*1186Sayznaga /* values for the state field of a dimm_sid_cache_t */
134*1186Sayznaga #define	MC_DIMM_SIDS_INVALID	0
135*1186Sayznaga #define	MC_DIMM_SIDS_REQUESTED	1
136*1186Sayznaga #define	MC_DIMM_SIDS_AVAILABLE	2
137*1186Sayznaga 
1380Sstevel@tonic-gate extern int (*p2get_mem_unum)(int, uint64_t, char *, int, int *);
1390Sstevel@tonic-gate extern int (*p2get_mem_info)(int, uint64_t, uint64_t *, uint64_t *,
1400Sstevel@tonic-gate     uint64_t *, int *, int *, int *);
141*1186Sayznaga extern int (*p2get_mem_offset)(uint64_t, uint64_t *);
142*1186Sayznaga extern int (*p2get_mem_addr)(int, char *, uint64_t, uint64_t *);
143*1186Sayznaga extern int (*p2get_mem_sid)(int, int, char *, int, int *);
144*1186Sayznaga extern int (*p2init_sid_cache)(void);
145*1186Sayznaga extern void plat_add_mem_unum_label(char *, int, int, int);
146*1186Sayznaga extern dimm_sid_cache_t *plat_alloc_sid_cache(int *);
147*1186Sayznaga extern int plat_populate_sid_cache(dimm_sid_cache_t *, int);
1480Sstevel@tonic-gate 
1490Sstevel@tonic-gate uint64_t get_mcr(int);
1500Sstevel@tonic-gate 
1510Sstevel@tonic-gate #ifdef	DEBUG
1520Sstevel@tonic-gate 
1530Sstevel@tonic-gate #include <sys/promif.h>
1540Sstevel@tonic-gate 
1550Sstevel@tonic-gate /* useful debugging level of DPRINTF */
1560Sstevel@tonic-gate #define	MC_ATTACH_DEBUG	0x00000001
1570Sstevel@tonic-gate #define	MC_DETACH_DEBUG	0x00000002
1580Sstevel@tonic-gate #define	MC_CMD_DEBUG	0x00000004
1590Sstevel@tonic-gate #define	MC_REG_DEBUG	0x00000008
1600Sstevel@tonic-gate #define	MC_GUNUM_DEBUG	0x00000010
1610Sstevel@tonic-gate #define	MC_CNSTRC_DEBUG	0x00000020
1620Sstevel@tonic-gate #define	MC_DESTRC_DEBUG	0x00000040
1630Sstevel@tonic-gate #define	MC_LIST_DEBUG	0x00000080
1640Sstevel@tonic-gate 
1650Sstevel@tonic-gate static uint_t mc_debug = 0;
1660Sstevel@tonic-gate 
1670Sstevel@tonic-gate #define	_PRINTF prom_printf
1680Sstevel@tonic-gate #define	DPRINTF(flag, args)	if (mc_debug & flag) _PRINTF args;
1690Sstevel@tonic-gate #else
1700Sstevel@tonic-gate #define	DPRINTF(flag, args)
1710Sstevel@tonic-gate 
1720Sstevel@tonic-gate #endif /* DEBUG */
1730Sstevel@tonic-gate 
1740Sstevel@tonic-gate #endif	/* !_ASM */
1750Sstevel@tonic-gate 
1760Sstevel@tonic-gate /* Memory Address Decoding Registers */
1770Sstevel@tonic-gate #define	ASI_MCU_CTRL	0x72
1780Sstevel@tonic-gate #define	REGOFFSET	8
1790Sstevel@tonic-gate #define	MADR0OFFSET	0x10
1800Sstevel@tonic-gate 
1810Sstevel@tonic-gate /* Mask and shift constants for Memory Address Decoding */
1820Sstevel@tonic-gate #define	MADR_UPA_MASK	0x7fffc000000LL		/* 17 bits */
1830Sstevel@tonic-gate #define	MADR_LPA_MASK	0x000000003c0LL		/* 4 bits */
1840Sstevel@tonic-gate #define	MADR_LK_MASK	0x0000003c000LL		/* 4 bits */
1850Sstevel@tonic-gate 
1860Sstevel@tonic-gate #define	MADR_UPA_SHIFT	26
1870Sstevel@tonic-gate #define	MADR_LPA_SHIFT	6
1880Sstevel@tonic-gate #define	MADR_LK_SHIFT	14
1890Sstevel@tonic-gate 
1900Sstevel@tonic-gate #endif	/* _KERNEL */
1910Sstevel@tonic-gate 
1920Sstevel@tonic-gate #ifdef	__cplusplus
1930Sstevel@tonic-gate }
1940Sstevel@tonic-gate #endif
1950Sstevel@tonic-gate 
1960Sstevel@tonic-gate #endif	/* _SYS_MC_US3_H */
197