diff options
author | Giel van Schijndel <me@mortis.eu> | 2010-08-09 20:21:13 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-09 23:45:10 -0400 |
commit | 7721fea3d0fd93fb4d000eb737b444369358d6d3 (patch) | |
tree | 82584339f492a2d771a67924209871c81e3ec9c7 /drivers/hwmon/f71882fg.c | |
parent | 6b8e8282611ea35845dcff0cb321a7d735fc3155 (diff) |
hwmon: f71882fg: add support for the Fintek F71808E
Allow device probing to recognise the Fintek F71808E.
Sysfs interface:
* Fan/pwm control is the same as for F71889FG
* Temperature and voltage sensor handling is largely the same as for
the F71889FG
- Has one temperature sensor less (doesn't have temp3)
- Misses one voltage sensor (doesn't have V6, thus in6_input refers to
what in7_input refers for F71889FG)
For the purpose of the sysfs interface fxxxx_in_temp_attr[] is split up
such that it can largely be reused.
Signed-off-by: Giel van Schijndel <me@mortis.eu>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/hwmon/f71882fg.c')
-rw-r--r-- | drivers/hwmon/f71882fg.c | 83 |
1 files changed, 75 insertions, 8 deletions
diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c index 537841ef44b9..6207120dcd4d 100644 --- a/drivers/hwmon/f71882fg.c +++ b/drivers/hwmon/f71882fg.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #define SIO_REG_ADDR 0x60 /* Logical device address (2 bytes) */ | 45 | #define SIO_REG_ADDR 0x60 /* Logical device address (2 bytes) */ |
46 | 46 | ||
47 | #define SIO_FINTEK_ID 0x1934 /* Manufacturers ID */ | 47 | #define SIO_FINTEK_ID 0x1934 /* Manufacturers ID */ |
48 | #define SIO_F71808_ID 0x0901 /* Chipset ID */ | ||
48 | #define SIO_F71858_ID 0x0507 /* Chipset ID */ | 49 | #define SIO_F71858_ID 0x0507 /* Chipset ID */ |
49 | #define SIO_F71862_ID 0x0601 /* Chipset ID */ | 50 | #define SIO_F71862_ID 0x0601 /* Chipset ID */ |
50 | #define SIO_F71882_ID 0x0541 /* Chipset ID */ | 51 | #define SIO_F71882_ID 0x0541 /* Chipset ID */ |
@@ -96,9 +97,10 @@ static unsigned short force_id; | |||
96 | module_param(force_id, ushort, 0); | 97 | module_param(force_id, ushort, 0); |
97 | MODULE_PARM_DESC(force_id, "Override the detected device ID"); | 98 | MODULE_PARM_DESC(force_id, "Override the detected device ID"); |
98 | 99 | ||
99 | enum chips { f71858fg, f71862fg, f71882fg, f71889fg, f8000 }; | 100 | enum chips { f71808fg, f71858fg, f71862fg, f71882fg, f71889fg, f8000 }; |
100 | 101 | ||
101 | static const char *f71882fg_names[] = { | 102 | static const char *f71882fg_names[] = { |
103 | "f71808fg", | ||
102 | "f71858fg", | 104 | "f71858fg", |
103 | "f71862fg", | 105 | "f71862fg", |
104 | "f71882fg", | 106 | "f71882fg", |
@@ -306,8 +308,8 @@ static struct sensor_device_attribute_2 f71858fg_in_temp_attr[] = { | |||
306 | SENSOR_ATTR_2(temp3_fault, S_IRUGO, show_temp_fault, NULL, 0, 2), | 308 | SENSOR_ATTR_2(temp3_fault, S_IRUGO, show_temp_fault, NULL, 0, 2), |
307 | }; | 309 | }; |
308 | 310 | ||
309 | /* Temp and in attr common to the f71862fg, f71882fg and f71889fg */ | 311 | /* In attr common to the f71862fg, f71882fg and f71889fg */ |
310 | static struct sensor_device_attribute_2 fxxxx_in_temp_attr[] = { | 312 | static struct sensor_device_attribute_2 fxxxx_in_attr[] = { |
311 | SENSOR_ATTR_2(in0_input, S_IRUGO, show_in, NULL, 0, 0), | 313 | SENSOR_ATTR_2(in0_input, S_IRUGO, show_in, NULL, 0, 0), |
312 | SENSOR_ATTR_2(in1_input, S_IRUGO, show_in, NULL, 0, 1), | 314 | SENSOR_ATTR_2(in1_input, S_IRUGO, show_in, NULL, 0, 1), |
313 | SENSOR_ATTR_2(in2_input, S_IRUGO, show_in, NULL, 0, 2), | 315 | SENSOR_ATTR_2(in2_input, S_IRUGO, show_in, NULL, 0, 2), |
@@ -317,6 +319,22 @@ static struct sensor_device_attribute_2 fxxxx_in_temp_attr[] = { | |||
317 | SENSOR_ATTR_2(in6_input, S_IRUGO, show_in, NULL, 0, 6), | 319 | SENSOR_ATTR_2(in6_input, S_IRUGO, show_in, NULL, 0, 6), |
318 | SENSOR_ATTR_2(in7_input, S_IRUGO, show_in, NULL, 0, 7), | 320 | SENSOR_ATTR_2(in7_input, S_IRUGO, show_in, NULL, 0, 7), |
319 | SENSOR_ATTR_2(in8_input, S_IRUGO, show_in, NULL, 0, 8), | 321 | SENSOR_ATTR_2(in8_input, S_IRUGO, show_in, NULL, 0, 8), |
322 | }; | ||
323 | |||
324 | /* In attr for the f71808fg */ | ||
325 | static struct sensor_device_attribute_2 f71808_in_attr[] = { | ||
326 | SENSOR_ATTR_2(in0_input, S_IRUGO, show_in, NULL, 0, 0), | ||
327 | SENSOR_ATTR_2(in1_input, S_IRUGO, show_in, NULL, 0, 1), | ||
328 | SENSOR_ATTR_2(in2_input, S_IRUGO, show_in, NULL, 0, 2), | ||
329 | SENSOR_ATTR_2(in3_input, S_IRUGO, show_in, NULL, 0, 3), | ||
330 | SENSOR_ATTR_2(in4_input, S_IRUGO, show_in, NULL, 0, 4), | ||
331 | SENSOR_ATTR_2(in5_input, S_IRUGO, show_in, NULL, 0, 5), | ||
332 | SENSOR_ATTR_2(in6_input, S_IRUGO, show_in, NULL, 0, 7), | ||
333 | SENSOR_ATTR_2(in7_input, S_IRUGO, show_in, NULL, 0, 8), | ||
334 | }; | ||
335 | |||
336 | /* Temp attr common to the f71808fg, f71862fg, f71882fg and f71889fg */ | ||
337 | static struct sensor_device_attribute_2 fxxxx_temp_attr[] = { | ||
320 | SENSOR_ATTR_2(temp1_input, S_IRUGO, show_temp, NULL, 0, 1), | 338 | SENSOR_ATTR_2(temp1_input, S_IRUGO, show_temp, NULL, 0, 1), |
321 | SENSOR_ATTR_2(temp1_max, S_IRUGO|S_IWUSR, show_temp_max, | 339 | SENSOR_ATTR_2(temp1_max, S_IRUGO|S_IWUSR, show_temp_max, |
322 | store_temp_max, 0, 1), | 340 | store_temp_max, 0, 1), |
@@ -355,6 +373,10 @@ static struct sensor_device_attribute_2 fxxxx_in_temp_attr[] = { | |||
355 | store_temp_beep, 0, 6), | 373 | store_temp_beep, 0, 6), |
356 | SENSOR_ATTR_2(temp2_type, S_IRUGO, show_temp_type, NULL, 0, 2), | 374 | SENSOR_ATTR_2(temp2_type, S_IRUGO, show_temp_type, NULL, 0, 2), |
357 | SENSOR_ATTR_2(temp2_fault, S_IRUGO, show_temp_fault, NULL, 0, 2), | 375 | SENSOR_ATTR_2(temp2_fault, S_IRUGO, show_temp_fault, NULL, 0, 2), |
376 | }; | ||
377 | |||
378 | /* Temp and in attr common to the f71862fg, f71882fg and f71889fg */ | ||
379 | static struct sensor_device_attribute_2 f71862_temp_attr[] = { | ||
358 | SENSOR_ATTR_2(temp3_input, S_IRUGO, show_temp, NULL, 0, 3), | 380 | SENSOR_ATTR_2(temp3_input, S_IRUGO, show_temp, NULL, 0, 3), |
359 | SENSOR_ATTR_2(temp3_max, S_IRUGO|S_IWUSR, show_temp_max, | 381 | SENSOR_ATTR_2(temp3_max, S_IRUGO|S_IWUSR, show_temp_max, |
360 | store_temp_max, 0, 3), | 382 | store_temp_max, 0, 3), |
@@ -989,6 +1011,11 @@ static struct f71882fg_data *f71882fg_update_device(struct device *dev) | |||
989 | data->temp_type[1] = 6; | 1011 | data->temp_type[1] = 6; |
990 | break; | 1012 | break; |
991 | } | 1013 | } |
1014 | } else if (data->type == f71808fg) { | ||
1015 | reg = f71882fg_read8(data, F71882FG_REG_TEMP_TYPE); | ||
1016 | data->temp_type[1] = (reg & 0x02) ? 2 : 4; | ||
1017 | data->temp_type[2] = (reg & 0x04) ? 2 : 4; | ||
1018 | |||
992 | } else { | 1019 | } else { |
993 | reg2 = f71882fg_read8(data, F71882FG_REG_PECI); | 1020 | reg2 = f71882fg_read8(data, F71882FG_REG_PECI); |
994 | if ((reg2 & 0x03) == 0x01) | 1021 | if ((reg2 & 0x03) == 0x01) |
@@ -1871,7 +1898,8 @@ static ssize_t store_pwm_auto_point_temp(struct device *dev, | |||
1871 | 1898 | ||
1872 | val /= 1000; | 1899 | val /= 1000; |
1873 | 1900 | ||
1874 | if (data->type == f71889fg) | 1901 | if (data->type == f71889fg |
1902 | || data->type == f71808fg) | ||
1875 | val = SENSORS_LIMIT(val, -128, 127); | 1903 | val = SENSORS_LIMIT(val, -128, 127); |
1876 | else | 1904 | else |
1877 | val = SENSORS_LIMIT(val, 0, 127); | 1905 | val = SENSORS_LIMIT(val, 0, 127); |
@@ -1974,8 +2002,28 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) | |||
1974 | /* fall through! */ | 2002 | /* fall through! */ |
1975 | case f71862fg: | 2003 | case f71862fg: |
1976 | err = f71882fg_create_sysfs_files(pdev, | 2004 | err = f71882fg_create_sysfs_files(pdev, |
1977 | fxxxx_in_temp_attr, | 2005 | f71862_temp_attr, |
1978 | ARRAY_SIZE(fxxxx_in_temp_attr)); | 2006 | ARRAY_SIZE(f71862_temp_attr)); |
2007 | if (err) | ||
2008 | goto exit_unregister_sysfs; | ||
2009 | err = f71882fg_create_sysfs_files(pdev, | ||
2010 | fxxxx_in_attr, | ||
2011 | ARRAY_SIZE(fxxxx_in_attr)); | ||
2012 | if (err) | ||
2013 | goto exit_unregister_sysfs; | ||
2014 | err = f71882fg_create_sysfs_files(pdev, | ||
2015 | fxxxx_temp_attr, | ||
2016 | ARRAY_SIZE(fxxxx_temp_attr)); | ||
2017 | break; | ||
2018 | case f71808fg: | ||
2019 | err = f71882fg_create_sysfs_files(pdev, | ||
2020 | f71808_in_attr, | ||
2021 | ARRAY_SIZE(f71808_in_attr)); | ||
2022 | if (err) | ||
2023 | goto exit_unregister_sysfs; | ||
2024 | err = f71882fg_create_sysfs_files(pdev, | ||
2025 | fxxxx_temp_attr, | ||
2026 | ARRAY_SIZE(fxxxx_temp_attr)); | ||
1979 | break; | 2027 | break; |
1980 | case f8000: | 2028 | case f8000: |
1981 | err = f71882fg_create_sysfs_files(pdev, | 2029 | err = f71882fg_create_sysfs_files(pdev, |
@@ -2002,6 +2050,7 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) | |||
2002 | case f71862fg: | 2050 | case f71862fg: |
2003 | err = (data->pwm_enable & 0x15) != 0x15; | 2051 | err = (data->pwm_enable & 0x15) != 0x15; |
2004 | break; | 2052 | break; |
2053 | case f71808fg: | ||
2005 | case f71882fg: | 2054 | case f71882fg: |
2006 | case f71889fg: | 2055 | case f71889fg: |
2007 | err = 0; | 2056 | err = 0; |
@@ -2047,6 +2096,7 @@ static int __devinit f71882fg_probe(struct platform_device *pdev) | |||
2047 | f8000_auto_pwm_attr, | 2096 | f8000_auto_pwm_attr, |
2048 | ARRAY_SIZE(f8000_auto_pwm_attr)); | 2097 | ARRAY_SIZE(f8000_auto_pwm_attr)); |
2049 | break; | 2098 | break; |
2099 | case f71808fg: | ||
2050 | case f71889fg: | 2100 | case f71889fg: |
2051 | for (i = 0; i < nr_fans; i++) { | 2101 | for (i = 0; i < nr_fans; i++) { |
2052 | data->pwm_auto_point_mapping[i] = | 2102 | data->pwm_auto_point_mapping[i] = |
@@ -2126,8 +2176,22 @@ static int f71882fg_remove(struct platform_device *pdev) | |||
2126 | /* fall through! */ | 2176 | /* fall through! */ |
2127 | case f71862fg: | 2177 | case f71862fg: |
2128 | f71882fg_remove_sysfs_files(pdev, | 2178 | f71882fg_remove_sysfs_files(pdev, |
2129 | fxxxx_in_temp_attr, | 2179 | f71862_temp_attr, |
2130 | ARRAY_SIZE(fxxxx_in_temp_attr)); | 2180 | ARRAY_SIZE(f71862_temp_attr)); |
2181 | f71882fg_remove_sysfs_files(pdev, | ||
2182 | fxxxx_in_attr, | ||
2183 | ARRAY_SIZE(fxxxx_in_attr)); | ||
2184 | f71882fg_remove_sysfs_files(pdev, | ||
2185 | fxxxx_temp_attr, | ||
2186 | ARRAY_SIZE(fxxxx_temp_attr)); | ||
2187 | break; | ||
2188 | case f71808fg: | ||
2189 | f71882fg_remove_sysfs_files(pdev, | ||
2190 | f71808_in_attr, | ||
2191 | ARRAY_SIZE(f71808_in_attr)); | ||
2192 | f71882fg_remove_sysfs_files(pdev, | ||
2193 | fxxxx_temp_attr, | ||
2194 | ARRAY_SIZE(fxxxx_temp_attr)); | ||
2131 | break; | 2195 | break; |
2132 | case f8000: | 2196 | case f8000: |
2133 | f71882fg_remove_sysfs_files(pdev, | 2197 | f71882fg_remove_sysfs_files(pdev, |
@@ -2195,6 +2259,9 @@ static int __init f71882fg_find(int sioaddr, unsigned short *address, | |||
2195 | 2259 | ||
2196 | devid = force_id ? force_id : superio_inw(sioaddr, SIO_REG_DEVID); | 2260 | devid = force_id ? force_id : superio_inw(sioaddr, SIO_REG_DEVID); |
2197 | switch (devid) { | 2261 | switch (devid) { |
2262 | case SIO_F71808_ID: | ||
2263 | sio_data->type = f71808fg; | ||
2264 | break; | ||
2198 | case SIO_F71858_ID: | 2265 | case SIO_F71858_ID: |
2199 | sio_data->type = f71858fg; | 2266 | sio_data->type = f71858fg; |
2200 | break; | 2267 | break; |