diff options
author | Jean Delvare <khali@linux-fr.org> | 2010-10-28 14:31:50 -0400 |
---|---|---|
committer | Jean Delvare <khali@endymion.delvare> | 2010-10-28 14:31:50 -0400 |
commit | f6c61cff8bcb58b8dfb645d4243a049908c02024 (patch) | |
tree | bff2919dcf335f38cb36bdbd27fd5c5870e4b0e9 /drivers/hwmon/lm85.c | |
parent | c36364dbf38382ef6be2fb99a3ce361a679c0ecb (diff) |
hwmon: (lm85) Add support for ADT7468 high-frequency PWM mode
The ADT7468 supports a high-frequency PWM output mode where all PWM
outputs are driven by a 22.5 kHz clock. Add support for this mode, and
document it, as it may surprise the user that setting one PWM output
frequency also affects the other PWM outputs.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Darrick J. Wong <djwong@us.ibm.com>
Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>
Diffstat (limited to 'drivers/hwmon/lm85.c')
-rw-r--r-- | drivers/hwmon/lm85.c | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index 2e8f0c9458d4..1e229847f37a 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c | |||
@@ -64,9 +64,12 @@ enum chips { | |||
64 | #define LM85_REG_VERSTEP 0x3f | 64 | #define LM85_REG_VERSTEP 0x3f |
65 | 65 | ||
66 | #define ADT7468_REG_CFG5 0x7c | 66 | #define ADT7468_REG_CFG5 0x7c |
67 | #define ADT7468_OFF64 0x01 | 67 | #define ADT7468_OFF64 (1 << 0) |
68 | #define ADT7468_HFPWM (1 << 1) | ||
68 | #define IS_ADT7468_OFF64(data) \ | 69 | #define IS_ADT7468_OFF64(data) \ |
69 | ((data)->type == adt7468 && !((data)->cfg5 & ADT7468_OFF64)) | 70 | ((data)->type == adt7468 && !((data)->cfg5 & ADT7468_OFF64)) |
71 | #define IS_ADT7468_HFPWM(data) \ | ||
72 | ((data)->type == adt7468 && !((data)->cfg5 & ADT7468_HFPWM)) | ||
70 | 73 | ||
71 | /* These are the recognized values for the above regs */ | 74 | /* These are the recognized values for the above regs */ |
72 | #define LM85_COMPANY_NATIONAL 0x01 | 75 | #define LM85_COMPANY_NATIONAL 0x01 |
@@ -567,8 +570,14 @@ static ssize_t show_pwm_freq(struct device *dev, | |||
567 | { | 570 | { |
568 | int nr = to_sensor_dev_attr(attr)->index; | 571 | int nr = to_sensor_dev_attr(attr)->index; |
569 | struct lm85_data *data = lm85_update_device(dev); | 572 | struct lm85_data *data = lm85_update_device(dev); |
570 | return sprintf(buf, "%d\n", FREQ_FROM_REG(data->freq_map, | 573 | int freq; |
571 | data->pwm_freq[nr])); | 574 | |
575 | if (IS_ADT7468_HFPWM(data)) | ||
576 | freq = 22500; | ||
577 | else | ||
578 | freq = FREQ_FROM_REG(data->freq_map, data->pwm_freq[nr]); | ||
579 | |||
580 | return sprintf(buf, "%d\n", freq); | ||
572 | } | 581 | } |
573 | 582 | ||
574 | static ssize_t set_pwm_freq(struct device *dev, | 583 | static ssize_t set_pwm_freq(struct device *dev, |
@@ -580,10 +589,22 @@ static ssize_t set_pwm_freq(struct device *dev, | |||
580 | long val = simple_strtol(buf, NULL, 10); | 589 | long val = simple_strtol(buf, NULL, 10); |
581 | 590 | ||
582 | mutex_lock(&data->update_lock); | 591 | mutex_lock(&data->update_lock); |
583 | data->pwm_freq[nr] = FREQ_TO_REG(data->freq_map, val); | 592 | /* The ADT7468 has a special high-frequency PWM output mode, |
584 | lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), | 593 | * where all PWM outputs are driven by a 22.5 kHz clock. |
585 | (data->zone[nr].range << 4) | 594 | * This might confuse the user, but there's not much we can do. */ |
586 | | data->pwm_freq[nr]); | 595 | if (data->type == adt7468 && val >= 11300) { /* High freq. mode */ |
596 | data->cfg5 &= ~ADT7468_HFPWM; | ||
597 | lm85_write_value(client, ADT7468_REG_CFG5, data->cfg5); | ||
598 | } else { /* Low freq. mode */ | ||
599 | data->pwm_freq[nr] = FREQ_TO_REG(data->freq_map, val); | ||
600 | lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), | ||
601 | (data->zone[nr].range << 4) | ||
602 | | data->pwm_freq[nr]); | ||
603 | if (data->type == adt7468) { | ||
604 | data->cfg5 |= ADT7468_HFPWM; | ||
605 | lm85_write_value(client, ADT7468_REG_CFG5, data->cfg5); | ||
606 | } | ||
607 | } | ||
587 | mutex_unlock(&data->update_lock); | 608 | mutex_unlock(&data->update_lock); |
588 | return count; | 609 | return count; |
589 | } | 610 | } |