xref: /onnv-gate/usr/src/uts/sun4u/montecarlo/sys/acebus.h (revision 1708:ea74d8598a3a)
1*1708Sstevel /*
2*1708Sstevel  * CDDL HEADER START
3*1708Sstevel  *
4*1708Sstevel  * The contents of this file are subject to the terms of the
5*1708Sstevel  * Common Development and Distribution License (the "License").
6*1708Sstevel  * You may not use this file except in compliance with the License.
7*1708Sstevel  *
8*1708Sstevel  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*1708Sstevel  * or http://www.opensolaris.org/os/licensing.
10*1708Sstevel  * See the License for the specific language governing permissions
11*1708Sstevel  * and limitations under the License.
12*1708Sstevel  *
13*1708Sstevel  * When distributing Covered Code, include this CDDL HEADER in each
14*1708Sstevel  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*1708Sstevel  * If applicable, add the following below this CDDL HEADER, with the
16*1708Sstevel  * fields enclosed by brackets "[]" replaced with your own identifying
17*1708Sstevel  * information: Portions Copyright [yyyy] [name of copyright owner]
18*1708Sstevel  *
19*1708Sstevel  * CDDL HEADER END
20*1708Sstevel  */
21*1708Sstevel 
22*1708Sstevel /*
23*1708Sstevel  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*1708Sstevel  * Use is subject to license terms.
25*1708Sstevel  */
26*1708Sstevel 
27*1708Sstevel #ifndef _SYS_ACEBUS_H
28*1708Sstevel #define	_SYS_ACEBUS_H
29*1708Sstevel 
30*1708Sstevel #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*1708Sstevel 
32*1708Sstevel #ifdef	__cplusplus
33*1708Sstevel extern "C" {
34*1708Sstevel #endif
35*1708Sstevel 
36*1708Sstevel /*
37*1708Sstevel  * driver state type:
38*1708Sstevel  */
39*1708Sstevel typedef enum { NEW = 0, ATTACHED, RESUMED, DETACHED,
40*1708Sstevel 		SUSPENDED, PM_SUSPENDED } driver_state_t;
41*1708Sstevel 
42*1708Sstevel /*
43*1708Sstevel  * The i86pc specific code fragments are to support the debug of "honeynut"
44*1708Sstevel  * and "multigrain" prototypes on i86pc platform.  Most of the fragments
45*1708Sstevel  * deal with differences in the interrupt dispatching between the prototypes
46*1708Sstevel  * and the cheerio ebus.  On the prototype boards, all interrupt lines are
47*1708Sstevel  * tied together.  For this case, the nexus driver uses a common interrupt
48*1708Sstevel  * handler to poll all of its children.
49*1708Sstevel  */
50*1708Sstevel #if defined(i86pc)
51*1708Sstevel #define	MAX_EBUS_DEVS	6
52*1708Sstevel 
53*1708Sstevel /*
54*1708Sstevel  * ebus device interrupt info;
55*1708Sstevel  */
56*1708Sstevel typedef struct {
57*1708Sstevel 	char *name;
58*1708Sstevel 	uint_t inuse;
59*1708Sstevel 	uint_t (*handler)();
60*1708Sstevel 	caddr_t arg;
61*1708Sstevel } ebus_intr_slot_t;
62*1708Sstevel #endif
63*1708Sstevel 
64*1708Sstevel struct ebus_intr_map {
65*1708Sstevel 	uint32_t ebus_phys_hi;
66*1708Sstevel 	uint32_t ebus_phys_low;
67*1708Sstevel 	uint32_t ebus_intr;
68*1708Sstevel 	uint32_t intr_ctlr_nodeid;
69*1708Sstevel 	uint32_t ino;
70*1708Sstevel };
71*1708Sstevel 
72*1708Sstevel struct ebus_intr_map_mask {
73*1708Sstevel 	uint32_t ebus_phys_hi;
74*1708Sstevel 	uint32_t ebus_phys_low;
75*1708Sstevel 	uint32_t ebus_intr;
76*1708Sstevel };
77*1708Sstevel 
78*1708Sstevel /*
79*1708Sstevel  * driver soft state structure:
80*1708Sstevel  */
81*1708Sstevel typedef struct {
82*1708Sstevel 	dev_info_t *dip;
83*1708Sstevel 	driver_state_t state;
84*1708Sstevel 	pci_regspec_t *reg;
85*1708Sstevel 	int nreg;
86*1708Sstevel 	struct ebus_pci_rangespec *rangep;
87*1708Sstevel 	int range_cnt;
88*1708Sstevel 
89*1708Sstevel #if defined(i86pc)
90*1708Sstevel 	ddi_iblock_cookie_t iblock;
91*1708Sstevel 	ddi_idevice_cookie_t idevice;
92*1708Sstevel 	ebus_intr_slot_t intr_slot[MAX_EBUS_DEVS];
93*1708Sstevel #endif
94*1708Sstevel #if defined(__sparc)
95*1708Sstevel 	/* Interrupt support */
96*1708Sstevel 	int intr_map_size;
97*1708Sstevel 	struct ebus_intr_map *intr_map;
98*1708Sstevel 	struct ebus_intr_map_mask *intr_map_mask;
99*1708Sstevel #endif
100*1708Sstevel } ebus_devstate_t;
101*1708Sstevel 
102*1708Sstevel /*
103*1708Sstevel  * definition of ebus reg spec entry:
104*1708Sstevel  */
105*1708Sstevel typedef struct {
106*1708Sstevel 	uint32_t addr_hi;
107*1708Sstevel 	uint32_t addr_low;
108*1708Sstevel 	uint32_t size;
109*1708Sstevel } ebus_regspec_t;
110*1708Sstevel 
111*1708Sstevel /* EBUS range entry */
112*1708Sstevel struct ebus_pci_rangespec {
113*1708Sstevel 	uint32_t ebus_phys_hi;			/* Child hi range address */
114*1708Sstevel 	uint32_t ebus_phys_low;			/* Child low range address */
115*1708Sstevel 	uint32_t pci_phys_hi;			/* Parent hi rng addr */
116*1708Sstevel 	uint32_t pci_phys_mid;			/* Parent mid rng addr */
117*1708Sstevel 	uint32_t pci_phys_low;			/* Parent low rng addr */
118*1708Sstevel 	uint32_t rng_size;			/* Range size */
119*1708Sstevel };
120*1708Sstevel 
121*1708Sstevel /*
122*1708Sstevel  * use macros for soft state and driver properties:
123*1708Sstevel  */
124*1708Sstevel #define	get_acebus_soft_state(i)	\
125*1708Sstevel 	((ebus_devstate_t *)ddi_get_soft_state(per_acebus_state, (i)))
126*1708Sstevel 
127*1708Sstevel #define	alloc_acebus_soft_state(i)	\
128*1708Sstevel 	ddi_soft_state_zalloc(per_acebus_state, (i))
129*1708Sstevel 
130*1708Sstevel #define	free_acebus_soft_state(i)	\
131*1708Sstevel 	ddi_soft_state_free(per_acebus_state, (i))
132*1708Sstevel 
133*1708Sstevel 
134*1708Sstevel #define	getprop(dip, name, addr, intp)		\
135*1708Sstevel 		ddi_getlongprop(DDI_DEV_T_ANY, (dip), DDI_PROP_DONTPASS, \
136*1708Sstevel 				(name), (caddr_t)(addr), (intp))
137*1708Sstevel 
138*1708Sstevel /*
139*1708Sstevel  * register offsets and lengths:
140*1708Sstevel  */
141*1708Sstevel #define	TCR_OFFSET	0x710000
142*1708Sstevel #define	TCR_LENGTH	12
143*1708Sstevel 
144*1708Sstevel #define	CSR_IO_RINDEX		2
145*1708Sstevel #define	CSR_SIZE		0x00800000
146*1708Sstevel #define	TCR1_OFF		0x00710000
147*1708Sstevel #define	TCR2_OFF		0x00710004
148*1708Sstevel #define	TCR3_OFF		0x00710008
149*1708Sstevel #define	PMD_AUX_OFF		0x00728000
150*1708Sstevel #define	FREQ_AUX_OFF		0x0072a000
151*1708Sstevel #define	DCSR1_OFF		0x00700000
152*1708Sstevel #define	DACR1_OFF		0x00700004
153*1708Sstevel #define	DBCR1_OFF		0x00700008
154*1708Sstevel #define	DCSR2_OFF		0x00702000
155*1708Sstevel #define	DACR2_OFF		0x00702004
156*1708Sstevel #define	DBCR2_OFF		0x00702008
157*1708Sstevel #define	DCSR3_OFF		0x00704000
158*1708Sstevel #define	DACR3_OFF		0x00704004
159*1708Sstevel #define	DBCR3_OFF		0x00704008
160*1708Sstevel #define	DCSR4_OFF		0x00706000
161*1708Sstevel #define	DACR4_OFF		0x00706004
162*1708Sstevel #define	DBCR4_OFF		0x00706008
163*1708Sstevel 
164*1708Sstevel /*
165*1708Sstevel  * timing control register settings:
166*1708Sstevel  */
167*1708Sstevel #define	TCR1		0x08101008
168*1708Sstevel #define	TCR2		0x08100020
169*1708Sstevel #define	TCR3		0x00000020
170*1708Sstevel #define	TCR1_REGVAL	0xe3080808
171*1708Sstevel #define	TCR2_REGVAL	0x0808ff20
172*1708Sstevel #define	TCR3_REGVAL	0x91f3c420
173*1708Sstevel 
174*1708Sstevel 
175*1708Sstevel 
176*1708Sstevel #if defined(DEBUG)
177*1708Sstevel #define	D_IDENTIFY	0x00000001
178*1708Sstevel #define	D_ATTACH	0x00000002
179*1708Sstevel #define	D_DETACH	0x00000004
180*1708Sstevel #define	D_MAP		0x00000008
181*1708Sstevel #define	D_CTLOPS	0x00000010
182*1708Sstevel #define	D_INTR		0x00000100
183*1708Sstevel 
184*1708Sstevel #define	DBG(flag, psp, fmt)	\
185*1708Sstevel 	acebus_debug(flag, psp, fmt, 0, 0, 0, 0, 0);
186*1708Sstevel #define	DBG1(flag, psp, fmt, a1)	\
187*1708Sstevel 	acebus_debug(flag, psp, fmt, (uintptr_t)(a1), 0, 0, 0, 0);
188*1708Sstevel #define	DBG2(flag, psp, fmt, a1, a2)	\
189*1708Sstevel 	acebus_debug(flag, psp, fmt, (uintptr_t)(a1), (uintptr_t)(a2), 0, 0, 0);
190*1708Sstevel #define	DBG3(flag, psp, fmt, a1, a2, a3)	\
191*1708Sstevel 	acebus_debug(flag, psp, fmt, (uintptr_t)(a1), (uintptr_t)(a2), \
192*1708Sstevel 	    (uintptr_t)(a3), 0, 0);
193*1708Sstevel #define	DBG4(flag, psp, fmt, a1, a2, a3, a4)	\
194*1708Sstevel 	acebus_debug(flag, psp, fmt, (uintptr_t)(a1), (uintptr_t)(a2), \
195*1708Sstevel 	    (uintptr_t)(a3), \
196*1708Sstevel 		(uintptr_t)(a4), 0);
197*1708Sstevel #define	DBG5(flag, psp, fmt, a1, a2, a3, a4, a5)	\
198*1708Sstevel 	acebus_debug(flag, psp, fmt, (uintptr_t)(a1), (uintptr_t)(a2), \
199*1708Sstevel 	    (uintptr_t)(a3), \
200*1708Sstevel 		(uintptr_t)(a4), (uintptr_t)(a5));
201*1708Sstevel static void
202*1708Sstevel acebus_debug(uint_t, ebus_devstate_t *, char *, uintptr_t, uintptr_t, uintptr_t,
203*1708Sstevel     uintptr_t, uintptr_t);
204*1708Sstevel #else
205*1708Sstevel #define	DBG(flag, psp, fmt)
206*1708Sstevel #define	DBG1(flag, psp, fmt, a1)
207*1708Sstevel #define	DBG2(flag, psp, fmt, a1, a2)
208*1708Sstevel #define	DBG3(flag, psp, fmt, a1, a2, a3)
209*1708Sstevel #define	DBG4(flag, psp, fmt, a1, a2, a3, a4)
210*1708Sstevel #define	DBG5(flag, psp, fmt, a1, a2, a3, a4, a5)
211*1708Sstevel #endif
212*1708Sstevel 
213*1708Sstevel #ifdef	__cplusplus
214*1708Sstevel }
215*1708Sstevel #endif
216*1708Sstevel 
217*1708Sstevel #endif	/* _SYS_ACEBUS_H */
218