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 2003 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	_ENVD_H
28*7c478bd9Sstevel@tonic-gate #define	_ENVD_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
33*7c478bd9Sstevel@tonic-gate #include <libintl.h>
34*7c478bd9Sstevel@tonic-gate 
35*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
36*7c478bd9Sstevel@tonic-gate extern "C" {
37*7c478bd9Sstevel@tonic-gate #endif
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate #define	SENSORPOLL_INTERVAL	4
40*7c478bd9Sstevel@tonic-gate #define	INTERRUPTPOLL_INTERVAL	2
41*7c478bd9Sstevel@tonic-gate #define	WARNING_INTERVAL	30
42*7c478bd9Sstevel@tonic-gate #define	SHUTDOWN_INTERVAL	60
43*7c478bd9Sstevel@tonic-gate #define	ENV_CONF_FILE		"envmodel.conf"
44*7c478bd9Sstevel@tonic-gate #define	TUNABLE_CONF_FILE	"piclenvd.conf"
45*7c478bd9Sstevel@tonic-gate #define	PM_DEVICE		"/dev/pm"
46*7c478bd9Sstevel@tonic-gate #define	SHUTDOWN_CMD		"/usr/sbin/shutdown -y -g 60 -i 5"
47*7c478bd9Sstevel@tonic-gate #define	PICL_PLUGINS_NODE	"plugins"
48*7c478bd9Sstevel@tonic-gate #define	PICL_ENVIRONMENTAL_NODE	"environmental"
49*7c478bd9Sstevel@tonic-gate 
50*7c478bd9Sstevel@tonic-gate /*
51*7c478bd9Sstevel@tonic-gate  * ADC Sample of ADM in Khz, currently 11.2 KHz
52*7c478bd9Sstevel@tonic-gate  */
53*7c478bd9Sstevel@tonic-gate #define	ADCSAMPLE		11250
54*7c478bd9Sstevel@tonic-gate 
55*7c478bd9Sstevel@tonic-gate /*
56*7c478bd9Sstevel@tonic-gate  * Taco Platform Details
57*7c478bd9Sstevel@tonic-gate  */
58*7c478bd9Sstevel@tonic-gate #define	MAX_SENSORS	3
59*7c478bd9Sstevel@tonic-gate #define	MAX_FANS	2
60*7c478bd9Sstevel@tonic-gate #define	MAX_HWMS	1
61*7c478bd9Sstevel@tonic-gate 
62*7c478bd9Sstevel@tonic-gate /*
63*7c478bd9Sstevel@tonic-gate  * ADM1031 Hardware Monitor IDs
64*7c478bd9Sstevel@tonic-gate  * Used as index into arrays
65*7c478bd9Sstevel@tonic-gate  */
66*7c478bd9Sstevel@tonic-gate #define	CPU_HWM_ID	0
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate #define	CPU_HWM_DEVFS	\
69*7c478bd9Sstevel@tonic-gate 	"/devices/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,5c:control"
70*7c478bd9Sstevel@tonic-gate 
71*7c478bd9Sstevel@tonic-gate #define	HWM_FAN1	0
72*7c478bd9Sstevel@tonic-gate #define	HWM_FAN2	1
73*7c478bd9Sstevel@tonic-gate 
74*7c478bd9Sstevel@tonic-gate /*
75*7c478bd9Sstevel@tonic-gate  * Taco sensor IDs as used in FRUID segment
76*7c478bd9Sstevel@tonic-gate  */
77*7c478bd9Sstevel@tonic-gate #define	SYS_IN_SENSOR_ID	0
78*7c478bd9Sstevel@tonic-gate #define	CPU_SENSOR_ID		1
79*7c478bd9Sstevel@tonic-gate #define	INT_AMB_SENSOR_ID	2
80*7c478bd9Sstevel@tonic-gate #define	MAX_SENSOR_ID		2
81*7c478bd9Sstevel@tonic-gate 
82*7c478bd9Sstevel@tonic-gate /*
83*7c478bd9Sstevel@tonic-gate  * Taco fan IDs used in FRUID segment
84*7c478bd9Sstevel@tonic-gate  */
85*7c478bd9Sstevel@tonic-gate #define	SYSTEM_FAN_ID		0
86*7c478bd9Sstevel@tonic-gate #define	CPU_FAN_ID		1
87*7c478bd9Sstevel@tonic-gate #define	MAX_FAN_ID		1
88*7c478bd9Sstevel@tonic-gate 
89*7c478bd9Sstevel@tonic-gate /*
90*7c478bd9Sstevel@tonic-gate  * devfs-path for various fans and their min/max speeds
91*7c478bd9Sstevel@tonic-gate  */
92*7c478bd9Sstevel@tonic-gate #define	ENV_CPU_FAN_DEVFS	\
93*7c478bd9Sstevel@tonic-gate 	"/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,5c:fan_2"
94*7c478bd9Sstevel@tonic-gate #define	ENV_SYSTEM_FAN_DEVFS	\
95*7c478bd9Sstevel@tonic-gate 	"/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,5c:fan_1"
96*7c478bd9Sstevel@tonic-gate 
97*7c478bd9Sstevel@tonic-gate #define	FAN_RANGE_DEFAULT	4
98*7c478bd9Sstevel@tonic-gate #define	CPU_FAN_SPEED_MIN	14
99*7c478bd9Sstevel@tonic-gate #define	CPU_FAN_SPEED_MAX	100
100*7c478bd9Sstevel@tonic-gate 
101*7c478bd9Sstevel@tonic-gate #define	SYSTEM_OUT_FAN_SPEED_MIN	14
102*7c478bd9Sstevel@tonic-gate #define	SYSTEM_OUT_FAN_SPEED_MAX	100
103*7c478bd9Sstevel@tonic-gate 
104*7c478bd9Sstevel@tonic-gate #define	SYSTEM_INTAKE_FAN_SPEED_MIN	14
105*7c478bd9Sstevel@tonic-gate #define	SYSTEM_INTAKE_FAN_SPEED_MAX	100
106*7c478bd9Sstevel@tonic-gate 
107*7c478bd9Sstevel@tonic-gate 
108*7c478bd9Sstevel@tonic-gate 
109*7c478bd9Sstevel@tonic-gate /*
110*7c478bd9Sstevel@tonic-gate  * devfs-path for various temperature sensors and CPU platform path
111*7c478bd9Sstevel@tonic-gate  */
112*7c478bd9Sstevel@tonic-gate #define	SENSOR_CPU_DIE_DEVFS	\
113*7c478bd9Sstevel@tonic-gate 	"/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,5c:remote_2"
114*7c478bd9Sstevel@tonic-gate #define	SENSOR_SYS_IN_DEVFS	\
115*7c478bd9Sstevel@tonic-gate 	"/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,5c:remote_1"
116*7c478bd9Sstevel@tonic-gate #define	SENSOR_INT_AMB_DEVFS	\
117*7c478bd9Sstevel@tonic-gate 	"/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,5c:local"
118*7c478bd9Sstevel@tonic-gate 
119*7c478bd9Sstevel@tonic-gate /*
120*7c478bd9Sstevel@tonic-gate  * Temperature type
121*7c478bd9Sstevel@tonic-gate  */
122*7c478bd9Sstevel@tonic-gate typedef int16_t tempr_t;
123*7c478bd9Sstevel@tonic-gate 
124*7c478bd9Sstevel@tonic-gate 
125*7c478bd9Sstevel@tonic-gate /*
126*7c478bd9Sstevel@tonic-gate  * Fan names
127*7c478bd9Sstevel@tonic-gate  */
128*7c478bd9Sstevel@tonic-gate #define	ENV_SYSTEM_INTAKE_FAN	"intake-fan"
129*7c478bd9Sstevel@tonic-gate #define	ENV_SYSTEM_OUT_FAN	"outtake-fan"
130*7c478bd9Sstevel@tonic-gate #define	ENV_CPU_FAN		"cpu-fan"
131*7c478bd9Sstevel@tonic-gate #define	ENV_SYSTEM_IN_OUT_FANS	"intake-outtake-fans"
132*7c478bd9Sstevel@tonic-gate 
133*7c478bd9Sstevel@tonic-gate /*
134*7c478bd9Sstevel@tonic-gate  * Sensor names
135*7c478bd9Sstevel@tonic-gate  */
136*7c478bd9Sstevel@tonic-gate #define	SENSOR_CPU_DIE		"cpu"
137*7c478bd9Sstevel@tonic-gate #define	SENSOR_SYS_IN		"sys-in"
138*7c478bd9Sstevel@tonic-gate #define	SENSOR_INT_AMB		"int-amb"
139*7c478bd9Sstevel@tonic-gate 
140*7c478bd9Sstevel@tonic-gate /* Bit Map of ADM 1031 Status 1/2 Registers */
141*7c478bd9Sstevel@tonic-gate enum adm1031 {
142*7c478bd9Sstevel@tonic-gate 	FANFAULT = 0x2,
143*7c478bd9Sstevel@tonic-gate 	REMOTEHIGH = 0x4,
144*7c478bd9Sstevel@tonic-gate 	REMOTELOW = 0x8,
145*7c478bd9Sstevel@tonic-gate 	REMOTETHERN = 0x10,
146*7c478bd9Sstevel@tonic-gate 	LHIGH = 0x40,
147*7c478bd9Sstevel@tonic-gate 	LLOW  = 0x80
148*7c478bd9Sstevel@tonic-gate } adm1031_t;
149*7c478bd9Sstevel@tonic-gate 
150*7c478bd9Sstevel@tonic-gate /* ADM Stat 1/2 Mask */
151*7c478bd9Sstevel@tonic-gate enum adm1031Mask {
152*7c478bd9Sstevel@tonic-gate 	STAT1MASK = 0xdc,
153*7c478bd9Sstevel@tonic-gate 	STAT2MASK = 0x1c
154*7c478bd9Sstevel@tonic-gate } adm1031Mask_t;
155*7c478bd9Sstevel@tonic-gate 
156*7c478bd9Sstevel@tonic-gate /*
157*7c478bd9Sstevel@tonic-gate  * ES segment related structures
158*7c478bd9Sstevel@tonic-gate  */
159*7c478bd9Sstevel@tonic-gate typedef struct id_off {
160*7c478bd9Sstevel@tonic-gate 	uint_t id;
161*7c478bd9Sstevel@tonic-gate 	ushort_t offset;
162*7c478bd9Sstevel@tonic-gate } id_off_t;
163*7c478bd9Sstevel@tonic-gate 
164*7c478bd9Sstevel@tonic-gate typedef struct fan_ctl_pair {
165*7c478bd9Sstevel@tonic-gate 	uchar_t tMin;
166*7c478bd9Sstevel@tonic-gate 	uchar_t tRange;
167*7c478bd9Sstevel@tonic-gate } fan_ctl_pair_t;
168*7c478bd9Sstevel@tonic-gate 
169*7c478bd9Sstevel@tonic-gate typedef struct Correction_Pair {
170*7c478bd9Sstevel@tonic-gate 	uchar_t measured;
171*7c478bd9Sstevel@tonic-gate 	uchar_t corrected;
172*7c478bd9Sstevel@tonic-gate } Correction_Pair_t;
173*7c478bd9Sstevel@tonic-gate 
174*7c478bd9Sstevel@tonic-gate #define	ES_SENSOR_POLICY_LEN	8
175*7c478bd9Sstevel@tonic-gate #define	ES_CORRECTION_PAIRS	12
176*7c478bd9Sstevel@tonic-gate 
177*7c478bd9Sstevel@tonic-gate typedef struct sensor_ctrl_blk {
178*7c478bd9Sstevel@tonic-gate 	uchar_t  high_power_off;
179*7c478bd9Sstevel@tonic-gate 	uchar_t  high_shutdown;
180*7c478bd9Sstevel@tonic-gate 	uchar_t  high_warning;
181*7c478bd9Sstevel@tonic-gate 	uchar_t  low_warning;
182*7c478bd9Sstevel@tonic-gate 	uchar_t  low_shutdown;
183*7c478bd9Sstevel@tonic-gate 	uchar_t  low_power_off;
184*7c478bd9Sstevel@tonic-gate 	uchar_t  sensorPolicy[ES_SENSOR_POLICY_LEN];
185*7c478bd9Sstevel@tonic-gate 	ushort_t correctionEntries;
186*7c478bd9Sstevel@tonic-gate 	Correction_Pair_t correctionPair[ES_CORRECTION_PAIRS];
187*7c478bd9Sstevel@tonic-gate } sensor_ctrl_blk_t;
188*7c478bd9Sstevel@tonic-gate 
189*7c478bd9Sstevel@tonic-gate 
190*7c478bd9Sstevel@tonic-gate #define	ES_FAN_CTL_PAIRS	4
191*7c478bd9Sstevel@tonic-gate 
192*7c478bd9Sstevel@tonic-gate typedef struct fan_ctrl_blk {
193*7c478bd9Sstevel@tonic-gate 	uchar_t  tSpinUp;
194*7c478bd9Sstevel@tonic-gate 	uchar_t  minFanSpeed;
195*7c478bd9Sstevel@tonic-gate 	ushort_t setPoint;
196*7c478bd9Sstevel@tonic-gate 	ushort_t loopGain;
197*7c478bd9Sstevel@tonic-gate 	ushort_t loopBias;
198*7c478bd9Sstevel@tonic-gate 	ushort_t hysteresis;
199*7c478bd9Sstevel@tonic-gate 	ushort_t fanViabTestInt;
200*7c478bd9Sstevel@tonic-gate 	ushort_t fanViabTestThresh;
201*7c478bd9Sstevel@tonic-gate 	ushort_t grossFanThresh;
202*7c478bd9Sstevel@tonic-gate 	uchar_t no_ctl_pairs;
203*7c478bd9Sstevel@tonic-gate 	fan_ctl_pair_t fan_ctl_pairs[ES_FAN_CTL_PAIRS];
204*7c478bd9Sstevel@tonic-gate } fan_ctrl_blk_t;
205*7c478bd9Sstevel@tonic-gate 
206*7c478bd9Sstevel@tonic-gate #define	TEMP_IN_WARNING_RANGE(val, sensorp) \
207*7c478bd9Sstevel@tonic-gate 	((val) > (sensorp)->es_ptr->high_warning || \
208*7c478bd9Sstevel@tonic-gate 		(val) < (char)((sensorp)->es_ptr->low_warning))
209*7c478bd9Sstevel@tonic-gate 
210*7c478bd9Sstevel@tonic-gate #define	TEMP_IN_SHUTDOWN_RANGE(val, sensorp) \
211*7c478bd9Sstevel@tonic-gate 	((val) > (sensorp)->es_ptr->high_shutdown || \
212*7c478bd9Sstevel@tonic-gate 		(val) < (char)((sensorp)->es_ptr->low_shutdown))
213*7c478bd9Sstevel@tonic-gate 
214*7c478bd9Sstevel@tonic-gate /*
215*7c478bd9Sstevel@tonic-gate  * Macros to fetch 16 and 32 bit data from unaligned address
216*7c478bd9Sstevel@tonic-gate  */
217*7c478bd9Sstevel@tonic-gate #define	GET_UNALIGN16(addr)	\
218*7c478bd9Sstevel@tonic-gate 	(((*(uint8_t *)addr) << 8) | *((uint8_t *)addr + 1))
219*7c478bd9Sstevel@tonic-gate 
220*7c478bd9Sstevel@tonic-gate #define	GET_UNALIGN32(addr)	\
221*7c478bd9Sstevel@tonic-gate 	(((*(uint8_t *)addr) << 24) | (*((uint8_t *)addr + 1) << 16) | \
222*7c478bd9Sstevel@tonic-gate 	((*((uint8_t *)addr + 2)) << 8) | (*((uint8_t *)addr + 3)))
223*7c478bd9Sstevel@tonic-gate 
224*7c478bd9Sstevel@tonic-gate /*
225*7c478bd9Sstevel@tonic-gate  * SEEPROM section header layout and location
226*7c478bd9Sstevel@tonic-gate  */
227*7c478bd9Sstevel@tonic-gate typedef struct {
228*7c478bd9Sstevel@tonic-gate 	uint8_t		header_tag;		/* section header tag */
229*7c478bd9Sstevel@tonic-gate 	uint8_t		header_version[2];	/* header version (msb) */
230*7c478bd9Sstevel@tonic-gate 	uint8_t		header_length;		/* header length */
231*7c478bd9Sstevel@tonic-gate 	uint8_t		header_crc8;		/* crc8 */
232*7c478bd9Sstevel@tonic-gate 	uint8_t		segment_count;		/* total number of segments */
233*7c478bd9Sstevel@tonic-gate } section_layout_t;
234*7c478bd9Sstevel@tonic-gate 
235*7c478bd9Sstevel@tonic-gate #define	SECTION_HDR_OFFSET	0x1800
236*7c478bd9Sstevel@tonic-gate #define	SECTION_HDR_TAG		0x08
237*7c478bd9Sstevel@tonic-gate #define	SECTION_HDR_VER		0x0001
238*7c478bd9Sstevel@tonic-gate #define	SECTION_HDR_LENGTH	0x06
239*7c478bd9Sstevel@tonic-gate 
240*7c478bd9Sstevel@tonic-gate /*
241*7c478bd9Sstevel@tonic-gate  * SEEPROM segment header layout
242*7c478bd9Sstevel@tonic-gate  */
243*7c478bd9Sstevel@tonic-gate typedef struct {
244*7c478bd9Sstevel@tonic-gate 	uint16_t	name;		/* segment name */
245*7c478bd9Sstevel@tonic-gate 	uint16_t	descriptor[2];	/* descriptor (msb) */
246*7c478bd9Sstevel@tonic-gate 	uint16_t	offset;		/* segment data offset */
247*7c478bd9Sstevel@tonic-gate 	uint16_t	length;		/* segment length */
248*7c478bd9Sstevel@tonic-gate } segment_layout_t;
249*7c478bd9Sstevel@tonic-gate 
250*7c478bd9Sstevel@tonic-gate #define	ENVSEG_NAME		0x4553	/* environmental segment name */
251*7c478bd9Sstevel@tonic-gate #define	ENVSEG_VERSION		2	/* environmental segment version */
252*7c478bd9Sstevel@tonic-gate 
253*7c478bd9Sstevel@tonic-gate #define	SENSOR_WARN		1
254*7c478bd9Sstevel@tonic-gate #define	SENSOR_OK		0
255*7c478bd9Sstevel@tonic-gate 
256*7c478bd9Sstevel@tonic-gate /*
257*7c478bd9Sstevel@tonic-gate  * SEEPROM environmental segment header layout
258*7c478bd9Sstevel@tonic-gate  */
259*7c478bd9Sstevel@tonic-gate typedef struct {
260*7c478bd9Sstevel@tonic-gate 	uint16_t	sensor_id[2];	/* unique sensor ID (on this FRU) */
261*7c478bd9Sstevel@tonic-gate 	uint16_t	offset;		/* sensor data record offset */
262*7c478bd9Sstevel@tonic-gate } envseg_sensor_t;
263*7c478bd9Sstevel@tonic-gate 
264*7c478bd9Sstevel@tonic-gate typedef struct {
265*7c478bd9Sstevel@tonic-gate 	uint8_t		version;	/* envseg version */
266*7c478bd9Sstevel@tonic-gate 	uint8_t		sensor_count;	/* total number of sensor records */
267*7c478bd9Sstevel@tonic-gate 	envseg_sensor_t	sensors[1];	/* sensor table (variable length) */
268*7c478bd9Sstevel@tonic-gate } envseg_layout_t;
269*7c478bd9Sstevel@tonic-gate 
270*7c478bd9Sstevel@tonic-gate /*
271*7c478bd9Sstevel@tonic-gate  * FRU envseg list
272*7c478bd9Sstevel@tonic-gate  */
273*7c478bd9Sstevel@tonic-gate typedef struct fruenvseg {
274*7c478bd9Sstevel@tonic-gate 	struct fruenvseg	*next;		/* next entry */
275*7c478bd9Sstevel@tonic-gate 	char			*fru;		/* FRU SEEPROM path */
276*7c478bd9Sstevel@tonic-gate 	void			*envsegbufp;	/* envseg data buffer */
277*7c478bd9Sstevel@tonic-gate 	int			envseglen;	/* envseg length */
278*7c478bd9Sstevel@tonic-gate } fruenvseg_t;
279*7c478bd9Sstevel@tonic-gate 
280*7c478bd9Sstevel@tonic-gate #define	I2C_DEVFS	"/devices/pci@1e,600000/isa@7/i2c@0,320"
281*7c478bd9Sstevel@tonic-gate #define	MBFRU_DEV	"/motherboard-fru-prom@0,a8:motherboard-fru-prom"
282*7c478bd9Sstevel@tonic-gate #define	FRU_SEEPROM_NAME	"motherboard-fru-prom"
283*7c478bd9Sstevel@tonic-gate /*
284*7c478bd9Sstevel@tonic-gate  * Table data structures
285*7c478bd9Sstevel@tonic-gate  */
286*7c478bd9Sstevel@tonic-gate typedef struct {
287*7c478bd9Sstevel@tonic-gate 	int32_t	x;
288*7c478bd9Sstevel@tonic-gate 	int32_t	y;
289*7c478bd9Sstevel@tonic-gate } point_t;
290*7c478bd9Sstevel@tonic-gate 
291*7c478bd9Sstevel@tonic-gate typedef struct {
292*7c478bd9Sstevel@tonic-gate 	int	nentries;
293*7c478bd9Sstevel@tonic-gate 	point_t	*xymap;
294*7c478bd9Sstevel@tonic-gate } table_t;
295*7c478bd9Sstevel@tonic-gate 
296*7c478bd9Sstevel@tonic-gate /*
297*7c478bd9Sstevel@tonic-gate  * Temperature sensor related data structure
298*7c478bd9Sstevel@tonic-gate  */
299*7c478bd9Sstevel@tonic-gate typedef struct env_sensor {
300*7c478bd9Sstevel@tonic-gate 	char		*name;			/* sensor name */
301*7c478bd9Sstevel@tonic-gate 	char		*devfs_path;		/* sensor device devfs path */
302*7c478bd9Sstevel@tonic-gate 	sensor_ctrl_blk_t *es_ptr;
303*7c478bd9Sstevel@tonic-gate 	uchar_t		id;
304*7c478bd9Sstevel@tonic-gate 	int		hwm_id;
305*7c478bd9Sstevel@tonic-gate 	void		*fanp;
306*7c478bd9Sstevel@tonic-gate 	int		fd;			/* device file descriptor */
307*7c478bd9Sstevel@tonic-gate 	int		error;			/* error flag */
308*7c478bd9Sstevel@tonic-gate 	boolean_t 	present;		/* sensor present */
309*7c478bd9Sstevel@tonic-gate 	tempr_t		cur_temp;		/* current temperature */
310*7c478bd9Sstevel@tonic-gate 	time_t		warning_tstamp;		/* last warning time (secs) */
311*7c478bd9Sstevel@tonic-gate 	time_t		shutdown_tstamp;	/* shutdown temp time (secs) */
312*7c478bd9Sstevel@tonic-gate 	boolean_t 	shutdown_initiated;	/* shutdown initated */
313*7c478bd9Sstevel@tonic-gate 	table_t		*crtbl;			/* Correction table */
314*7c478bd9Sstevel@tonic-gate 	tempr_t		tmin;
315*7c478bd9Sstevel@tonic-gate } env_sensor_t;
316*7c478bd9Sstevel@tonic-gate 
317*7c478bd9Sstevel@tonic-gate extern	env_sensor_t *sensor_lookup(char *sensor_name);
318*7c478bd9Sstevel@tonic-gate extern	int get_temperature(env_sensor_t *, tempr_t *);
319*7c478bd9Sstevel@tonic-gate 
320*7c478bd9Sstevel@tonic-gate /*
321*7c478bd9Sstevel@tonic-gate  * Fan information data structure
322*7c478bd9Sstevel@tonic-gate  */
323*7c478bd9Sstevel@tonic-gate typedef int fanspeed_t;
324*7c478bd9Sstevel@tonic-gate 
325*7c478bd9Sstevel@tonic-gate typedef struct env_fan {
326*7c478bd9Sstevel@tonic-gate 	char		*name;			/* fan name */
327*7c478bd9Sstevel@tonic-gate 	char		*devfs_path;		/* fan device devfs path */
328*7c478bd9Sstevel@tonic-gate 	fan_ctrl_blk_t	*es_ptr;
329*7c478bd9Sstevel@tonic-gate 	uchar_t		id;
330*7c478bd9Sstevel@tonic-gate 	fanspeed_t	speed_min;		/* minimum speed */
331*7c478bd9Sstevel@tonic-gate 	fanspeed_t	speed_max;		/* maximum speed */
332*7c478bd9Sstevel@tonic-gate 	int		forced_speed;		/* forced (fixed) speed */
333*7c478bd9Sstevel@tonic-gate 	int		fd;			/* device file descriptor */
334*7c478bd9Sstevel@tonic-gate 	boolean_t	present;		/* fan present */
335*7c478bd9Sstevel@tonic-gate 	int		speedrange;		/* speed range N */
336*7c478bd9Sstevel@tonic-gate 	int		fanstat;		/* Fan status */
337*7c478bd9Sstevel@tonic-gate 	uint8_t		cspeed;			/* Current speed (tach) */
338*7c478bd9Sstevel@tonic-gate 	uint8_t		lspeed;			/* Last speed (tach) */
339*7c478bd9Sstevel@tonic-gate 	int		conccnt;		/* Concurrent tach count */
340*7c478bd9Sstevel@tonic-gate } env_fan_t;
341*7c478bd9Sstevel@tonic-gate 
342*7c478bd9Sstevel@tonic-gate /*
343*7c478bd9Sstevel@tonic-gate  * Tuneables
344*7c478bd9Sstevel@tonic-gate  */
345*7c478bd9Sstevel@tonic-gate typedef struct env_tuneable {
346*7c478bd9Sstevel@tonic-gate 	char		*name;
347*7c478bd9Sstevel@tonic-gate 	char		type;
348*7c478bd9Sstevel@tonic-gate 	void		*value;
349*7c478bd9Sstevel@tonic-gate 	int		(*rfunc)(ptree_rarg_t *, void *);
350*7c478bd9Sstevel@tonic-gate 	int		(*wfunc)(ptree_warg_t *, const void *);
351*7c478bd9Sstevel@tonic-gate 	int		nbytes;
352*7c478bd9Sstevel@tonic-gate 	picl_prophdl_t proph;
353*7c478bd9Sstevel@tonic-gate } env_tuneable_t;
354*7c478bd9Sstevel@tonic-gate 
355*7c478bd9Sstevel@tonic-gate extern	env_fan_t *fan_lookup(char *fan_name);
356*7c478bd9Sstevel@tonic-gate extern	int get_fan_speed(env_fan_t *, fanspeed_t *);
357*7c478bd9Sstevel@tonic-gate extern	int set_fan_speed(env_fan_t *, fanspeed_t);
358*7c478bd9Sstevel@tonic-gate 
359*7c478bd9Sstevel@tonic-gate extern int env_debug;
360*7c478bd9Sstevel@tonic-gate extern void envd_log(int pri, const char *fmt, ...);
361*7c478bd9Sstevel@tonic-gate 
362*7c478bd9Sstevel@tonic-gate /*
363*7c478bd9Sstevel@tonic-gate  * Various messages
364*7c478bd9Sstevel@tonic-gate  */
365*7c478bd9Sstevel@tonic-gate #define	ENVD_PLUGIN_INIT_FAILED		\
366*7c478bd9Sstevel@tonic-gate 	gettext("SUNW_piclenvd: initialization failed!\n")
367*7c478bd9Sstevel@tonic-gate 
368*7c478bd9Sstevel@tonic-gate #define	ENVD_PICL_SETUP_FAILED		\
369*7c478bd9Sstevel@tonic-gate 	gettext("SUNW_piclenvd: PICL setup failed!\n")
370*7c478bd9Sstevel@tonic-gate 
371*7c478bd9Sstevel@tonic-gate #define	PM_THREAD_CREATE_FAILED		\
372*7c478bd9Sstevel@tonic-gate 	gettext("SUNW_piclenvd: pmthr thread creation failed!\n")
373*7c478bd9Sstevel@tonic-gate 
374*7c478bd9Sstevel@tonic-gate #define	PM_THREAD_EXITING		\
375*7c478bd9Sstevel@tonic-gate 	gettext("SUNW_piclenvd: pmthr exiting! errno:%d %s\n")
376*7c478bd9Sstevel@tonic-gate 
377*7c478bd9Sstevel@tonic-gate #define	ENVTHR_THREAD_CREATE_FAILED		\
378*7c478bd9Sstevel@tonic-gate 	gettext("SUNW_piclenvd: envthr thread creation failed!\n")
379*7c478bd9Sstevel@tonic-gate 
380*7c478bd9Sstevel@tonic-gate #define	ENV_SHUTDOWN_MSG		\
381*7c478bd9Sstevel@tonic-gate 	gettext("SUNW_piclenvd: '%s' sensor temperature %d outside safe " \
382*7c478bd9Sstevel@tonic-gate 	"limits (%d...%d). Shutting down the system.\n")
383*7c478bd9Sstevel@tonic-gate 
384*7c478bd9Sstevel@tonic-gate #define	ENV_WARNING_MSG			\
385*7c478bd9Sstevel@tonic-gate 	gettext("SUNW_piclenvd: '%s' sensor temperature %d outside safe " \
386*7c478bd9Sstevel@tonic-gate 	"operating limits (%d...%d).\n")
387*7c478bd9Sstevel@tonic-gate 
388*7c478bd9Sstevel@tonic-gate #define	ENV_FAN_OPEN_FAIL		\
389*7c478bd9Sstevel@tonic-gate 	gettext("SUNW_piclenvd: can't open '%s' fan path:%s errno:%d %s\n")
390*7c478bd9Sstevel@tonic-gate 
391*7c478bd9Sstevel@tonic-gate #define	ENV_SENSOR_OPEN_FAIL		\
392*7c478bd9Sstevel@tonic-gate 	gettext("SUNW_piclenvd: can't open '%s' sensor path:%s errno:%d %s\n")
393*7c478bd9Sstevel@tonic-gate 
394*7c478bd9Sstevel@tonic-gate #define	ENV_SENSOR_ACCESS_FAIL		\
395*7c478bd9Sstevel@tonic-gate 	gettext("SUNW_piclenvd: can't access '%s' sensor errno:%d %s\n")
396*7c478bd9Sstevel@tonic-gate 
397*7c478bd9Sstevel@tonic-gate #define	ENV_SENSOR_ACCESS_OK		\
398*7c478bd9Sstevel@tonic-gate 	gettext("SUNW_piclenvd: '%s' sensor is accessible now.\n")
399*7c478bd9Sstevel@tonic-gate 
400*7c478bd9Sstevel@tonic-gate #define	ENV_FRU_OPEN_FAIL		\
401*7c478bd9Sstevel@tonic-gate 	gettext("SUNW_piclenvd: can't open FRU SEEPROM path:%s errno:%d %s\n")
402*7c478bd9Sstevel@tonic-gate 
403*7c478bd9Sstevel@tonic-gate #define	ENV_FRU_BAD_ENVSEG		\
404*7c478bd9Sstevel@tonic-gate 	gettext("SUNW_piclenvd: version mismatch or environmental segment " \
405*7c478bd9Sstevel@tonic-gate 	"header too short in FRU SEEPROM %s\n")
406*7c478bd9Sstevel@tonic-gate 
407*7c478bd9Sstevel@tonic-gate #define	ENV_FRU_BAD_SENSOR_ENTRY	\
408*7c478bd9Sstevel@tonic-gate 	gettext("SUNW_piclenvd: discarding bad sensor entry (sensor_id " \
409*7c478bd9Sstevel@tonic-gate 	"%x sensor '%s') in FRU SEEPROM %s\n")
410*7c478bd9Sstevel@tonic-gate 
411*7c478bd9Sstevel@tonic-gate #define	ENV_FRU_SENSOR_MAP_NOMEM	\
412*7c478bd9Sstevel@tonic-gate 	gettext("SUNW_piclenvd: out of memory, discarding sensor map for " \
413*7c478bd9Sstevel@tonic-gate 	"sensor_id %x (sensor '%s') in FRU SEEPROM %s\n")
414*7c478bd9Sstevel@tonic-gate 
415*7c478bd9Sstevel@tonic-gate #define	ENV_ADM_OPEN_FAIL		\
416*7c478bd9Sstevel@tonic-gate 	gettext("SUNW_piclenvd: can't open hwm path:%s errno:%d %s\n")
417*7c478bd9Sstevel@tonic-gate 
418*7c478bd9Sstevel@tonic-gate #define	ENV_ADM_MANUAL_MODE \
419*7c478bd9Sstevel@tonic-gate 	gettext("SUNW_piclenvd: Cannot change the ADM Chip to Manual mode")
420*7c478bd9Sstevel@tonic-gate 
421*7c478bd9Sstevel@tonic-gate #define	ENV_ADM_AUTO_MODE \
422*7c478bd9Sstevel@tonic-gate 	gettext("SUNW_piclenvd: Cannot change the ADM Chip to Auto mode")
423*7c478bd9Sstevel@tonic-gate 
424*7c478bd9Sstevel@tonic-gate #define	ENV_FAN_FAULT \
425*7c478bd9Sstevel@tonic-gate 	gettext("SUNW_piclenvd: ADM %s, Fan %s Fault")
426*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
427*7c478bd9Sstevel@tonic-gate }
428*7c478bd9Sstevel@tonic-gate #endif
429*7c478bd9Sstevel@tonic-gate 
430*7c478bd9Sstevel@tonic-gate #endif	/* _ENVD_H */
431