xref: /onnv-gate/usr/src/uts/sun4u/sys/i2c/clients/adm1031_impl.h (revision 946:5fb89afc576e)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
50Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
70Sstevel@tonic-gate  * with the License.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate  * See the License for the specific language governing permissions
120Sstevel@tonic-gate  * and limitations under the License.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * CDDL HEADER END
210Sstevel@tonic-gate  */
220Sstevel@tonic-gate /*
23*946Smathue  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #ifndef _ADM1031_IMPL_H
280Sstevel@tonic-gate #define	_ADM1031_IMPL_H
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #ifdef	__cplusplus
330Sstevel@tonic-gate extern "C" {
340Sstevel@tonic-gate #endif
350Sstevel@tonic-gate 
360Sstevel@tonic-gate 
370Sstevel@tonic-gate #define	ADM1031_PIL			4
380Sstevel@tonic-gate #define	ADM1031_MAX_XFER		4
390Sstevel@tonic-gate 
400Sstevel@tonic-gate #define	ADM1031_WRITE_COMMAND_BASE	30
410Sstevel@tonic-gate 
420Sstevel@tonic-gate 
430Sstevel@tonic-gate /* This register has the value of fan speeds */
440Sstevel@tonic-gate #define	ADM1031_FAN_SPEED_INST_REG_1		0x08
450Sstevel@tonic-gate #define	ADM1031_FAN_SPEED_INST_REG_2		0x09
460Sstevel@tonic-gate 
470Sstevel@tonic-gate /* This register has the value of temperatures */
480Sstevel@tonic-gate 
490Sstevel@tonic-gate #define	ADM1031_LOCAL_TEMP_INST_REG		0x0A
500Sstevel@tonic-gate #define	ADM1031_REMOTE_TEMP_INST_REG_1		0x0B
510Sstevel@tonic-gate #define	ADM1031_REMOTE_TEMP_INST_REG_2		0x0C
520Sstevel@tonic-gate 
530Sstevel@tonic-gate 
540Sstevel@tonic-gate #define	ADM1031_STAT_1_REG			0x02
550Sstevel@tonic-gate #define	ADM1031_STAT_2_REG			0x03
560Sstevel@tonic-gate #define	ADM1031_DEVICE_ID_REG			0x3D
570Sstevel@tonic-gate #define	ADM1031_CONFIG_REG_1			0x00
580Sstevel@tonic-gate #define	ADM1031_CONFIG_REG_2 			0x01
590Sstevel@tonic-gate #define	ADM1031_FAN_CHAR_1_REG			0x20
600Sstevel@tonic-gate #define	ADM1031_FAN_CHAR_2_REG			0x21
610Sstevel@tonic-gate #define	ADM1031_FAN_SPEED_CONFIG_REG		0x22
620Sstevel@tonic-gate #define	ADM1031_FAN_HIGH_LIMIT_1_REG		0x10
630Sstevel@tonic-gate #define	ADM1031_FAN_HIGH_LIMIT_2_REG		0x11
640Sstevel@tonic-gate #define	ADM1031_LOCAL_TEMP_RANGE_REG		0x24
650Sstevel@tonic-gate #define	ADM1031_REMOTE_TEMP_RANGE_1_REG		0x25
660Sstevel@tonic-gate #define	ADM1031_REMOTE_TEMP_RANGE_2_REG		0x26
670Sstevel@tonic-gate #define	ADM1031_EXTD_TEMP_RESL_REG		0x06
680Sstevel@tonic-gate #define	ADM1031_LOCAL_TEMP_OFFSET_REG		0x0D
690Sstevel@tonic-gate #define	ADM1031_REMOTE_TEMP_OFFSET_1_REG	0x0E
700Sstevel@tonic-gate #define	ADM1031_REMOTE_TEMP_OFFSET_2_REG	0x0F
710Sstevel@tonic-gate #define	ADM1031_LOCAL_TEMP_HIGH_LIMIT_REG	0x14
720Sstevel@tonic-gate #define	ADM1031_REMOTE_TEMP_HIGH_LIMIT_1_REG    0x18
730Sstevel@tonic-gate #define	ADM1031_REMOTE_TEMP_HIGH_LIMIT_2_REG    0x1C
740Sstevel@tonic-gate #define	ADM1031_LOCAL_TEMP_LOW_LIMIT_REG	0x15
750Sstevel@tonic-gate #define	ADM1031_REMOTE_TEMP_LOW_LIMIT_1_REG	0x19
760Sstevel@tonic-gate #define	ADM1031_REMOTE_TEMP_LOW_LIMIT_2_REG	0x1D
770Sstevel@tonic-gate #define	ADM1031_LOCAL_TEMP_THERM_LIMIT_REG	0x16
780Sstevel@tonic-gate #define	ADM1031_REMOTE_TEMP_THERM_LIMIT_1_REG	0x1A
790Sstevel@tonic-gate #define	ADM1031_REMOTE_TEMP_THERM_LIMIT_2_REG	0x1E
800Sstevel@tonic-gate 
810Sstevel@tonic-gate 
820Sstevel@tonic-gate 
830Sstevel@tonic-gate #define	ADM1031_TEMP_CHANS		3
840Sstevel@tonic-gate #define	ADM1031_FAN_SPEED_CHANS		2
850Sstevel@tonic-gate 
860Sstevel@tonic-gate #define	ADM1031_TEMPERATURES		0
870Sstevel@tonic-gate #define	ADM1031_FANS			1
880Sstevel@tonic-gate #define	ADM1031_CONTROL			2
890Sstevel@tonic-gate 
900Sstevel@tonic-gate 
910Sstevel@tonic-gate #define	ADM1031_INST_TO_MINOR(x)	((x << 8) & 0xF00)
920Sstevel@tonic-gate #define	ADM1031_FCN_TO_MINOR(x)		((x << 4) & 0x0F0)
930Sstevel@tonic-gate #define	ADM1031_FCNINST_TO_MINOR(x)	(x & 0x00F)
940Sstevel@tonic-gate #define	ADM1031_MINOR_TO_FCNINST(x)	(0x00F & x)
950Sstevel@tonic-gate #define	ADM1031_MINOR_TO_FCN(x)		((0x0F0 & x) >> 4)
960Sstevel@tonic-gate #define	ADM1031_MINOR_TO_INST(x)	((x & 0xF00) >> 8)
970Sstevel@tonic-gate 
980Sstevel@tonic-gate #define	ADM1031_CHECK_FOR_WRITES(x)	 (x > 26)
990Sstevel@tonic-gate 
1000Sstevel@tonic-gate /*
1010Sstevel@tonic-gate  * Maximum speed for a fan is 0xf(100% PWM duty cycle) and minimum is
1020Sstevel@tonic-gate  * 0x0(0% PWM duty cycle).
1030Sstevel@tonic-gate  */
104*946Smathue #define	ADM1031_CHECK_INVALID_SPEED(x) ((x) > 0x0F)
1050Sstevel@tonic-gate 
1060Sstevel@tonic-gate /*
1070Sstevel@tonic-gate  * Check if the minor node corresponds with the correct function.
1080Sstevel@tonic-gate  */
1090Sstevel@tonic-gate #define	ADM1031_CHECK_FAN_CMD(x)	\
1100Sstevel@tonic-gate 	(((x >= 6) && (x < 11)) || ((x >= 36) && (x < 41)))
1110Sstevel@tonic-gate 
1120Sstevel@tonic-gate #define	ADM1031_CHECK_TEMPERATURE_CMD(x) 	\
1130Sstevel@tonic-gate 	(((x >= 11) && (x < 27)) || ((x >= 41) && (x < 57)))
1140Sstevel@tonic-gate 
1150Sstevel@tonic-gate #define	ADM1031_CHECK_CONTROL_CMD(x)	\
1160Sstevel@tonic-gate 	(((x >= 1) && (x < 6)) || ((x >= 34) && (x < 36)))
1170Sstevel@tonic-gate 
1180Sstevel@tonic-gate 
1190Sstevel@tonic-gate #define	MLSN(x)		(x & 0xf0)
1200Sstevel@tonic-gate #define	MMSN(x)		(x & 0x0f)
1210Sstevel@tonic-gate 
1220Sstevel@tonic-gate #define	ADM1031_BUSYFLAG	0x1
1230Sstevel@tonic-gate #define	ADM1031_TBUFFLAG	0x2
1240Sstevel@tonic-gate #define	ADM1031_REGFLAG		0x4
1250Sstevel@tonic-gate #define	ADM1031_MUTEXFLAG	0x8
1260Sstevel@tonic-gate #define	ADM1031_INTRFLAG	0x10
1270Sstevel@tonic-gate #define	ADM1031_AUTOFLAG	0x80
1280Sstevel@tonic-gate 
1290Sstevel@tonic-gate #define	ADM1031_NODE_TYPE	"ddi_i2c:hardware_monitor"
1300Sstevel@tonic-gate 
1310Sstevel@tonic-gate typedef struct adm1031_cpr_state {
1320Sstevel@tonic-gate 	uint8_t		config_reg_1;
1330Sstevel@tonic-gate 	uint8_t		config_reg_2;
1340Sstevel@tonic-gate 	uint8_t		fan_speed_reg;
1350Sstevel@tonic-gate } adm1031_cpr_state_t;
1360Sstevel@tonic-gate 
1370Sstevel@tonic-gate typedef struct adm1031_unit {
1380Sstevel@tonic-gate 	dev_info_t		*adm1031_dip;
1390Sstevel@tonic-gate 	i2c_transfer_t		*adm1031_transfer;
1400Sstevel@tonic-gate 	ddi_iblock_cookie_t	adm1031_icookie;
1410Sstevel@tonic-gate 	kmutex_t		adm1031_mutex;
1420Sstevel@tonic-gate 	kcondvar_t		adm1031_cv;
1430Sstevel@tonic-gate 	kmutex_t		adm1031_imutex;
1440Sstevel@tonic-gate 	kcondvar_t		adm1031_icv;
1450Sstevel@tonic-gate 	int			adm1031_cvwaiting;
1460Sstevel@tonic-gate 	int			adm1031_flags;
1470Sstevel@tonic-gate 	i2c_client_hdl_t	adm1031_hdl;
1480Sstevel@tonic-gate 	char			adm1031_name[12];
1490Sstevel@tonic-gate 	int			adm1031_oflag;
1500Sstevel@tonic-gate 	adm1031_cpr_state_t	adm1031_cpr_state;
1510Sstevel@tonic-gate } adm1031_unit_t;
1520Sstevel@tonic-gate 
1530Sstevel@tonic-gate typedef struct minor_info {
1540Sstevel@tonic-gate 	char			*minor_name;
1550Sstevel@tonic-gate 	uchar_t			reg;
1560Sstevel@tonic-gate } minor_info;
1570Sstevel@tonic-gate 
1580Sstevel@tonic-gate #ifdef	__cplusplus
1590Sstevel@tonic-gate }
1600Sstevel@tonic-gate #endif
1610Sstevel@tonic-gate 
1620Sstevel@tonic-gate #endif /* _ADM1031_IMPL_H */
163