xref: /titanic_50/usr/src/uts/sun4u/starcat/sys/iosramreg.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 2000 Sun Microsystems, Inc.  All rights reserved.
24*03831d35Sstevel  * Use is subject to license terms.
25*03831d35Sstevel  */
26*03831d35Sstevel 
27*03831d35Sstevel #ifndef	_SYS_IOSRAMREG_H
28*03831d35Sstevel #define	_SYS_IOSRAMREG_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 
38*03831d35Sstevel /*
39*03831d35Sstevel  * iosram_reg_t property  (an array of following tuple/data)
40*03831d35Sstevel  *	address format
41*03831d35Sstevel  *	  hi  npt000ss  bbbbbbbb  dddddfff  rrrrrrrr
42*03831d35Sstevel  *	 mid  hhhhhhhh  hhhhhhhh  hhhhhhhh  hhhhhhhh
43*03831d35Sstevel  *	 low  llllllll  llllllll  llllllll  llllllll
44*03831d35Sstevel  *
45*03831d35Sstevel  *	size format
46*03831d35Sstevel  *	  hi  hhhhhhhh  hhhhhhhh  hhhhhhhh  hhhhhhhh
47*03831d35Sstevel  *	 low  llllllll  llllllll  llllllll  llllllll
48*03831d35Sstevel  *	 n=0 if relocatable
49*03831d35Sstevel  *	 p=1 if addressable region is prefetchable
50*03831d35Sstevel  *	 t=1 if address region is aliased
51*03831d35Sstevel  *	 ss=00 Config. space also n,p,t must be 0
52*03831d35Sstevel  *	   =01 I/O space p must be 0
53*03831d35Sstevel  *	   =10 32 bit address memory space
54*03831d35Sstevel  *	   =11 64 bit address memory space
55*03831d35Sstevel  *	 bbbbbbbb 8 bit bus number
56*03831d35Sstevel  *	 ddddd 5 bit device number
57*03831d35Sstevel  *	 fff 3 bit function number
58*03831d35Sstevel  *	 rrrrrrrr 8 bit register number
59*03831d35Sstevel  *	 hhhhhhhh 32 bit unsigned number
60*03831d35Sstevel  *	 llllllll 32 bit unsigned number
61*03831d35Sstevel  *
62*03831d35Sstevel  *	 address: 64 bits memory space
63*03831d35Sstevel  *	  hi 00000011  00000000  00000000  00000000
64*03831d35Sstevel  *	     0x03000000
65*03831d35Sstevel  *	 mid 00000000  00000000  00000000  00000000
66*03831d35Sstevel  *	     0x00000000
67*03831d35Sstevel  *	 low 00000000  00010000  00000000  00000000
68*03831d35Sstevel  *	     0x00100000
69*03831d35Sstevel  *	 size
70*03831d35Sstevel  *	  hi 00000000  00000000  00000000  00000000
71*03831d35Sstevel  *	 low 00000000  00000011  11111111  11111111
72*03831d35Sstevel  */
73*03831d35Sstevel 
74*03831d35Sstevel typedef struct {
75*03831d35Sstevel 	uint32_t	addr_hi;
76*03831d35Sstevel 	uint32_t	addr_lo;
77*03831d35Sstevel 	uint32_t	size;
78*03831d35Sstevel } iosram_reg_t;
79*03831d35Sstevel 
80*03831d35Sstevel 
81*03831d35Sstevel /*
82*03831d35Sstevel  * SBBC access structures.  Each SBBC register is 32 bits aligned on a 16
83*03831d35Sstevel  * byte boundary.  The iosram_sbbc_region structure should be mapped onto
84*03831d35Sstevel  * the SBBC register space starting at 0x1000 to achieve correct alignment
85*03831d35Sstevel  * between structure fields and SBBC registers.
86*03831d35Sstevel  */
87*03831d35Sstevel typedef struct iosram_sbbcr {
88*03831d35Sstevel 	uint32_t	reg;		/* 32-bit register */
89*03831d35Sstevel 	uint32_t	pad[3];		/* padding to fill out 16 bytes */
90*03831d35Sstevel } iosram_sbbcr_t;
91*03831d35Sstevel 
92*03831d35Sstevel typedef struct iosram_sbbc_region {
93*03831d35Sstevel 	iosram_sbbcr_t	synch[16];	/* 0x1000 - 10ff - semaphore region */
94*03831d35Sstevel 	iosram_sbbcr_t	pad0[240];	/* 0x1100 - 1fff - padding */
95*03831d35Sstevel 	iosram_sbbcr_t	p0_int_gen;	/* 0x2000 - 200f - PCI port 0 */
96*03831d35Sstevel 					/*    interrupt generation */
97*03831d35Sstevel 	iosram_sbbcr_t	p1_int_gen;	/* 0x2010 - 201f - PCI port 1 */
98*03831d35Sstevel 					/*    interrupt generation */
99*03831d35Sstevel 	iosram_sbbcr_t	pad1[48];	/* 0x2020 - 231f - padding */
100*03831d35Sstevel 	iosram_sbbcr_t	int_status;	/* 0x2320 - 232f - interrupt status */
101*03831d35Sstevel 	iosram_sbbcr_t	int_enable;	/* 0x2330 - 233f - interrupt enables */
102*03831d35Sstevel } iosram_sbbc_region_t;
103*03831d35Sstevel 
104*03831d35Sstevel #define	IOSRAM_SBBC_MAP_OFFSET	0x1000	/* offset of SBBC regs to be mapped */
105*03831d35Sstevel #define	IOSRAM_SBBC_MAP_INDEX   0x1	/* address space set # for SBBC regs */
106*03831d35Sstevel #define	IOSRAM_SBBC_INT0	0x01
107*03831d35Sstevel #define	IOSRAM_SBBC_INT1	0x10
108*03831d35Sstevel 
109*03831d35Sstevel /*
110*03831d35Sstevel  * SBBC hardware semaphore access
111*03831d35Sstevel  */
112*03831d35Sstevel 
113*03831d35Sstevel /* indices into sbbc_region->synch array */
114*03831d35Sstevel #define	IOSRAM_SEMA_SMS_IDX	0x1	/* when accessed by SMS */
115*03831d35Sstevel #define	IOSRAM_SEMA_DOM_IDX	0x8	/* when accessed by domain */
116*03831d35Sstevel #define	IOSRAM_SEMA_OBP_IDX	0xf	/* when accessed by OBP */
117*03831d35Sstevel 
118*03831d35Sstevel /* mask for bits used to encode how semaphore was acquired (bits 1-4) */
119*03831d35Sstevel #define	IOSRAM_SEMA_MASK	0x1e
120*03831d35Sstevel 
121*03831d35Sstevel /* read an write semaphore values using domain assigned register */
122*03831d35Sstevel #define	IOSRAM_SEMA_RD(softp)	ddi_get32((softp)->sbbc_handle, \
123*03831d35Sstevel 	&(softp->sbbc_region->synch[IOSRAM_SEMA_DOM_IDX].reg));
124*03831d35Sstevel #define	IOSRAM_SEMA_WR(softp, v) ddi_put32((softp)->sbbc_handle, \
125*03831d35Sstevel 	&(softp->sbbc_region->synch[IOSRAM_SEMA_DOM_IDX].reg), v);
126*03831d35Sstevel 
127*03831d35Sstevel #define	IOSRAM_SEMA_IS_HELD(v)	((v) & 0x1)
128*03831d35Sstevel #define	IOSRAM_SEMA_GET_IDX(v)	(((v) & IOSRAM_SEMA_MASK) >> 1)
129*03831d35Sstevel 
130*03831d35Sstevel #ifdef	__cplusplus
131*03831d35Sstevel }
132*03831d35Sstevel #endif
133*03831d35Sstevel 
134*03831d35Sstevel #endif	/* _SYS_IOSRAMREG_H */
135