xref: /illumos-gate/usr/src/lib/libprtdiag_psr/sparc/opl/common/opl_picl.h (revision 581cede61ac9c14d8d4ea452562a567189eead78)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  *
25  * Opl Platform header file.
26  *
27  * 	called when :
28  *	machine_type == MTYPE_OPL
29  */
30 
31 #ifndef	_OPL_PICL_H
32 #define	_OPL_PICL_H
33 
34 #pragma ident	"%Z%%M%	%I%	%E% SMI"
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * Property names
42  */
43 #define	OBP_PROP_REG			"reg"
44 #define	OBP_PROP_CLOCK_FREQ		"clock-frequency"
45 #define	OBP_PROP_BOARD_NUM		"board#"
46 #define	OBP_PROP_REVISION_ID		"revision-id"
47 #define	OBP_PROP_VENDOR_ID		"vendor-id"
48 #define	OBP_PROP_DEVICE_ID		"device-id"
49 #define	OBP_PROP_VERSION_NUM		"version#"
50 #define	OBP_PROP_BOARD_TYPE		"board_type"
51 #define	OBP_PROP_ECACHE_SIZE		"ecache-size"
52 #define	OBP_PROP_IMPLEMENTATION		"implementation#"
53 #define	OBP_PROP_MASK			"mask#"
54 #define	OBP_PROP_COMPATIBLE		"compatible"
55 #define	OBP_PROP_BANNER_NAME		"banner-name"
56 #define	OBP_PROP_MODEL			"model"
57 #define	OBP_PROP_66MHZ_CAPABLE		"66mhz-capable"
58 #define	OBP_PROP_VERSION		"version"
59 #define	OBP_PROP_INSTANCE		"instance"
60 
61 /* PCI BUS types */
62 
63 #define	PCI_UNKN	-1
64 #define	PCI	10
65 #define	PCIX	20
66 #define	PCIE	30
67 
68 /* PCI device defines */
69 
70 #define	PCI_CONF_VENID		0x0		/* vendor id, 2 bytes */
71 #define	PCI_CONF_DEVID		0x2		/* device id, 2 bytes */
72 #define	PCI_CONF_CAP_PTR	0x34		/* 1 byte capability pointer */
73 #define	PCI_CAP_ID_PCI_E	0x10		/* PCI Express supported */
74 #define	PCIE_LINKCAP		0x0C		/* Link Capability */
75 #define	PCIE_LINKSTS		0x12		/* Link Status */
76 #define	PCI_CAP_MASK		0xff		/* CAP Mask */
77 #define	PCI_DEV_MASK		0xF800		/* Dev# Mask */
78 #define	PCI_FUNC_MASK		0x700		/* Func# Mask */
79 #define	PCI_BUS_MASK		0x1ff0000	/* Bus# Mask */
80 #define	PCI_LINK_MASK		0x1f		/* Link Mask */
81 
82 #define	PCI_LINK_SHIFT		4		/* Link shift Bits */
83 #define	PCI_FREQ_66		66		/* PCI default freq */
84 #define	PCI_FREQ_100		100
85 
86 /* PCI frequencies */
87 
88 #define	PCI_FREQ_133		133
89 #define	PCI_FREQ_266		266
90 #define	PCI_FREQ_533		533
91 
92 /* PCI frequency shift bits */
93 
94 #define	PCI_SHIFT_133		17
95 #define	PCI_SHIFT_266		30
96 #define	PCI_SHIFT_533		31
97 
98 /* PCI frequency modes */
99 
100 #define	PCI_MODE_66		1
101 #define	PCI_MODE_100		2
102 #define	PCI_MODE_133		3
103 
104 /* PCI frequency SEC status masks */
105 
106 #define	PCI_SEC_133		0x2
107 #define	PCI_SEC_266		0x4000
108 #define	PCI_SEC_533		0x8000
109 #define	PCI_LEAF_ULONG		1UL
110 
111 
112 /* Invalid property value */
113 #define	PROP_INVALID		-1
114 
115 /* Macros */
116 
117 #define	IS_PCI(name) \
118 	(((name) != NULL) && (strncmp((name), "pci", 3) == 0))
119 
120 #define	IS_EBUS(class) \
121 	(((class) != NULL) && (strncmp((class), "ebus", 4) == 0))
122 
123 #define	ROUND_TO_MHZ(x)	(((x) + 500000)/ 1000000)
124 
125 #define	PRINT_FREQ_FMT(arg_1, arg_2) \
126 		if (((arg_1) != 0) && \
127 			((arg_2) != 0)) \
128 				log_printf("%4d, %4d  ", (arg_1), (arg_2)); \
129 			else if ((arg_2) != 0) \
130 				log_printf("  --, %4d  ", (arg_2)); \
131 			else if ((arg_1) != 0) \
132 				log_printf("%4d,  -- ", (arg_1)); \
133 			else \
134 				log_printf("  --,  --  ");
135 
136 #define	PRINT_FMT(arg_1, arg_2) \
137 		if (((arg_1) != PROP_INVALID) && \
138 			((arg_2) != PROP_INVALID)) \
139 				log_printf("%4d, %4d  ", (arg_1), (arg_2)); \
140 			else if ((arg_2) != PROP_INVALID) \
141 				log_printf("  --, %4d  ", (arg_2)); \
142 			else if ((arg_1) != PROP_INVALID) \
143 				log_printf("%4d,  -- ", (arg_1)); \
144 			else \
145 				log_printf("  --,  --  ");
146 
147 
148 
149 #ifdef __cplusplus
150 }
151 #endif
152 
153 #endif /* _OPL_PICL_H */
154