xref: /titanic_50/usr/src/uts/sun4u/sys/epic.h (revision 2df1fe9ca32bb227b9158c67f5c00b54c20b10fd)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 
23 /*
24  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 #ifndef _EPIC_H
29 #define	_EPIC_H
30 
31 #pragma ident	"%Z%%M%	%I%	%E% SMI"
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 
38 /*
39  * EPIC is slow device. Need to interlace delay between two accesses.
40  */
41 #define	EPIC_DELAY 10000
42 
43 /*
44  * EPIC Registers from Indirect Address/Data
45  */
46 #define	EPIC_FIRE_INTERRUPT		0x01
47 #define	EPIC_FIRE_INT_MASK		0x01
48 
49 #define	EPIC_IND_FW_VERSION		0x05
50 
51 #define	EPIC_IND_LED_STATE0		0x06
52 
53 #define	EPIC_ALERT_LED_MASK		0x0C
54 #define	EPIC_ALERT_LED_OFF		0x00
55 #define	EPIC_ALERT_LED_ON		0x04
56 
57 #define	EPIC_POWER_LED_MASK		0x30
58 #define	EPIC_POWER_LED_OFF		0x00
59 #define	EPIC_POWER_LED_ON		0x10
60 #define	EPIC_POWER_LED_SB_BLINK		0x20
61 #define	EPIC_POWER_LED_FAST_BLINK	0x30
62 
63 #define	EPIC_HOST_INT_ENABLE_REG	0x1a
64 #define	EPIC_POWER_BUTTON_INT		0x01
65 #define	EPIC_HOST_INTR_CLEAR		0x00
66 #define	EPIC_POWER_BUTTON_INT_MASK	0x01
67 #define	EPIC_HOST_INT_STATUS_REG	0x1b
68 
69 #define	EPIC_ATOM_DATA			0x80
70 #define	EPIC_ATOM_ADDR			0x81
71 
72 #define	EPIC_ATOM_INTR_CLEAR		0x01
73 #define	EPIC_ATOM_INTR_READ		0x02
74 #define	EPIC_ATOM_INTR_ENABLE		0x03
75 
76 
77 /*
78  * EPIC ioctl commands
79  */
80 
81 #define	EPIC_SET_ALERT_LED		0x11
82 #define	EPIC_RESET_ALERT_LED		0x12
83 
84 #define	EPIC_SET_POWER_LED		0x21
85 #define	EPIC_RESET_POWER_LED		0x22
86 #define	EPIC_SB_BL_POWER_LED		0x23
87 #define	EPIC_FAST_BL_POWER_LED		0x24
88 
89 #define	EPIC_GET_FW			0x30
90 
91 /*
92  *	READ/WRITE macros for the port used by epic (LED) driver
93  */
94 
95 #define	EPIC_READ(HANDLE, REG, LHS, ADDR)\
96 		drv_usecwait(EPIC_DELAY);\
97 		(void) ddi_put8((HANDLE),\
98 		(uint8_t *)(REG)+\
99 		    EPIC_IND_ADDR, (ADDR));\
100 		drv_usecwait(EPIC_DELAY);\
101 		(LHS) =  ddi_get8((HANDLE),\
102 				(uint8_t *)(REG)+\
103 				EPIC_IND_DATA);
104 
105 #define	EPIC_WRITE(HANDLE, REG, ADDR, MASK, DATA)\
106 		drv_usecwait(EPIC_DELAY);\
107 		(void) ddi_put8((HANDLE),\
108 		(uint8_t *)(REG)+\
109 		    EPIC_IND_ADDR, (ADDR));\
110 		drv_usecwait(EPIC_DELAY);\
111 		(void) ddi_put8((HANDLE),\
112 		(uint8_t *)(REG)+\
113 		    EPIC_WRITE_MASK, (MASK));\
114 		drv_usecwait(EPIC_DELAY);\
115 		(void) ddi_put8((HANDLE),\
116 		(uint8_t *)(REG)+\
117 		    EPIC_IND_DATA, (DATA));
118 
119 /*
120  *	READ/WRITE macros for the port used by power button driver
121  */
122 
123 #define	EPIC_RD(HANDLE, REG, LHS)\
124 		drv_usecwait(EPIC_DELAY);\
125 		(LHS) =  ddi_get8((HANDLE),\
126 			(uint8_t *)(REG)+\
127 			EPIC_ATOM_DATA);
128 
129 #define	EPIC_WR(HANDLE, REG, DATA)\
130 		drv_usecwait(EPIC_DELAY);\
131 		(void) ddi_put8((HANDLE),\
132 		(uint8_t *)(REG)+\
133 		EPIC_ATOM_ADDR, (DATA));
134 
135 
136 #ifdef	__cplusplus
137 }
138 #endif
139 
140 #endif /* _EPIC_H */
141