Commit 3490c92a authored by Chris Packham's avatar Chris Packham Committed by Guenter Roeck

hwmon: (adt7475) add high frequency support

Systems using 4-wire fans usually require high frequency (22.5kHz)
output on the pwm. Add 22500 as a valid option in the pwmfreq_table. In
high frequency mode the low-order bit are ignored so they can safely be
set to 0.
Signed-off-by: default avatarChris Packham <chris.packham@alliedtelesis.co.nz>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 1d58f5ef
...@@ -852,7 +852,7 @@ static ssize_t set_pwmctrl(struct device *dev, struct device_attribute *attr, ...@@ -852,7 +852,7 @@ static ssize_t set_pwmctrl(struct device *dev, struct device_attribute *attr,
/* List of frequencies for the PWM */ /* List of frequencies for the PWM */
static const int pwmfreq_table[] = { static const int pwmfreq_table[] = {
11, 14, 22, 29, 35, 44, 58, 88 11, 14, 22, 29, 35, 44, 58, 88, 22500
}; };
static ssize_t show_pwmfreq(struct device *dev, struct device_attribute *attr, static ssize_t show_pwmfreq(struct device *dev, struct device_attribute *attr,
...@@ -860,9 +860,10 @@ static ssize_t show_pwmfreq(struct device *dev, struct device_attribute *attr, ...@@ -860,9 +860,10 @@ static ssize_t show_pwmfreq(struct device *dev, struct device_attribute *attr,
{ {
struct adt7475_data *data = adt7475_update_device(dev); struct adt7475_data *data = adt7475_update_device(dev);
struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr); struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
int i = clamp_val(data->range[sattr->index] & 0xf, 0,
ARRAY_SIZE(pwmfreq_table) - 1);
return sprintf(buf, "%d\n", return sprintf(buf, "%d\n", pwmfreq_table[i]);
pwmfreq_table[data->range[sattr->index] & 7]);
} }
static ssize_t set_pwmfreq(struct device *dev, struct device_attribute *attr, static ssize_t set_pwmfreq(struct device *dev, struct device_attribute *attr,
...@@ -883,7 +884,7 @@ static ssize_t set_pwmfreq(struct device *dev, struct device_attribute *attr, ...@@ -883,7 +884,7 @@ static ssize_t set_pwmfreq(struct device *dev, struct device_attribute *attr,
data->range[sattr->index] = data->range[sattr->index] =
adt7475_read(TEMP_TRANGE_REG(sattr->index)); adt7475_read(TEMP_TRANGE_REG(sattr->index));
data->range[sattr->index] &= ~7; data->range[sattr->index] &= ~0xf;
data->range[sattr->index] |= out; data->range[sattr->index] |= out;
i2c_smbus_write_byte_data(client, TEMP_TRANGE_REG(sattr->index), i2c_smbus_write_byte_data(client, TEMP_TRANGE_REG(sattr->index),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment