/* lm87_hw.h - Header for the LM87 ACPI hardware monitor (SMBus) library */

/* Copyright 2004 Kontron Modular Computers */

/*
modification history
--------------------
01a,01mar01,mg	created
LM87_VCC2_LSB adapted to CP6000, CP306	

*/

#ifndef LM87_HW_H
#define LM87_HW_H

#ifdef __cplusplus
extern "C" {
#endif

/* includes */

/* defines */

/* SMBus address definitions */
#define	LM87_ADDR1			0x2e	/* address of 1st LM87 on PEP boards */
#define LM87_ADDR_START		0x2c
#define LM87_ADDR_END		0x2f
#define LM87_ADDR_MASK		0x03	/* mask SMB address to access array */


/* defintions to select thresholds */
#define LM87_LOW			0		/* select low threshold */
#define LM87_HIGH			1		/* select high threshold */

/* definitions for temperature handling */
#define LM87_TEMP_MAX		127
#define LM87_TEMP_MIN		(-55)

/* definitions to select temperature measurement */
#define LM87_TEMP_INT		0		/* select internal temperature measurement */
#define LM87_TEMP_RMT		1		/* select remote temperature measurement */

/* definitions for voltage handling */
#define	LM87_VCC1			0		/* measure at VCCP1 pin */
#define	LM87_2V5			1		/* measure at +2.5V pin */
#define	LM87_3V3			2		/* measure at +3.3V pin */
#define	LM87_5V				3		/* measure at +5.0V pin */
#define	LM87_12V			4		/* measure at +12V  pin */
#define	LM87_VCC2			5		/* measure at VCCP2 pin */

/* definitions for fan handling */
#define	LM87_FAN1			0		/* measure at FAN1 pin */
#define	LM87_FAN2			1		/* measure at FAN2 pin */
#define	LM87_DIV1			0		/* FAN count divisor 1 */
#define	LM87_DIV2			1		/* FAN count divisor 2 */
#define	LM87_DIV4			2		/* FAN count divisor 4 */
#define	LM87_DIV8			3		/* FAN count divisor 8 */

/* definitions for power supply management */
#define LM87_VCC1_LSB			(14.1*1e-3)
#define LM87_2V5_LSB			(13.0*1e-3)
#define LM87_3V3_LSB			(17.2*1e-3)
#define LM87_5V_LSB				(26.0*1e-3)
#define LM87_12V_LSB			(62.5*1e-3)
#define LM87_VCC2_LSB			(-71.0*1e-3)

/* definitions for DAC */
#define LM87_DAC_LSB			(9.8*1e-3)

/* definitions for fan */
#define LM87_FAN_LSB			(1.35*1e+6)

/* register offsets */
#define	LM87_CFG1			0x40	/* configuration register 1 */
#define	LM87_ISR1			0x41	/* interrupt status register 1 */
#define	LM87_ISR2			0x42	/* interrupt status register 2 */
#define	LM87_IMR1			0x43	/* interrupt mask register 1 */
#define	LM87_IMR2			0x44	/* interrupt mask register 2 */
#define	LM87_CICL			0x46	/* CI clear register */
#define	LM87_VIDF			0x47	/* VID/Fan divisor register */
#define	LM87_VID4			0x49	/* VID4 register */
#define	LM87_CFG2			0x4a	/* configuration register 2*/
#define	LM87_ISR1_MIR		0x4c	/* interrupt status register 1 mirror - reading does not reset the status bits */
#define	LM87_ISR2_MIR		0x4d	/* interrupt status register 2 mirror - reading does not reset the status bits */
#define LM87_SMBALERT		0x80	/* SMBAlert register*/

/* parameter ram offsets */
#define	LM87_VRDAC			0x19	/* DAC data register address */
#define	LM87_RAM_2V5		0x20	/* 2.5V value address */
#define	LM87_RAM_VCCP1		0x21	/* Vccp1 value address */
#define	LM87_RAM_3V3		0x22	/* 3.3V value address */
#define	LM87_RAM_5V			0x23	/* 5V value address */
#define	LM87_RAM_12V		0x24	/* 12V value address */
#define	LM87_RAM_VCCP2		0x25	/* Vccp2 value address */
#define LM87_RAM_RMT_TEMP	0x26	/* remote temperature value address */
#define	LM87_RAM_INT_TEMP	0x27	/* internal temperature value address */
#define	LM87_RAM_FAN1		0x28	/* FAN1 counter value address */
#define	LM87_RAM_FAN2		0x29	/* FAN2 counter value address */
#define	LM87_RAM_2V5_HL		0x2b	/* 2.5V high limit address */
#define	LM87_RAM_2V5_LL		0x2c	/* 2.5V low limit address */
#define	LM87_RAM_VCCP1_HL	0x2d	/* Vccp1 high limit address */
#define	LM87_RAM_VCCP1_LL	0x2e	/* Vccp1 low limit address */
#define	LM87_RAM_3V3_HL		0x2f	/* 3.3V high limit address */
#define	LM87_RAM_3V3_LL		0x30	/* 3.3V low limit address */
#define	LM87_RAM_5V_HL		0x31	/* 5V high limit address */
#define	LM87_RAM_5V_LL		0x32	/* 5V low limit address */
#define	LM87_RAM_12V_HL		0x33	/* 12V high limit address */
#define	LM87_RAM_12V_LL		0x34	/* 12V low limit address */
#define	LM87_RAM_VCCP2_HL	0x35	/* Vccp2 high limit address */
#define	LM87_RAM_VCCP2_LL	0x36	/* Vccp2 low limit address */
#define	LM87_RAM_RMT_TEMP_HL	0x37	/* remote temperature 1 high limit address */
#define	LM87_RAM_RMT_TEMP_LL	0x38	/* remote temperature 1 low limit address */
#define	LM87_RAM_INT_TEMP_HL	0x39	/* internal temperature high limit address */
#define	LM87_RAM_INT_TEMP_LL	0x3a	/* internal temperature low limit address */
#define	LM87_RAM_FAN1_LL	0x3b	/* FAN1 counter low limit address */
#define	LM87_RAM_FAN2_LL	0x3c	/* FAN2 counter low limit address */

/* SMBAlert register bits */
#define LM87_SMBALERT_ENABLE	0x40	/* enable SMB Alert use by LM87 */

/* configuration register bits */
#define	LM87_CFG_START		0x01	/* start monitoring */
#define LM87_CFG_INTERRUPT	0x02	/* enables the INT# interrupt output */
#define LM87_CFG_THERM		0x04	/* enables the THERM# interrupt output */
#define	LM87_CFG_INTCLR		0x08	/* clear INT bit / resume monitoring */
#define	LM87_CFG_INIT		0x80	/* set LM87 to POR state */

/* interrupt mask register 1 bits */
#define	LM87_IMR1_2V5		0x01	/* 2.5V high/low limit exceeded */
#define	LM87_IMR1_VCC1		0x02	/* Vccp1 high/low limit exceeded */
#define	LM87_IMR1_3V3		0x04	/* 3.3V high/low limit exceeded */
#define	LM87_IMR1_5V		0x08	/* 5V high/low limit exceeded */
#define	LM87_IMR1_INT_TEMP	0x10	/* internal temperature high/low limit exceeded */
#define	LM87_IMR1_RMT_TEMP	0x20	/* remote temperature high/low limit exceeded */
#define	LM87_IMR1_FAN1		0x40	/* FAN1 count limit exceeded */
#define	LM87_IMR1_FAN2		0x80	/* FAN2 count limit exceeded */

/* interrupt mask register 2 bits */
#define	LM87_IMR2_12V		0x01	/* +12V high/low limit exceeded */
#define	LM87_IMR2_VCC2		0x02	/* Vccp2 high/low limit exceeded */
#define	LM87_IMR2_CI		0x10	/* CI (Chassis Intrusion) input has gone high */
#define	LM87_IMR2_TLOW		0x20	/* THERM# input has been pulled low by external circuitry */
#define	LM87_IMR2_D1		0x40	/* D1 inputs are shorted to Vcc or open circuit */
#define	LM87_IMR2_D2		0x80	/* D2 inputs are shorted to Vcc or open circuit */

/* interrupt status register 1 bits */
#define	LM87_ISR1_2V5		0x01	/* 2.5V high/low limit exceeded */
#define	LM87_ISR1_VCC1		0x02	/* Vccp1 high/low limit exceeded */
#define	LM87_ISR1_3V3		0x04	/* 3.3V high/low limit exceeded */
#define	LM87_ISR1_5V		0x08	/* 5V high/low limit exceeded */
#define	LM87_ISR1_INT_TEMP	0x10	/* internal temperature high/low limit exceeded */
#define	LM87_ISR1_RMT_TEMP	0x20	/* remote temperature high/low limit exceeded */
#define	LM87_ISR1_FAN1		0x40	/* FAN1 count limit exceeded */
#define	LM87_ISR1_FAN2		0x80	/* FAN2 count limit exceeded */

/* interrupt status register 2 bits */
#define	LM87_ISR2_12V		0x01	/* +12V high/low limit exceeded */
#define	LM87_ISR2_VCC2		0x02	/* Vccp2 high/low limit exceeded */
#define	LM87_ISR2_CI		0x10	/* CI (Chassis Intrusion) input has gone high */
#define	LM87_ISR2_TLOW		0x20	/* THERM# input has been pulled low by external circuitry */
#define	LM87_ISR2_D1		0x40	/* D1 inputs are shorted to Vcc or open circuit */
#define	LM87_ISR2_D2		0x80	/* D2 inputs are shorted to Vcc or open circuit */

/* temperature configuration register bits */
#define LM87_TCFG_MODE_MSK	0xfc	/* mode mask */
#define LM87_TCFG_CM		0x02	/* comparator mode */

/* extended mode register 1 bits */
#define	LM87_EMR1_EME		0x01	/* extended mode enable */

/* extended mode register 2 bits */
#define	LM87_EMR2_HYST_MSK	0xf8	/* hyst mask */

/* function declarations */

#ifdef __cplusplus
}
#endif

#endif /* LM87_HW_H */
