xref: /titanic_50/usr/src/uts/sun4u/sys/upa64s.h (revision f47a9c508408507a404eaf38dd597e6ac41f92e6)
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*f47a9c50Smathue  * 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_UPA64S_VAR_H
287c478bd9Sstevel@tonic-gate #define	_SYS_UPA64S_VAR_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 #define	HI32(x) ((uint32_t)(((uint64_t)(x)) >> 32))
37*f47a9c50Smathue #define	LO32(x) ((uint32_t)(uintptr_t)(x))
387c478bd9Sstevel@tonic-gate #define	UPA64S_PORTS	2	/* number of UPA ports per device */
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate /*
417c478bd9Sstevel@tonic-gate  * the following typedef is used to describe the state
427c478bd9Sstevel@tonic-gate  * of a UPA port interrupt.
437c478bd9Sstevel@tonic-gate  */
447c478bd9Sstevel@tonic-gate typedef enum { INO_FREE = 0, INO_INUSE } ino_state_t;
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate /*
477c478bd9Sstevel@tonic-gate  * INO related macros:
487c478bd9Sstevel@tonic-gate  */
497c478bd9Sstevel@tonic-gate #define	UPA64S_MAKE_MONDO(id, ino)	((id) << 6 | (ino))
507c478bd9Sstevel@tonic-gate #define	UPA64S_MONDO_TO_INO(mondo) 	((mondo) & 0x3f)
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate /*
537c478bd9Sstevel@tonic-gate  * Interrupt Mapping Registers
547c478bd9Sstevel@tonic-gate  */
557c478bd9Sstevel@tonic-gate #define	IMR_MONDO			0x7ff
567c478bd9Sstevel@tonic-gate #define	IMR_TID_BIT			26
577c478bd9Sstevel@tonic-gate #define	IMR_TID				(0x1f << IMR_TID_BIT)
587c478bd9Sstevel@tonic-gate #define	IMR_VALID			(1u << 31)
597c478bd9Sstevel@tonic-gate #define	UPA64S_IMR_TO_CPUID(imr)	(((imr) & IMR_TID) >> IMR_TID_BIT)
607c478bd9Sstevel@tonic-gate #define	UPA64S_IMR_TO_MONDO(imr)	((imr) & IMR_MONDO)
617c478bd9Sstevel@tonic-gate #define	UPA64S_CPUID_TO_IMR(cpuid)	((cpuid) << IMR_TID_BIT)
627c478bd9Sstevel@tonic-gate #define	UPA64S_GET_MAP_REG(mondo, imr)	((mondo) | (imr) | IMR_VALID)
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate /*
657c478bd9Sstevel@tonic-gate  * The following structure defines the format of UPA64S addresses.
667c478bd9Sstevel@tonic-gate  * This structure is used to hold UPA64S "reg" property entries.
677c478bd9Sstevel@tonic-gate  */
687c478bd9Sstevel@tonic-gate typedef struct upa64s_regspec {
697c478bd9Sstevel@tonic-gate 	uint64_t upa64s_phys;
707c478bd9Sstevel@tonic-gate 	uint64_t upa64s_size;
717c478bd9Sstevel@tonic-gate } upa64s_regspec_t;
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate /*
747c478bd9Sstevel@tonic-gate  * The following structure defines the format of a "ranges"
757c478bd9Sstevel@tonic-gate  * property entry for UPA64S bus node.
767c478bd9Sstevel@tonic-gate  */
777c478bd9Sstevel@tonic-gate typedef struct upa64s_ranges {
787c478bd9Sstevel@tonic-gate 	uint64_t upa64s_child;
797c478bd9Sstevel@tonic-gate 	uint64_t upa64s_parent;
807c478bd9Sstevel@tonic-gate 	uint64_t upa64s_size;
817c478bd9Sstevel@tonic-gate } upa64s_ranges_t;
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate /*
847c478bd9Sstevel@tonic-gate  * per-upa64s soft state structure:
857c478bd9Sstevel@tonic-gate  */
867c478bd9Sstevel@tonic-gate typedef struct upa64s_devstate {
877c478bd9Sstevel@tonic-gate 	dev_info_t *dip;			/* devinfo structure */
887c478bd9Sstevel@tonic-gate 	uint_t safari_id;			/* safari device id */
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate 	ino_state_t ino_state[UPA64S_PORTS];	/* INO state */
917c478bd9Sstevel@tonic-gate 	uint64_t *imr[UPA64S_PORTS];		/* Intr mapping reg; treat */
927c478bd9Sstevel@tonic-gate 						/* as two element array */
937c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t imr_ah[UPA64S_PORTS];	/* Mapping handle */
947c478bd9Sstevel@tonic-gate 	uint64_t imr_data[UPA64S_PORTS];	/* imr save/restore area */
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate 	caddr_t config_base;			/* conf base address */
977c478bd9Sstevel@tonic-gate 	uint64_t *upa0_config;			/* UPA 0 config */
987c478bd9Sstevel@tonic-gate 	uint64_t *upa1_config;			/* UPA 1 config */
997c478bd9Sstevel@tonic-gate 	uint64_t *if_config;			/* UPA inteface config */
1007c478bd9Sstevel@tonic-gate 	uint64_t *estar;			/* UPA estar control */
1017c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t config_base_ah;	/* config acc handle */
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate 	int power_level;			/* upa64s' power level */
1047c478bd9Sstevel@tonic-gate 	int saved_power_level;			/* power level during suspend */
1057c478bd9Sstevel@tonic-gate } upa64s_devstate_t;
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate /*
1087c478bd9Sstevel@tonic-gate  * UPA64S Register Offsets
1097c478bd9Sstevel@tonic-gate  */
1107c478bd9Sstevel@tonic-gate #define	UPA64S_UPA0_CONFIG_OFFSET	0x00
1117c478bd9Sstevel@tonic-gate #define	UPA64S_UPA1_CONFIG_OFFSET	0x08
1127c478bd9Sstevel@tonic-gate #define	UPA64S_IF_CONFIG_OFFSET		0x10
1137c478bd9Sstevel@tonic-gate #define	UPA64S_ESTAR_OFFSET		0x18
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate /*
1167c478bd9Sstevel@tonic-gate  * UPA64S Interface Configurations
1177c478bd9Sstevel@tonic-gate  */
1187c478bd9Sstevel@tonic-gate #define	UPA64S_NOT_POK_RST_L	0x0
1197c478bd9Sstevel@tonic-gate #define	UPA64S_POK_RST_L	0x2
1207c478bd9Sstevel@tonic-gate #define	UPA64S_POK_NOT_RST_L	0x3
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate /*
1237c478bd9Sstevel@tonic-gate  * UPA64S Energy Star Control Register
1247c478bd9Sstevel@tonic-gate  */
1257c478bd9Sstevel@tonic-gate #define	UPA64S_FULL_SPEED	0x01
1267c478bd9Sstevel@tonic-gate #define	UPA64S_1_2_SPEED	0x02
1277c478bd9Sstevel@tonic-gate #define	UPA64S_1_64_SPEED	0x40
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate /*
1307c478bd9Sstevel@tonic-gate  * Power Management definitions
1317c478bd9Sstevel@tonic-gate  */
1327c478bd9Sstevel@tonic-gate #define	UPA64S_PM_COMP		0		/* power management component */
1337c478bd9Sstevel@tonic-gate #define	UPA64S_PM_UNKNOWN	-1		/* power unknown */
1347c478bd9Sstevel@tonic-gate #define	UPA64S_PM_RESET		0		/* power off */
1357c478bd9Sstevel@tonic-gate #define	UPA64S_PM_NORMOP	1		/* power on */
1367c478bd9Sstevel@tonic-gate 
1377c478bd9Sstevel@tonic-gate /*
1387c478bd9Sstevel@tonic-gate  * upa64s soft state macros:
1397c478bd9Sstevel@tonic-gate  */
1407c478bd9Sstevel@tonic-gate #define	get_upa64s_soft_state(i)	\
1417c478bd9Sstevel@tonic-gate 	((upa64s_devstate_t *)ddi_get_soft_state(per_upa64s_state, (i)))
1427c478bd9Sstevel@tonic-gate #define	alloc_upa64s_soft_state(i)	\
1437c478bd9Sstevel@tonic-gate 	ddi_soft_state_zalloc(per_upa64s_state, (i))
1447c478bd9Sstevel@tonic-gate #define	free_upa64s_soft_state(i)	\
1457c478bd9Sstevel@tonic-gate 	ddi_soft_state_free(per_upa64s_state, (i))
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate /*
1487c478bd9Sstevel@tonic-gate  * debugging definitions:
1497c478bd9Sstevel@tonic-gate  */
1507c478bd9Sstevel@tonic-gate #if defined(DEBUG)
1517c478bd9Sstevel@tonic-gate #define	D_ATTACH	0x00000001
1527c478bd9Sstevel@tonic-gate #define	D_DETACH	0x00000002
1537c478bd9Sstevel@tonic-gate #define	D_POWER		0x00000004
1547c478bd9Sstevel@tonic-gate #define	D_MAP		0x00000008
1557c478bd9Sstevel@tonic-gate #define	D_CTLOPS	0x00000010
1567c478bd9Sstevel@tonic-gate #define	D_G_ISPEC	0x00000020
1577c478bd9Sstevel@tonic-gate #define	D_A_ISPEC	0x00000040
1587c478bd9Sstevel@tonic-gate #define	D_R_ISPEC	0x00000080
1597c478bd9Sstevel@tonic-gate #define	D_INIT_CLD	0x00400000
1607c478bd9Sstevel@tonic-gate #define	D_RM_CLD	0x00800000
1617c478bd9Sstevel@tonic-gate #define	D_GET_REG	0x01000000
1627c478bd9Sstevel@tonic-gate #define	D_XLATE_REG	0x02000000
1637c478bd9Sstevel@tonic-gate #define	D_INTRDIST	0x04000000
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate #define	D_CONT		0x80000000
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate #define	DBG(flag, psp, fmt) \
1687c478bd9Sstevel@tonic-gate 	upa64s_debug(flag, psp, fmt, 0, 0, 0, 0, 0);
1697c478bd9Sstevel@tonic-gate #define	DBG1(flag, psp, fmt, a1) \
1707c478bd9Sstevel@tonic-gate 	upa64s_debug(flag, psp, fmt, (uintptr_t)(a1), 0, 0, 0, 0);
1717c478bd9Sstevel@tonic-gate #define	DBG2(flag, psp, fmt, a1, a2) \
1727c478bd9Sstevel@tonic-gate 	upa64s_debug(flag, psp, fmt, (uintptr_t)(a1), (uintptr_t)(a2), 0, 0, 0);
1737c478bd9Sstevel@tonic-gate #define	DBG3(flag, psp, fmt, a1, a2, a3) \
1747c478bd9Sstevel@tonic-gate 	upa64s_debug(flag, psp, fmt, (uintptr_t)(a1), (uintptr_t)(a2), \
1757c478bd9Sstevel@tonic-gate 		(uintptr_t)(a3), 0, 0);
1767c478bd9Sstevel@tonic-gate #define	DBG4(flag, psp, fmt, a1, a2, a3, a4) \
1777c478bd9Sstevel@tonic-gate 	upa64s_debug(flag, psp, fmt, (uintptr_t)(a1), (uintptr_t)(a2), \
1787c478bd9Sstevel@tonic-gate 		(uintptr_t)(a3), (uintptr_t)(a4), 0);
1797c478bd9Sstevel@tonic-gate #define	DBG5(flag, psp, fmt, a1, a2, a3, a4, a5) \
1807c478bd9Sstevel@tonic-gate 	upa64s_debug(flag, psp, fmt, (uintptr_t)(a1), (uintptr_t)(a2), \
1817c478bd9Sstevel@tonic-gate 		(uintptr_t)(a3), (uintptr_t)(a4), (uintptr_t)(a5));
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate static void upa64s_debug(uint_t, dev_info_t *, char *, uintptr_t, uintptr_t, \
1847c478bd9Sstevel@tonic-gate 	uintptr_t, uintptr_t, uintptr_t);
1857c478bd9Sstevel@tonic-gate #else
1867c478bd9Sstevel@tonic-gate #define	DBG(flag, psp, fmt)
1877c478bd9Sstevel@tonic-gate #define	DBG1(flag, psp, fmt, a1)
1887c478bd9Sstevel@tonic-gate #define	DBG2(flag, psp, fmt, a1, a2)
1897c478bd9Sstevel@tonic-gate #define	DBG3(flag, psp, fmt, a1, a2, a3)
1907c478bd9Sstevel@tonic-gate #define	DBG4(flag, psp, fmt, a1, a2, a3, a4)
1917c478bd9Sstevel@tonic-gate #define	DBG5(flag, psp, fmt, a1, a2, a3, a4, a5)
1927c478bd9Sstevel@tonic-gate #define	dump_dma_handle(flag, psp, h)
1937c478bd9Sstevel@tonic-gate #endif
1947c478bd9Sstevel@tonic-gate 
1957c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1967c478bd9Sstevel@tonic-gate }
1977c478bd9Sstevel@tonic-gate #endif
1987c478bd9Sstevel@tonic-gate 
1997c478bd9Sstevel@tonic-gate #endif	/* _SYS_UPA64S_VAR_H */
200