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 2009 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#ifdef __cplusplus
35extern "C" {
36#endif
37
38/*
39 * Property names
40 */
41#define	OBP_PROP_REG			"reg"
42#define	OBP_PROP_CLOCK_FREQ		"clock-frequency"
43#define	OBP_PROP_BOARD_NUM		"board#"
44#define	OBP_PROP_REVISION_ID		"revision-id"
45#define	OBP_PROP_VENDOR_ID		"vendor-id"
46#define	OBP_PROP_DEVICE_ID		"device-id"
47#define	OBP_PROP_VERSION_NUM		"version#"
48#define	OBP_PROP_BOARD_TYPE		"board_type"
49#define	OBP_PROP_ECACHE_SIZE		"ecache-size"
50#define	OBP_PROP_IMPLEMENTATION		"implementation#"
51#define	OBP_PROP_MASK			"mask#"
52#define	OBP_PROP_COMPATIBLE		"compatible"
53#define	OBP_PROP_BANNER_NAME		"banner-name"
54#define	OBP_PROP_MODEL			"model"
55#define	OBP_PROP_66MHZ_CAPABLE		"66mhz-capable"
56#define	OBP_PROP_VERSION		"version"
57#define	OBP_PROP_INSTANCE		"instance"
58
59/* PCI BUS types */
60
61#define	PCI_UNKN	-1
62#define	PCI	10
63#define	PCIX	20
64#define	PCIE	30
65
66/* PCI device defines */
67
68#define	PCI_CONF_VENID		0x0		/* vendor id, 2 bytes */
69#define	PCI_CONF_DEVID		0x2		/* device id, 2 bytes */
70#define	PCI_CONF_CAP_PTR	0x34		/* 1 byte capability pointer */
71#define	PCI_CAP_ID_PCI_E	0x10		/* PCI Express supported */
72#define	PCIE_LINKCAP		0x0C		/* Link Capability */
73#define	PCIE_LINKSTS		0x12		/* Link Status */
74#define	PCI_CAP_MASK		0xff		/* CAP Mask */
75#define	PCI_DEV_MASK		0xF800		/* Dev# Mask */
76#define	PCI_FUNC_MASK		0x700		/* Func# Mask */
77#define	PCI_BUS_MASK		0x1ff0000	/* Bus# Mask */
78#define	PCI_LINK_MASK		0x1f		/* Link Mask */
79
80#define	PCI_LINK_SHIFT		4		/* Link shift Bits */
81#define	PCI_FREQ_33		33		/* legacy PCI default freq */
82#define	PCI_FREQ_66		66		/* PCI default freq */
83#define	PCI_FREQ_100		100
84
85/* PCI frequencies */
86
87#define	PCI_FREQ_133		133
88#define	PCI_FREQ_266		266
89#define	PCI_FREQ_533		533
90
91/* PCI frequency shift bits */
92
93#define	PCI_SHIFT_133		17
94#define	PCI_SHIFT_266		30
95#define	PCI_SHIFT_533		31
96
97/* PCI frequency modes */
98
99#define	PCI_MODE_66		1
100#define	PCI_MODE_100		2
101#define	PCI_MODE_133		3
102
103/* PCI frequency SEC status masks */
104
105#define	PCI_SEC_133		0x2
106#define	PCI_SEC_266		0x4000
107#define	PCI_SEC_533		0x8000
108#define	PCI_LEAF_ULONG		1UL
109
110
111/* Invalid property value */
112#define	PROP_INVALID		-1
113
114/* Macros */
115
116#define	IS_PCI(name) \
117	(((name) != NULL) && (strncmp((name), "pci", 3) == 0))
118
119#define	IS_EBUS(class) \
120	(((class) != NULL) && (strncmp((class), "ebus", 4) == 0))
121
122#define	ROUND_TO_MHZ(x)	(((x) + 500000)/ 1000000)
123
124#define	PRINT_FREQ_FMT(arg_1, arg_2) \
125		if (((arg_1) != 0) && \
126			((arg_2) != 0)) \
127				log_printf("%4d, %4d  ", (arg_1), (arg_2)); \
128			else if ((arg_2) != 0) \
129				log_printf("  --, %4d  ", (arg_2)); \
130			else if ((arg_1) != 0) \
131				log_printf("%4d,  -- ", (arg_1)); \
132			else \
133				log_printf("  --,  --  ");
134
135#define	PRINT_FMT(arg_1, arg_2) \
136		if (((arg_1) != PROP_INVALID) && \
137			((arg_2) != PROP_INVALID)) \
138				log_printf("%4d, %4d  ", (arg_1), (arg_2)); \
139			else if ((arg_2) != PROP_INVALID) \
140				log_printf("  --, %4d  ", (arg_2)); \
141			else if ((arg_1) != PROP_INVALID) \
142				log_printf("%4d,  -- ", (arg_1)); \
143			else \
144				log_printf("  --,  --  ");
145
146
147
148#ifdef __cplusplus
149}
150#endif
151
152#endif /* _OPL_PICL_H */
153