Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

adt7470: fix pwm at a certain level during temperature sensor scan

In the small window that it takes to read the temperature sensors, the pwm
outputs momentarily drop to 0. This causes a noticeable hiccup in fan
speed, which is slightly annoying. The solution is to manually program
the pwm output with whatever the automatic value is and then shift the
fans to manual control while reading temperatures. Once that is done, put
the fans back to whatever mode of control was there before.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Darrick J. Wong and committed by
Linus Torvalds
2e75a4b7 8f8c1fb0

+24 -1
+24 -1
drivers/hwmon/adt7470.c
··· 74 74 #define ADT7470_REG_PWM12_CFG 0x68 75 75 #define ADT7470_PWM2_AUTO_MASK 0x40 76 76 #define ADT7470_PWM1_AUTO_MASK 0x80 77 + #define ADT7470_PWM_AUTO_MASK 0xC0 77 78 #define ADT7470_REG_PWM34_CFG 0x69 78 79 #define ADT7470_PWM3_AUTO_MASK 0x40 79 80 #define ADT7470_PWM4_AUTO_MASK 0x80 ··· 224 223 struct i2c_client *client = to_i2c_client(dev); 225 224 struct adt7470_data *data = i2c_get_clientdata(client); 226 225 unsigned long local_jiffies = jiffies; 227 - u8 cfg; 226 + u8 cfg, pwm[4], pwm_cfg[2]; 228 227 int i; 229 228 230 229 mutex_lock(&data->lock); ··· 232 231 SENSOR_REFRESH_INTERVAL) 233 232 && data->sensors_valid) 234 233 goto no_sensor_update; 234 + 235 + /* save pwm[1-4] config register */ 236 + pwm_cfg[0] = i2c_smbus_read_byte_data(client, ADT7470_REG_PWM_CFG(0)); 237 + pwm_cfg[1] = i2c_smbus_read_byte_data(client, ADT7470_REG_PWM_CFG(2)); 238 + 239 + /* set manual pwm to whatever it is set to now */ 240 + for (i = 0; i < ADT7470_FAN_COUNT; i++) 241 + pwm[i] = i2c_smbus_read_byte_data(client, ADT7470_REG_PWM(i)); 242 + 243 + /* put pwm in manual mode */ 244 + i2c_smbus_write_byte_data(client, ADT7470_REG_PWM_CFG(0), 245 + pwm_cfg[0] & ~(ADT7470_PWM_AUTO_MASK)); 246 + i2c_smbus_write_byte_data(client, ADT7470_REG_PWM_CFG(2), 247 + pwm_cfg[1] & ~(ADT7470_PWM_AUTO_MASK)); 248 + 249 + /* write pwm control to whatever it was */ 250 + for (i = 0; i < ADT7470_FAN_COUNT; i++) 251 + i2c_smbus_write_byte_data(client, ADT7470_REG_PWM(i), pwm[i]); 235 252 236 253 /* start reading temperature sensors */ 237 254 cfg = i2c_smbus_read_byte_data(client, ADT7470_REG_CFG); ··· 267 248 cfg = i2c_smbus_read_byte_data(client, ADT7470_REG_CFG); 268 249 cfg &= ~0x80; 269 250 i2c_smbus_write_byte_data(client, ADT7470_REG_CFG, cfg); 251 + 252 + /* restore pwm[1-4] config registers */ 253 + i2c_smbus_write_byte_data(client, ADT7470_REG_PWM_CFG(0), pwm_cfg[0]); 254 + i2c_smbus_write_byte_data(client, ADT7470_REG_PWM_CFG(2), pwm_cfg[1]); 270 255 271 256 for (i = 0; i < ADT7470_TEMP_COUNT; i++) 272 257 data->temp[i] = i2c_smbus_read_byte_data(client,