xref: /titanic_51/usr/src/uts/sun4u/sys/pic16f747.h (revision 43a291055ab3951f6372241323fd4e2486098fff)
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  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _PIC16F747_H
28 #define	_PIC16F747_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * PIC Registers
38  */
39 #define	RF_COMMAND	0x00
40 #define	RF_STATUS	0x01
41 #define	RF_IND_DATA	0x40
42 #define	RF_IND_ADDR	0x41
43 #define	RF_ENV_S0	0x80
44 #define	RF_ENV_S1	0x81
45 #define	RF_TPM_S0	0xC0
46 #define	RF_TPM_S1	0xC1
47 
48 /*
49  * PIC Registers from Indirect Address/Data
50  */
51 #define	RF_FAN0_PERIOD	0x00
52 #define	RF_FAN1_PERIOD	0x01
53 #define	RF_FAN2_PERIOD	0x02
54 #define	RF_FAN3_PERIOD	0x03
55 #define	RF_FAN4_PERIOD	0x04
56 #define	RF_LOCAL_TEMP	0x06
57 #define	RF_REMOTE1_TEMP	0x07
58 #define	RF_REMOTE2_TEMP	0x08
59 #define	RF_REMOTE3_TEMP	0x09
60 #define	RF_LM95221_TEMP	0x0A
61 #define	RF_FIRE_TEMP	0x0B
62 #define	RF_LSI1064_TEMP	0x0C
63 #define	RF_FRONT_TEMP	0x0D
64 #define	RF_FAN_STATUS	0x0E
65 #define	RF_VCORE0	0x0F
66 #define	RF_VCORE1	0x10
67 
68 /*
69  * Bitmasks for RF_STATUS register
70  */
71 #define	ST_FFAULT		0x01	/* fan failure has occurred */
72 #define	ST_ENV_BUSY		0x02	/* environmental bus is busy */
73 #define	ST_STALE_ADT_DATA	0x04	/* ADT7462 data currently invalid */
74 #define	ST_STALE_LM_DATA	0x08	/* LM95221 data currently invalid */
75 #define	ST_FW_VERSION		0xF0	/* firmware version number */
76 
77 /*
78  * Bitmasks for RF_COMMAND values
79  */
80 #define	CMD_TO_ESTAR		0x01
81 #define	CMD_PIC_RESET		0x80
82 
83 /* Number of fans/sensors */
84 #define	MAX_PIC_NODES		16
85 #define	N_FANS			5
86 #define	N_SENSORS		8
87 #define	N_PIC_NODES		(N_FANS+N_SENSORS+1)
88 
89 /*
90  * PIC devices' node name and register offset
91  */
92 #define	PICDEV_NODE_TYPE	"pic_client:env-monitor"
93 typedef struct minor_node_info {
94 	char		*minor_name;	/* node name */
95 	uint8_t		reg_offset;	/* indirect register offset */
96 	uint8_t		ff_shift;	/* fan fault shift (only for fans) */
97 } minor_node_info;
98 
99 /*
100  * PIC device minor numbers are constructed as <inst_9-12>:<unit_0-8>
101  */
102 #define	PIC_INST_TO_MINOR(x)	(((x) << 8) & 0x0F00)
103 #define	PIC_UNIT_TO_MINOR(x)	((x) & 0xFF)
104 #define	PIC_MINOR_TO_UNIT(x)	((x) & 0xFF)
105 #define	PIC_MINOR_TO_INST(x)	(((x)>> 8) & 0xF)
106 
107 /*
108  * PIC ioctl commands
109  */
110 #define	PICIOC	('X'<<8)
111 #define	PIC_GET_TEMPERATURE	(PICIOC|1)
112 #define	PIC_GET_FAN_SPEED	(PICIOC|2)
113 #define	PIC_SET_FAN_SPEED	(PICIOC|3)
114 #define	PIC_GET_STATUS		(PICIOC|4)
115 #define	PIC_GET_FAN_STATUS	(PICIOC|5)
116 #define	PIC_SET_ESTAR_MODE	(PICIOC|6)
117 
118 /*
119  * Miscellaneous
120  */
121 #define	MAX_PIC_INSTANCES	4
122 #define	MAX_RETRIES		10
123 
124 #ifdef	__cplusplus
125 }
126 #endif
127 
128 #endif /* _PIC16F747_H */
129