#include <linux/err.h>
#include <linux/mutex.h>
#include <linux/io.h>
+#include <linux/acpi.h>
#define DRVNAME "f71882fg"
0, 1),
SENSOR_ATTR_2(pwm2_auto_point2_temp_hyst, S_IRUGO,
show_pwm_auto_point_temp_hyst, NULL, 3, 1),
+
+ SENSOR_ATTR_2(pwm3, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 2),
+ SENSOR_ATTR_2(pwm3_enable, S_IRUGO|S_IWUSR, show_pwm_enable,
+ store_pwm_enable, 0, 2),
+ SENSOR_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO|S_IWUSR,
+ show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
+ 1, 2),
+ SENSOR_ATTR_2(pwm3_auto_point2_pwm, S_IRUGO|S_IWUSR,
+ show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
+ 4, 2),
+ SENSOR_ATTR_2(pwm3_auto_point1_temp, S_IRUGO|S_IWUSR,
+ show_pwm_auto_point_temp, store_pwm_auto_point_temp,
+ 0, 2),
+ SENSOR_ATTR_2(pwm3_auto_point2_temp, S_IRUGO|S_IWUSR,
+ show_pwm_auto_point_temp, store_pwm_auto_point_temp,
+ 3, 2),
+ SENSOR_ATTR_2(pwm3_auto_point1_temp_hyst, S_IRUGO|S_IWUSR,
+ show_pwm_auto_point_temp_hyst,
+ store_pwm_auto_point_temp_hyst,
+ 0, 2),
+ SENSOR_ATTR_2(pwm3_auto_point2_temp_hyst, S_IRUGO,
+ show_pwm_auto_point_temp_hyst, NULL, 3, 2),
};
/* Fan / PWM attr for the f71882fg */
outb(SIO_LOCK_KEY, base);
}
-static inline u16 fan_from_reg(u16 reg)
+static inline int fan_from_reg(u16 reg)
{
return reg ? (1500000 / reg) : 0;
}
-static inline u16 fan_to_reg(u16 fan)
+static inline u16 fan_to_reg(int fan)
{
return fan ? (1500000 / fan) : 0;
}
int result;
struct f71882fg_data *data = f71882fg_update_device(dev);
int nr = to_sensor_dev_attr_2(devattr)->index;
+ int temp_start = (data->type == f8000) ? 0 : 1;
- result = 1 << ((data->pwm_auto_point_mapping[nr] & 3) - 1);
+ result = 1 << ((data->pwm_auto_point_mapping[nr] & 3) - temp_start);
return sprintf(buf, "%d\n", result);
}
{
struct f71882fg_data *data = dev_get_drvdata(dev);
int nr = to_sensor_dev_attr_2(devattr)->index;
+ int temp_start = (data->type == f8000) ? 0 : 1;
long val = simple_strtol(buf, NULL, 10);
+
switch (val) {
case 1:
- val = 1;
+ val = 0;
break;
case 2:
- val = 2;
+ val = 1;
break;
case 4:
- val = 3;
+ val = 2;
break;
default:
return -EINVAL;
}
+ val += temp_start;
mutex_lock(&data->update_lock);
data->pwm_auto_point_mapping[nr] =
f71882fg_read8(data, F71882FG_REG_POINT_MAPPING(nr));
{
struct f71882fg_data *data;
struct f71882fg_sio_data *sio_data = pdev->dev.platform_data;
- int err;
+ int err, i, nr_fans = (sio_data->type == f71882fg) ? 4 : 3;
u8 start_reg;
data = kzalloc(sizeof(struct f71882fg_data), GFP_KERNEL);
goto exit_free;
}
+ data->pwm_enable = f71882fg_read8(data, F71882FG_REG_PWM_ENABLE);
/* If it is a 71862 and the fan / pwm part is enabled sanity check
the pwm settings */
if (data->type == f71862fg && (start_reg & 0x02)) {
- u8 reg = f71882fg_read8(data, F71882FG_REG_PWM_ENABLE);
- if ((reg & 0x15) != 0x15) {
+ if ((data->pwm_enable & 0x15) != 0x15) {
dev_err(&pdev->dev,
"Invalid (reserved) pwm settings: 0x%02x\n",
- (unsigned int)reg);
+ (unsigned int)data->pwm_enable);
err = -ENODEV;
goto exit_free;
}
}
if (err)
goto exit_unregister_sysfs;
+
+ for (i = 0; i < nr_fans; i++)
+ dev_info(&pdev->dev, "Fan: %d is in %s mode\n", i + 1,
+ (data->pwm_enable & (1 << 2 * i)) ?
+ "duty-cycle" : "RPM");
}
data->hwmon_dev = hwmon_device_register(&pdev->dev);
return -ENOMEM;
res.name = f71882fg_pdev->name;
+ err = acpi_check_resource_conflict(&res);
+ if (err)
+ return err;
+
err = platform_device_add_resources(f71882fg_pdev, &res, 1);
if (err) {
printk(KERN_ERR DRVNAME ": Device resource addition failed\n");