xref: /titanic_52/usr/src/uts/sun4u/sys/mc-us3.h (revision d00f0155af9a9a671eb08a0dc30f5ea0a379c36c)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
23*d00f0155Sayznaga  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef	_SYS_MC_US3_H
287c478bd9Sstevel@tonic-gate #define	_SYS_MC_US3_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
337c478bd9Sstevel@tonic-gate extern "C" {
347c478bd9Sstevel@tonic-gate #endif
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #if defined(_KERNEL)
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #define	NBANKS	4
397c478bd9Sstevel@tonic-gate #define	NDGRPS	2
407c478bd9Sstevel@tonic-gate #define	NDIMMS	4
417c478bd9Sstevel@tonic-gate #define	MAX_DEVLEN	8
427c478bd9Sstevel@tonic-gate #define	TRANSFER_SIZE	64
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #ifndef	_ASM
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate struct mc_soft_state {
477c478bd9Sstevel@tonic-gate 	dev_info_t *dip;	/* dev info of myself */
487c478bd9Sstevel@tonic-gate 	int portid;
497c478bd9Sstevel@tonic-gate 	int size;
507c478bd9Sstevel@tonic-gate 	void *memlayoutp;
517c478bd9Sstevel@tonic-gate 	volatile uchar_t *mc_base; /* Mapped base address of MC registers */
527c478bd9Sstevel@tonic-gate };
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate struct dimm_info {
55*d00f0155Sayznaga 	char	label[NDGRPS * NDIMMS][MAX_DEVLEN];	/* dimm label */
567c478bd9Sstevel@tonic-gate 	char	sym_flag;	/* 1: symmetric 0: asymmetric */
577c478bd9Sstevel@tonic-gate 	char	data[1];
587c478bd9Sstevel@tonic-gate };
597c478bd9Sstevel@tonic-gate 
60*d00f0155Sayznaga typedef char dimm_sid_t[DIMM_SERIAL_ID_LEN];
61*d00f0155Sayznaga 
627c478bd9Sstevel@tonic-gate struct pin_info {
637c478bd9Sstevel@tonic-gate 	uchar_t	dimmtable[144];
647c478bd9Sstevel@tonic-gate 	uchar_t	pintable[576];
657c478bd9Sstevel@tonic-gate };
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate /* This struct is included at the following structs to set up list */
687c478bd9Sstevel@tonic-gate typedef struct mc_dlist {
697c478bd9Sstevel@tonic-gate 	struct mc_dlist *next;
707c478bd9Sstevel@tonic-gate 	struct mc_dlist *prev;
717c478bd9Sstevel@tonic-gate 	int id;
727c478bd9Sstevel@tonic-gate } mc_dlist_t;
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate /* unique segment id */
757c478bd9Sstevel@tonic-gate struct seg_info {
767c478bd9Sstevel@tonic-gate 	mc_dlist_t seg_node;
777c478bd9Sstevel@tonic-gate 	int nbanks;		/* The number of banks at this segment */
787c478bd9Sstevel@tonic-gate 	uint32_t ifactor;	/* Max interleave factor at this segment */
797c478bd9Sstevel@tonic-gate 	uint64_t base;
807c478bd9Sstevel@tonic-gate 	uint64_t size;		/* memory size per segment */
817c478bd9Sstevel@tonic-gate 	struct bank_info *hb_inseg;	/* first bank at this segment */
827c478bd9Sstevel@tonic-gate 	struct bank_info *tb_inseg;	/* last bank at this segment */
837c478bd9Sstevel@tonic-gate };
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate /* id = mc_id * nbanks + bank_no */
867c478bd9Sstevel@tonic-gate struct bank_info {
877c478bd9Sstevel@tonic-gate 	mc_dlist_t bank_node;
887c478bd9Sstevel@tonic-gate 	int local_id;		/* unique local bank id per segment */
897c478bd9Sstevel@tonic-gate 	int seg_id;		/* unique segment id */
907c478bd9Sstevel@tonic-gate 	int devgrp_id;		/* unique device group id */
917c478bd9Sstevel@tonic-gate 	ushort_t valid;		/* valid flag per logic bank */
927c478bd9Sstevel@tonic-gate 	ushort_t uk;		/* Upper Mask field to mask match 4 PA[37:26] */
937c478bd9Sstevel@tonic-gate 	uint_t um;		/* Upper Match field to match PA[42:26] */
947c478bd9Sstevel@tonic-gate 	uchar_t lk;		/* Lower Mask field to mask match 4 PA[9:6] */
957c478bd9Sstevel@tonic-gate 	uchar_t lm;		/* Lower Match field to match PA[9:6] */
96*d00f0155Sayznaga 	uchar_t pos;		/* front=0, back=1 */
977c478bd9Sstevel@tonic-gate 	uint64_t size;		/* memory size per logical bank */
987c478bd9Sstevel@tonic-gate 	struct bank_info *n_inseg; /* next bank at the same segment */
997c478bd9Sstevel@tonic-gate 	struct bank_info *p_inseg; /* previous bank at the same segment */
1007c478bd9Sstevel@tonic-gate 	struct dimm_info *dimminfop;
101*d00f0155Sayznaga 	dimm_sid_t *dimmsidp[NDIMMS];
1027c478bd9Sstevel@tonic-gate };
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate /* id = mc_id * ndevgrps + devgrp_no */
1057c478bd9Sstevel@tonic-gate struct dgrp_info {
1067c478bd9Sstevel@tonic-gate 	mc_dlist_t dgrp_node;
1077c478bd9Sstevel@tonic-gate 	int ndevices;	/* The number of available devices on this dev group */
1087c478bd9Sstevel@tonic-gate 	uint64_t size;	/* memory size per physical dimm group */
1097c478bd9Sstevel@tonic-gate 	int deviceids[NDIMMS];	/* 4 dimms per group on excalibur */
1107c478bd9Sstevel@tonic-gate };
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate /* id = id of dgrp_info * ndevices + device_no */
1137c478bd9Sstevel@tonic-gate struct device_info {
1147c478bd9Sstevel@tonic-gate 	mc_dlist_t dev_node;
1157c478bd9Sstevel@tonic-gate 	char label[MAX_DEVLEN];
1167c478bd9Sstevel@tonic-gate 	uint64_t size;		/* memory size per physical dimm */
1177c478bd9Sstevel@tonic-gate };
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate /* id = portid */
1207c478bd9Sstevel@tonic-gate struct mctrl_info {
1217c478bd9Sstevel@tonic-gate 	mc_dlist_t mctrl_node;
1227c478bd9Sstevel@tonic-gate 	int ndevgrps;		/* The number of dimm groups */
1237c478bd9Sstevel@tonic-gate 	int devgrpids[NDGRPS];
1247c478bd9Sstevel@tonic-gate };
1257c478bd9Sstevel@tonic-gate 
126*d00f0155Sayznaga typedef struct dimm_sid_cache {
127*d00f0155Sayznaga 	int	mcid;	/* mc portid */
128*d00f0155Sayznaga 	int	seg_id;	/* segment these DIMMs are in */
129*d00f0155Sayznaga 	int	state;	/* state of cache for this mc */
130*d00f0155Sayznaga 	dimm_sid_t	*sids;  /* ptr to array of serial ids */
131*d00f0155Sayznaga } dimm_sid_cache_t;
132*d00f0155Sayznaga 
133*d00f0155Sayznaga /* values for the state field of a dimm_sid_cache_t */
134*d00f0155Sayznaga #define	MC_DIMM_SIDS_INVALID	0
135*d00f0155Sayznaga #define	MC_DIMM_SIDS_REQUESTED	1
136*d00f0155Sayznaga #define	MC_DIMM_SIDS_AVAILABLE	2
137*d00f0155Sayznaga 
1387c478bd9Sstevel@tonic-gate extern int (*p2get_mem_unum)(int, uint64_t, char *, int, int *);
1397c478bd9Sstevel@tonic-gate extern int (*p2get_mem_info)(int, uint64_t, uint64_t *, uint64_t *,
1407c478bd9Sstevel@tonic-gate     uint64_t *, int *, int *, int *);
141*d00f0155Sayznaga extern int (*p2get_mem_offset)(uint64_t, uint64_t *);
142*d00f0155Sayznaga extern int (*p2get_mem_addr)(int, char *, uint64_t, uint64_t *);
143*d00f0155Sayznaga extern int (*p2get_mem_sid)(int, int, char *, int, int *);
144*d00f0155Sayznaga extern int (*p2init_sid_cache)(void);
145*d00f0155Sayznaga extern void plat_add_mem_unum_label(char *, int, int, int);
146*d00f0155Sayznaga extern dimm_sid_cache_t *plat_alloc_sid_cache(int *);
147*d00f0155Sayznaga extern int plat_populate_sid_cache(dimm_sid_cache_t *, int);
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate uint64_t get_mcr(int);
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate #ifdef	DEBUG
1527c478bd9Sstevel@tonic-gate 
1537c478bd9Sstevel@tonic-gate #include <sys/promif.h>
1547c478bd9Sstevel@tonic-gate 
1557c478bd9Sstevel@tonic-gate /* useful debugging level of DPRINTF */
1567c478bd9Sstevel@tonic-gate #define	MC_ATTACH_DEBUG	0x00000001
1577c478bd9Sstevel@tonic-gate #define	MC_DETACH_DEBUG	0x00000002
1587c478bd9Sstevel@tonic-gate #define	MC_CMD_DEBUG	0x00000004
1597c478bd9Sstevel@tonic-gate #define	MC_REG_DEBUG	0x00000008
1607c478bd9Sstevel@tonic-gate #define	MC_GUNUM_DEBUG	0x00000010
1617c478bd9Sstevel@tonic-gate #define	MC_CNSTRC_DEBUG	0x00000020
1627c478bd9Sstevel@tonic-gate #define	MC_DESTRC_DEBUG	0x00000040
1637c478bd9Sstevel@tonic-gate #define	MC_LIST_DEBUG	0x00000080
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate static uint_t mc_debug = 0;
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate #define	_PRINTF prom_printf
1687c478bd9Sstevel@tonic-gate #define	DPRINTF(flag, args)	if (mc_debug & flag) _PRINTF args;
1697c478bd9Sstevel@tonic-gate #else
1707c478bd9Sstevel@tonic-gate #define	DPRINTF(flag, args)
1717c478bd9Sstevel@tonic-gate 
1727c478bd9Sstevel@tonic-gate #endif /* DEBUG */
1737c478bd9Sstevel@tonic-gate 
1747c478bd9Sstevel@tonic-gate #endif	/* !_ASM */
1757c478bd9Sstevel@tonic-gate 
1767c478bd9Sstevel@tonic-gate /* Memory Address Decoding Registers */
1777c478bd9Sstevel@tonic-gate #define	ASI_MCU_CTRL	0x72
1787c478bd9Sstevel@tonic-gate #define	REGOFFSET	8
1797c478bd9Sstevel@tonic-gate #define	MADR0OFFSET	0x10
1807c478bd9Sstevel@tonic-gate 
1817c478bd9Sstevel@tonic-gate /* Mask and shift constants for Memory Address Decoding */
1827c478bd9Sstevel@tonic-gate #define	MADR_UPA_MASK	0x7fffc000000LL		/* 17 bits */
1837c478bd9Sstevel@tonic-gate #define	MADR_LPA_MASK	0x000000003c0LL		/* 4 bits */
1847c478bd9Sstevel@tonic-gate #define	MADR_LK_MASK	0x0000003c000LL		/* 4 bits */
1857c478bd9Sstevel@tonic-gate 
1867c478bd9Sstevel@tonic-gate #define	MADR_UPA_SHIFT	26
1877c478bd9Sstevel@tonic-gate #define	MADR_LPA_SHIFT	6
1887c478bd9Sstevel@tonic-gate #define	MADR_LK_SHIFT	14
1897c478bd9Sstevel@tonic-gate 
1907c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1937c478bd9Sstevel@tonic-gate }
1947c478bd9Sstevel@tonic-gate #endif
1957c478bd9Sstevel@tonic-gate 
1967c478bd9Sstevel@tonic-gate #endif	/* _SYS_MC_US3_H */
197