aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/w83627ehf.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/w83627ehf.c')
-rw-r--r--drivers/hwmon/w83627ehf.c60
1 files changed, 36 insertions, 24 deletions
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index d10fe706c856..2420f1c6f4e9 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -196,22 +196,23 @@ static const u8 W83627EHF_PWM_MODE_SHIFT[] = { 0, 1, 0, 6 };
196static const u8 W83627EHF_PWM_ENABLE_SHIFT[] = { 2, 4, 1, 4 }; 196static const u8 W83627EHF_PWM_ENABLE_SHIFT[] = { 2, 4, 1, 4 };
197 197
198/* FAN Duty Cycle, be used to control */ 198/* FAN Duty Cycle, be used to control */
199static const u8 W83627EHF_REG_PWM[] = { 0x01, 0x03, 0x11, 0x61 }; 199static const u16 W83627EHF_REG_PWM[] = { 0x01, 0x03, 0x11, 0x61 };
200static const u8 W83627EHF_REG_TARGET[] = { 0x05, 0x06, 0x13, 0x63 }; 200static const u16 W83627EHF_REG_TARGET[] = { 0x05, 0x06, 0x13, 0x63 };
201static const u8 W83627EHF_REG_TOLERANCE[] = { 0x07, 0x07, 0x14, 0x62 }; 201static const u8 W83627EHF_REG_TOLERANCE[] = { 0x07, 0x07, 0x14, 0x62 };
202 202
203/* Advanced Fan control, some values are common for all fans */ 203/* Advanced Fan control, some values are common for all fans */
204static const u8 W83627EHF_REG_FAN_START_OUTPUT[] = { 0x0a, 0x0b, 0x16, 0x65 }; 204static const u16 W83627EHF_REG_FAN_START_OUTPUT[] = { 0x0a, 0x0b, 0x16, 0x65 };
205static const u8 W83627EHF_REG_FAN_STOP_OUTPUT[] = { 0x08, 0x09, 0x15, 0x64 }; 205static const u16 W83627EHF_REG_FAN_STOP_OUTPUT[] = { 0x08, 0x09, 0x15, 0x64 };
206static const u8 W83627EHF_REG_FAN_STOP_TIME[] = { 0x0c, 0x0d, 0x17, 0x66 }; 206static const u16 W83627EHF_REG_FAN_STOP_TIME[] = { 0x0c, 0x0d, 0x17, 0x66 };
207 207
208static const u8 W83627EHF_REG_FAN_MAX_OUTPUT_COMMON[] 208static const u16 W83627EHF_REG_FAN_MAX_OUTPUT_COMMON[]
209 = { 0xff, 0x67, 0xff, 0x69 }; 209 = { 0xff, 0x67, 0xff, 0x69 };
210static const u8 W83627EHF_REG_FAN_STEP_OUTPUT_COMMON[] 210static const u16 W83627EHF_REG_FAN_STEP_OUTPUT_COMMON[]
211 = { 0xff, 0x68, 0xff, 0x6a }; 211 = { 0xff, 0x68, 0xff, 0x6a };
212 212
213static const u8 W83627EHF_REG_FAN_MAX_OUTPUT_W83667_B[] = { 0x67, 0x69, 0x6b }; 213static const u16 W83627EHF_REG_FAN_MAX_OUTPUT_W83667_B[] = { 0x67, 0x69, 0x6b };
214static const u8 W83627EHF_REG_FAN_STEP_OUTPUT_W83667_B[] = { 0x68, 0x6a, 0x6c }; 214static const u16 W83627EHF_REG_FAN_STEP_OUTPUT_W83667_B[]
215 = { 0x68, 0x6a, 0x6c };
215 216
216static const char *const w83667hg_b_temp_label[] = { 217static const char *const w83667hg_b_temp_label[] = {
217 "SYSTIN", 218 "SYSTIN",
@@ -310,10 +311,15 @@ struct w83627ehf_data {
310 u8 temp_src[NUM_REG_TEMP]; 311 u8 temp_src[NUM_REG_TEMP];
311 const char * const *temp_label; 312 const char * const *temp_label;
312 313
313 const u8 *REG_FAN_START_OUTPUT; 314 const u16 *REG_PWM;
314 const u8 *REG_FAN_STOP_OUTPUT; 315 const u16 *REG_TARGET;
315 const u8 *REG_FAN_MAX_OUTPUT; 316 const u16 *REG_FAN;
316 const u8 *REG_FAN_STEP_OUTPUT; 317 const u16 *REG_FAN_MIN;
318 const u16 *REG_FAN_START_OUTPUT;
319 const u16 *REG_FAN_STOP_OUTPUT;
320 const u16 *REG_FAN_STOP_TIME;
321 const u16 *REG_FAN_MAX_OUTPUT;
322 const u16 *REG_FAN_STEP_OUTPUT;
317 323
318 struct mutex update_lock; 324 struct mutex update_lock;
319 char valid; /* !=0 if following fields are valid */ 325 char valid; /* !=0 if following fields are valid */
@@ -524,9 +530,9 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev)
524 continue; 530 continue;
525 531
526 data->fan[i] = w83627ehf_read_value(data, 532 data->fan[i] = w83627ehf_read_value(data,
527 W83627EHF_REG_FAN[i]); 533 data->REG_FAN[i]);
528 data->fan_min[i] = w83627ehf_read_value(data, 534 data->fan_min[i] = w83627ehf_read_value(data,
529 W83627EHF_REG_FAN_MIN[i]); 535 data->REG_FAN_MIN[i]);
530 536
531 /* If we failed to measure the fan speed and clock 537 /* If we failed to measure the fan speed and clock
532 divider can be increased, let's try that for next 538 divider can be increased, let's try that for next
@@ -543,7 +549,7 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev)
543 if (data->fan_min[i] >= 2 549 if (data->fan_min[i] >= 2
544 && data->fan_min[i] != 255) 550 && data->fan_min[i] != 255)
545 w83627ehf_write_value(data, 551 w83627ehf_write_value(data,
546 W83627EHF_REG_FAN_MIN[i], 552 data->REG_FAN_MIN[i],
547 (data->fan_min[i] /= 2)); 553 (data->fan_min[i] /= 2));
548 } 554 }
549 } 555 }
@@ -566,13 +572,13 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev)
566 ((pwmcfg >> W83627EHF_PWM_ENABLE_SHIFT[i]) 572 ((pwmcfg >> W83627EHF_PWM_ENABLE_SHIFT[i])
567 & 3) + 1; 573 & 3) + 1;
568 data->pwm[i] = w83627ehf_read_value(data, 574 data->pwm[i] = w83627ehf_read_value(data,
569 W83627EHF_REG_PWM[i]); 575 data->REG_PWM[i]);
570 data->fan_start_output[i] = w83627ehf_read_value(data, 576 data->fan_start_output[i] = w83627ehf_read_value(data,
571 W83627EHF_REG_FAN_START_OUTPUT[i]); 577 data->REG_FAN_START_OUTPUT[i]);
572 data->fan_stop_output[i] = w83627ehf_read_value(data, 578 data->fan_stop_output[i] = w83627ehf_read_value(data,
573 W83627EHF_REG_FAN_STOP_OUTPUT[i]); 579 data->REG_FAN_STOP_OUTPUT[i]);
574 data->fan_stop_time[i] = w83627ehf_read_value(data, 580 data->fan_stop_time[i] = w83627ehf_read_value(data,
575 W83627EHF_REG_FAN_STOP_TIME[i]); 581 data->REG_FAN_STOP_TIME[i]);
576 582
577 if (data->REG_FAN_MAX_OUTPUT[i] != 0xff) 583 if (data->REG_FAN_MAX_OUTPUT[i] != 0xff)
578 data->fan_max_output[i] = 584 data->fan_max_output[i] =
@@ -586,7 +592,7 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev)
586 592
587 data->target_temp[i] = 593 data->target_temp[i] =
588 w83627ehf_read_value(data, 594 w83627ehf_read_value(data,
589 W83627EHF_REG_TARGET[i]) & 595 data->REG_TARGET[i]) &
590 (data->pwm_mode[i] == 1 ? 0x7f : 0xff); 596 (data->pwm_mode[i] == 1 ? 0x7f : 0xff);
591 data->tolerance[i] = (tolerance >> (i == 1 ? 4 : 0)) 597 data->tolerance[i] = (tolerance >> (i == 1 ? 4 : 0))
592 & 0x0f; 598 & 0x0f;
@@ -822,7 +828,7 @@ store_fan_min(struct device *dev, struct device_attribute *attr,
822 /* Give the chip time to sample a new speed value */ 828 /* Give the chip time to sample a new speed value */
823 data->last_updated = jiffies; 829 data->last_updated = jiffies;
824 } 830 }
825 w83627ehf_write_value(data, W83627EHF_REG_FAN_MIN[nr], 831 w83627ehf_write_value(data, data->REG_FAN_MIN[nr],
826 data->fan_min[nr]); 832 data->fan_min[nr]);
827 mutex_unlock(&data->update_lock); 833 mutex_unlock(&data->update_lock);
828 834
@@ -1029,7 +1035,7 @@ store_pwm(struct device *dev, struct device_attribute *attr,
1029 1035
1030 mutex_lock(&data->update_lock); 1036 mutex_lock(&data->update_lock);
1031 data->pwm[nr] = val; 1037 data->pwm[nr] = val;
1032 w83627ehf_write_value(data, W83627EHF_REG_PWM[nr], val); 1038 w83627ehf_write_value(data, data->REG_PWM[nr], val);
1033 mutex_unlock(&data->update_lock); 1039 mutex_unlock(&data->update_lock);
1034 return count; 1040 return count;
1035} 1041}
@@ -1094,7 +1100,7 @@ store_target_temp(struct device *dev, struct device_attribute *attr,
1094 1100
1095 mutex_lock(&data->update_lock); 1101 mutex_lock(&data->update_lock);
1096 data->target_temp[nr] = val; 1102 data->target_temp[nr] = val;
1097 w83627ehf_write_value(data, W83627EHF_REG_TARGET[nr], val); 1103 w83627ehf_write_value(data, data->REG_TARGET[nr], val);
1098 mutex_unlock(&data->update_lock); 1104 mutex_unlock(&data->update_lock);
1099 return count; 1105 return count;
1100} 1106}
@@ -1509,8 +1515,14 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
1509 data->temp_label = w83667hg_b_temp_label; 1515 data->temp_label = w83667hg_b_temp_label;
1510 } 1516 }
1511 1517
1518 data->REG_PWM = W83627EHF_REG_PWM;
1519 data->REG_TARGET = W83627EHF_REG_TARGET;
1520 data->REG_FAN = W83627EHF_REG_FAN;
1521 data->REG_FAN_MIN = W83627EHF_REG_FAN_MIN;
1512 data->REG_FAN_START_OUTPUT = W83627EHF_REG_FAN_START_OUTPUT; 1522 data->REG_FAN_START_OUTPUT = W83627EHF_REG_FAN_START_OUTPUT;
1513 data->REG_FAN_STOP_OUTPUT = W83627EHF_REG_FAN_STOP_OUTPUT; 1523 data->REG_FAN_STOP_OUTPUT = W83627EHF_REG_FAN_STOP_OUTPUT;
1524 data->REG_FAN_STOP_TIME = W83627EHF_REG_FAN_STOP_TIME;
1525 data->REG_FAN_START_OUTPUT = W83627EHF_REG_FAN_START_OUTPUT;
1514 if (sio_data->kind == w83667hg_b) { 1526 if (sio_data->kind == w83667hg_b) {
1515 data->REG_FAN_MAX_OUTPUT = 1527 data->REG_FAN_MAX_OUTPUT =
1516 W83627EHF_REG_FAN_MAX_OUTPUT_W83667_B; 1528 W83627EHF_REG_FAN_MAX_OUTPUT_W83667_B;