xref: /illumos-gate/usr/src/uts/sun4u/opl/sys/pcicmu/pcmu_util.h (revision 2aeafac3612e19716bf8164f89c3c9196342979c)
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 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_PCMU_UTIL_H
27 #define	_SYS_PCMU_UTIL_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 
36 /*
37  * Prototypes
38  */
39 extern int pcmu_init_child(pcmu_t *, dev_info_t *);
40 extern int pcmu_uninit_child(pcmu_t *, dev_info_t *);
41 extern int pcmu_report_dev(dev_info_t *);
42 extern int get_pcmu_properties(pcmu_t *, dev_info_t *);
43 extern void free_pcmu_properties(pcmu_t *);
44 extern int pcmu_get_portid(dev_info_t *);
45 extern int pcmu_reloc_reg(dev_info_t *, dev_info_t *, pcmu_t *,
46     pci_regspec_t *);
47 extern int pcmu_xlate_reg(pcmu_t *, pci_regspec_t *, struct regspec *);
48 extern off_t pcmu_get_reg_set_size(dev_info_t *, int);
49 extern uint_t pcmu_get_nreg_set(dev_info_t *);
50 extern uint64_t pcmu_get_cfg_pabase(pcmu_t *);
51 extern int pcmu_cfg_report(dev_info_t *, ddi_fm_error_t *,
52     pcmu_errstate_t *, int, uint32_t);
53 
54 #ifdef DEBUG
55 
56 extern uint64_t pcmu_debug_flags;
57 
58 typedef struct pcmu_dflag_to_str {
59 	uint64_t flag;
60 	char *string;
61 } pcmu_dflag_to_str_t;
62 
63 #define	PCMU_DBG_ATTACH		0x1ull
64 #define	PCMU_DBG_DETACH		0x2ull
65 #define	PCMU_DBG_MAP		0x4ull
66 #define	PCMU_DBG_A_INTX		0x8ull
67 #define	PCMU_DBG_R_INTX		0x10ull
68 #define	PCMU_DBG_INIT_CLD	0x20ull
69 #define	PCMU_DBG_CTLOPS		0x40ull
70 #define	PCMU_DBG_INTR		0x80ull
71 #define	PCMU_DBG_ERR_INTR	0x100ull
72 #define	PCMU_DBG_BUS_FAULT	0x200ull
73 #define	PCMU_DBG_IB		(0x20ull << 32)
74 #define	PCMU_DBG_CB		(0x40ull << 32)
75 #define	PCMU_DBG_PBM		(0x80ull << 32)
76 #define	PCMU_DBG_CONT		(0x100ull << 32)
77 #define	PCMU_DBG_OPEN		(0x1000ull << 32)
78 #define	PCMU_DBG_CLOSE		(0x2000ull << 32)
79 #define	PCMU_DBG_IOCTL		(0x4000ull << 32)
80 #define	PCMU_DBG_PWR		(0x8000ull << 32)
81 
82 
83 #define	PCMU_DBG0(flag, dip, fmt)	\
84 	pcmu_debug(flag, dip, fmt, 0, 0, 0, 0, 0);
85 
86 #define	PCMU_DBG1(flag, dip, fmt, a1)	\
87 	pcmu_debug(flag, dip, fmt, (uintptr_t)(a1), 0, 0, 0, 0);
88 
89 #define	PCMU_DBG2(flag, dip, fmt, a1, a2)	\
90 	pcmu_debug(flag, dip, fmt, (uintptr_t)(a1), (uintptr_t)(a2), 0, 0, 0);
91 
92 #define	PCMU_DBG3(flag, dip, fmt, a1, a2, a3)	\
93 	pcmu_debug(flag, dip, fmt, (uintptr_t)(a1),	\
94 		(uintptr_t)(a2), (uintptr_t)(a3), 0, 0);
95 
96 #define	PCMU_DBG4(flag, dip, fmt, a1, a2, a3, a4)	\
97 	pcmu_debug(flag, dip, fmt, (uintptr_t)(a1),	\
98 		(uintptr_t)(a2), (uintptr_t)(a3), \
99 		(uintptr_t)(a4), 0);
100 
101 #define	PCMU_DBG5(flag, dip, fmt, a1, a2, a3, a4, a5)	\
102 	pcmu_debug(flag, dip, fmt, (uintptr_t)(a1),	\
103 		(uintptr_t)(a2), (uintptr_t)(a3), \
104 		(uintptr_t)(a4), (uintptr_t)(a5));
105 
106 extern void pcmu_debug(uint64_t, dev_info_t *, char *,
107 			uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t);
108 #else /* DEBUG */
109 
110 #define	PCMU_DBG0(flag, dip, fmt)
111 #define	PCMU_DBG1(flag, dip, fmt, a1)
112 #define	PCMU_DBG2(flag, dip, fmt, a1, a2)
113 #define	PCMU_DBG3(flag, dip, fmt, a1, a2, a3)
114 #define	PCMU_DBG4(flag, dip, fmt, a1, a2, a3, a4)
115 #define	PCMU_DBG5(flag, dip, fmt, a1, a2, a3, a4, a5)
116 
117 #endif /* DEBUG */
118 
119 #ifdef	__cplusplus
120 }
121 #endif
122 
123 #endif	/* _SYS_PCMU_UTIL_H */
124