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