From 6b2f1e18bb7b7cd2e14d67d0b7087006c4bc5787 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sat, 28 Feb 2004 15:46:46 +0000 Subject: [PATCH] Backport Takeru Komoriya's changes from Linux 2.6. This fixes loading it87 with reset=1. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@2316 7894878c-1315-0410-8ee3-d5d059ff63e0 --- kernel/chips/it87.c | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/kernel/chips/it87.c b/kernel/chips/it87.c index 17fc4586..6c2309f8 100644 --- a/kernel/chips/it87.c +++ b/kernel/chips/it87.c @@ -118,7 +118,7 @@ superio_exit(void) static int update_vbat = 0; /* Reset the registers on init */ -static int reset_it87 = 0; +static int reset = 0; /* Many IT87 constants specified below */ @@ -663,15 +663,43 @@ static int it87_write_value(struct i2c_client *client, u8 reg, u8 value) return i2c_smbus_write_byte_data(client, reg, value); } -/* Called when we have found a new IT87. It should set limits, etc. */ +/* Called when we have found a new IT87. */ static void it87_init_client(struct i2c_client *client) { - if( reset_it87 ) { + int tmp; + + if (reset) { + /* Reset all except Watchdog values and last conversion values + This sets fan-divs to 2, among others */ it87_write_value(client, IT87_REG_CONFIG, 0x80); } + + /* Check if temperature channnels are reset manually or by some reason */ + tmp = it87_read_value(client, IT87_REG_TEMP_ENABLE); + if ((tmp & 0x3f) == 0) { + /* Temp1,Temp3=thermistor; Temp2=thermal diode */ + tmp = (tmp & 0xc0) | 0x2a; + it87_write_value(client, IT87_REG_TEMP_ENABLE, tmp); + } + + /* Check if voltage monitors are reset manually or by some reason */ + tmp = it87_read_value(client, IT87_REG_VIN_ENABLE); + if ((tmp & 0xff) == 0) { + /* Enable all voltage monitors */ + it87_write_value(client, IT87_REG_VIN_ENABLE, 0xff); + } + + /* Check if tachometers are reset manually or by some reason */ + tmp = it87_read_value(client, IT87_REG_FAN_CTRL); + if ((tmp & 0x70) == 0) { + /* Enable all fan tachometers */ + tmp = (tmp & 0x8f) | 0x70; + it87_write_value(client, IT87_REG_FAN_CTRL, tmp); + } + /* Start monitoring */ it87_write_value(client, IT87_REG_CONFIG, - (it87_read_value(client, IT87_REG_CONFIG) & 0xb7) + (it87_read_value(client, IT87_REG_CONFIG) & 0x36) | (update_vbat ? 0x41 : 0x01)); } @@ -1104,8 +1132,8 @@ MODULE_AUTHOR("Chris Gauthron "); MODULE_DESCRIPTION("IT8705F, IT8712F, Sis950 driver"); MODULE_PARM(update_vbat, "i"); MODULE_PARM_DESC(update_vbat, "Update vbat if set else return powerup value"); -MODULE_PARM(reset_it87, "i"); -MODULE_PARM_DESC(reset_it87, "Reset the chip's registers, default no"); +MODULE_PARM(reset, "i"); +MODULE_PARM_DESC(reset, "Reset the chip's registers, default no"); module_init(sm_it87_init); module_exit(sm_it87_exit);