xref: /titanic_50/usr/src/uts/sun4u/sys/pic16f747.h (revision 2a8d6eba033e4713ab12b61178f0513f1f075482)
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_FAN5_PERIOD	0x05	/* unused */
57 #define	RF_LOCAL_TEMP	0x06
58 #define	RF_REMOTE1_TEMP	0x07
59 #define	RF_REMOTE2_TEMP	0x08
60 #define	RF_REMOTE3_TEMP	0x09
61 #define	RF_LM95221_TEMP	0x0A
62 #define	RF_FIRE_TEMP	0x0B
63 #define	RF_LSI1064_TEMP	0x0C
64 #define	RF_FRONT_TEMP	0x0D
65 #define	RF_FAN_STATUS	0x0E
66 #define	RF_VCORE0	0x0F
67 #define	RF_VCORE1	0x10
68 #define	RF_VMEM0	0x11
69 #define	RF_VMEM1	0x12
70 #define	RF_PSU_TEMP	0x13
71 
72 /*
73  * Bitmasks for RF_COMMAND values
74  */
75 #define	CMD_TO_ESTAR		0x01
76 #define	CMD_PIC_RESET		0x80
77 
78 /*
79  * Bitmasks for RF_STATUS values
80  */
81 #define	ST_FFAULT		0x01	/* fan failure has occurred */
82 #define	ST_ENV_BUSY		0x02	/* environmental bus is busy */
83 #define	ST_ENV_STALE		0x04	/* ADT7462/LM95221 data invalid */
84 #define	ST_TPM_GOOD		0x08	/* TPM self test passed */
85 #define	ST_FW_VERSION		0xF0	/* firmware version number */
86 
87 /*
88  * Fan fault bits in RF_FAN_STATUS
89  */
90 #define	F0_FLT_BIT		0
91 #define	F1_FLT_BIT		1
92 #define	F2_FLT_BIT		2
93 #define	F3_FLT_BIT		3
94 #define	F4_FLT_BIT		4
95 #define	F5_FLT_BIT		5	/* unused */
96 #define	PSUF_FLT_BIT		6
97 
98 /* Number of fans/sensors */
99 #define	N_FANS			5
100 #define	N_SENSORS		9
101 #define	N_PIC_NODES		(N_FANS+N_SENSORS+1)
102 
103 /*
104  * PIC devices' node name and register offset
105  */
106 #define	PICDEV_NODE_TYPE	"pic_client:env-monitor"
107 typedef struct minor_node_info {
108 	char		*minor_name;	/* node name */
109 	uint8_t		reg_offset;	/* indirect register offset */
110 	uint8_t		ff_shift;	/* fan fault shift (only for fans) */
111 } minor_node_info;
112 
113 /*
114  * PIC device minor numbers are constructed as <inst_8-11>:<unit_0-7>
115  */
116 #define	PIC_INST_TO_MINOR(x)	(((x) << 8) & 0x0F00)
117 #define	PIC_UNIT_TO_MINOR(x)	((x) & 0xFF)
118 #define	PIC_MINOR_TO_UNIT(x)	((x) & 0xFF)
119 #define	PIC_MINOR_TO_INST(x)	(((x)>> 8) & 0xF)
120 
121 /*
122  * PIC ioctl commands
123  */
124 #define	PICIOC	('X'<<8)
125 #define	PIC_GET_TEMPERATURE	(PICIOC|1)
126 #define	PIC_GET_FAN_SPEED	(PICIOC|2)
127 #define	PIC_SET_FAN_SPEED	(PICIOC|3)
128 #define	PIC_GET_STATUS		(PICIOC|4)
129 #define	PIC_GET_FAN_STATUS	(PICIOC|5)
130 #define	PIC_SET_ESTAR_MODE	(PICIOC|6)
131 
132 /*
133  * Miscellaneous
134  */
135 #define	MAX_PIC_INSTANCES	4
136 #define	MAX_RETRIES		10
137 
138 #ifdef	__cplusplus
139 }
140 #endif
141 
142 #endif /* _PIC16F747_H */
143