aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2012-03-23 05:02:17 -0400
committerJean Delvare <khali@endymion.delvare>2012-03-23 05:02:17 -0400
commit72fea694c4208d7ee1704a7dbccddd54af352cde (patch)
treead5db0b19671d6dac0a4da35f82e469ae4681cba /drivers/hwmon
parent941a956b0e387b21f385f486c34ef67576775cfc (diff)
hwmon: (w83795) Unconditionally support manual fan speed control
Manual fan speed control uses a standard interface and has received sufficient testing and review by now, it can be enabled unconditionally. This includes attributes pwm[1-8], pwm[1-8]_enable, pwm[1-8]_mode and pwm[1-8]_freq. We only let the user switch from automatic mode to manual mode, but not the other way around, as automatic control settings may not have been set properly by the BIOS. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/Kconfig9
-rw-r--r--drivers/hwmon/w83795.c38
2 files changed, 29 insertions, 18 deletions
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 811e6c47e7e..783a3144ffd 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -1229,18 +1229,19 @@ config SENSORS_W83795
1229 depends on I2C && EXPERIMENTAL 1229 depends on I2C && EXPERIMENTAL
1230 help 1230 help
1231 If you say yes here you get support for the Winbond W83795G and 1231 If you say yes here you get support for the Winbond W83795G and
1232 W83795ADG hardware monitoring chip. 1232 W83795ADG hardware monitoring chip, including manual fan speed
1233 control.
1233 1234
1234 This driver can also be built as a module. If so, the module 1235 This driver can also be built as a module. If so, the module
1235 will be called w83795. 1236 will be called w83795.
1236 1237
1237config SENSORS_W83795_FANCTRL 1238config SENSORS_W83795_FANCTRL
1238 boolean "Include fan control support (DANGEROUS)" 1239 boolean "Include automatic fan control support (DANGEROUS)"
1239 depends on SENSORS_W83795 && EXPERIMENTAL 1240 depends on SENSORS_W83795 && EXPERIMENTAL
1240 default n 1241 default n
1241 help 1242 help
1242 If you say yes here, support for the both manual and automatic 1243 If you say yes here, support for automatic fan speed control
1243 fan control features will be included in the driver. 1244 will be included in the driver.
1244 1245
1245 This part of the code wasn't carefully reviewed and tested yet, 1246 This part of the code wasn't carefully reviewed and tested yet,
1246 so enabling this option is strongly discouraged on production 1247 so enabling this option is strongly discouraged on production
diff --git a/drivers/hwmon/w83795.c b/drivers/hwmon/w83795.c
index deb12c98280..5478dd13623 100644
--- a/drivers/hwmon/w83795.c
+++ b/drivers/hwmon/w83795.c
@@ -929,6 +929,14 @@ store_pwm_enable(struct device *dev, struct device_attribute *attr,
929 if (val < 1 || val > 2) 929 if (val < 1 || val > 2)
930 return -EINVAL; 930 return -EINVAL;
931 931
932#ifndef CONFIG_SENSORS_W83795_FANCTRL
933 if (val > 1) {
934 dev_warn(dev, "Automatic fan speed control support disabled\n");
935 dev_warn(dev, "Build with CONFIG_SENSORS_W83795_FANCTRL=y if you want it\n");
936 return -EOPNOTSUPP;
937 }
938#endif
939
932 mutex_lock(&data->update_lock); 940 mutex_lock(&data->update_lock);
933 switch (val) { 941 switch (val) {
934 case 1: 942 case 1:
@@ -1625,18 +1633,18 @@ store_sf_setup(struct device *dev, struct device_attribute *attr,
1625#define SENSOR_ATTR_PWM(index) { \ 1633#define SENSOR_ATTR_PWM(index) { \
1626 SENSOR_ATTR_2(pwm##index, S_IWUSR | S_IRUGO, show_pwm, \ 1634 SENSOR_ATTR_2(pwm##index, S_IWUSR | S_IRUGO, show_pwm, \
1627 store_pwm, PWM_OUTPUT, index - 1), \ 1635 store_pwm, PWM_OUTPUT, index - 1), \
1636 SENSOR_ATTR_2(pwm##index##_enable, S_IWUSR | S_IRUGO, \
1637 show_pwm_enable, store_pwm_enable, NOT_USED, index - 1), \
1638 SENSOR_ATTR_2(pwm##index##_mode, S_IRUGO, \
1639 show_pwm_mode, NULL, NOT_USED, index - 1), \
1640 SENSOR_ATTR_2(pwm##index##_freq, S_IWUSR | S_IRUGO, \
1641 show_pwm, store_pwm, PWM_FREQ, index - 1), \
1628 SENSOR_ATTR_2(pwm##index##_nonstop, S_IWUSR | S_IRUGO, \ 1642 SENSOR_ATTR_2(pwm##index##_nonstop, S_IWUSR | S_IRUGO, \
1629 show_pwm, store_pwm, PWM_NONSTOP, index - 1), \ 1643 show_pwm, store_pwm, PWM_NONSTOP, index - 1), \
1630 SENSOR_ATTR_2(pwm##index##_start, S_IWUSR | S_IRUGO, \ 1644 SENSOR_ATTR_2(pwm##index##_start, S_IWUSR | S_IRUGO, \
1631 show_pwm, store_pwm, PWM_START, index - 1), \ 1645 show_pwm, store_pwm, PWM_START, index - 1), \
1632 SENSOR_ATTR_2(pwm##index##_stop_time, S_IWUSR | S_IRUGO, \ 1646 SENSOR_ATTR_2(pwm##index##_stop_time, S_IWUSR | S_IRUGO, \
1633 show_pwm, store_pwm, PWM_STOP_TIME, index - 1), \ 1647 show_pwm, store_pwm, PWM_STOP_TIME, index - 1), \
1634 SENSOR_ATTR_2(pwm##index##_freq, S_IWUSR | S_IRUGO, \
1635 show_pwm, store_pwm, PWM_FREQ, index - 1), \
1636 SENSOR_ATTR_2(pwm##index##_enable, S_IWUSR | S_IRUGO, \
1637 show_pwm_enable, store_pwm_enable, NOT_USED, index - 1), \
1638 SENSOR_ATTR_2(pwm##index##_mode, S_IRUGO, \
1639 show_pwm_mode, NULL, NOT_USED, index - 1), \
1640 SENSOR_ATTR_2(fan##index##_target, S_IWUSR | S_IRUGO, \ 1648 SENSOR_ATTR_2(fan##index##_target, S_IWUSR | S_IRUGO, \
1641 show_fanin, store_fanin, FANIN_TARGET, index - 1) } 1649 show_fanin, store_fanin, FANIN_TARGET, index - 1) }
1642 1650
@@ -1953,6 +1961,14 @@ static int w83795_detect(struct i2c_client *client,
1953 return 0; 1961 return 0;
1954} 1962}
1955 1963
1964#ifdef CONFIG_SENSORS_W83795_FANCTRL
1965#define NUM_PWM_ATTRIBUTES ARRAY_SIZE(w83795_pwm[0])
1966#define NUM_TEMP_ATTRIBUTES ARRAY_SIZE(w83795_temp[0])
1967#else
1968#define NUM_PWM_ATTRIBUTES 4
1969#define NUM_TEMP_ATTRIBUTES 8
1970#endif
1971
1956static int w83795_handle_files(struct device *dev, int (*fn)(struct device *, 1972static int w83795_handle_files(struct device *dev, int (*fn)(struct device *,
1957 const struct device_attribute *)) 1973 const struct device_attribute *))
1958{ 1974{
@@ -2006,24 +2022,18 @@ static int w83795_handle_files(struct device *dev, int (*fn)(struct device *,
2006 } 2022 }
2007 } 2023 }
2008 2024
2009#ifdef CONFIG_SENSORS_W83795_FANCTRL
2010 for (i = 0; i < data->has_pwm; i++) { 2025 for (i = 0; i < data->has_pwm; i++) {
2011 for (j = 0; j < ARRAY_SIZE(w83795_pwm[0]); j++) { 2026 for (j = 0; j < NUM_PWM_ATTRIBUTES; j++) {
2012 err = fn(dev, &w83795_pwm[i][j].dev_attr); 2027 err = fn(dev, &w83795_pwm[i][j].dev_attr);
2013 if (err) 2028 if (err)
2014 return err; 2029 return err;
2015 } 2030 }
2016 } 2031 }
2017#endif
2018 2032
2019 for (i = 0; i < ARRAY_SIZE(w83795_temp); i++) { 2033 for (i = 0; i < ARRAY_SIZE(w83795_temp); i++) {
2020 if (!(data->has_temp & (1 << i))) 2034 if (!(data->has_temp & (1 << i)))
2021 continue; 2035 continue;
2022#ifdef CONFIG_SENSORS_W83795_FANCTRL 2036 for (j = 0; j < NUM_TEMP_ATTRIBUTES; j++) {
2023 for (j = 0; j < ARRAY_SIZE(w83795_temp[0]); j++) {
2024#else
2025 for (j = 0; j < 8; j++) {
2026#endif
2027 if (j == 7 && !data->enable_beep) 2037 if (j == 7 && !data->enable_beep)
2028 continue; 2038 continue;
2029 err = fn(dev, &w83795_temp[i][j].dev_attr); 2039 err = fn(dev, &w83795_temp[i][j].dev_attr);