xref: /onnv-gate/usr/src/lib/libprtdiag_psr/sparc/opl/common/opl_picl.h (revision 11285:0fa6a178fb93)
13418Ssubhan /*
23418Ssubhan  * CDDL HEADER START
33418Ssubhan  *
43418Ssubhan  * The contents of this file are subject to the terms of the
53418Ssubhan  * Common Development and Distribution License (the "License").
63418Ssubhan  * You may not use this file except in compliance with the License.
73418Ssubhan  *
83418Ssubhan  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
93418Ssubhan  * or http://www.opensolaris.org/os/licensing.
103418Ssubhan  * See the License for the specific language governing permissions
113418Ssubhan  * and limitations under the License.
123418Ssubhan  *
133418Ssubhan  * When distributing Covered Code, include this CDDL HEADER in each
143418Ssubhan  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
153418Ssubhan  * If applicable, add the following below this CDDL HEADER, with the
163418Ssubhan  * fields enclosed by brackets "[]" replaced with your own identifying
173418Ssubhan  * information: Portions Copyright [yyyy] [name of copyright owner]
183418Ssubhan  *
193418Ssubhan  * CDDL HEADER END
203418Ssubhan  */
213418Ssubhan /*
22*11285SMichael.Bergknoff@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
233418Ssubhan  * Use is subject to license terms.
243418Ssubhan  *
253418Ssubhan  * Opl Platform header file.
263418Ssubhan  *
273418Ssubhan  * 	called when :
283418Ssubhan  *	machine_type == MTYPE_OPL
293418Ssubhan  */
303418Ssubhan 
313418Ssubhan #ifndef	_OPL_PICL_H
323418Ssubhan #define	_OPL_PICL_H
333418Ssubhan 
343418Ssubhan #ifdef __cplusplus
353418Ssubhan extern "C" {
363418Ssubhan #endif
373418Ssubhan 
383418Ssubhan /*
393418Ssubhan  * Property names
403418Ssubhan  */
413418Ssubhan #define	OBP_PROP_REG			"reg"
423418Ssubhan #define	OBP_PROP_CLOCK_FREQ		"clock-frequency"
433418Ssubhan #define	OBP_PROP_BOARD_NUM		"board#"
443418Ssubhan #define	OBP_PROP_REVISION_ID		"revision-id"
453418Ssubhan #define	OBP_PROP_VENDOR_ID		"vendor-id"
463418Ssubhan #define	OBP_PROP_DEVICE_ID		"device-id"
473418Ssubhan #define	OBP_PROP_VERSION_NUM		"version#"
483418Ssubhan #define	OBP_PROP_BOARD_TYPE		"board_type"
493418Ssubhan #define	OBP_PROP_ECACHE_SIZE		"ecache-size"
503418Ssubhan #define	OBP_PROP_IMPLEMENTATION		"implementation#"
513418Ssubhan #define	OBP_PROP_MASK			"mask#"
523418Ssubhan #define	OBP_PROP_COMPATIBLE		"compatible"
533418Ssubhan #define	OBP_PROP_BANNER_NAME		"banner-name"
543418Ssubhan #define	OBP_PROP_MODEL			"model"
553418Ssubhan #define	OBP_PROP_66MHZ_CAPABLE		"66mhz-capable"
563418Ssubhan #define	OBP_PROP_VERSION		"version"
573418Ssubhan #define	OBP_PROP_INSTANCE		"instance"
583418Ssubhan 
593418Ssubhan /* PCI BUS types */
603418Ssubhan 
616344Smb158278 #define	PCI_UNKN	-1
623418Ssubhan #define	PCI	10
633418Ssubhan #define	PCIX	20
643418Ssubhan #define	PCIE	30
653418Ssubhan 
663418Ssubhan /* PCI device defines */
673418Ssubhan 
683418Ssubhan #define	PCI_CONF_VENID		0x0		/* vendor id, 2 bytes */
693418Ssubhan #define	PCI_CONF_DEVID		0x2		/* device id, 2 bytes */
703418Ssubhan #define	PCI_CONF_CAP_PTR	0x34		/* 1 byte capability pointer */
713418Ssubhan #define	PCI_CAP_ID_PCI_E	0x10		/* PCI Express supported */
723418Ssubhan #define	PCIE_LINKCAP		0x0C		/* Link Capability */
733418Ssubhan #define	PCIE_LINKSTS		0x12		/* Link Status */
743418Ssubhan #define	PCI_CAP_MASK		0xff		/* CAP Mask */
753418Ssubhan #define	PCI_DEV_MASK		0xF800		/* Dev# Mask */
763418Ssubhan #define	PCI_FUNC_MASK		0x700		/* Func# Mask */
773418Ssubhan #define	PCI_BUS_MASK		0x1ff0000	/* Bus# Mask */
783418Ssubhan #define	PCI_LINK_MASK		0x1f		/* Link Mask */
793418Ssubhan 
803418Ssubhan #define	PCI_LINK_SHIFT		4		/* Link shift Bits */
81*11285SMichael.Bergknoff@Sun.COM #define	PCI_FREQ_33		33		/* legacy PCI default freq */
823418Ssubhan #define	PCI_FREQ_66		66		/* PCI default freq */
833418Ssubhan #define	PCI_FREQ_100		100
843418Ssubhan 
853418Ssubhan /* PCI frequencies */
863418Ssubhan 
873418Ssubhan #define	PCI_FREQ_133		133
883418Ssubhan #define	PCI_FREQ_266		266
893418Ssubhan #define	PCI_FREQ_533		533
903418Ssubhan 
913418Ssubhan /* PCI frequency shift bits */
923418Ssubhan 
933418Ssubhan #define	PCI_SHIFT_133		17
943418Ssubhan #define	PCI_SHIFT_266		30
953418Ssubhan #define	PCI_SHIFT_533		31
963418Ssubhan 
973418Ssubhan /* PCI frequency modes */
983418Ssubhan 
993418Ssubhan #define	PCI_MODE_66		1
1003418Ssubhan #define	PCI_MODE_100		2
1013418Ssubhan #define	PCI_MODE_133		3
1023418Ssubhan 
1033418Ssubhan /* PCI frequency SEC status masks */
1043418Ssubhan 
1053418Ssubhan #define	PCI_SEC_133		0x2
1063418Ssubhan #define	PCI_SEC_266		0x4000
1073418Ssubhan #define	PCI_SEC_533		0x8000
1083418Ssubhan #define	PCI_LEAF_ULONG		1UL
1093418Ssubhan 
1103418Ssubhan 
1113418Ssubhan /* Invalid property value */
1123418Ssubhan #define	PROP_INVALID		-1
1133418Ssubhan 
1143418Ssubhan /* Macros */
1153418Ssubhan 
1163418Ssubhan #define	IS_PCI(name) \
1173418Ssubhan 	(((name) != NULL) && (strncmp((name), "pci", 3) == 0))
1183418Ssubhan 
1193418Ssubhan #define	IS_EBUS(class) \
1203418Ssubhan 	(((class) != NULL) && (strncmp((class), "ebus", 4) == 0))
1213418Ssubhan 
1223418Ssubhan #define	ROUND_TO_MHZ(x)	(((x) + 500000)/ 1000000)
1233418Ssubhan 
1243418Ssubhan #define	PRINT_FREQ_FMT(arg_1, arg_2) \
1253418Ssubhan 		if (((arg_1) != 0) && \
1263418Ssubhan 			((arg_2) != 0)) \
1273418Ssubhan 				log_printf("%4d, %4d  ", (arg_1), (arg_2)); \
1283418Ssubhan 			else if ((arg_2) != 0) \
1293418Ssubhan 				log_printf("  --, %4d  ", (arg_2)); \
1303418Ssubhan 			else if ((arg_1) != 0) \
1313418Ssubhan 				log_printf("%4d,  -- ", (arg_1)); \
1323418Ssubhan 			else \
1333418Ssubhan 				log_printf("  --,  --  ");
1343418Ssubhan 
1353418Ssubhan #define	PRINT_FMT(arg_1, arg_2) \
1363418Ssubhan 		if (((arg_1) != PROP_INVALID) && \
1373418Ssubhan 			((arg_2) != PROP_INVALID)) \
1383418Ssubhan 				log_printf("%4d, %4d  ", (arg_1), (arg_2)); \
1393418Ssubhan 			else if ((arg_2) != PROP_INVALID) \
1403418Ssubhan 				log_printf("  --, %4d  ", (arg_2)); \
1413418Ssubhan 			else if ((arg_1) != PROP_INVALID) \
1423418Ssubhan 				log_printf("%4d,  -- ", (arg_1)); \
1433418Ssubhan 			else \
1443418Ssubhan 				log_printf("  --,  --  ");
1453418Ssubhan 
1463418Ssubhan 
1473418Ssubhan 
1483418Ssubhan #ifdef __cplusplus
1493418Ssubhan }
1503418Ssubhan #endif
1513418Ssubhan 
1523418Ssubhan #endif /* _OPL_PICL_H */
153