xref: /titanic_44/usr/src/uts/sun4u/sys/sysiosbus.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_SYSIOSBUS_H
28*7c478bd9Sstevel@tonic-gate #define	_SYS_SYSIOSBUS_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #ifndef _ASM
33*7c478bd9Sstevel@tonic-gate #include <sys/avintr.h>
34*7c478bd9Sstevel@tonic-gate #include <sys/vmem.h>
35*7c478bd9Sstevel@tonic-gate #include <sys/ontrap.h>
36*7c478bd9Sstevel@tonic-gate #include <sys/machsystm.h>
37*7c478bd9Sstevel@tonic-gate #endif
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
40*7c478bd9Sstevel@tonic-gate extern "C" {
41*7c478bd9Sstevel@tonic-gate #endif
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate /* Things for debugging */
44*7c478bd9Sstevel@tonic-gate #ifdef SYSIO_MEM_DEBUG
45*7c478bd9Sstevel@tonic-gate #define	IO_MEMUSAGE
46*7c478bd9Sstevel@tonic-gate #endif /* SYSIO_MEM_DEBUG */
47*7c478bd9Sstevel@tonic-gate 
48*7c478bd9Sstevel@tonic-gate /*
49*7c478bd9Sstevel@tonic-gate  * sysio sbus constant definitions.
50*7c478bd9Sstevel@tonic-gate  */
51*7c478bd9Sstevel@tonic-gate #define	NATURAL_REG_SIZE	0x8	/* 8 Bytes is Fusion reg size */
52*7c478bd9Sstevel@tonic-gate #define	MIN_REG_SIZE		0x4	/* Smallest Fusion reg size */
53*7c478bd9Sstevel@tonic-gate #define	OFF_SYSIO_CTRL_REG	0x10
54*7c478bd9Sstevel@tonic-gate #define	SYSIO_CTRL_REG_SIZE	(NATURAL_REG_SIZE)
55*7c478bd9Sstevel@tonic-gate #define	OFF_SBUS_CTRL_REG	0x2000
56*7c478bd9Sstevel@tonic-gate #define	SBUS_CTRL_REG_SIZE	(NATURAL_REG_SIZE)
57*7c478bd9Sstevel@tonic-gate #define	OFF_SBUS_SLOT_CONFIG	0x2020
58*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT_CONFIG_SIZE	(NATURAL_REG_SIZE * 7)
59*7c478bd9Sstevel@tonic-gate #define	OFF_INTR_MAPPING_REG	0x2c00
60*7c478bd9Sstevel@tonic-gate /* #define	INTR_MAPPING_REG_SIZE	(NATURAL_REG_SIZE * 16 * 8)  */
61*7c478bd9Sstevel@tonic-gate #define	INTR_MAPPING_REG_SIZE	0x490
62*7c478bd9Sstevel@tonic-gate #define	OFF_CLR_INTR_REG	0x3408
63*7c478bd9Sstevel@tonic-gate /* #define	CLR_INTR_REG_SIZE	(NATURAL_REG_SIZE * 16 * 8) */
64*7c478bd9Sstevel@tonic-gate #define	CLR_INTR_REG_SIZE	0x488
65*7c478bd9Sstevel@tonic-gate #define	OFF_INTR_RETRY_REG	0x2c20
66*7c478bd9Sstevel@tonic-gate #define	INTR_RETRY_REG_SIZE	(MIN_REG_SIZE)
67*7c478bd9Sstevel@tonic-gate #define	OFF_SBUS_INTR_STATE_REG	0x4800
68*7c478bd9Sstevel@tonic-gate #define	SBUS_INTR_STATE_REG_SIZE (NATURAL_REG_SIZE * 2)
69*7c478bd9Sstevel@tonic-gate #define	SYSIO_IGN		46
70*7c478bd9Sstevel@tonic-gate #define	SBUS_ARBIT_ALL		0x3full
71*7c478bd9Sstevel@tonic-gate #define	SYSIO_VER_SHIFT		56
72*7c478bd9Sstevel@tonic-gate 
73*7c478bd9Sstevel@tonic-gate /* Error registers */
74*7c478bd9Sstevel@tonic-gate #define	OFF_SYSIO_ECC_REGS	0x20
75*7c478bd9Sstevel@tonic-gate #define	SYSIO_ECC_REGS_SIZE	NATURAL_REG_SIZE
76*7c478bd9Sstevel@tonic-gate #define	OFF_SYSIO_UE_REGS	0x30
77*7c478bd9Sstevel@tonic-gate #define	SYSIO_UE_REGS_SIZE	(NATURAL_REG_SIZE * 2)
78*7c478bd9Sstevel@tonic-gate #define	OFF_SYSIO_CE_REGS	0x40
79*7c478bd9Sstevel@tonic-gate #define	SYSIO_CE_REGS_SIZE	(NATURAL_REG_SIZE * 2)
80*7c478bd9Sstevel@tonic-gate #define	OFF_SBUS_ERR_REGS	0x2010
81*7c478bd9Sstevel@tonic-gate #define	SBUS_ERR_REGS_SIZE	(NATURAL_REG_SIZE * 2)
82*7c478bd9Sstevel@tonic-gate 
83*7c478bd9Sstevel@tonic-gate /* Interrupts */
84*7c478bd9Sstevel@tonic-gate #define	INTERRUPT_CPU_FIELD	26	/* Bit shift for mondo TID field */
85*7c478bd9Sstevel@tonic-gate #define	INTERRUPT_GROUP_NUMBER	6	/* Bit shift for mondo IGN field */
86*7c478bd9Sstevel@tonic-gate #define	INTERRUPT_VALID		0x80000000ull /* Mondo valid bit */
87*7c478bd9Sstevel@tonic-gate #define	SBUS_INTR_IDLE		0ull
88*7c478bd9Sstevel@tonic-gate #define	INT_PENDING 		3	/* state of the interrupt dispatch */
89*7c478bd9Sstevel@tonic-gate /*
90*7c478bd9Sstevel@tonic-gate  * Fix these (RAZ)
91*7c478bd9Sstevel@tonic-gate  * Interrupt Mapping Register defines
92*7c478bd9Sstevel@tonic-gate  */
93*7c478bd9Sstevel@tonic-gate #define	IMR_VALID		0x80000000ull	/* Valid bit */
94*7c478bd9Sstevel@tonic-gate #define	IMR_TID			0x7C000000ull	/* TID bits */
95*7c478bd9Sstevel@tonic-gate #define	IMR_IGN			0x000007C0ull	/* IGN bits */
96*7c478bd9Sstevel@tonic-gate #define	IMR_INO			0x0000003Full	/* INO bits */
97*7c478bd9Sstevel@tonic-gate #define	IMR_TID_SHIFT		26		/* Bit shift for TID field */
98*7c478bd9Sstevel@tonic-gate #define	IMR_IGN_SHIFT		6		/* Bit shift for IGN field */
99*7c478bd9Sstevel@tonic-gate 
100*7c478bd9Sstevel@tonic-gate #define	MAX_SBUS		(30)
101*7c478bd9Sstevel@tonic-gate #define	MAX_SBUS_LEVEL		(7)
102*7c478bd9Sstevel@tonic-gate #define	MAX_SBUS_SLOTS	(7)		/* 4 external slots + 3 internal */
103*7c478bd9Sstevel@tonic-gate #define	EXT_SBUS_SLOTS		4	/* Number of external sbus slots */
104*7c478bd9Sstevel@tonic-gate #define	MAX_SBUS_SLOT_ADDR	0x10	/* Max slot address on SYSIO */
105*7c478bd9Sstevel@tonic-gate #define	SYSIO_BURST_RANGE	(0x7f)	/* 32 bit: 64 Byte to 1 Byte burst */
106*7c478bd9Sstevel@tonic-gate #define	SYSIO64_BURST_RANGE	(0x78)	/* 64 bit: 64 Byte to 8 Byte burst */
107*7c478bd9Sstevel@tonic-gate #define	SYSIO_BURST_MASK	0xffff
108*7c478bd9Sstevel@tonic-gate #define	SYSIO64_BURST_MASK	0xffff0000
109*7c478bd9Sstevel@tonic-gate #define	SYSIO64_BURST_SHIFT	16
110*7c478bd9Sstevel@tonic-gate #define	MAX_PIL			16
111*7c478bd9Sstevel@tonic-gate 
112*7c478bd9Sstevel@tonic-gate /* Slot config register defines */
113*7c478bd9Sstevel@tonic-gate #define	SBUS_ETM		0x4000ull
114*7c478bd9Sstevel@tonic-gate #define	SYSIO_SLAVEBURST_MASK	0x1e	/* Mask for hardware register */
115*7c478bd9Sstevel@tonic-gate #define	SYSIO_SLAVEBURST_RANGE	(0x78)	/* 32 bit: 64 Byte to 8 Byte burst */
116*7c478bd9Sstevel@tonic-gate #define	SYSIO64_SLAVEBURST_RANGE (0x78)	/* 64 bit: 64 Byte to 8 Byte burst */
117*7c478bd9Sstevel@tonic-gate #define	SYSIO_SLAVEBURST_REGSHIFT 2	/* Convert bit positions 2**8 to 2**1 */
118*7c478bd9Sstevel@tonic-gate 
119*7c478bd9Sstevel@tonic-gate /*
120*7c478bd9Sstevel@tonic-gate  * Offsets of sysio, sbus, registers
121*7c478bd9Sstevel@tonic-gate  */
122*7c478bd9Sstevel@tonic-gate /* Slot configuration register mapping offsets */
123*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT0_CONFIG	0x0
124*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT1_CONFIG	0x1
125*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT2_CONFIG	0x2
126*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT3_CONFIG	0x3
127*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT4_CONFIG	0x4
128*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT5_CONFIG	0x5
129*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT6_CONFIG	0x6
130*7c478bd9Sstevel@tonic-gate 
131*7c478bd9Sstevel@tonic-gate /* Interrupt mapping register mapping offsets */
132*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT0_MAPREG	0x0
133*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT1_MAPREG	0x1
134*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT2_MAPREG	0x2
135*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT3_MAPREG	0x3
136*7c478bd9Sstevel@tonic-gate #define	ESP_MAPREG		0x80
137*7c478bd9Sstevel@tonic-gate #define	ETHER_MAPREG		0x81
138*7c478bd9Sstevel@tonic-gate #define	PP_MAPREG		0x82
139*7c478bd9Sstevel@tonic-gate #define	AUDIO_MAPREG		0x83
140*7c478bd9Sstevel@tonic-gate #define	KBDMOUSE_MAPREG		0x85
141*7c478bd9Sstevel@tonic-gate #define	FLOPPY_MAPREG		0x86
142*7c478bd9Sstevel@tonic-gate #define	THERMAL_MAPREG		0x87
143*7c478bd9Sstevel@tonic-gate #define	TIMER0_MAPREG		0x8C
144*7c478bd9Sstevel@tonic-gate #define	TIMER1_MAPREG		0x8D
145*7c478bd9Sstevel@tonic-gate #define	UE_ECC_MAPREG		0x8E
146*7c478bd9Sstevel@tonic-gate #define	CE_ECC_MAPREG		0x8F
147*7c478bd9Sstevel@tonic-gate #define	SBUS_ERR_MAPREG		0x90
148*7c478bd9Sstevel@tonic-gate #define	PM_WAKEUP_MAPREG	0x91
149*7c478bd9Sstevel@tonic-gate #define	FFB_MAPPING_REG		0x92
150*7c478bd9Sstevel@tonic-gate #define	EXP_MAPPING_REG		0x93
151*7c478bd9Sstevel@tonic-gate 
152*7c478bd9Sstevel@tonic-gate /* Interrupt clear register mapping offsets */
153*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT0_L1_CLEAR	0x0
154*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT0_L2_CLEAR	0x1
155*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT0_L3_CLEAR	0x2
156*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT0_L4_CLEAR	0x3
157*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT0_L5_CLEAR	0x4
158*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT0_L6_CLEAR	0x5
159*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT0_L7_CLEAR	0x6
160*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT1_L1_CLEAR	0x8
161*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT1_L2_CLEAR	0x9
162*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT1_L3_CLEAR	0xa
163*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT1_L4_CLEAR	0xb
164*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT1_L5_CLEAR	0xc
165*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT1_L6_CLEAR	0xd
166*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT1_L7_CLEAR	0xe
167*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT2_L1_CLEAR	0x10
168*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT2_L2_CLEAR	0x11
169*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT2_L3_CLEAR	0x12
170*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT2_L4_CLEAR	0x13
171*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT2_L5_CLEAR	0x14
172*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT2_L6_CLEAR	0x15
173*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT2_L7_CLEAR	0x16
174*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT3_L1_CLEAR	0x18
175*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT3_L2_CLEAR	0x19
176*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT3_L3_CLEAR	0x1a
177*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT3_L4_CLEAR	0x1b
178*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT3_L5_CLEAR	0x1c
179*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT3_L6_CLEAR	0x1d
180*7c478bd9Sstevel@tonic-gate #define	SBUS_SLOT3_L7_CLEAR	0x1e
181*7c478bd9Sstevel@tonic-gate #define	ESP_CLEAR		0x7f
182*7c478bd9Sstevel@tonic-gate #define	ETHER_CLEAR		0x80
183*7c478bd9Sstevel@tonic-gate #define	PP_CLEAR		0x81
184*7c478bd9Sstevel@tonic-gate #define	AUDIO_CLEAR		0x82
185*7c478bd9Sstevel@tonic-gate #define	KBDMOUSE_CLEAR		0x84
186*7c478bd9Sstevel@tonic-gate #define	FLOPPY_CLEAR		0x85
187*7c478bd9Sstevel@tonic-gate #define	THERMAL_CLEAR		0x86
188*7c478bd9Sstevel@tonic-gate #define	TIMER0_CLEAR		0x8B
189*7c478bd9Sstevel@tonic-gate #define	TIMER1_CLEAR		0x8C
190*7c478bd9Sstevel@tonic-gate #define	UE_ECC_CLEAR		0x8D
191*7c478bd9Sstevel@tonic-gate #define	CE_ECC_CLEAR		0x8E
192*7c478bd9Sstevel@tonic-gate #define	SBUS_ERR_CLEAR		0x8F
193*7c478bd9Sstevel@tonic-gate #define	PM_WAKEUP_CLEAR		0x90
194*7c478bd9Sstevel@tonic-gate 
195*7c478bd9Sstevel@tonic-gate /*
196*7c478bd9Sstevel@tonic-gate  * Bit shift for accessing the keyboard mouse interrupt state reg.
197*7c478bd9Sstevel@tonic-gate  * note - The external devices are the only other devices where
198*7c478bd9Sstevel@tonic-gate  * we need to check the interrupt state before adding or removing
199*7c478bd9Sstevel@tonic-gate  * interrupts.  There is an algorithm to calculate their bit shift.
200*7c478bd9Sstevel@tonic-gate  */
201*7c478bd9Sstevel@tonic-gate #define	ESP_INTR_STATE_SHIFT		0
202*7c478bd9Sstevel@tonic-gate #define	ETHER_INTR_STATE_SHIFT		2
203*7c478bd9Sstevel@tonic-gate #define	PP_INTR_STATE_SHIFT		4
204*7c478bd9Sstevel@tonic-gate #define	AUDIO_INTR_STATE_SHIFT		6
205*7c478bd9Sstevel@tonic-gate #define	KBDMOUSE_INTR_STATE_SHIFT	10
206*7c478bd9Sstevel@tonic-gate #define	FLOPPY_INTR_STATE_SHIFT		12
207*7c478bd9Sstevel@tonic-gate #define	THERMAL_INTR_STATE_SHIFT	14
208*7c478bd9Sstevel@tonic-gate #define	TIMER0_INTR_STATE_SHIFT		22
209*7c478bd9Sstevel@tonic-gate #define	TIMER1_INTR_STATE_SHIFT		24
210*7c478bd9Sstevel@tonic-gate #define	UE_INTR_STATE_SHIFT		26
211*7c478bd9Sstevel@tonic-gate #define	CE_INTR_STATE_SHIFT		28
212*7c478bd9Sstevel@tonic-gate #define	SERR_INTR_STATE_SHIFT		30
213*7c478bd9Sstevel@tonic-gate #define	PM_INTR_STATE_SHIFT		32
214*7c478bd9Sstevel@tonic-gate 
215*7c478bd9Sstevel@tonic-gate #define	MAX_INO_TABLE_SIZE	58	/* Max num of sbus devices on sysio */
216*7c478bd9Sstevel@tonic-gate #define	MAX_MONDO_EXTERNAL	0x1f
217*7c478bd9Sstevel@tonic-gate #define	SBUS_MAX_INO		0x3f
218*7c478bd9Sstevel@tonic-gate #define	THERMAL_MONDO		0x2a
219*7c478bd9Sstevel@tonic-gate #define	UE_ECC_MONDO		0x34
220*7c478bd9Sstevel@tonic-gate #define	CE_ECC_MONDO		0x35
221*7c478bd9Sstevel@tonic-gate #define	SBUS_ERR_MONDO		0x36
222*7c478bd9Sstevel@tonic-gate 
223*7c478bd9Sstevel@tonic-gate /* used for the picN kstats */
224*7c478bd9Sstevel@tonic-gate #define	SBUS_NUM_PICS	2
225*7c478bd9Sstevel@tonic-gate #define	SBUS_NUM_EVENTS	14
226*7c478bd9Sstevel@tonic-gate #define	SBUS_PIC0_MASK	0x00000000FFFFFFFFULL	/* pic0 bits of %pic */
227*7c478bd9Sstevel@tonic-gate 
228*7c478bd9Sstevel@tonic-gate /* Offsets for Performance registers */
229*7c478bd9Sstevel@tonic-gate #define	OFF_SBUS_PCR	0x100
230*7c478bd9Sstevel@tonic-gate #define	OFF_SBUS_PIC	0x108
231*7c478bd9Sstevel@tonic-gate 
232*7c478bd9Sstevel@tonic-gate /*
233*7c478bd9Sstevel@tonic-gate  * used to build array of event-names and pcr-mask values
234*7c478bd9Sstevel@tonic-gate  */
235*7c478bd9Sstevel@tonic-gate typedef	struct	sbus_event_mask {
236*7c478bd9Sstevel@tonic-gate 	char	*event_name;
237*7c478bd9Sstevel@tonic-gate 	uint64_t pcr_mask;
238*7c478bd9Sstevel@tonic-gate } sbus_event_mask_t;
239*7c478bd9Sstevel@tonic-gate 
240*7c478bd9Sstevel@tonic-gate /*
241*7c478bd9Sstevel@tonic-gate  * This type is used to describe addresses that we expect a device
242*7c478bd9Sstevel@tonic-gate  * to place on a bus i.e. addresses from the iommu address space.
243*7c478bd9Sstevel@tonic-gate  */
244*7c478bd9Sstevel@tonic-gate typedef	uint32_t	ioaddr_t;
245*7c478bd9Sstevel@tonic-gate 
246*7c478bd9Sstevel@tonic-gate 
247*7c478bd9Sstevel@tonic-gate /*
248*7c478bd9Sstevel@tonic-gate  * sysio sbus soft state data structure.
249*7c478bd9Sstevel@tonic-gate  * We use the sbus_ctrl_reg to flush hardware store buffers because
250*7c478bd9Sstevel@tonic-gate  * there is very little hardware contention on this register.
251*7c478bd9Sstevel@tonic-gate  */
252*7c478bd9Sstevel@tonic-gate struct sbus_soft_state {
253*7c478bd9Sstevel@tonic-gate 	dev_info_t *dip;		/* dev info of myself */
254*7c478bd9Sstevel@tonic-gate 	int upa_id;			/* UPA ID of this SYSIO */
255*7c478bd9Sstevel@tonic-gate 
256*7c478bd9Sstevel@tonic-gate 	/*
257*7c478bd9Sstevel@tonic-gate 	 * device node address property:
258*7c478bd9Sstevel@tonic-gate 	 */
259*7c478bd9Sstevel@tonic-gate 	caddr_t address;
260*7c478bd9Sstevel@tonic-gate 
261*7c478bd9Sstevel@tonic-gate 	/*
262*7c478bd9Sstevel@tonic-gate 	 * access handles in case we need to map the registers ourself:
263*7c478bd9Sstevel@tonic-gate 	 */
264*7c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t ac;
265*7c478bd9Sstevel@tonic-gate 
266*7c478bd9Sstevel@tonic-gate 	volatile uint64_t *iommu_flush_reg; /* IOMMU regs */
267*7c478bd9Sstevel@tonic-gate 	volatile uint64_t *iommu_ctrl_reg;
268*7c478bd9Sstevel@tonic-gate 	volatile uint64_t *tsb_base_addr;  /* Hardware reg for phys TSB base */
269*7c478bd9Sstevel@tonic-gate 	volatile uint64_t *soft_tsb_base_addr; /* virtual address of TSB base */
270*7c478bd9Sstevel@tonic-gate 	volatile uint64_t *iommu_tlb_tag;
271*7c478bd9Sstevel@tonic-gate 	volatile uint64_t *iommu_tlb_data;
272*7c478bd9Sstevel@tonic-gate 
273*7c478bd9Sstevel@tonic-gate 	size_t iommu_dvma_size;
274*7c478bd9Sstevel@tonic-gate 	ioaddr_t iommu_dvma_base;
275*7c478bd9Sstevel@tonic-gate 	uint16_t iommu_tsb_cookie;
276*7c478bd9Sstevel@tonic-gate 
277*7c478bd9Sstevel@tonic-gate 
278*7c478bd9Sstevel@tonic-gate 	volatile uint64_t *sysio_ctrl_reg;	/* sysio regs */
279*7c478bd9Sstevel@tonic-gate 	volatile uint64_t *sbus_ctrl_reg;   /* also used to flush store bufs */
280*7c478bd9Sstevel@tonic-gate 	volatile uint64_t *sbus_slot_config_reg;
281*7c478bd9Sstevel@tonic-gate 	uint_t sbus_slave_burstsizes[MAX_SBUS_SLOTS];
282*7c478bd9Sstevel@tonic-gate 
283*7c478bd9Sstevel@tonic-gate 	volatile uint64_t *intr_mapping_reg;	/* Interrupt regs */
284*7c478bd9Sstevel@tonic-gate 	volatile uint64_t *clr_intr_reg;
285*7c478bd9Sstevel@tonic-gate 	volatile uint64_t *intr_retry_reg;
286*7c478bd9Sstevel@tonic-gate 	volatile uint64_t *sbus_intr_state;
287*7c478bd9Sstevel@tonic-gate 	volatile uint64_t *obio_intr_state;
288*7c478bd9Sstevel@tonic-gate 	int8_t intr_hndlr_cnt[MAX_SBUS_SLOT_ADDR]; /* intmapreg cntr by slot */
289*7c478bd9Sstevel@tonic-gate 	uchar_t spurious_cntrs[MAX_PIL + 1];	/* Spurious intr counter */
290*7c478bd9Sstevel@tonic-gate 
291*7c478bd9Sstevel@tonic-gate 	volatile uint64_t *sysio_ecc_reg;	/* sysio ecc control reg */
292*7c478bd9Sstevel@tonic-gate 	volatile uint64_t *sysio_ue_reg;	/* sysio ue ecc error regs */
293*7c478bd9Sstevel@tonic-gate 	volatile uint64_t *sysio_ce_reg;	/* sysio ce ecc error regs */
294*7c478bd9Sstevel@tonic-gate 	volatile uint64_t *sbus_err_reg;	/* sbus async error regs */
295*7c478bd9Sstevel@tonic-gate 
296*7c478bd9Sstevel@tonic-gate 	volatile uint64_t *str_buf_ctrl_reg;	/* streaming buffer regs */
297*7c478bd9Sstevel@tonic-gate 	volatile uint64_t *str_buf_flush_reg;
298*7c478bd9Sstevel@tonic-gate 	volatile uint64_t *str_buf_sync_reg;
299*7c478bd9Sstevel@tonic-gate 	volatile uint64_t *str_buf_pg_tag_diag;
300*7c478bd9Sstevel@tonic-gate 	kmutex_t sync_reg_lock;			/* lock around sync flush reg */
301*7c478bd9Sstevel@tonic-gate 	int stream_buf_off;
302*7c478bd9Sstevel@tonic-gate 
303*7c478bd9Sstevel@tonic-gate 	uint_t sbus_burst_sizes;
304*7c478bd9Sstevel@tonic-gate 	uint_t sbus64_burst_sizes;
305*7c478bd9Sstevel@tonic-gate 
306*7c478bd9Sstevel@tonic-gate 	vmem_t *dvma_arena;		/* DVMA arena for this IOMMU */
307*7c478bd9Sstevel@tonic-gate 	uintptr_t dvma_call_list_id;	/* DVMA callback list */
308*7c478bd9Sstevel@tonic-gate 	kmutex_t dma_pool_lock;
309*7c478bd9Sstevel@tonic-gate 	caddr_t dmaimplbase;		/* dma_pool_lock protects this */
310*7c478bd9Sstevel@tonic-gate 	int	dma_reserve;		/* Size reserved for fast DVMA */
311*7c478bd9Sstevel@tonic-gate 
312*7c478bd9Sstevel@tonic-gate 	struct sbus_wrapper_arg *intr_list[MAX_INO_TABLE_SIZE];
313*7c478bd9Sstevel@tonic-gate 	kmutex_t intr_poll_list_lock;	/* to add/rem to intr poll list */
314*7c478bd9Sstevel@tonic-gate 	kmutex_t pokefault_mutex;	/* mutex for pokefaults */
315*7c478bd9Sstevel@tonic-gate 	on_trap_data_t *ontrap_data;	/* Data used to handle poke faults */
316*7c478bd9Sstevel@tonic-gate 	hrtime_t bto_timestamp;		/* time of first timeout */
317*7c478bd9Sstevel@tonic-gate 	int bto_ctr;			/* counter for timeouts thereafter */
318*7c478bd9Sstevel@tonic-gate 	pfn_t sbus_io_lo_pfn;
319*7c478bd9Sstevel@tonic-gate 	pfn_t sbus_io_hi_pfn;
320*7c478bd9Sstevel@tonic-gate 	struct iophyslist *sbus_io_ranges;
321*7c478bd9Sstevel@tonic-gate 	int intr_mapping_ign;		/* placeholder for the IGN */
322*7c478bd9Sstevel@tonic-gate #ifdef	_STARFIRE
323*7c478bd9Sstevel@tonic-gate 	caddr_t ittrans_cookie;		/* starfire intr target translation */
324*7c478bd9Sstevel@tonic-gate #endif	/* _STARFIRE */
325*7c478bd9Sstevel@tonic-gate #ifdef	DEBUG
326*7c478bd9Sstevel@tonic-gate 	kmutex_t iomemlock;		/* Memory usage lock (debug only) */
327*7c478bd9Sstevel@tonic-gate 	struct io_mem_list *iomem;	/* Memory usage list (debug only) */
328*7c478bd9Sstevel@tonic-gate #endif /* DEBUG */
329*7c478bd9Sstevel@tonic-gate 	/*
330*7c478bd9Sstevel@tonic-gate 	 * Performance registers and kstat.
331*7c478bd9Sstevel@tonic-gate 	 */
332*7c478bd9Sstevel@tonic-gate 	volatile uint64_t *sbus_pcr;	/* perf counter control */
333*7c478bd9Sstevel@tonic-gate 	volatile uint64_t *sbus_pic; 	/* perf counter register */
334*7c478bd9Sstevel@tonic-gate 	kstat_t	*sbus_counters_ksp;	/* perf counter kstat */
335*7c478bd9Sstevel@tonic-gate };
336*7c478bd9Sstevel@tonic-gate 
337*7c478bd9Sstevel@tonic-gate 
338*7c478bd9Sstevel@tonic-gate /*
339*7c478bd9Sstevel@tonic-gate  * Ugly interrupt cruft due to sysio inconsistencies.
340*7c478bd9Sstevel@tonic-gate  */
341*7c478bd9Sstevel@tonic-gate struct sbus_slot_entry {
342*7c478bd9Sstevel@tonic-gate 	uint64_t slot_config;
343*7c478bd9Sstevel@tonic-gate 	uint64_t mapping_reg;
344*7c478bd9Sstevel@tonic-gate 	uint64_t clear_reg;
345*7c478bd9Sstevel@tonic-gate 	int diagreg_shift;
346*7c478bd9Sstevel@tonic-gate };
347*7c478bd9Sstevel@tonic-gate 
348*7c478bd9Sstevel@tonic-gate struct sbus_intr_handler {
349*7c478bd9Sstevel@tonic-gate 	dev_info_t *dip;
350*7c478bd9Sstevel@tonic-gate 	uint32_t inum;
351*7c478bd9Sstevel@tonic-gate 	uint_t (*funcp)();
352*7c478bd9Sstevel@tonic-gate 	caddr_t arg1;
353*7c478bd9Sstevel@tonic-gate 	caddr_t arg2;
354*7c478bd9Sstevel@tonic-gate 	uint_t	intr_state;
355*7c478bd9Sstevel@tonic-gate 	struct sbus_intr_handler *next;
356*7c478bd9Sstevel@tonic-gate };
357*7c478bd9Sstevel@tonic-gate 
358*7c478bd9Sstevel@tonic-gate /* sbus Interrupt routine wrapper structure */
359*7c478bd9Sstevel@tonic-gate struct sbus_wrapper_arg {
360*7c478bd9Sstevel@tonic-gate 	struct sbus_soft_state *softsp;
361*7c478bd9Sstevel@tonic-gate 	volatile uint64_t *clear_reg;
362*7c478bd9Sstevel@tonic-gate 	uint32_t pil;
363*7c478bd9Sstevel@tonic-gate 	struct sbus_intr_handler *handler_list;
364*7c478bd9Sstevel@tonic-gate };
365*7c478bd9Sstevel@tonic-gate 
366*7c478bd9Sstevel@tonic-gate 
367*7c478bd9Sstevel@tonic-gate /*
368*7c478bd9Sstevel@tonic-gate  * SYSIO parent private data structure contains register, interrupt, property
369*7c478bd9Sstevel@tonic-gate  * and range information.
370*7c478bd9Sstevel@tonic-gate  * Note: the only thing different from the "generic" sbus parent private
371*7c478bd9Sstevel@tonic-gate  * data is the interrupt specification.
372*7c478bd9Sstevel@tonic-gate  */
373*7c478bd9Sstevel@tonic-gate struct sysio_parent_private_data {
374*7c478bd9Sstevel@tonic-gate 	int par_nreg;			/* number of regs */
375*7c478bd9Sstevel@tonic-gate 	struct regspec *par_reg;	/* array of regs */
376*7c478bd9Sstevel@tonic-gate 	int par_nintr;			/* number of interrupts */
377*7c478bd9Sstevel@tonic-gate 	struct sysiointrspec *par_intr;	/* array of possible interrupts */
378*7c478bd9Sstevel@tonic-gate 	int par_nrng;			/* number of ranges */
379*7c478bd9Sstevel@tonic-gate 	struct rangespec *par_rng;	/* array of ranges */
380*7c478bd9Sstevel@tonic-gate 	uint_t slot;			/* Slot number, on this sbus */
381*7c478bd9Sstevel@tonic-gate 	uint_t offset;			/* Offset of first real "reg" */
382*7c478bd9Sstevel@tonic-gate };
383*7c478bd9Sstevel@tonic-gate #define	SYSIO_PD(d)	\
384*7c478bd9Sstevel@tonic-gate 	((struct sysio_parent_private_data *)DEVI((d))->devi_parent_data)
385*7c478bd9Sstevel@tonic-gate 
386*7c478bd9Sstevel@tonic-gate #define	sysio_pd_getnreg(dev)		(SYSIO_PD(dev)->par_nreg)
387*7c478bd9Sstevel@tonic-gate #define	sysio_pd_getnintr(dev)		(SYSIO_PD(dev)->par_nintr)
388*7c478bd9Sstevel@tonic-gate #define	sysio_pd_getnrng(dev)		(SYSIO_PD(dev)->par_nrng)
389*7c478bd9Sstevel@tonic-gate #define	sysio_pd_getslot(dev)		(SYSIO_PD(dev)->slot)
390*7c478bd9Sstevel@tonic-gate #define	sysio_pd_getoffset(dev)		(SYSIO_PD(dev)->offset)
391*7c478bd9Sstevel@tonic-gate 
392*7c478bd9Sstevel@tonic-gate #define	sysio_pd_getreg(dev, n)		(&SYSIO_PD(dev)->par_reg[(n)])
393*7c478bd9Sstevel@tonic-gate #define	sysio_pd_getintr(dev, n)	(&SYSIO_PD(dev)->par_intr[(n)])
394*7c478bd9Sstevel@tonic-gate #define	sysio_pd_getrng(dev, n)		(&SYSIO_PD(dev)->par_rng[(n)])
395*7c478bd9Sstevel@tonic-gate 
396*7c478bd9Sstevel@tonic-gate #define	IS_INTRA_SBUS(softsp, pfn)	(pfn >= softsp->sbus_io_lo_pfn && \
397*7c478bd9Sstevel@tonic-gate 					    pfn <= softsp->sbus_io_hi_pfn)
398*7c478bd9Sstevel@tonic-gate 
399*7c478bd9Sstevel@tonic-gate /* Used for legacy interrupts */
400*7c478bd9Sstevel@tonic-gate #define	SBUS_INTR_STATE_DISABLE		0	/* disabled */
401*7c478bd9Sstevel@tonic-gate #define	SBUS_INTR_STATE_ENABLE		1	/* enabled */
402*7c478bd9Sstevel@tonic-gate 
403*7c478bd9Sstevel@tonic-gate struct io_mem_list {
404*7c478bd9Sstevel@tonic-gate 	dev_info_t *rdip;
405*7c478bd9Sstevel@tonic-gate 	ulong_t	ioaddr;
406*7c478bd9Sstevel@tonic-gate 	ulong_t	addr;
407*7c478bd9Sstevel@tonic-gate 	pgcnt_t npages;
408*7c478bd9Sstevel@tonic-gate 	pfn_t *pfn;
409*7c478bd9Sstevel@tonic-gate 	struct io_mem_list *next;
410*7c478bd9Sstevel@tonic-gate };
411*7c478bd9Sstevel@tonic-gate 
412*7c478bd9Sstevel@tonic-gate /*
413*7c478bd9Sstevel@tonic-gate  * Function prototypes.
414*7c478bd9Sstevel@tonic-gate  */
415*7c478bd9Sstevel@tonic-gate 
416*7c478bd9Sstevel@tonic-gate 
417*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
418*7c478bd9Sstevel@tonic-gate }
419*7c478bd9Sstevel@tonic-gate #endif
420*7c478bd9Sstevel@tonic-gate 
421*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_SYSIOSBUS_H */
422