diff options
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/Kconfig | 39 | ||||
-rw-r--r-- | drivers/hwmon/Makefile | 1 | ||||
-rw-r--r-- | drivers/hwmon/ad7414.c | 268 | ||||
-rw-r--r-- | drivers/hwmon/adt7473.c | 16 | ||||
-rw-r--r-- | drivers/hwmon/dme1737.c | 523 | ||||
-rw-r--r-- | drivers/hwmon/f71882fg.c | 6 | ||||
-rw-r--r-- | drivers/hwmon/hwmon-vid.c | 144 | ||||
-rw-r--r-- | drivers/hwmon/it87.c | 45 | ||||
-rw-r--r-- | drivers/hwmon/lm75.c | 282 | ||||
-rw-r--r-- | drivers/hwmon/lm85.c | 672 | ||||
-rw-r--r-- | drivers/hwmon/thmc50.c | 28 | ||||
-rw-r--r-- | drivers/hwmon/w83627hf.c | 101 | ||||
-rw-r--r-- | drivers/hwmon/w83791d.c | 24 |
13 files changed, 1336 insertions, 813 deletions
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 00ff53348491..bf4ebfb86fa5 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig | |||
@@ -57,6 +57,16 @@ config SENSORS_ABITUGURU3 | |||
57 | This driver can also be built as a module. If so, the module | 57 | This driver can also be built as a module. If so, the module |
58 | will be called abituguru3. | 58 | will be called abituguru3. |
59 | 59 | ||
60 | config SENSORS_AD7414 | ||
61 | tristate "Analog Devices AD7414" | ||
62 | depends on I2C && EXPERIMENTAL | ||
63 | help | ||
64 | If you say yes here you get support for the Analog Devices | ||
65 | AD7414 temperature monitoring chip. | ||
66 | |||
67 | This driver can also be built as a module. If so, the module | ||
68 | will be called ad7414. | ||
69 | |||
60 | config SENSORS_AD7418 | 70 | config SENSORS_AD7418 |
61 | tristate "Analog Devices AD7416, AD7417 and AD7418" | 71 | tristate "Analog Devices AD7416, AD7417 and AD7418" |
62 | depends on I2C && EXPERIMENTAL | 72 | depends on I2C && EXPERIMENTAL |
@@ -124,7 +134,7 @@ config SENSORS_ADM1031 | |||
124 | 134 | ||
125 | config SENSORS_ADM9240 | 135 | config SENSORS_ADM9240 |
126 | tristate "Analog Devices ADM9240 and compatibles" | 136 | tristate "Analog Devices ADM9240 and compatibles" |
127 | depends on I2C && EXPERIMENTAL | 137 | depends on I2C |
128 | select HWMON_VID | 138 | select HWMON_VID |
129 | help | 139 | help |
130 | If you say yes here you get support for Analog Devices ADM9240, | 140 | If you say yes here you get support for Analog Devices ADM9240, |
@@ -394,13 +404,24 @@ config SENSORS_LM75 | |||
394 | tristate "National Semiconductor LM75 and compatibles" | 404 | tristate "National Semiconductor LM75 and compatibles" |
395 | depends on I2C | 405 | depends on I2C |
396 | help | 406 | help |
397 | If you say yes here you get support for National Semiconductor LM75 | 407 | If you say yes here you get support for one common type of |
398 | sensor chips and clones: Dallas Semiconductor DS75 and DS1775 (in | 408 | temperature sensor chip, with models including: |
399 | 9-bit precision mode), and TelCom (now Microchip) TCN75. | 409 | |
410 | - Dallas Semiconductor DS75 and DS1775 | ||
411 | - Maxim MAX6625 and MAX6626 | ||
412 | - Microchip MCP980x | ||
413 | - National Semiconductor LM75 | ||
414 | - NXP's LM75A | ||
415 | - ST Microelectronics STDS75 | ||
416 | - TelCom (now Microchip) TCN75 | ||
417 | - Texas Instruments TMP100, TMP101, TMP75, TMP175, TMP275 | ||
418 | |||
419 | This driver supports driver model based binding through board | ||
420 | specific I2C device tables. | ||
400 | 421 | ||
401 | The DS75 and DS1775 in 10- to 12-bit precision modes will require | 422 | It also supports the "legacy" style of driver binding. To use |
402 | a force module parameter. The driver will not handle the extra | 423 | that with some chips which don't replicate LM75 quirks exactly, |
403 | precision anyhow. | 424 | you may need the "force" module parameter. |
404 | 425 | ||
405 | This driver can also be built as a module. If so, the module | 426 | This driver can also be built as a module. If so, the module |
406 | will be called lm75. | 427 | will be called lm75. |
@@ -564,8 +585,8 @@ config SENSORS_DME1737 | |||
564 | select HWMON_VID | 585 | select HWMON_VID |
565 | help | 586 | help |
566 | If you say yes here you get support for the hardware monitoring | 587 | If you say yes here you get support for the hardware monitoring |
567 | and fan control features of the SMSC DME1737 (and compatibles | 588 | and fan control features of the SMSC DME1737, SCH311x, SCH5027, and |
568 | like the Asus A8000) and SCH311x Super-I/O chips. | 589 | Asus A8000 Super-I/O chips. |
569 | 590 | ||
570 | This driver can also be built as a module. If so, the module | 591 | This driver can also be built as a module. If so, the module |
571 | will be called dme1737. | 592 | will be called dme1737. |
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index d098677e08de..7943e5cefb06 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile | |||
@@ -15,6 +15,7 @@ obj-$(CONFIG_SENSORS_W83791D) += w83791d.o | |||
15 | 15 | ||
16 | obj-$(CONFIG_SENSORS_ABITUGURU) += abituguru.o | 16 | obj-$(CONFIG_SENSORS_ABITUGURU) += abituguru.o |
17 | obj-$(CONFIG_SENSORS_ABITUGURU3)+= abituguru3.o | 17 | obj-$(CONFIG_SENSORS_ABITUGURU3)+= abituguru3.o |
18 | obj-$(CONFIG_SENSORS_AD7414) += ad7414.o | ||
18 | obj-$(CONFIG_SENSORS_AD7418) += ad7418.o | 19 | obj-$(CONFIG_SENSORS_AD7418) += ad7418.o |
19 | obj-$(CONFIG_SENSORS_ADM1021) += adm1021.o | 20 | obj-$(CONFIG_SENSORS_ADM1021) += adm1021.o |
20 | obj-$(CONFIG_SENSORS_ADM1025) += adm1025.o | 21 | obj-$(CONFIG_SENSORS_ADM1025) += adm1025.o |
diff --git a/drivers/hwmon/ad7414.c b/drivers/hwmon/ad7414.c new file mode 100644 index 000000000000..ce8d94fbfd7e --- /dev/null +++ b/drivers/hwmon/ad7414.c | |||
@@ -0,0 +1,268 @@ | |||
1 | /* | ||
2 | * An hwmon driver for the Analog Devices AD7414 | ||
3 | * | ||
4 | * Copyright 2006 Stefan Roese <sr at denx.de>, DENX Software Engineering | ||
5 | * | ||
6 | * Copyright (c) 2008 PIKA Technologies | ||
7 | * Sean MacLennan <smaclennan@pikatech.com> | ||
8 | * | ||
9 | * Copyright (c) 2008 Spansion Inc. | ||
10 | * Frank Edelhaeuser <frank.edelhaeuser at spansion.com> | ||
11 | * (converted to "new style" I2C driver model, removed checkpatch.pl warnings) | ||
12 | * | ||
13 | * Based on ad7418.c | ||
14 | * Copyright 2006 Tower Technologies, Alessandro Zummo <a.zummo at towertech.it> | ||
15 | * | ||
16 | * This program is free software; you can redistribute it and/or modify | ||
17 | * it under the terms of the GNU General Public License as published by | ||
18 | * the Free Software Foundation; either version 2 of the License, or | ||
19 | * (at your option) any later version. | ||
20 | */ | ||
21 | |||
22 | #include <linux/module.h> | ||
23 | #include <linux/jiffies.h> | ||
24 | #include <linux/i2c.h> | ||
25 | #include <linux/hwmon.h> | ||
26 | #include <linux/hwmon-sysfs.h> | ||
27 | #include <linux/err.h> | ||
28 | #include <linux/mutex.h> | ||
29 | #include <linux/sysfs.h> | ||
30 | |||
31 | |||
32 | /* AD7414 registers */ | ||
33 | #define AD7414_REG_TEMP 0x00 | ||
34 | #define AD7414_REG_CONF 0x01 | ||
35 | #define AD7414_REG_T_HIGH 0x02 | ||
36 | #define AD7414_REG_T_LOW 0x03 | ||
37 | |||
38 | static u8 AD7414_REG_LIMIT[] = { AD7414_REG_T_HIGH, AD7414_REG_T_LOW }; | ||
39 | |||
40 | struct ad7414_data { | ||
41 | struct device *hwmon_dev; | ||
42 | struct mutex lock; /* atomic read data updates */ | ||
43 | char valid; /* !=0 if following fields are valid */ | ||
44 | unsigned long next_update; /* In jiffies */ | ||
45 | s16 temp_input; /* Register values */ | ||
46 | s8 temps[ARRAY_SIZE(AD7414_REG_LIMIT)]; | ||
47 | }; | ||
48 | |||
49 | /* REG: (0.25C/bit, two's complement) << 6 */ | ||
50 | static inline int ad7414_temp_from_reg(s16 reg) | ||
51 | { | ||
52 | /* use integer division instead of equivalent right shift to | ||
53 | * guarantee arithmetic shift and preserve the sign | ||
54 | */ | ||
55 | return ((int)reg / 64) * 250; | ||
56 | } | ||
57 | |||
58 | static inline int ad7414_read(struct i2c_client *client, u8 reg) | ||
59 | { | ||
60 | if (reg == AD7414_REG_TEMP) { | ||
61 | int value = i2c_smbus_read_word_data(client, reg); | ||
62 | return (value < 0) ? value : swab16(value); | ||
63 | } else | ||
64 | return i2c_smbus_read_byte_data(client, reg); | ||
65 | } | ||
66 | |||
67 | static inline int ad7414_write(struct i2c_client *client, u8 reg, u8 value) | ||
68 | { | ||
69 | return i2c_smbus_write_byte_data(client, reg, value); | ||
70 | } | ||
71 | |||
72 | struct ad7414_data *ad7414_update_device(struct device *dev) | ||
73 | { | ||
74 | struct i2c_client *client = to_i2c_client(dev); | ||
75 | struct ad7414_data *data = i2c_get_clientdata(client); | ||
76 | |||
77 | mutex_lock(&data->lock); | ||
78 | |||
79 | if (time_after(jiffies, data->next_update) || !data->valid) { | ||
80 | int value, i; | ||
81 | |||
82 | dev_dbg(&client->dev, "starting ad7414 update\n"); | ||
83 | |||
84 | value = ad7414_read(client, AD7414_REG_TEMP); | ||
85 | if (value < 0) | ||
86 | dev_dbg(&client->dev, "AD7414_REG_TEMP err %d\n", | ||
87 | value); | ||
88 | else | ||
89 | data->temp_input = value; | ||
90 | |||
91 | for (i = 0; i < ARRAY_SIZE(AD7414_REG_LIMIT); ++i) { | ||
92 | value = ad7414_read(client, AD7414_REG_LIMIT[i]); | ||
93 | if (value < 0) | ||
94 | dev_dbg(&client->dev, "AD7414 reg %d err %d\n", | ||
95 | AD7414_REG_LIMIT[i], value); | ||
96 | else | ||
97 | data->temps[i] = value; | ||
98 | } | ||
99 | |||
100 | data->next_update = jiffies + HZ + HZ / 2; | ||
101 | data->valid = 1; | ||
102 | } | ||
103 | |||
104 | mutex_unlock(&data->lock); | ||
105 | |||
106 | return data; | ||
107 | } | ||
108 | |||
109 | static ssize_t show_temp_input(struct device *dev, | ||
110 | struct device_attribute *attr, char *buf) | ||
111 | { | ||
112 | struct ad7414_data *data = ad7414_update_device(dev); | ||
113 | return sprintf(buf, "%d\n", ad7414_temp_from_reg(data->temp_input)); | ||
114 | } | ||
115 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input, NULL, 0); | ||
116 | |||
117 | static ssize_t show_max_min(struct device *dev, struct device_attribute *attr, | ||
118 | char *buf) | ||
119 | { | ||
120 | int index = to_sensor_dev_attr(attr)->index; | ||
121 | struct ad7414_data *data = ad7414_update_device(dev); | ||
122 | return sprintf(buf, "%d\n", data->temps[index] * 1000); | ||
123 | } | ||
124 | |||
125 | static ssize_t set_max_min(struct device *dev, | ||
126 | struct device_attribute *attr, | ||
127 | const char *buf, size_t count) | ||
128 | { | ||
129 | struct i2c_client *client = to_i2c_client(dev); | ||
130 | struct ad7414_data *data = i2c_get_clientdata(client); | ||
131 | int index = to_sensor_dev_attr(attr)->index; | ||
132 | u8 reg = AD7414_REG_LIMIT[index]; | ||
133 | long temp = simple_strtol(buf, NULL, 10); | ||
134 | |||
135 | temp = SENSORS_LIMIT(temp, -40000, 85000); | ||
136 | temp = (temp + (temp < 0 ? -500 : 500)) / 1000; | ||
137 | |||
138 | mutex_lock(&data->lock); | ||
139 | data->temps[index] = temp; | ||
140 | ad7414_write(client, reg, temp); | ||
141 | mutex_unlock(&data->lock); | ||
142 | return count; | ||
143 | } | ||
144 | |||
145 | static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, | ||
146 | show_max_min, set_max_min, 0); | ||
147 | static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, | ||
148 | show_max_min, set_max_min, 1); | ||
149 | |||
150 | static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, | ||
151 | char *buf) | ||
152 | { | ||
153 | int bitnr = to_sensor_dev_attr(attr)->index; | ||
154 | struct ad7414_data *data = ad7414_update_device(dev); | ||
155 | int value = (data->temp_input >> bitnr) & 1; | ||
156 | return sprintf(buf, "%d\n", value); | ||
157 | } | ||
158 | |||
159 | static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, 3); | ||
160 | static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 4); | ||
161 | |||
162 | static struct attribute *ad7414_attributes[] = { | ||
163 | &sensor_dev_attr_temp1_input.dev_attr.attr, | ||
164 | &sensor_dev_attr_temp1_max.dev_attr.attr, | ||
165 | &sensor_dev_attr_temp1_min.dev_attr.attr, | ||
166 | &sensor_dev_attr_temp1_max_alarm.dev_attr.attr, | ||
167 | &sensor_dev_attr_temp1_min_alarm.dev_attr.attr, | ||
168 | NULL | ||
169 | }; | ||
170 | |||
171 | static const struct attribute_group ad7414_group = { | ||
172 | .attrs = ad7414_attributes, | ||
173 | }; | ||
174 | |||
175 | static int ad7414_probe(struct i2c_client *client, | ||
176 | const struct i2c_device_id *dev_id) | ||
177 | { | ||
178 | struct ad7414_data *data; | ||
179 | int conf; | ||
180 | int err = 0; | ||
181 | |||
182 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA | | ||
183 | I2C_FUNC_SMBUS_READ_WORD_DATA)) | ||
184 | goto exit; | ||
185 | |||
186 | data = kzalloc(sizeof(struct ad7414_data), GFP_KERNEL); | ||
187 | if (!data) { | ||
188 | err = -ENOMEM; | ||
189 | goto exit; | ||
190 | } | ||
191 | |||
192 | i2c_set_clientdata(client, data); | ||
193 | mutex_init(&data->lock); | ||
194 | |||
195 | dev_info(&client->dev, "chip found\n"); | ||
196 | |||
197 | /* Make sure the chip is powered up. */ | ||
198 | conf = i2c_smbus_read_byte_data(client, AD7414_REG_CONF); | ||
199 | if (conf < 0) | ||
200 | dev_warn(&client->dev, | ||
201 | "ad7414_probe unable to read config register.\n"); | ||
202 | else { | ||
203 | conf &= ~(1 << 7); | ||
204 | i2c_smbus_write_byte_data(client, AD7414_REG_CONF, conf); | ||
205 | } | ||
206 | |||
207 | /* Register sysfs hooks */ | ||
208 | err = sysfs_create_group(&client->dev.kobj, &ad7414_group); | ||
209 | if (err) | ||
210 | goto exit_free; | ||
211 | |||
212 | data->hwmon_dev = hwmon_device_register(&client->dev); | ||
213 | if (IS_ERR(data->hwmon_dev)) { | ||
214 | err = PTR_ERR(data->hwmon_dev); | ||
215 | goto exit_remove; | ||
216 | } | ||
217 | |||
218 | return 0; | ||
219 | |||
220 | exit_remove: | ||
221 | sysfs_remove_group(&client->dev.kobj, &ad7414_group); | ||
222 | exit_free: | ||
223 | kfree(data); | ||
224 | exit: | ||
225 | return err; | ||
226 | } | ||
227 | |||
228 | static int __devexit ad7414_remove(struct i2c_client *client) | ||
229 | { | ||
230 | struct ad7414_data *data = i2c_get_clientdata(client); | ||
231 | |||
232 | hwmon_device_unregister(data->hwmon_dev); | ||
233 | sysfs_remove_group(&client->dev.kobj, &ad7414_group); | ||
234 | kfree(data); | ||
235 | return 0; | ||
236 | } | ||
237 | |||
238 | static const struct i2c_device_id ad7414_id[] = { | ||
239 | { "ad7414", 0 }, | ||
240 | {} | ||
241 | }; | ||
242 | |||
243 | static struct i2c_driver ad7414_driver = { | ||
244 | .driver = { | ||
245 | .name = "ad7414", | ||
246 | }, | ||
247 | .probe = ad7414_probe, | ||
248 | .remove = __devexit_p(ad7414_remove), | ||
249 | .id_table = ad7414_id, | ||
250 | }; | ||
251 | |||
252 | static int __init ad7414_init(void) | ||
253 | { | ||
254 | return i2c_add_driver(&ad7414_driver); | ||
255 | } | ||
256 | module_init(ad7414_init); | ||
257 | |||
258 | static void __exit ad7414_exit(void) | ||
259 | { | ||
260 | i2c_del_driver(&ad7414_driver); | ||
261 | } | ||
262 | module_exit(ad7414_exit); | ||
263 | |||
264 | MODULE_AUTHOR("Stefan Roese <sr at denx.de>, " | ||
265 | "Frank Edelhaeuser <frank.edelhaeuser at spansion.com>"); | ||
266 | |||
267 | MODULE_DESCRIPTION("AD7414 driver"); | ||
268 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/hwmon/adt7473.c b/drivers/hwmon/adt7473.c index ce4a7cb5a116..3a0b63136479 100644 --- a/drivers/hwmon/adt7473.c +++ b/drivers/hwmon/adt7473.c | |||
@@ -39,32 +39,20 @@ I2C_CLIENT_INSMOD_1(adt7473); | |||
39 | #define ADT7473_REG_BASE_ADDR 0x20 | 39 | #define ADT7473_REG_BASE_ADDR 0x20 |
40 | 40 | ||
41 | #define ADT7473_REG_VOLT_BASE_ADDR 0x21 | 41 | #define ADT7473_REG_VOLT_BASE_ADDR 0x21 |
42 | #define ADT7473_REG_VOLT_MAX_ADDR 0x22 | ||
43 | #define ADT7473_REG_VOLT_MIN_BASE_ADDR 0x46 | 42 | #define ADT7473_REG_VOLT_MIN_BASE_ADDR 0x46 |
44 | #define ADT7473_REG_VOLT_MIN_MAX_ADDR 0x49 | ||
45 | 43 | ||
46 | #define ADT7473_REG_TEMP_BASE_ADDR 0x25 | 44 | #define ADT7473_REG_TEMP_BASE_ADDR 0x25 |
47 | #define ADT7473_REG_TEMP_MAX_ADDR 0x27 | ||
48 | #define ADT7473_REG_TEMP_LIMITS_BASE_ADDR 0x4E | 45 | #define ADT7473_REG_TEMP_LIMITS_BASE_ADDR 0x4E |
49 | #define ADT7473_REG_TEMP_LIMITS_MAX_ADDR 0x53 | ||
50 | #define ADT7473_REG_TEMP_TMIN_BASE_ADDR 0x67 | 46 | #define ADT7473_REG_TEMP_TMIN_BASE_ADDR 0x67 |
51 | #define ADT7473_REG_TEMP_TMIN_MAX_ADDR 0x69 | ||
52 | #define ADT7473_REG_TEMP_TMAX_BASE_ADDR 0x6A | 47 | #define ADT7473_REG_TEMP_TMAX_BASE_ADDR 0x6A |
53 | #define ADT7473_REG_TEMP_TMAX_MAX_ADDR 0x6C | ||
54 | 48 | ||
55 | #define ADT7473_REG_FAN_BASE_ADDR 0x28 | 49 | #define ADT7473_REG_FAN_BASE_ADDR 0x28 |
56 | #define ADT7473_REG_FAN_MAX_ADDR 0x2F | ||
57 | #define ADT7473_REG_FAN_MIN_BASE_ADDR 0x54 | 50 | #define ADT7473_REG_FAN_MIN_BASE_ADDR 0x54 |
58 | #define ADT7473_REG_FAN_MIN_MAX_ADDR 0x5B | ||
59 | 51 | ||
60 | #define ADT7473_REG_PWM_BASE_ADDR 0x30 | 52 | #define ADT7473_REG_PWM_BASE_ADDR 0x30 |
61 | #define ADT7473_REG_PWM_MAX_ADDR 0x32 | ||
62 | #define ADT7473_REG_PWM_MIN_BASE_ADDR 0x64 | 53 | #define ADT7473_REG_PWM_MIN_BASE_ADDR 0x64 |
63 | #define ADT7473_REG_PWM_MIN_MAX_ADDR 0x66 | ||
64 | #define ADT7473_REG_PWM_MAX_BASE_ADDR 0x38 | 54 | #define ADT7473_REG_PWM_MAX_BASE_ADDR 0x38 |
65 | #define ADT7473_REG_PWM_MAX_MAX_ADDR 0x3A | ||
66 | #define ADT7473_REG_PWM_BHVR_BASE_ADDR 0x5C | 55 | #define ADT7473_REG_PWM_BHVR_BASE_ADDR 0x5C |
67 | #define ADT7473_REG_PWM_BHVR_MAX_ADDR 0x5E | ||
68 | #define ADT7473_PWM_BHVR_MASK 0xE0 | 56 | #define ADT7473_PWM_BHVR_MASK 0xE0 |
69 | #define ADT7473_PWM_BHVR_SHIFT 5 | 57 | #define ADT7473_PWM_BHVR_SHIFT 5 |
70 | 58 | ||
@@ -102,7 +90,6 @@ I2C_CLIENT_INSMOD_1(adt7473); | |||
102 | #define ADT7473_FAN4_ALARM 0x20 | 90 | #define ADT7473_FAN4_ALARM 0x20 |
103 | #define ADT7473_R1T_SHORT 0x40 | 91 | #define ADT7473_R1T_SHORT 0x40 |
104 | #define ADT7473_R2T_SHORT 0x80 | 92 | #define ADT7473_R2T_SHORT 0x80 |
105 | #define ADT7473_REG_MAX_ADDR 0x80 | ||
106 | 93 | ||
107 | #define ALARM2(x) ((x) << 8) | 94 | #define ALARM2(x) ((x) << 8) |
108 | 95 | ||
@@ -583,10 +570,9 @@ static ssize_t set_max_duty_at_crit(struct device *dev, | |||
583 | struct i2c_client *client = to_i2c_client(dev); | 570 | struct i2c_client *client = to_i2c_client(dev); |
584 | struct adt7473_data *data = i2c_get_clientdata(client); | 571 | struct adt7473_data *data = i2c_get_clientdata(client); |
585 | int temp = simple_strtol(buf, NULL, 10); | 572 | int temp = simple_strtol(buf, NULL, 10); |
586 | temp = temp && 0xFF; | ||
587 | 573 | ||
588 | mutex_lock(&data->lock); | 574 | mutex_lock(&data->lock); |
589 | data->max_duty_at_overheat = temp; | 575 | data->max_duty_at_overheat = !!temp; |
590 | reg = i2c_smbus_read_byte_data(client, ADT7473_REG_CFG4); | 576 | reg = i2c_smbus_read_byte_data(client, ADT7473_REG_CFG4); |
591 | if (temp) | 577 | if (temp) |
592 | reg |= ADT7473_CFG4_MAX_DUTY_AT_OVT; | 578 | reg |= ADT7473_CFG4_MAX_DUTY_AT_OVT; |
diff --git a/drivers/hwmon/dme1737.c b/drivers/hwmon/dme1737.c index 7673f65877e1..cdb8311e4ef7 100644 --- a/drivers/hwmon/dme1737.c +++ b/drivers/hwmon/dme1737.c | |||
@@ -1,11 +1,11 @@ | |||
1 | /* | 1 | /* |
2 | * dme1737.c - Driver for the SMSC DME1737, Asus A8000, and SMSC SCH311x | 2 | * dme1737.c - Driver for the SMSC DME1737, Asus A8000, SMSC SCH311x and |
3 | * Super-I/O chips integrated hardware monitoring features. | 3 | * SCH5027 Super-I/O chips integrated hardware monitoring features. |
4 | * Copyright (c) 2007 Juerg Haefliger <juergh@gmail.com> | 4 | * Copyright (c) 2007, 2008 Juerg Haefliger <juergh@gmail.com> |
5 | * | 5 | * |
6 | * This driver is an I2C/ISA hybrid, meaning that it uses the I2C bus to access | 6 | * This driver is an I2C/ISA hybrid, meaning that it uses the I2C bus to access |
7 | * the chip registers if a DME1737 (or A8000) is found and the ISA bus if a | 7 | * the chip registers if a DME1737, A8000, or SCH5027 is found and the ISA bus |
8 | * SCH311x chip is found. Both types of chips have very similar hardware | 8 | * if a SCH311x chip is found. Both types of chips have very similar hardware |
9 | * monitoring capabilities but differ in the way they can be accessed. | 9 | * monitoring capabilities but differ in the way they can be accessed. |
10 | * | 10 | * |
11 | * This program is free software; you can redistribute it and/or modify | 11 | * This program is free software; you can redistribute it and/or modify |
@@ -48,11 +48,19 @@ static unsigned short force_id; | |||
48 | module_param(force_id, ushort, 0); | 48 | module_param(force_id, ushort, 0); |
49 | MODULE_PARM_DESC(force_id, "Override the detected device ID"); | 49 | MODULE_PARM_DESC(force_id, "Override the detected device ID"); |
50 | 50 | ||
51 | static int probe_all_addr; | ||
52 | module_param(probe_all_addr, bool, 0); | ||
53 | MODULE_PARM_DESC(probe_all_addr, "Include probing of non-standard LPC " | ||
54 | "addresses"); | ||
55 | |||
51 | /* Addresses to scan */ | 56 | /* Addresses to scan */ |
52 | static const unsigned short normal_i2c[] = {0x2c, 0x2d, 0x2e, I2C_CLIENT_END}; | 57 | static const unsigned short normal_i2c[] = {0x2c, 0x2d, 0x2e, I2C_CLIENT_END}; |
53 | 58 | ||
54 | /* Insmod parameters */ | 59 | /* Insmod parameters */ |
55 | I2C_CLIENT_INSMOD_1(dme1737); | 60 | I2C_CLIENT_INSMOD_2(dme1737, sch5027); |
61 | |||
62 | /* ISA chip types */ | ||
63 | enum isa_chips { sch311x = sch5027 + 1 }; | ||
56 | 64 | ||
57 | /* --------------------------------------------------------------------- | 65 | /* --------------------------------------------------------------------- |
58 | * Registers | 66 | * Registers |
@@ -158,6 +166,7 @@ static const u8 DME1737_BIT_ALARM_FAN[] = {10, 11, 12, 13, 22, 23}; | |||
158 | #define DME1737_VERSTEP 0x88 | 166 | #define DME1737_VERSTEP 0x88 |
159 | #define DME1737_VERSTEP_MASK 0xf8 | 167 | #define DME1737_VERSTEP_MASK 0xf8 |
160 | #define SCH311X_DEVICE 0x8c | 168 | #define SCH311X_DEVICE 0x8c |
169 | #define SCH5027_VERSTEP 0x69 | ||
161 | 170 | ||
162 | /* Length of ISA address segment */ | 171 | /* Length of ISA address segment */ |
163 | #define DME1737_EXTENT 2 | 172 | #define DME1737_EXTENT 2 |
@@ -176,6 +185,8 @@ struct dme1737_data { | |||
176 | int valid; /* !=0 if following fields are valid */ | 185 | int valid; /* !=0 if following fields are valid */ |
177 | unsigned long last_update; /* in jiffies */ | 186 | unsigned long last_update; /* in jiffies */ |
178 | unsigned long last_vbat; /* in jiffies */ | 187 | unsigned long last_vbat; /* in jiffies */ |
188 | enum chips type; | ||
189 | const int *in_nominal; /* pointer to IN_NOMINAL array */ | ||
179 | 190 | ||
180 | u8 vid; | 191 | u8 vid; |
181 | u8 pwm_rr_en; | 192 | u8 pwm_rr_en; |
@@ -210,20 +221,27 @@ struct dme1737_data { | |||
210 | }; | 221 | }; |
211 | 222 | ||
212 | /* Nominal voltage values */ | 223 | /* Nominal voltage values */ |
213 | static const int IN_NOMINAL[] = {5000, 2250, 3300, 5000, 12000, 3300, 3300}; | 224 | static const int IN_NOMINAL_DME1737[] = {5000, 2250, 3300, 5000, 12000, 3300, |
225 | 3300}; | ||
226 | static const int IN_NOMINAL_SCH311x[] = {2500, 1500, 3300, 5000, 12000, 3300, | ||
227 | 3300}; | ||
228 | static const int IN_NOMINAL_SCH5027[] = {5000, 2250, 3300, 1125, 1125, 3300, | ||
229 | 3300}; | ||
230 | #define IN_NOMINAL(type) ((type) == sch311x ? IN_NOMINAL_SCH311x : \ | ||
231 | (type) == sch5027 ? IN_NOMINAL_SCH5027 : \ | ||
232 | IN_NOMINAL_DME1737) | ||
214 | 233 | ||
215 | /* Voltage input | 234 | /* Voltage input |
216 | * Voltage inputs have 16 bits resolution, limit values have 8 bits | 235 | * Voltage inputs have 16 bits resolution, limit values have 8 bits |
217 | * resolution. */ | 236 | * resolution. */ |
218 | static inline int IN_FROM_REG(int reg, int ix, int res) | 237 | static inline int IN_FROM_REG(int reg, int nominal, int res) |
219 | { | 238 | { |
220 | return (reg * IN_NOMINAL[ix] + (3 << (res - 3))) / (3 << (res - 2)); | 239 | return (reg * nominal + (3 << (res - 3))) / (3 << (res - 2)); |
221 | } | 240 | } |
222 | 241 | ||
223 | static inline int IN_TO_REG(int val, int ix) | 242 | static inline int IN_TO_REG(int val, int nominal) |
224 | { | 243 | { |
225 | return SENSORS_LIMIT((val * 192 + IN_NOMINAL[ix] / 2) / | 244 | return SENSORS_LIMIT((val * 192 + nominal / 2) / nominal, 0, 255); |
226 | IN_NOMINAL[ix], 0, 255); | ||
227 | } | 245 | } |
228 | 246 | ||
229 | /* Temperature input | 247 | /* Temperature input |
@@ -552,7 +570,10 @@ static struct dme1737_data *dme1737_update_device(struct device *dev) | |||
552 | 570 | ||
553 | /* Sample register contents every 1 sec */ | 571 | /* Sample register contents every 1 sec */ |
554 | if (time_after(jiffies, data->last_update + HZ) || !data->valid) { | 572 | if (time_after(jiffies, data->last_update + HZ) || !data->valid) { |
555 | data->vid = dme1737_read(client, DME1737_REG_VID) & 0x3f; | 573 | if (data->type != sch5027) { |
574 | data->vid = dme1737_read(client, DME1737_REG_VID) & | ||
575 | 0x3f; | ||
576 | } | ||
556 | 577 | ||
557 | /* In (voltage) registers */ | 578 | /* In (voltage) registers */ |
558 | for (ix = 0; ix < ARRAY_SIZE(data->in); ix++) { | 579 | for (ix = 0; ix < ARRAY_SIZE(data->in); ix++) { |
@@ -580,8 +601,10 @@ static struct dme1737_data *dme1737_update_device(struct device *dev) | |||
580 | DME1737_REG_TEMP_MIN(ix)); | 601 | DME1737_REG_TEMP_MIN(ix)); |
581 | data->temp_max[ix] = dme1737_read(client, | 602 | data->temp_max[ix] = dme1737_read(client, |
582 | DME1737_REG_TEMP_MAX(ix)); | 603 | DME1737_REG_TEMP_MAX(ix)); |
583 | data->temp_offset[ix] = dme1737_read(client, | 604 | if (data->type != sch5027) { |
584 | DME1737_REG_TEMP_OFFSET(ix)); | 605 | data->temp_offset[ix] = dme1737_read(client, |
606 | DME1737_REG_TEMP_OFFSET(ix)); | ||
607 | } | ||
585 | } | 608 | } |
586 | 609 | ||
587 | /* In and temp LSB registers | 610 | /* In and temp LSB registers |
@@ -656,9 +679,11 @@ static struct dme1737_data *dme1737_update_device(struct device *dev) | |||
656 | data->zone_abs[ix] = dme1737_read(client, | 679 | data->zone_abs[ix] = dme1737_read(client, |
657 | DME1737_REG_ZONE_ABS(ix)); | 680 | DME1737_REG_ZONE_ABS(ix)); |
658 | } | 681 | } |
659 | for (ix = 0; ix < ARRAY_SIZE(data->zone_hyst); ix++) { | 682 | if (data->type != sch5027) { |
660 | data->zone_hyst[ix] = dme1737_read(client, | 683 | for (ix = 0; ix < ARRAY_SIZE(data->zone_hyst); ix++) { |
684 | data->zone_hyst[ix] = dme1737_read(client, | ||
661 | DME1737_REG_ZONE_HYST(ix)); | 685 | DME1737_REG_ZONE_HYST(ix)); |
686 | } | ||
662 | } | 687 | } |
663 | 688 | ||
664 | /* Alarm registers */ | 689 | /* Alarm registers */ |
@@ -722,13 +747,13 @@ static ssize_t show_in(struct device *dev, struct device_attribute *attr, | |||
722 | 747 | ||
723 | switch (fn) { | 748 | switch (fn) { |
724 | case SYS_IN_INPUT: | 749 | case SYS_IN_INPUT: |
725 | res = IN_FROM_REG(data->in[ix], ix, 16); | 750 | res = IN_FROM_REG(data->in[ix], data->in_nominal[ix], 16); |
726 | break; | 751 | break; |
727 | case SYS_IN_MIN: | 752 | case SYS_IN_MIN: |
728 | res = IN_FROM_REG(data->in_min[ix], ix, 8); | 753 | res = IN_FROM_REG(data->in_min[ix], data->in_nominal[ix], 8); |
729 | break; | 754 | break; |
730 | case SYS_IN_MAX: | 755 | case SYS_IN_MAX: |
731 | res = IN_FROM_REG(data->in_max[ix], ix, 8); | 756 | res = IN_FROM_REG(data->in_max[ix], data->in_nominal[ix], 8); |
732 | break; | 757 | break; |
733 | case SYS_IN_ALARM: | 758 | case SYS_IN_ALARM: |
734 | res = (data->alarms >> DME1737_BIT_ALARM_IN[ix]) & 0x01; | 759 | res = (data->alarms >> DME1737_BIT_ALARM_IN[ix]) & 0x01; |
@@ -755,12 +780,12 @@ static ssize_t set_in(struct device *dev, struct device_attribute *attr, | |||
755 | mutex_lock(&data->update_lock); | 780 | mutex_lock(&data->update_lock); |
756 | switch (fn) { | 781 | switch (fn) { |
757 | case SYS_IN_MIN: | 782 | case SYS_IN_MIN: |
758 | data->in_min[ix] = IN_TO_REG(val, ix); | 783 | data->in_min[ix] = IN_TO_REG(val, data->in_nominal[ix]); |
759 | dme1737_write(client, DME1737_REG_IN_MIN(ix), | 784 | dme1737_write(client, DME1737_REG_IN_MIN(ix), |
760 | data->in_min[ix]); | 785 | data->in_min[ix]); |
761 | break; | 786 | break; |
762 | case SYS_IN_MAX: | 787 | case SYS_IN_MAX: |
763 | data->in_max[ix] = IN_TO_REG(val, ix); | 788 | data->in_max[ix] = IN_TO_REG(val, data->in_nominal[ix]); |
764 | dme1737_write(client, DME1737_REG_IN_MAX(ix), | 789 | dme1737_write(client, DME1737_REG_IN_MAX(ix), |
765 | data->in_max[ix]); | 790 | data->in_max[ix]); |
766 | break; | 791 | break; |
@@ -1153,7 +1178,7 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *attr, | |||
1153 | return sprintf(buf, "%d\n", res); | 1178 | return sprintf(buf, "%d\n", res); |
1154 | } | 1179 | } |
1155 | 1180 | ||
1156 | static struct attribute *dme1737_attr_pwm[]; | 1181 | static struct attribute *dme1737_pwm_chmod_attr[]; |
1157 | static void dme1737_chmod_file(struct device*, struct attribute*, mode_t); | 1182 | static void dme1737_chmod_file(struct device*, struct attribute*, mode_t); |
1158 | 1183 | ||
1159 | static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, | 1184 | static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, |
@@ -1217,7 +1242,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, | |||
1217 | switch (val) { | 1242 | switch (val) { |
1218 | case 0: | 1243 | case 0: |
1219 | /* Change permissions of pwm[ix] to read-only */ | 1244 | /* Change permissions of pwm[ix] to read-only */ |
1220 | dme1737_chmod_file(dev, dme1737_attr_pwm[ix], | 1245 | dme1737_chmod_file(dev, dme1737_pwm_chmod_attr[ix], |
1221 | S_IRUGO); | 1246 | S_IRUGO); |
1222 | /* Turn fan fully on */ | 1247 | /* Turn fan fully on */ |
1223 | data->pwm_config[ix] = PWM_EN_TO_REG(0, | 1248 | data->pwm_config[ix] = PWM_EN_TO_REG(0, |
@@ -1232,12 +1257,12 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, | |||
1232 | dme1737_write(client, DME1737_REG_PWM_CONFIG(ix), | 1257 | dme1737_write(client, DME1737_REG_PWM_CONFIG(ix), |
1233 | data->pwm_config[ix]); | 1258 | data->pwm_config[ix]); |
1234 | /* Change permissions of pwm[ix] to read-writeable */ | 1259 | /* Change permissions of pwm[ix] to read-writeable */ |
1235 | dme1737_chmod_file(dev, dme1737_attr_pwm[ix], | 1260 | dme1737_chmod_file(dev, dme1737_pwm_chmod_attr[ix], |
1236 | S_IRUGO | S_IWUSR); | 1261 | S_IRUGO | S_IWUSR); |
1237 | break; | 1262 | break; |
1238 | case 2: | 1263 | case 2: |
1239 | /* Change permissions of pwm[ix] to read-only */ | 1264 | /* Change permissions of pwm[ix] to read-only */ |
1240 | dme1737_chmod_file(dev, dme1737_attr_pwm[ix], | 1265 | dme1737_chmod_file(dev, dme1737_pwm_chmod_attr[ix], |
1241 | S_IRUGO); | 1266 | S_IRUGO); |
1242 | /* Turn on auto mode using the saved zone channel | 1267 | /* Turn on auto mode using the saved zone channel |
1243 | * assignment */ | 1268 | * assignment */ |
@@ -1501,9 +1526,9 @@ SENSOR_DEVICE_ATTR_PWM_1TO3(3); | |||
1501 | /* PWMs 5-6 */ | 1526 | /* PWMs 5-6 */ |
1502 | 1527 | ||
1503 | #define SENSOR_DEVICE_ATTR_PWM_5TO6(ix) \ | 1528 | #define SENSOR_DEVICE_ATTR_PWM_5TO6(ix) \ |
1504 | static SENSOR_DEVICE_ATTR_2(pwm##ix, S_IRUGO | S_IWUSR, \ | 1529 | static SENSOR_DEVICE_ATTR_2(pwm##ix, S_IRUGO, \ |
1505 | show_pwm, set_pwm, SYS_PWM, ix-1); \ | 1530 | show_pwm, set_pwm, SYS_PWM, ix-1); \ |
1506 | static SENSOR_DEVICE_ATTR_2(pwm##ix##_freq, S_IRUGO | S_IWUSR, \ | 1531 | static SENSOR_DEVICE_ATTR_2(pwm##ix##_freq, S_IRUGO, \ |
1507 | show_pwm, set_pwm, SYS_PWM_FREQ, ix-1); \ | 1532 | show_pwm, set_pwm, SYS_PWM_FREQ, ix-1); \ |
1508 | static SENSOR_DEVICE_ATTR_2(pwm##ix##_enable, S_IRUGO, \ | 1533 | static SENSOR_DEVICE_ATTR_2(pwm##ix##_enable, S_IRUGO, \ |
1509 | show_pwm, NULL, SYS_PWM_ENABLE, ix-1) | 1534 | show_pwm, NULL, SYS_PWM_ENABLE, ix-1) |
@@ -1517,225 +1542,286 @@ static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm); | |||
1517 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); | 1542 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); |
1518 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); /* for ISA devices */ | 1543 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); /* for ISA devices */ |
1519 | 1544 | ||
1520 | #define SENSOR_DEV_ATTR_IN(ix) \ | ||
1521 | &sensor_dev_attr_in##ix##_input.dev_attr.attr, \ | ||
1522 | &sensor_dev_attr_in##ix##_min.dev_attr.attr, \ | ||
1523 | &sensor_dev_attr_in##ix##_max.dev_attr.attr, \ | ||
1524 | &sensor_dev_attr_in##ix##_alarm.dev_attr.attr | ||
1525 | |||
1526 | /* These attributes are read-writeable only if the chip is *not* locked */ | ||
1527 | #define SENSOR_DEV_ATTR_TEMP_LOCK(ix) \ | ||
1528 | &sensor_dev_attr_temp##ix##_offset.dev_attr.attr | ||
1529 | |||
1530 | #define SENSOR_DEV_ATTR_TEMP(ix) \ | ||
1531 | SENSOR_DEV_ATTR_TEMP_LOCK(ix), \ | ||
1532 | &sensor_dev_attr_temp##ix##_input.dev_attr.attr, \ | ||
1533 | &sensor_dev_attr_temp##ix##_min.dev_attr.attr, \ | ||
1534 | &sensor_dev_attr_temp##ix##_max.dev_attr.attr, \ | ||
1535 | &sensor_dev_attr_temp##ix##_alarm.dev_attr.attr, \ | ||
1536 | &sensor_dev_attr_temp##ix##_fault.dev_attr.attr | ||
1537 | |||
1538 | /* These attributes are read-writeable only if the chip is *not* locked */ | ||
1539 | #define SENSOR_DEV_ATTR_ZONE_LOCK(ix) \ | ||
1540 | &sensor_dev_attr_zone##ix##_auto_point1_temp_hyst.dev_attr.attr, \ | ||
1541 | &sensor_dev_attr_zone##ix##_auto_point1_temp.dev_attr.attr, \ | ||
1542 | &sensor_dev_attr_zone##ix##_auto_point2_temp.dev_attr.attr, \ | ||
1543 | &sensor_dev_attr_zone##ix##_auto_point3_temp.dev_attr.attr | ||
1544 | |||
1545 | #define SENSOR_DEV_ATTR_ZONE(ix) \ | ||
1546 | SENSOR_DEV_ATTR_ZONE_LOCK(ix), \ | ||
1547 | &sensor_dev_attr_zone##ix##_auto_channels_temp.dev_attr.attr | ||
1548 | |||
1549 | #define SENSOR_DEV_ATTR_FAN_1TO4(ix) \ | ||
1550 | &sensor_dev_attr_fan##ix##_input.dev_attr.attr, \ | ||
1551 | &sensor_dev_attr_fan##ix##_min.dev_attr.attr, \ | ||
1552 | &sensor_dev_attr_fan##ix##_alarm.dev_attr.attr, \ | ||
1553 | &sensor_dev_attr_fan##ix##_type.dev_attr.attr | ||
1554 | |||
1555 | #define SENSOR_DEV_ATTR_FAN_5TO6(ix) \ | ||
1556 | &sensor_dev_attr_fan##ix##_input.dev_attr.attr, \ | ||
1557 | &sensor_dev_attr_fan##ix##_min.dev_attr.attr, \ | ||
1558 | &sensor_dev_attr_fan##ix##_alarm.dev_attr.attr, \ | ||
1559 | &sensor_dev_attr_fan##ix##_max.dev_attr.attr | ||
1560 | |||
1561 | /* These attributes are read-writeable only if the chip is *not* locked */ | ||
1562 | #define SENSOR_DEV_ATTR_PWM_1TO3_LOCK(ix) \ | ||
1563 | &sensor_dev_attr_pwm##ix##_freq.dev_attr.attr, \ | ||
1564 | &sensor_dev_attr_pwm##ix##_enable.dev_attr.attr, \ | ||
1565 | &sensor_dev_attr_pwm##ix##_ramp_rate.dev_attr.attr, \ | ||
1566 | &sensor_dev_attr_pwm##ix##_auto_channels_zone.dev_attr.attr, \ | ||
1567 | &sensor_dev_attr_pwm##ix##_auto_pwm_min.dev_attr.attr, \ | ||
1568 | &sensor_dev_attr_pwm##ix##_auto_point1_pwm.dev_attr.attr | ||
1569 | |||
1570 | #define SENSOR_DEV_ATTR_PWM_1TO3(ix) \ | ||
1571 | SENSOR_DEV_ATTR_PWM_1TO3_LOCK(ix), \ | ||
1572 | &sensor_dev_attr_pwm##ix.dev_attr.attr, \ | ||
1573 | &sensor_dev_attr_pwm##ix##_auto_point2_pwm.dev_attr.attr | ||
1574 | |||
1575 | /* These attributes are read-writeable only if the chip is *not* locked */ | ||
1576 | #define SENSOR_DEV_ATTR_PWM_5TO6_LOCK(ix) \ | ||
1577 | &sensor_dev_attr_pwm##ix.dev_attr.attr, \ | ||
1578 | &sensor_dev_attr_pwm##ix##_freq.dev_attr.attr | ||
1579 | |||
1580 | #define SENSOR_DEV_ATTR_PWM_5TO6(ix) \ | ||
1581 | SENSOR_DEV_ATTR_PWM_5TO6_LOCK(ix), \ | ||
1582 | &sensor_dev_attr_pwm##ix##_enable.dev_attr.attr | ||
1583 | |||
1584 | /* This struct holds all the attributes that are always present and need to be | 1545 | /* This struct holds all the attributes that are always present and need to be |
1585 | * created unconditionally. The attributes that need modification of their | 1546 | * created unconditionally. The attributes that need modification of their |
1586 | * permissions are created read-only and write permissions are added or removed | 1547 | * permissions are created read-only and write permissions are added or removed |
1587 | * on the fly when required */ | 1548 | * on the fly when required */ |
1588 | static struct attribute *dme1737_attr[] ={ | 1549 | static struct attribute *dme1737_attr[] ={ |
1589 | /* Voltages */ | 1550 | /* Voltages */ |
1590 | SENSOR_DEV_ATTR_IN(0), | 1551 | &sensor_dev_attr_in0_input.dev_attr.attr, |
1591 | SENSOR_DEV_ATTR_IN(1), | 1552 | &sensor_dev_attr_in0_min.dev_attr.attr, |
1592 | SENSOR_DEV_ATTR_IN(2), | 1553 | &sensor_dev_attr_in0_max.dev_attr.attr, |
1593 | SENSOR_DEV_ATTR_IN(3), | 1554 | &sensor_dev_attr_in0_alarm.dev_attr.attr, |
1594 | SENSOR_DEV_ATTR_IN(4), | 1555 | &sensor_dev_attr_in1_input.dev_attr.attr, |
1595 | SENSOR_DEV_ATTR_IN(5), | 1556 | &sensor_dev_attr_in1_min.dev_attr.attr, |
1596 | SENSOR_DEV_ATTR_IN(6), | 1557 | &sensor_dev_attr_in1_max.dev_attr.attr, |
1558 | &sensor_dev_attr_in1_alarm.dev_attr.attr, | ||
1559 | &sensor_dev_attr_in2_input.dev_attr.attr, | ||
1560 | &sensor_dev_attr_in2_min.dev_attr.attr, | ||
1561 | &sensor_dev_attr_in2_max.dev_attr.attr, | ||
1562 | &sensor_dev_attr_in2_alarm.dev_attr.attr, | ||
1563 | &sensor_dev_attr_in3_input.dev_attr.attr, | ||
1564 | &sensor_dev_attr_in3_min.dev_attr.attr, | ||
1565 | &sensor_dev_attr_in3_max.dev_attr.attr, | ||
1566 | &sensor_dev_attr_in3_alarm.dev_attr.attr, | ||
1567 | &sensor_dev_attr_in4_input.dev_attr.attr, | ||
1568 | &sensor_dev_attr_in4_min.dev_attr.attr, | ||
1569 | &sensor_dev_attr_in4_max.dev_attr.attr, | ||
1570 | &sensor_dev_attr_in4_alarm.dev_attr.attr, | ||
1571 | &sensor_dev_attr_in5_input.dev_attr.attr, | ||
1572 | &sensor_dev_attr_in5_min.dev_attr.attr, | ||
1573 | &sensor_dev_attr_in5_max.dev_attr.attr, | ||
1574 | &sensor_dev_attr_in5_alarm.dev_attr.attr, | ||
1575 | &sensor_dev_attr_in6_input.dev_attr.attr, | ||
1576 | &sensor_dev_attr_in6_min.dev_attr.attr, | ||
1577 | &sensor_dev_attr_in6_max.dev_attr.attr, | ||
1578 | &sensor_dev_attr_in6_alarm.dev_attr.attr, | ||
1579 | /* Temperatures */ | ||
1580 | &sensor_dev_attr_temp1_input.dev_attr.attr, | ||
1581 | &sensor_dev_attr_temp1_min.dev_attr.attr, | ||
1582 | &sensor_dev_attr_temp1_max.dev_attr.attr, | ||
1583 | &sensor_dev_attr_temp1_alarm.dev_attr.attr, | ||
1584 | &sensor_dev_attr_temp1_fault.dev_attr.attr, | ||
1585 | &sensor_dev_attr_temp2_input.dev_attr.attr, | ||
1586 | &sensor_dev_attr_temp2_min.dev_attr.attr, | ||
1587 | &sensor_dev_attr_temp2_max.dev_attr.attr, | ||
1588 | &sensor_dev_attr_temp2_alarm.dev_attr.attr, | ||
1589 | &sensor_dev_attr_temp2_fault.dev_attr.attr, | ||
1590 | &sensor_dev_attr_temp3_input.dev_attr.attr, | ||
1591 | &sensor_dev_attr_temp3_min.dev_attr.attr, | ||
1592 | &sensor_dev_attr_temp3_max.dev_attr.attr, | ||
1593 | &sensor_dev_attr_temp3_alarm.dev_attr.attr, | ||
1594 | &sensor_dev_attr_temp3_fault.dev_attr.attr, | ||
1595 | /* Zones */ | ||
1596 | &sensor_dev_attr_zone1_auto_point1_temp.dev_attr.attr, | ||
1597 | &sensor_dev_attr_zone1_auto_point2_temp.dev_attr.attr, | ||
1598 | &sensor_dev_attr_zone1_auto_point3_temp.dev_attr.attr, | ||
1599 | &sensor_dev_attr_zone1_auto_channels_temp.dev_attr.attr, | ||
1600 | &sensor_dev_attr_zone2_auto_point1_temp.dev_attr.attr, | ||
1601 | &sensor_dev_attr_zone2_auto_point2_temp.dev_attr.attr, | ||
1602 | &sensor_dev_attr_zone2_auto_point3_temp.dev_attr.attr, | ||
1603 | &sensor_dev_attr_zone2_auto_channels_temp.dev_attr.attr, | ||
1604 | &sensor_dev_attr_zone3_auto_point1_temp.dev_attr.attr, | ||
1605 | &sensor_dev_attr_zone3_auto_point2_temp.dev_attr.attr, | ||
1606 | &sensor_dev_attr_zone3_auto_point3_temp.dev_attr.attr, | ||
1607 | &sensor_dev_attr_zone3_auto_channels_temp.dev_attr.attr, | ||
1608 | NULL | ||
1609 | }; | ||
1610 | |||
1611 | static const struct attribute_group dme1737_group = { | ||
1612 | .attrs = dme1737_attr, | ||
1613 | }; | ||
1614 | |||
1615 | /* The following struct holds misc attributes, which are not available in all | ||
1616 | * chips. Their creation depends on the chip type which is determined during | ||
1617 | * module load. */ | ||
1618 | static struct attribute *dme1737_misc_attr[] = { | ||
1597 | /* Temperatures */ | 1619 | /* Temperatures */ |
1598 | SENSOR_DEV_ATTR_TEMP(1), | 1620 | &sensor_dev_attr_temp1_offset.dev_attr.attr, |
1599 | SENSOR_DEV_ATTR_TEMP(2), | 1621 | &sensor_dev_attr_temp2_offset.dev_attr.attr, |
1600 | SENSOR_DEV_ATTR_TEMP(3), | 1622 | &sensor_dev_attr_temp3_offset.dev_attr.attr, |
1601 | /* Zones */ | 1623 | /* Zones */ |
1602 | SENSOR_DEV_ATTR_ZONE(1), | 1624 | &sensor_dev_attr_zone1_auto_point1_temp_hyst.dev_attr.attr, |
1603 | SENSOR_DEV_ATTR_ZONE(2), | 1625 | &sensor_dev_attr_zone2_auto_point1_temp_hyst.dev_attr.attr, |
1604 | SENSOR_DEV_ATTR_ZONE(3), | 1626 | &sensor_dev_attr_zone3_auto_point1_temp_hyst.dev_attr.attr, |
1605 | /* Misc */ | 1627 | /* Misc */ |
1606 | &dev_attr_vrm.attr, | 1628 | &dev_attr_vrm.attr, |
1607 | &dev_attr_cpu0_vid.attr, | 1629 | &dev_attr_cpu0_vid.attr, |
1608 | NULL | 1630 | NULL |
1609 | }; | 1631 | }; |
1610 | 1632 | ||
1611 | static const struct attribute_group dme1737_group = { | 1633 | static const struct attribute_group dme1737_misc_group = { |
1612 | .attrs = dme1737_attr, | 1634 | .attrs = dme1737_misc_attr, |
1613 | }; | 1635 | }; |
1614 | 1636 | ||
1615 | /* The following structs hold the PWM attributes, some of which are optional. | 1637 | /* The following structs hold the PWM attributes, some of which are optional. |
1616 | * Their creation depends on the chip configuration which is determined during | 1638 | * Their creation depends on the chip configuration which is determined during |
1617 | * module load. */ | 1639 | * module load. */ |
1618 | static struct attribute *dme1737_attr_pwm1[] = { | 1640 | static struct attribute *dme1737_pwm1_attr[] = { |
1619 | SENSOR_DEV_ATTR_PWM_1TO3(1), | 1641 | &sensor_dev_attr_pwm1.dev_attr.attr, |
1642 | &sensor_dev_attr_pwm1_freq.dev_attr.attr, | ||
1643 | &sensor_dev_attr_pwm1_enable.dev_attr.attr, | ||
1644 | &sensor_dev_attr_pwm1_ramp_rate.dev_attr.attr, | ||
1645 | &sensor_dev_attr_pwm1_auto_channels_zone.dev_attr.attr, | ||
1646 | &sensor_dev_attr_pwm1_auto_point1_pwm.dev_attr.attr, | ||
1647 | &sensor_dev_attr_pwm1_auto_point2_pwm.dev_attr.attr, | ||
1620 | NULL | 1648 | NULL |
1621 | }; | 1649 | }; |
1622 | static struct attribute *dme1737_attr_pwm2[] = { | 1650 | static struct attribute *dme1737_pwm2_attr[] = { |
1623 | SENSOR_DEV_ATTR_PWM_1TO3(2), | 1651 | &sensor_dev_attr_pwm2.dev_attr.attr, |
1652 | &sensor_dev_attr_pwm2_freq.dev_attr.attr, | ||
1653 | &sensor_dev_attr_pwm2_enable.dev_attr.attr, | ||
1654 | &sensor_dev_attr_pwm2_ramp_rate.dev_attr.attr, | ||
1655 | &sensor_dev_attr_pwm2_auto_channels_zone.dev_attr.attr, | ||
1656 | &sensor_dev_attr_pwm2_auto_point1_pwm.dev_attr.attr, | ||
1657 | &sensor_dev_attr_pwm2_auto_point2_pwm.dev_attr.attr, | ||
1624 | NULL | 1658 | NULL |
1625 | }; | 1659 | }; |
1626 | static struct attribute *dme1737_attr_pwm3[] = { | 1660 | static struct attribute *dme1737_pwm3_attr[] = { |
1627 | SENSOR_DEV_ATTR_PWM_1TO3(3), | 1661 | &sensor_dev_attr_pwm3.dev_attr.attr, |
1662 | &sensor_dev_attr_pwm3_freq.dev_attr.attr, | ||
1663 | &sensor_dev_attr_pwm3_enable.dev_attr.attr, | ||
1664 | &sensor_dev_attr_pwm3_ramp_rate.dev_attr.attr, | ||
1665 | &sensor_dev_attr_pwm3_auto_channels_zone.dev_attr.attr, | ||
1666 | &sensor_dev_attr_pwm3_auto_point1_pwm.dev_attr.attr, | ||
1667 | &sensor_dev_attr_pwm3_auto_point2_pwm.dev_attr.attr, | ||
1628 | NULL | 1668 | NULL |
1629 | }; | 1669 | }; |
1630 | static struct attribute *dme1737_attr_pwm5[] = { | 1670 | static struct attribute *dme1737_pwm5_attr[] = { |
1631 | SENSOR_DEV_ATTR_PWM_5TO6(5), | 1671 | &sensor_dev_attr_pwm5.dev_attr.attr, |
1672 | &sensor_dev_attr_pwm5_freq.dev_attr.attr, | ||
1673 | &sensor_dev_attr_pwm5_enable.dev_attr.attr, | ||
1632 | NULL | 1674 | NULL |
1633 | }; | 1675 | }; |
1634 | static struct attribute *dme1737_attr_pwm6[] = { | 1676 | static struct attribute *dme1737_pwm6_attr[] = { |
1635 | SENSOR_DEV_ATTR_PWM_5TO6(6), | 1677 | &sensor_dev_attr_pwm6.dev_attr.attr, |
1678 | &sensor_dev_attr_pwm6_freq.dev_attr.attr, | ||
1679 | &sensor_dev_attr_pwm6_enable.dev_attr.attr, | ||
1636 | NULL | 1680 | NULL |
1637 | }; | 1681 | }; |
1638 | 1682 | ||
1639 | static const struct attribute_group dme1737_pwm_group[] = { | 1683 | static const struct attribute_group dme1737_pwm_group[] = { |
1640 | { .attrs = dme1737_attr_pwm1 }, | 1684 | { .attrs = dme1737_pwm1_attr }, |
1641 | { .attrs = dme1737_attr_pwm2 }, | 1685 | { .attrs = dme1737_pwm2_attr }, |
1642 | { .attrs = dme1737_attr_pwm3 }, | 1686 | { .attrs = dme1737_pwm3_attr }, |
1643 | { .attrs = NULL }, | 1687 | { .attrs = NULL }, |
1644 | { .attrs = dme1737_attr_pwm5 }, | 1688 | { .attrs = dme1737_pwm5_attr }, |
1645 | { .attrs = dme1737_attr_pwm6 }, | 1689 | { .attrs = dme1737_pwm6_attr }, |
1690 | }; | ||
1691 | |||
1692 | /* The following struct holds misc PWM attributes, which are not available in | ||
1693 | * all chips. Their creation depends on the chip type which is determined | ||
1694 | * during module load. */ | ||
1695 | static struct attribute *dme1737_pwm_misc_attr[] = { | ||
1696 | &sensor_dev_attr_pwm1_auto_pwm_min.dev_attr.attr, | ||
1697 | &sensor_dev_attr_pwm2_auto_pwm_min.dev_attr.attr, | ||
1698 | &sensor_dev_attr_pwm3_auto_pwm_min.dev_attr.attr, | ||
1646 | }; | 1699 | }; |
1647 | 1700 | ||
1648 | /* The following structs hold the fan attributes, some of which are optional. | 1701 | /* The following structs hold the fan attributes, some of which are optional. |
1649 | * Their creation depends on the chip configuration which is determined during | 1702 | * Their creation depends on the chip configuration which is determined during |
1650 | * module load. */ | 1703 | * module load. */ |
1651 | static struct attribute *dme1737_attr_fan1[] = { | 1704 | static struct attribute *dme1737_fan1_attr[] = { |
1652 | SENSOR_DEV_ATTR_FAN_1TO4(1), | 1705 | &sensor_dev_attr_fan1_input.dev_attr.attr, |
1706 | &sensor_dev_attr_fan1_min.dev_attr.attr, | ||
1707 | &sensor_dev_attr_fan1_alarm.dev_attr.attr, | ||
1708 | &sensor_dev_attr_fan1_type.dev_attr.attr, | ||
1653 | NULL | 1709 | NULL |
1654 | }; | 1710 | }; |
1655 | static struct attribute *dme1737_attr_fan2[] = { | 1711 | static struct attribute *dme1737_fan2_attr[] = { |
1656 | SENSOR_DEV_ATTR_FAN_1TO4(2), | 1712 | &sensor_dev_attr_fan2_input.dev_attr.attr, |
1713 | &sensor_dev_attr_fan2_min.dev_attr.attr, | ||
1714 | &sensor_dev_attr_fan2_alarm.dev_attr.attr, | ||
1715 | &sensor_dev_attr_fan2_type.dev_attr.attr, | ||
1657 | NULL | 1716 | NULL |
1658 | }; | 1717 | }; |
1659 | static struct attribute *dme1737_attr_fan3[] = { | 1718 | static struct attribute *dme1737_fan3_attr[] = { |
1660 | SENSOR_DEV_ATTR_FAN_1TO4(3), | 1719 | &sensor_dev_attr_fan3_input.dev_attr.attr, |
1720 | &sensor_dev_attr_fan3_min.dev_attr.attr, | ||
1721 | &sensor_dev_attr_fan3_alarm.dev_attr.attr, | ||
1722 | &sensor_dev_attr_fan3_type.dev_attr.attr, | ||
1661 | NULL | 1723 | NULL |
1662 | }; | 1724 | }; |
1663 | static struct attribute *dme1737_attr_fan4[] = { | 1725 | static struct attribute *dme1737_fan4_attr[] = { |
1664 | SENSOR_DEV_ATTR_FAN_1TO4(4), | 1726 | &sensor_dev_attr_fan4_input.dev_attr.attr, |
1727 | &sensor_dev_attr_fan4_min.dev_attr.attr, | ||
1728 | &sensor_dev_attr_fan4_alarm.dev_attr.attr, | ||
1729 | &sensor_dev_attr_fan4_type.dev_attr.attr, | ||
1665 | NULL | 1730 | NULL |
1666 | }; | 1731 | }; |
1667 | static struct attribute *dme1737_attr_fan5[] = { | 1732 | static struct attribute *dme1737_fan5_attr[] = { |
1668 | SENSOR_DEV_ATTR_FAN_5TO6(5), | 1733 | &sensor_dev_attr_fan5_input.dev_attr.attr, |
1734 | &sensor_dev_attr_fan5_min.dev_attr.attr, | ||
1735 | &sensor_dev_attr_fan5_alarm.dev_attr.attr, | ||
1736 | &sensor_dev_attr_fan5_max.dev_attr.attr, | ||
1669 | NULL | 1737 | NULL |
1670 | }; | 1738 | }; |
1671 | static struct attribute *dme1737_attr_fan6[] = { | 1739 | static struct attribute *dme1737_fan6_attr[] = { |
1672 | SENSOR_DEV_ATTR_FAN_5TO6(6), | 1740 | &sensor_dev_attr_fan6_input.dev_attr.attr, |
1741 | &sensor_dev_attr_fan6_min.dev_attr.attr, | ||
1742 | &sensor_dev_attr_fan6_alarm.dev_attr.attr, | ||
1743 | &sensor_dev_attr_fan6_max.dev_attr.attr, | ||
1673 | NULL | 1744 | NULL |
1674 | }; | 1745 | }; |
1675 | 1746 | ||
1676 | static const struct attribute_group dme1737_fan_group[] = { | 1747 | static const struct attribute_group dme1737_fan_group[] = { |
1677 | { .attrs = dme1737_attr_fan1 }, | 1748 | { .attrs = dme1737_fan1_attr }, |
1678 | { .attrs = dme1737_attr_fan2 }, | 1749 | { .attrs = dme1737_fan2_attr }, |
1679 | { .attrs = dme1737_attr_fan3 }, | 1750 | { .attrs = dme1737_fan3_attr }, |
1680 | { .attrs = dme1737_attr_fan4 }, | 1751 | { .attrs = dme1737_fan4_attr }, |
1681 | { .attrs = dme1737_attr_fan5 }, | 1752 | { .attrs = dme1737_fan5_attr }, |
1682 | { .attrs = dme1737_attr_fan6 }, | 1753 | { .attrs = dme1737_fan6_attr }, |
1683 | }; | 1754 | }; |
1684 | 1755 | ||
1685 | /* The permissions of all of the following attributes are changed to read- | 1756 | /* The permissions of the following zone attributes are changed to read- |
1686 | * writeable if the chip is *not* locked. Otherwise they stay read-only. */ | 1757 | * writeable if the chip is *not* locked. Otherwise they stay read-only. */ |
1687 | static struct attribute *dme1737_attr_lock[] = { | 1758 | static struct attribute *dme1737_zone_chmod_attr[] = { |
1688 | /* Temperatures */ | 1759 | &sensor_dev_attr_zone1_auto_point1_temp.dev_attr.attr, |
1689 | SENSOR_DEV_ATTR_TEMP_LOCK(1), | 1760 | &sensor_dev_attr_zone1_auto_point2_temp.dev_attr.attr, |
1690 | SENSOR_DEV_ATTR_TEMP_LOCK(2), | 1761 | &sensor_dev_attr_zone1_auto_point3_temp.dev_attr.attr, |
1691 | SENSOR_DEV_ATTR_TEMP_LOCK(3), | 1762 | &sensor_dev_attr_zone2_auto_point1_temp.dev_attr.attr, |
1692 | /* Zones */ | 1763 | &sensor_dev_attr_zone2_auto_point2_temp.dev_attr.attr, |
1693 | SENSOR_DEV_ATTR_ZONE_LOCK(1), | 1764 | &sensor_dev_attr_zone2_auto_point3_temp.dev_attr.attr, |
1694 | SENSOR_DEV_ATTR_ZONE_LOCK(2), | 1765 | &sensor_dev_attr_zone3_auto_point1_temp.dev_attr.attr, |
1695 | SENSOR_DEV_ATTR_ZONE_LOCK(3), | 1766 | &sensor_dev_attr_zone3_auto_point2_temp.dev_attr.attr, |
1767 | &sensor_dev_attr_zone3_auto_point3_temp.dev_attr.attr, | ||
1696 | NULL | 1768 | NULL |
1697 | }; | 1769 | }; |
1698 | 1770 | ||
1699 | static const struct attribute_group dme1737_lock_group = { | 1771 | static const struct attribute_group dme1737_zone_chmod_group = { |
1700 | .attrs = dme1737_attr_lock, | 1772 | .attrs = dme1737_zone_chmod_attr, |
1701 | }; | 1773 | }; |
1702 | 1774 | ||
1703 | /* The permissions of the following PWM attributes are changed to read- | 1775 | /* The permissions of the following PWM attributes are changed to read- |
1704 | * writeable if the chip is *not* locked and the respective PWM is available. | 1776 | * writeable if the chip is *not* locked and the respective PWM is available. |
1705 | * Otherwise they stay read-only. */ | 1777 | * Otherwise they stay read-only. */ |
1706 | static struct attribute *dme1737_attr_pwm1_lock[] = { | 1778 | static struct attribute *dme1737_pwm1_chmod_attr[] = { |
1707 | SENSOR_DEV_ATTR_PWM_1TO3_LOCK(1), | 1779 | &sensor_dev_attr_pwm1_freq.dev_attr.attr, |
1780 | &sensor_dev_attr_pwm1_enable.dev_attr.attr, | ||
1781 | &sensor_dev_attr_pwm1_ramp_rate.dev_attr.attr, | ||
1782 | &sensor_dev_attr_pwm1_auto_channels_zone.dev_attr.attr, | ||
1783 | &sensor_dev_attr_pwm1_auto_point1_pwm.dev_attr.attr, | ||
1708 | NULL | 1784 | NULL |
1709 | }; | 1785 | }; |
1710 | static struct attribute *dme1737_attr_pwm2_lock[] = { | 1786 | static struct attribute *dme1737_pwm2_chmod_attr[] = { |
1711 | SENSOR_DEV_ATTR_PWM_1TO3_LOCK(2), | 1787 | &sensor_dev_attr_pwm2_freq.dev_attr.attr, |
1788 | &sensor_dev_attr_pwm2_enable.dev_attr.attr, | ||
1789 | &sensor_dev_attr_pwm2_ramp_rate.dev_attr.attr, | ||
1790 | &sensor_dev_attr_pwm2_auto_channels_zone.dev_attr.attr, | ||
1791 | &sensor_dev_attr_pwm2_auto_point1_pwm.dev_attr.attr, | ||
1712 | NULL | 1792 | NULL |
1713 | }; | 1793 | }; |
1714 | static struct attribute *dme1737_attr_pwm3_lock[] = { | 1794 | static struct attribute *dme1737_pwm3_chmod_attr[] = { |
1715 | SENSOR_DEV_ATTR_PWM_1TO3_LOCK(3), | 1795 | &sensor_dev_attr_pwm3_freq.dev_attr.attr, |
1796 | &sensor_dev_attr_pwm3_enable.dev_attr.attr, | ||
1797 | &sensor_dev_attr_pwm3_ramp_rate.dev_attr.attr, | ||
1798 | &sensor_dev_attr_pwm3_auto_channels_zone.dev_attr.attr, | ||
1799 | &sensor_dev_attr_pwm3_auto_point1_pwm.dev_attr.attr, | ||
1716 | NULL | 1800 | NULL |
1717 | }; | 1801 | }; |
1718 | static struct attribute *dme1737_attr_pwm5_lock[] = { | 1802 | static struct attribute *dme1737_pwm5_chmod_attr[] = { |
1719 | SENSOR_DEV_ATTR_PWM_5TO6_LOCK(5), | 1803 | &sensor_dev_attr_pwm5.dev_attr.attr, |
1804 | &sensor_dev_attr_pwm5_freq.dev_attr.attr, | ||
1720 | NULL | 1805 | NULL |
1721 | }; | 1806 | }; |
1722 | static struct attribute *dme1737_attr_pwm6_lock[] = { | 1807 | static struct attribute *dme1737_pwm6_chmod_attr[] = { |
1723 | SENSOR_DEV_ATTR_PWM_5TO6_LOCK(6), | 1808 | &sensor_dev_attr_pwm6.dev_attr.attr, |
1809 | &sensor_dev_attr_pwm6_freq.dev_attr.attr, | ||
1724 | NULL | 1810 | NULL |
1725 | }; | 1811 | }; |
1726 | 1812 | ||
1727 | static const struct attribute_group dme1737_pwm_lock_group[] = { | 1813 | static const struct attribute_group dme1737_pwm_chmod_group[] = { |
1728 | { .attrs = dme1737_attr_pwm1_lock }, | 1814 | { .attrs = dme1737_pwm1_chmod_attr }, |
1729 | { .attrs = dme1737_attr_pwm2_lock }, | 1815 | { .attrs = dme1737_pwm2_chmod_attr }, |
1730 | { .attrs = dme1737_attr_pwm3_lock }, | 1816 | { .attrs = dme1737_pwm3_chmod_attr }, |
1731 | { .attrs = NULL }, | 1817 | { .attrs = NULL }, |
1732 | { .attrs = dme1737_attr_pwm5_lock }, | 1818 | { .attrs = dme1737_pwm5_chmod_attr }, |
1733 | { .attrs = dme1737_attr_pwm6_lock }, | 1819 | { .attrs = dme1737_pwm6_chmod_attr }, |
1734 | }; | 1820 | }; |
1735 | 1821 | ||
1736 | /* Pwm[1-3] are read-writeable if the associated pwm is in manual mode and the | 1822 | /* Pwm[1-3] are read-writeable if the associated pwm is in manual mode and the |
1737 | * chip is not locked. Otherwise they are read-only. */ | 1823 | * chip is not locked. Otherwise they are read-only. */ |
1738 | static struct attribute *dme1737_attr_pwm[] = { | 1824 | static struct attribute *dme1737_pwm_chmod_attr[] = { |
1739 | &sensor_dev_attr_pwm1.dev_attr.attr, | 1825 | &sensor_dev_attr_pwm1.dev_attr.attr, |
1740 | &sensor_dev_attr_pwm2.dev_attr.attr, | 1826 | &sensor_dev_attr_pwm2.dev_attr.attr, |
1741 | &sensor_dev_attr_pwm3.dev_attr.attr, | 1827 | &sensor_dev_attr_pwm3.dev_attr.attr, |
@@ -1809,9 +1895,17 @@ static void dme1737_remove_files(struct device *dev) | |||
1809 | if (data->has_pwm & (1 << ix)) { | 1895 | if (data->has_pwm & (1 << ix)) { |
1810 | sysfs_remove_group(&dev->kobj, | 1896 | sysfs_remove_group(&dev->kobj, |
1811 | &dme1737_pwm_group[ix]); | 1897 | &dme1737_pwm_group[ix]); |
1898 | if (data->type != sch5027 && ix < 3) { | ||
1899 | sysfs_remove_file(&dev->kobj, | ||
1900 | dme1737_pwm_misc_attr[ix]); | ||
1901 | } | ||
1812 | } | 1902 | } |
1813 | } | 1903 | } |
1814 | 1904 | ||
1905 | if (data->type != sch5027) { | ||
1906 | sysfs_remove_group(&dev->kobj, &dme1737_misc_group); | ||
1907 | } | ||
1908 | |||
1815 | sysfs_remove_group(&dev->kobj, &dme1737_group); | 1909 | sysfs_remove_group(&dev->kobj, &dme1737_group); |
1816 | 1910 | ||
1817 | if (!data->client.driver) { | 1911 | if (!data->client.driver) { |
@@ -1835,6 +1929,13 @@ static int dme1737_create_files(struct device *dev) | |||
1835 | goto exit_remove; | 1929 | goto exit_remove; |
1836 | } | 1930 | } |
1837 | 1931 | ||
1932 | /* Create misc sysfs attributes */ | ||
1933 | if ((data->type != sch5027) && | ||
1934 | (err = sysfs_create_group(&dev->kobj, | ||
1935 | &dme1737_misc_group))) { | ||
1936 | goto exit_remove; | ||
1937 | } | ||
1938 | |||
1838 | /* Create fan sysfs attributes */ | 1939 | /* Create fan sysfs attributes */ |
1839 | for (ix = 0; ix < ARRAY_SIZE(dme1737_fan_group); ix++) { | 1940 | for (ix = 0; ix < ARRAY_SIZE(dme1737_fan_group); ix++) { |
1840 | if (data->has_fan & (1 << ix)) { | 1941 | if (data->has_fan & (1 << ix)) { |
@@ -1852,6 +1953,11 @@ static int dme1737_create_files(struct device *dev) | |||
1852 | &dme1737_pwm_group[ix]))) { | 1953 | &dme1737_pwm_group[ix]))) { |
1853 | goto exit_remove; | 1954 | goto exit_remove; |
1854 | } | 1955 | } |
1956 | if (data->type != sch5027 && ix < 3 && | ||
1957 | (err = sysfs_create_file(&dev->kobj, | ||
1958 | dme1737_pwm_misc_attr[ix]))) { | ||
1959 | goto exit_remove; | ||
1960 | } | ||
1855 | } | 1961 | } |
1856 | } | 1962 | } |
1857 | 1963 | ||
@@ -1861,16 +1967,27 @@ static int dme1737_create_files(struct device *dev) | |||
1861 | dev_info(dev, "Device is locked. Some attributes " | 1967 | dev_info(dev, "Device is locked. Some attributes " |
1862 | "will be read-only.\n"); | 1968 | "will be read-only.\n"); |
1863 | } else { | 1969 | } else { |
1864 | /* Change permissions of standard attributes */ | 1970 | /* Change permissions of zone sysfs attributes */ |
1865 | dme1737_chmod_group(dev, &dme1737_lock_group, | 1971 | dme1737_chmod_group(dev, &dme1737_zone_chmod_group, |
1866 | S_IRUGO | S_IWUSR); | 1972 | S_IRUGO | S_IWUSR); |
1867 | 1973 | ||
1868 | /* Change permissions of PWM attributes */ | 1974 | /* Change permissions of misc sysfs attributes */ |
1869 | for (ix = 0; ix < ARRAY_SIZE(dme1737_pwm_lock_group); ix++) { | 1975 | if (data->type != sch5027) { |
1976 | dme1737_chmod_group(dev, &dme1737_misc_group, | ||
1977 | S_IRUGO | S_IWUSR); | ||
1978 | } | ||
1979 | |||
1980 | /* Change permissions of PWM sysfs attributes */ | ||
1981 | for (ix = 0; ix < ARRAY_SIZE(dme1737_pwm_chmod_group); ix++) { | ||
1870 | if (data->has_pwm & (1 << ix)) { | 1982 | if (data->has_pwm & (1 << ix)) { |
1871 | dme1737_chmod_group(dev, | 1983 | dme1737_chmod_group(dev, |
1872 | &dme1737_pwm_lock_group[ix], | 1984 | &dme1737_pwm_chmod_group[ix], |
1985 | S_IRUGO | S_IWUSR); | ||
1986 | if (data->type != sch5027 && ix < 3) { | ||
1987 | dme1737_chmod_file(dev, | ||
1988 | dme1737_pwm_misc_attr[ix], | ||
1873 | S_IRUGO | S_IWUSR); | 1989 | S_IRUGO | S_IWUSR); |
1990 | } | ||
1874 | } | 1991 | } |
1875 | } | 1992 | } |
1876 | 1993 | ||
@@ -1879,7 +1996,7 @@ static int dme1737_create_files(struct device *dev) | |||
1879 | if ((data->has_pwm & (1 << ix)) && | 1996 | if ((data->has_pwm & (1 << ix)) && |
1880 | (PWM_EN_FROM_REG(data->pwm_config[ix]) == 1)) { | 1997 | (PWM_EN_FROM_REG(data->pwm_config[ix]) == 1)) { |
1881 | dme1737_chmod_file(dev, | 1998 | dme1737_chmod_file(dev, |
1882 | dme1737_attr_pwm[ix], | 1999 | dme1737_pwm_chmod_attr[ix], |
1883 | S_IRUGO | S_IWUSR); | 2000 | S_IRUGO | S_IWUSR); |
1884 | } | 2001 | } |
1885 | } | 2002 | } |
@@ -1900,6 +2017,9 @@ static int dme1737_init_device(struct device *dev) | |||
1900 | int ix; | 2017 | int ix; |
1901 | u8 reg; | 2018 | u8 reg; |
1902 | 2019 | ||
2020 | /* Point to the right nominal voltages array */ | ||
2021 | data->in_nominal = IN_NOMINAL(data->type); | ||
2022 | |||
1903 | data->config = dme1737_read(client, DME1737_REG_CONFIG); | 2023 | data->config = dme1737_read(client, DME1737_REG_CONFIG); |
1904 | /* Inform if part is not monitoring/started */ | 2024 | /* Inform if part is not monitoring/started */ |
1905 | if (!(data->config & 0x01)) { | 2025 | if (!(data->config & 0x01)) { |
@@ -2010,7 +2130,9 @@ static int dme1737_init_device(struct device *dev) | |||
2010 | data->pwm_acz[2] = 4; /* pwm3 -> zone3 */ | 2130 | data->pwm_acz[2] = 4; /* pwm3 -> zone3 */ |
2011 | 2131 | ||
2012 | /* Set VRM */ | 2132 | /* Set VRM */ |
2013 | data->vrm = vid_which_vrm(); | 2133 | if (data->type != sch5027) { |
2134 | data->vrm = vid_which_vrm(); | ||
2135 | } | ||
2014 | 2136 | ||
2015 | return 0; | 2137 | return 0; |
2016 | } | 2138 | } |
@@ -2029,9 +2151,10 @@ static int dme1737_i2c_get_features(int sio_cip, struct dme1737_data *data) | |||
2029 | dme1737_sio_enter(sio_cip); | 2151 | dme1737_sio_enter(sio_cip); |
2030 | 2152 | ||
2031 | /* Check device ID | 2153 | /* Check device ID |
2032 | * The DME1737 can return either 0x78 or 0x77 as its device ID. */ | 2154 | * The DME1737 can return either 0x78 or 0x77 as its device ID. |
2155 | * The SCH5027 returns 0x89 as its device ID. */ | ||
2033 | reg = force_id ? force_id : dme1737_sio_inb(sio_cip, 0x20); | 2156 | reg = force_id ? force_id : dme1737_sio_inb(sio_cip, 0x20); |
2034 | if (!(reg == 0x77 || reg == 0x78)) { | 2157 | if (!(reg == 0x77 || reg == 0x78 || reg == 0x89)) { |
2035 | err = -ENODEV; | 2158 | err = -ENODEV; |
2036 | goto exit; | 2159 | goto exit; |
2037 | } | 2160 | } |
@@ -2100,15 +2223,25 @@ static int dme1737_i2c_detect(struct i2c_adapter *adapter, int address, | |||
2100 | company = dme1737_read(client, DME1737_REG_COMPANY); | 2223 | company = dme1737_read(client, DME1737_REG_COMPANY); |
2101 | verstep = dme1737_read(client, DME1737_REG_VERSTEP); | 2224 | verstep = dme1737_read(client, DME1737_REG_VERSTEP); |
2102 | 2225 | ||
2103 | if (!((company == DME1737_COMPANY_SMSC) && | 2226 | if (company == DME1737_COMPANY_SMSC && |
2104 | ((verstep & DME1737_VERSTEP_MASK) == DME1737_VERSTEP))) { | 2227 | (verstep & DME1737_VERSTEP_MASK) == DME1737_VERSTEP) { |
2228 | kind = dme1737; | ||
2229 | } else if (company == DME1737_COMPANY_SMSC && | ||
2230 | verstep == SCH5027_VERSTEP) { | ||
2231 | kind = sch5027; | ||
2232 | } else { | ||
2105 | err = -ENODEV; | 2233 | err = -ENODEV; |
2106 | goto exit_kfree; | 2234 | goto exit_kfree; |
2107 | } | 2235 | } |
2108 | } | 2236 | } |
2109 | 2237 | ||
2110 | kind = dme1737; | 2238 | if (kind == sch5027) { |
2111 | name = "dme1737"; | 2239 | name = "sch5027"; |
2240 | } else { | ||
2241 | kind = dme1737; | ||
2242 | name = "dme1737"; | ||
2243 | } | ||
2244 | data->type = kind; | ||
2112 | 2245 | ||
2113 | /* Fill in the remaining client fields and put it into the global | 2246 | /* Fill in the remaining client fields and put it into the global |
2114 | * list */ | 2247 | * list */ |
@@ -2120,8 +2253,9 @@ static int dme1737_i2c_detect(struct i2c_adapter *adapter, int address, | |||
2120 | goto exit_kfree; | 2253 | goto exit_kfree; |
2121 | } | 2254 | } |
2122 | 2255 | ||
2123 | dev_info(dev, "Found a DME1737 chip at 0x%02x (rev 0x%02x).\n", | 2256 | dev_info(dev, "Found a %s chip at 0x%02x (rev 0x%02x).\n", |
2124 | client->addr, verstep); | 2257 | kind == sch5027 ? "SCH5027" : "DME1737", client->addr, |
2258 | verstep); | ||
2125 | 2259 | ||
2126 | /* Initialize the DME1737 chip */ | 2260 | /* Initialize the DME1737 chip */ |
2127 | if ((err = dme1737_init_device(dev))) { | 2261 | if ((err = dme1737_init_device(dev))) { |
@@ -2293,14 +2427,18 @@ static int __devinit dme1737_isa_probe(struct platform_device *pdev) | |||
2293 | client->addr = res->start; | 2427 | client->addr = res->start; |
2294 | platform_set_drvdata(pdev, data); | 2428 | platform_set_drvdata(pdev, data); |
2295 | 2429 | ||
2296 | company = dme1737_read(client, DME1737_REG_COMPANY); | 2430 | /* Skip chip detection if module is loaded with force_id parameter */ |
2297 | device = dme1737_read(client, DME1737_REG_DEVICE); | 2431 | if (!force_id) { |
2432 | company = dme1737_read(client, DME1737_REG_COMPANY); | ||
2433 | device = dme1737_read(client, DME1737_REG_DEVICE); | ||
2298 | 2434 | ||
2299 | if (!((company == DME1737_COMPANY_SMSC) && | 2435 | if (!((company == DME1737_COMPANY_SMSC) && |
2300 | (device == SCH311X_DEVICE))) { | 2436 | (device == SCH311X_DEVICE))) { |
2301 | err = -ENODEV; | 2437 | err = -ENODEV; |
2302 | goto exit_kfree; | 2438 | goto exit_kfree; |
2439 | } | ||
2303 | } | 2440 | } |
2441 | data->type = sch311x; | ||
2304 | 2442 | ||
2305 | /* Fill in the remaining client fields and initialize the mutex */ | 2443 | /* Fill in the remaining client fields and initialize the mutex */ |
2306 | strlcpy(client->name, "sch311x", I2C_NAME_SIZE); | 2444 | strlcpy(client->name, "sch311x", I2C_NAME_SIZE); |
@@ -2377,7 +2515,10 @@ static int __init dme1737_init(void) | |||
2377 | } | 2515 | } |
2378 | 2516 | ||
2379 | if (dme1737_isa_detect(0x2e, &addr) && | 2517 | if (dme1737_isa_detect(0x2e, &addr) && |
2380 | dme1737_isa_detect(0x4e, &addr)) { | 2518 | dme1737_isa_detect(0x4e, &addr) && |
2519 | (!probe_all_addr || | ||
2520 | (dme1737_isa_detect(0x162e, &addr) && | ||
2521 | dme1737_isa_detect(0x164e, &addr)))) { | ||
2381 | /* Return 0 if we didn't find an ISA device */ | 2522 | /* Return 0 if we didn't find an ISA device */ |
2382 | return 0; | 2523 | return 0; |
2383 | } | 2524 | } |
diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c index cbeb4984b5c7..67067e9a323e 100644 --- a/drivers/hwmon/f71882fg.c +++ b/drivers/hwmon/f71882fg.c | |||
@@ -87,8 +87,6 @@ static inline void superio_enter(int base); | |||
87 | static inline void superio_select(int base, int ld); | 87 | static inline void superio_select(int base, int ld); |
88 | static inline void superio_exit(int base); | 88 | static inline void superio_exit(int base); |
89 | 89 | ||
90 | static inline u16 fan_from_reg ( u16 reg ); | ||
91 | |||
92 | struct f71882fg_data { | 90 | struct f71882fg_data { |
93 | unsigned short addr; | 91 | unsigned short addr; |
94 | struct device *hwmon_dev; | 92 | struct device *hwmon_dev; |
@@ -116,10 +114,6 @@ struct f71882fg_data { | |||
116 | u8 temp_diode_open; | 114 | u8 temp_diode_open; |
117 | }; | 115 | }; |
118 | 116 | ||
119 | static u8 f71882fg_read8(struct f71882fg_data *data, u8 reg); | ||
120 | static u16 f71882fg_read16(struct f71882fg_data *data, u8 reg); | ||
121 | static void f71882fg_write8(struct f71882fg_data *data, u8 reg, u8 val); | ||
122 | |||
123 | /* Sysfs in*/ | 117 | /* Sysfs in*/ |
124 | static ssize_t show_in(struct device *dev, struct device_attribute *devattr, | 118 | static ssize_t show_in(struct device *dev, struct device_attribute *devattr, |
125 | char *buf); | 119 | char *buf); |
diff --git a/drivers/hwmon/hwmon-vid.c b/drivers/hwmon/hwmon-vid.c index 3330667280b9..7b0a32c4dcfb 100644 --- a/drivers/hwmon/hwmon-vid.c +++ b/drivers/hwmon/hwmon-vid.c | |||
@@ -1,76 +1,74 @@ | |||
1 | /* | 1 | /* |
2 | hwmon-vid.c - VID/VRM/VRD voltage conversions | 2 | * hwmon-vid.c - VID/VRM/VRD voltage conversions |
3 | 3 | * | |
4 | Copyright (c) 2004 Rudolf Marek <r.marek@assembler.cz> | 4 | * Copyright (c) 2004 Rudolf Marek <r.marek@assembler.cz> |
5 | 5 | * | |
6 | Partly imported from i2c-vid.h of the lm_sensors project | 6 | * Partly imported from i2c-vid.h of the lm_sensors project |
7 | Copyright (c) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com> | 7 | * Copyright (c) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com> |
8 | With assistance from Trent Piepho <xyzzy@speakeasy.org> | 8 | * With assistance from Trent Piepho <xyzzy@speakeasy.org> |
9 | 9 | * | |
10 | This program is free software; you can redistribute it and/or modify | 10 | * This program is free software; you can redistribute it and/or modify |
11 | it under the terms of the GNU General Public License as published by | 11 | * it under the terms of the GNU General Public License as published by |
12 | the Free Software Foundation; either version 2 of the License, or | 12 | * the Free Software Foundation; either version 2 of the License, or |
13 | (at your option) any later version. | 13 | * (at your option) any later version. |
14 | 14 | * | |
15 | This program is distributed in the hope that it will be useful, | 15 | * This program is distributed in the hope that it will be useful, |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | GNU General Public License for more details. | 18 | * GNU General Public License for more details. |
19 | 19 | * | |
20 | You should have received a copy of the GNU General Public License | 20 | * You should have received a copy of the GNU General Public License |
21 | along with this program; if not, write to the Free Software | 21 | * along with this program; if not, write to the Free Software |
22 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
27 | #include <linux/hwmon-vid.h> | 27 | #include <linux/hwmon-vid.h> |
28 | 28 | ||
29 | /* | 29 | /* |
30 | Common code for decoding VID pins. | 30 | * Common code for decoding VID pins. |
31 | 31 | * | |
32 | References: | 32 | * References: |
33 | 33 | * | |
34 | For VRM 8.4 to 9.1, "VRM x.y DC-DC Converter Design Guidelines", | 34 | * For VRM 8.4 to 9.1, "VRM x.y DC-DC Converter Design Guidelines", |
35 | available at http://developer.intel.com/. | 35 | * available at http://developer.intel.com/. |
36 | 36 | * | |
37 | For VRD 10.0 and up, "VRD x.y Design Guide", | 37 | * For VRD 10.0 and up, "VRD x.y Design Guide", |
38 | available at http://developer.intel.com/. | 38 | * available at http://developer.intel.com/. |
39 | 39 | * | |
40 | AMD Opteron processors don't follow the Intel specifications. | 40 | * AMD NPT 0Fh (Athlon64 & Opteron), AMD Publication 32559, |
41 | I'm going to "make up" 2.4 as the spec number for the Opterons. | 41 | * http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/32559.pdf |
42 | No good reason just a mnemonic for the 24x Opteron processor | 42 | * Table 71. VID Code Voltages |
43 | series. | 43 | * AMD Opteron processors don't follow the Intel specifications. |
44 | 44 | * I'm going to "make up" 2.4 as the spec number for the Opterons. | |
45 | Opteron VID encoding is: | 45 | * No good reason just a mnemonic for the 24x Opteron processor |
46 | 00000 = 1.550 V | 46 | * series. |
47 | 00001 = 1.525 V | 47 | * |
48 | . . . . | 48 | * The 17 specification is in fact Intel Mobile Voltage Positioning - |
49 | 11110 = 0.800 V | 49 | * (IMVP-II). You can find more information in the datasheet of Max1718 |
50 | 11111 = 0.000 V (off) | 50 | * http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2452 |
51 | 51 | * | |
52 | The 17 specification is in fact Intel Mobile Voltage Positioning - | 52 | * The 13 specification corresponds to the Intel Pentium M series. There |
53 | (IMVP-II). You can find more information in the datasheet of Max1718 | 53 | * doesn't seem to be any named specification for these. The conversion |
54 | http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2452 | 54 | * tables are detailed directly in the various Pentium M datasheets: |
55 | 55 | * http://www.intel.com/design/intarch/pentiumm/docs_pentiumm.htm | |
56 | The 13 specification corresponds to the Intel Pentium M series. There | 56 | * |
57 | doesn't seem to be any named specification for these. The conversion | 57 | * The 14 specification corresponds to Intel Core series. There |
58 | tables are detailed directly in the various Pentium M datasheets: | 58 | * doesn't seem to be any named specification for these. The conversion |
59 | http://www.intel.com/design/intarch/pentiumm/docs_pentiumm.htm | 59 | * tables are detailed directly in the various Pentium Core datasheets: |
60 | 60 | * http://www.intel.com/design/mobile/datashts/309221.htm | |
61 | The 14 specification corresponds to Intel Core series. There | 61 | * |
62 | doesn't seem to be any named specification for these. The conversion | 62 | * The 110 (VRM 11) specification corresponds to Intel Conroe based series. |
63 | tables are detailed directly in the various Pentium Core datasheets: | 63 | * http://www.intel.com/design/processor/applnots/313214.htm |
64 | http://www.intel.com/design/mobile/datashts/309221.htm | 64 | */ |
65 | 65 | ||
66 | The 110 (VRM 11) specification corresponds to Intel Conroe based series. | 66 | /* |
67 | http://www.intel.com/design/processor/applnots/313214.htm | 67 | * vrm is the VRM/VRD document version multiplied by 10. |
68 | */ | 68 | * val is the 4-bit or more VID code. |
69 | 69 | * Returned value is in mV to avoid floating point in the kernel. | |
70 | /* vrm is the VRM/VRD document version multiplied by 10. | 70 | * Some VID have some bits in uV scale, this is rounded to mV. |
71 | val is the 4-bit or more VID code. | 71 | */ |
72 | Returned value is in mV to avoid floating point in the kernel. | ||
73 | Some VID have some bits in uV scale, this is rounded to mV */ | ||
74 | int vid_from_reg(int val, u8 vrm) | 72 | int vid_from_reg(int val, u8 vrm) |
75 | { | 73 | { |
76 | int vid; | 74 | int vid; |
@@ -96,9 +94,11 @@ int vid_from_reg(int val, u8 vrm) | |||
96 | if (val < 0x02 || val > 0xb2) | 94 | if (val < 0x02 || val > 0xb2) |
97 | return 0; | 95 | return 0; |
98 | return((1600000 - (val - 2) * 6250 + 500) / 1000); | 96 | return((1600000 - (val - 2) * 6250 + 500) / 1000); |
99 | case 24: /* Opteron processor */ | 97 | |
100 | val &= 0x1f; | 98 | case 24: /* AMD NPT 0Fh (Athlon64 & Opteron) */ |
101 | return(val == 0x1f ? 0 : 1550 - val * 25); | 99 | val &= 0x3f; |
100 | return (val < 32) ? 1550 - 25 * val | ||
101 | : 775 - (25 * (val - 31)) / 2; | ||
102 | 102 | ||
103 | case 91: /* VRM 9.1 */ | 103 | case 91: /* VRM 9.1 */ |
104 | case 90: /* VRM 9.0 */ | 104 | case 90: /* VRM 9.0 */ |
@@ -141,9 +141,9 @@ int vid_from_reg(int val, u8 vrm) | |||
141 | 141 | ||
142 | 142 | ||
143 | /* | 143 | /* |
144 | After this point is the code to automatically determine which | 144 | * After this point is the code to automatically determine which |
145 | VRM/VRD specification should be used depending on the CPU. | 145 | * VRM/VRD specification should be used depending on the CPU. |
146 | */ | 146 | */ |
147 | 147 | ||
148 | struct vrm_model { | 148 | struct vrm_model { |
149 | u8 vendor; | 149 | u8 vendor; |
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index e12c132ff83a..30cdb0956779 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c | |||
@@ -151,9 +151,9 @@ static int fix_pwm_polarity; | |||
151 | /* The IT8718F has the VID value in a different register, in Super-I/O | 151 | /* The IT8718F has the VID value in a different register, in Super-I/O |
152 | configuration space. */ | 152 | configuration space. */ |
153 | #define IT87_REG_VID 0x0a | 153 | #define IT87_REG_VID 0x0a |
154 | /* Warning: register 0x0b is used for something completely different in | 154 | /* The IT8705F and IT8712F earlier than revision 0x08 use register 0x0b |
155 | new chips/revisions. I suspect only 16-bit tachometer mode will work | 155 | for fan divisors. Later IT8712F revisions must use 16-bit tachometer |
156 | for these. */ | 156 | mode. */ |
157 | #define IT87_REG_FAN_DIV 0x0b | 157 | #define IT87_REG_FAN_DIV 0x0b |
158 | #define IT87_REG_FAN_16BIT 0x0c | 158 | #define IT87_REG_FAN_16BIT 0x0c |
159 | 159 | ||
@@ -234,6 +234,7 @@ static const unsigned int pwm_freq[8] = { | |||
234 | struct it87_sio_data { | 234 | struct it87_sio_data { |
235 | enum chips type; | 235 | enum chips type; |
236 | /* Values read from Super-I/O config space */ | 236 | /* Values read from Super-I/O config space */ |
237 | u8 revision; | ||
237 | u8 vid_value; | 238 | u8 vid_value; |
238 | }; | 239 | }; |
239 | 240 | ||
@@ -242,6 +243,7 @@ struct it87_sio_data { | |||
242 | struct it87_data { | 243 | struct it87_data { |
243 | struct device *hwmon_dev; | 244 | struct device *hwmon_dev; |
244 | enum chips type; | 245 | enum chips type; |
246 | u8 revision; | ||
245 | 247 | ||
246 | unsigned short addr; | 248 | unsigned short addr; |
247 | const char *name; | 249 | const char *name; |
@@ -268,6 +270,16 @@ struct it87_data { | |||
268 | u8 manual_pwm_ctl[3]; /* manual PWM value set by user */ | 270 | u8 manual_pwm_ctl[3]; /* manual PWM value set by user */ |
269 | }; | 271 | }; |
270 | 272 | ||
273 | static inline int has_16bit_fans(const struct it87_data *data) | ||
274 | { | ||
275 | /* IT8705F Datasheet 0.4.1, 3h == Version G. | ||
276 | IT8712F Datasheet 0.9.1, section 8.3.5 indicates 7h == Version I. | ||
277 | These are the first revisions with 16bit tachometer support. */ | ||
278 | return (data->type == it87 && data->revision >= 0x03) | ||
279 | || (data->type == it8712 && data->revision >= 0x07) | ||
280 | || data->type == it8716 | ||
281 | || data->type == it8718; | ||
282 | } | ||
271 | 283 | ||
272 | static int it87_probe(struct platform_device *pdev); | 284 | static int it87_probe(struct platform_device *pdev); |
273 | static int __devexit it87_remove(struct platform_device *pdev); | 285 | static int __devexit it87_remove(struct platform_device *pdev); |
@@ -991,8 +1003,9 @@ static int __init it87_find(unsigned short *address, | |||
991 | } | 1003 | } |
992 | 1004 | ||
993 | err = 0; | 1005 | err = 0; |
1006 | sio_data->revision = superio_inb(DEVREV) & 0x0f; | ||
994 | pr_info("it87: Found IT%04xF chip at 0x%x, revision %d\n", | 1007 | pr_info("it87: Found IT%04xF chip at 0x%x, revision %d\n", |
995 | chip_type, *address, superio_inb(DEVREV) & 0x0f); | 1008 | chip_type, *address, sio_data->revision); |
996 | 1009 | ||
997 | /* Read GPIO config and VID value from LDN 7 (GPIO) */ | 1010 | /* Read GPIO config and VID value from LDN 7 (GPIO) */ |
998 | if (chip_type != IT8705F_DEVID) { | 1011 | if (chip_type != IT8705F_DEVID) { |
@@ -1045,6 +1058,7 @@ static int __devinit it87_probe(struct platform_device *pdev) | |||
1045 | 1058 | ||
1046 | data->addr = res->start; | 1059 | data->addr = res->start; |
1047 | data->type = sio_data->type; | 1060 | data->type = sio_data->type; |
1061 | data->revision = sio_data->revision; | ||
1048 | data->name = names[sio_data->type]; | 1062 | data->name = names[sio_data->type]; |
1049 | 1063 | ||
1050 | /* Now, we do the remaining detection. */ | 1064 | /* Now, we do the remaining detection. */ |
@@ -1069,7 +1083,7 @@ static int __devinit it87_probe(struct platform_device *pdev) | |||
1069 | goto ERROR2; | 1083 | goto ERROR2; |
1070 | 1084 | ||
1071 | /* Do not create fan files for disabled fans */ | 1085 | /* Do not create fan files for disabled fans */ |
1072 | if (data->type == it8716 || data->type == it8718) { | 1086 | if (has_16bit_fans(data)) { |
1073 | /* 16-bit tachometers */ | 1087 | /* 16-bit tachometers */ |
1074 | if (data->has_fan & (1 << 0)) { | 1088 | if (data->has_fan & (1 << 0)) { |
1075 | if ((err = device_create_file(dev, | 1089 | if ((err = device_create_file(dev, |
@@ -1350,7 +1364,7 @@ static void __devinit it87_init_device(struct platform_device *pdev) | |||
1350 | data->has_fan = (data->fan_main_ctrl >> 4) & 0x07; | 1364 | data->has_fan = (data->fan_main_ctrl >> 4) & 0x07; |
1351 | 1365 | ||
1352 | /* Set tachometers to 16-bit mode if needed */ | 1366 | /* Set tachometers to 16-bit mode if needed */ |
1353 | if (data->type == it8716 || data->type == it8718) { | 1367 | if (has_16bit_fans(data)) { |
1354 | tmp = it87_read_value(data, IT87_REG_FAN_16BIT); | 1368 | tmp = it87_read_value(data, IT87_REG_FAN_16BIT); |
1355 | if (~tmp & 0x07 & data->has_fan) { | 1369 | if (~tmp & 0x07 & data->has_fan) { |
1356 | dev_dbg(&pdev->dev, | 1370 | dev_dbg(&pdev->dev, |
@@ -1358,10 +1372,13 @@ static void __devinit it87_init_device(struct platform_device *pdev) | |||
1358 | it87_write_value(data, IT87_REG_FAN_16BIT, | 1372 | it87_write_value(data, IT87_REG_FAN_16BIT, |
1359 | tmp | 0x07); | 1373 | tmp | 0x07); |
1360 | } | 1374 | } |
1361 | if (tmp & (1 << 4)) | 1375 | /* IT8705F only supports three fans. */ |
1362 | data->has_fan |= (1 << 3); /* fan4 enabled */ | 1376 | if (data->type != it87) { |
1363 | if (tmp & (1 << 5)) | 1377 | if (tmp & (1 << 4)) |
1364 | data->has_fan |= (1 << 4); /* fan5 enabled */ | 1378 | data->has_fan |= (1 << 3); /* fan4 enabled */ |
1379 | if (tmp & (1 << 5)) | ||
1380 | data->has_fan |= (1 << 4); /* fan5 enabled */ | ||
1381 | } | ||
1365 | } | 1382 | } |
1366 | 1383 | ||
1367 | /* Set current fan mode registers and the default settings for the | 1384 | /* Set current fan mode registers and the default settings for the |
@@ -1426,7 +1443,7 @@ static struct it87_data *it87_update_device(struct device *dev) | |||
1426 | data->fan[i] = it87_read_value(data, | 1443 | data->fan[i] = it87_read_value(data, |
1427 | IT87_REG_FAN[i]); | 1444 | IT87_REG_FAN[i]); |
1428 | /* Add high byte if in 16-bit mode */ | 1445 | /* Add high byte if in 16-bit mode */ |
1429 | if (data->type == it8716 || data->type == it8718) { | 1446 | if (has_16bit_fans(data)) { |
1430 | data->fan[i] |= it87_read_value(data, | 1447 | data->fan[i] |= it87_read_value(data, |
1431 | IT87_REG_FANX[i]) << 8; | 1448 | IT87_REG_FANX[i]) << 8; |
1432 | data->fan_min[i] |= it87_read_value(data, | 1449 | data->fan_min[i] |= it87_read_value(data, |
@@ -1443,8 +1460,7 @@ static struct it87_data *it87_update_device(struct device *dev) | |||
1443 | } | 1460 | } |
1444 | 1461 | ||
1445 | /* Newer chips don't have clock dividers */ | 1462 | /* Newer chips don't have clock dividers */ |
1446 | if ((data->has_fan & 0x07) && data->type != it8716 | 1463 | if ((data->has_fan & 0x07) && !has_16bit_fans(data)) { |
1447 | && data->type != it8718) { | ||
1448 | i = it87_read_value(data, IT87_REG_FAN_DIV); | 1464 | i = it87_read_value(data, IT87_REG_FAN_DIV); |
1449 | data->fan_div[0] = i & 0x07; | 1465 | data->fan_div[0] = i & 0x07; |
1450 | data->fan_div[1] = (i >> 3) & 0x07; | 1466 | data->fan_div[1] = (i >> 3) & 0x07; |
@@ -1460,7 +1476,8 @@ static struct it87_data *it87_update_device(struct device *dev) | |||
1460 | data->fan_ctl = it87_read_value(data, IT87_REG_FAN_CTL); | 1476 | data->fan_ctl = it87_read_value(data, IT87_REG_FAN_CTL); |
1461 | 1477 | ||
1462 | data->sensor = it87_read_value(data, IT87_REG_TEMP_ENABLE); | 1478 | data->sensor = it87_read_value(data, IT87_REG_TEMP_ENABLE); |
1463 | /* The 8705 does not have VID capability */ | 1479 | /* The 8705 does not have VID capability. |
1480 | The 8718 does not use IT87_REG_VID for the same purpose. */ | ||
1464 | if (data->type == it8712 || data->type == it8716) { | 1481 | if (data->type == it8712 || data->type == it8716) { |
1465 | data->vid = it87_read_value(data, IT87_REG_VID); | 1482 | data->vid = it87_read_value(data, IT87_REG_VID); |
1466 | /* The older IT8712F revisions had only 5 VID pins, | 1483 | /* The older IT8712F revisions had only 5 VID pins, |
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index de698dc73020..7880c273c2c5 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c | |||
@@ -30,14 +30,37 @@ | |||
30 | #include "lm75.h" | 30 | #include "lm75.h" |
31 | 31 | ||
32 | 32 | ||
33 | /* Addresses to scan */ | 33 | /* |
34 | * This driver handles the LM75 and compatible digital temperature sensors. | ||
35 | * Only types which are _not_ listed in I2C_CLIENT_INSMOD_*() need to be | ||
36 | * listed here. We start at 9 since I2C_CLIENT_INSMOD_*() currently allow | ||
37 | * definition of up to 8 chip types (plus zero). | ||
38 | */ | ||
39 | |||
40 | enum lm75_type { /* keep sorted in alphabetical order */ | ||
41 | ds1775 = 9, | ||
42 | ds75, | ||
43 | /* lm75 -- in I2C_CLIENT_INSMOD_1() */ | ||
44 | lm75a, | ||
45 | max6625, | ||
46 | max6626, | ||
47 | mcp980x, | ||
48 | stds75, | ||
49 | tcn75, | ||
50 | tmp100, | ||
51 | tmp101, | ||
52 | tmp175, | ||
53 | tmp275, | ||
54 | tmp75, | ||
55 | }; | ||
56 | |||
57 | /* Addresses scanned by legacy style driver binding */ | ||
34 | static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, | 58 | static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, |
35 | 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; | 59 | 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; |
36 | 60 | ||
37 | /* Insmod parameters */ | 61 | /* Insmod parameters (only for legacy style driver binding) */ |
38 | I2C_CLIENT_INSMOD_1(lm75); | 62 | I2C_CLIENT_INSMOD_1(lm75); |
39 | 63 | ||
40 | /* Many LM75 constants specified below */ | ||
41 | 64 | ||
42 | /* The LM75 registers */ | 65 | /* The LM75 registers */ |
43 | #define LM75_REG_CONF 0x01 | 66 | #define LM75_REG_CONF 0x01 |
@@ -49,10 +72,11 @@ static const u8 LM75_REG_TEMP[3] = { | |||
49 | 72 | ||
50 | /* Each client has this additional data */ | 73 | /* Each client has this additional data */ |
51 | struct lm75_data { | 74 | struct lm75_data { |
52 | struct i2c_client client; | 75 | struct i2c_client *client; |
53 | struct device *hwmon_dev; | 76 | struct device *hwmon_dev; |
54 | struct mutex update_lock; | 77 | struct mutex update_lock; |
55 | char valid; /* !=0 if following fields are valid */ | 78 | u8 orig_conf; |
79 | char valid; /* !=0 if registers are valid */ | ||
56 | unsigned long last_updated; /* In jiffies */ | 80 | unsigned long last_updated; /* In jiffies */ |
57 | u16 temp[3]; /* Register values, | 81 | u16 temp[3]; /* Register values, |
58 | 0 = input | 82 | 0 = input |
@@ -60,23 +84,14 @@ struct lm75_data { | |||
60 | 2 = hyst */ | 84 | 2 = hyst */ |
61 | }; | 85 | }; |
62 | 86 | ||
63 | static int lm75_attach_adapter(struct i2c_adapter *adapter); | ||
64 | static int lm75_detect(struct i2c_adapter *adapter, int address, int kind); | ||
65 | static void lm75_init_client(struct i2c_client *client); | ||
66 | static int lm75_detach_client(struct i2c_client *client); | ||
67 | static int lm75_read_value(struct i2c_client *client, u8 reg); | 87 | static int lm75_read_value(struct i2c_client *client, u8 reg); |
68 | static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value); | 88 | static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value); |
69 | static struct lm75_data *lm75_update_device(struct device *dev); | 89 | static struct lm75_data *lm75_update_device(struct device *dev); |
70 | 90 | ||
71 | 91 | ||
72 | /* This is the driver that will be inserted */ | 92 | /*-----------------------------------------------------------------------*/ |
73 | static struct i2c_driver lm75_driver = { | 93 | |
74 | .driver = { | 94 | /* sysfs attributes for hwmon */ |
75 | .name = "lm75", | ||
76 | }, | ||
77 | .attach_adapter = lm75_attach_adapter, | ||
78 | .detach_client = lm75_detach_client, | ||
79 | }; | ||
80 | 95 | ||
81 | static ssize_t show_temp(struct device *dev, struct device_attribute *da, | 96 | static ssize_t show_temp(struct device *dev, struct device_attribute *da, |
82 | char *buf) | 97 | char *buf) |
@@ -109,13 +124,6 @@ static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, | |||
109 | show_temp, set_temp, 2); | 124 | show_temp, set_temp, 2); |
110 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); | 125 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); |
111 | 126 | ||
112 | static int lm75_attach_adapter(struct i2c_adapter *adapter) | ||
113 | { | ||
114 | if (!(adapter->class & I2C_CLASS_HWMON)) | ||
115 | return 0; | ||
116 | return i2c_probe(adapter, &addr_data, lm75_detect); | ||
117 | } | ||
118 | |||
119 | static struct attribute *lm75_attributes[] = { | 127 | static struct attribute *lm75_attributes[] = { |
120 | &sensor_dev_attr_temp1_input.dev_attr.attr, | 128 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
121 | &sensor_dev_attr_temp1_max.dev_attr.attr, | 129 | &sensor_dev_attr_temp1_max.dev_attr.attr, |
@@ -128,32 +136,144 @@ static const struct attribute_group lm75_group = { | |||
128 | .attrs = lm75_attributes, | 136 | .attrs = lm75_attributes, |
129 | }; | 137 | }; |
130 | 138 | ||
139 | /*-----------------------------------------------------------------------*/ | ||
140 | |||
141 | /* "New style" I2C driver binding -- following the driver model */ | ||
142 | |||
143 | static int | ||
144 | lm75_probe(struct i2c_client *client, const struct i2c_device_id *id) | ||
145 | { | ||
146 | struct lm75_data *data; | ||
147 | int status; | ||
148 | u8 set_mask, clr_mask; | ||
149 | int new; | ||
150 | |||
151 | if (!i2c_check_functionality(client->adapter, | ||
152 | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) | ||
153 | return -EIO; | ||
154 | |||
155 | data = kzalloc(sizeof(struct lm75_data), GFP_KERNEL); | ||
156 | if (!data) | ||
157 | return -ENOMEM; | ||
158 | |||
159 | i2c_set_clientdata(client, data); | ||
160 | |||
161 | data->client = client; | ||
162 | mutex_init(&data->update_lock); | ||
163 | |||
164 | /* Set to LM75 resolution (9 bits, 1/2 degree C) and range. | ||
165 | * Then tweak to be more precise when appropriate. | ||
166 | */ | ||
167 | set_mask = 0; | ||
168 | clr_mask = (1 << 0) /* continuous conversions */ | ||
169 | | (1 << 6) | (1 << 5); /* 9-bit mode */ | ||
170 | |||
171 | /* configure as specified */ | ||
172 | status = lm75_read_value(client, LM75_REG_CONF); | ||
173 | if (status < 0) { | ||
174 | dev_dbg(&client->dev, "Can't read config? %d\n", status); | ||
175 | goto exit_free; | ||
176 | } | ||
177 | data->orig_conf = status; | ||
178 | new = status & ~clr_mask; | ||
179 | new |= set_mask; | ||
180 | if (status != new) | ||
181 | lm75_write_value(client, LM75_REG_CONF, new); | ||
182 | dev_dbg(&client->dev, "Config %02x\n", new); | ||
183 | |||
184 | /* Register sysfs hooks */ | ||
185 | status = sysfs_create_group(&client->dev.kobj, &lm75_group); | ||
186 | if (status) | ||
187 | goto exit_free; | ||
188 | |||
189 | data->hwmon_dev = hwmon_device_register(&client->dev); | ||
190 | if (IS_ERR(data->hwmon_dev)) { | ||
191 | status = PTR_ERR(data->hwmon_dev); | ||
192 | goto exit_remove; | ||
193 | } | ||
194 | |||
195 | dev_info(&client->dev, "%s: sensor '%s'\n", | ||
196 | data->hwmon_dev->bus_id, client->name); | ||
197 | |||
198 | return 0; | ||
199 | |||
200 | exit_remove: | ||
201 | sysfs_remove_group(&client->dev.kobj, &lm75_group); | ||
202 | exit_free: | ||
203 | i2c_set_clientdata(client, NULL); | ||
204 | kfree(data); | ||
205 | return status; | ||
206 | } | ||
207 | |||
208 | static int lm75_remove(struct i2c_client *client) | ||
209 | { | ||
210 | struct lm75_data *data = i2c_get_clientdata(client); | ||
211 | |||
212 | hwmon_device_unregister(data->hwmon_dev); | ||
213 | sysfs_remove_group(&client->dev.kobj, &lm75_group); | ||
214 | lm75_write_value(client, LM75_REG_CONF, data->orig_conf); | ||
215 | i2c_set_clientdata(client, NULL); | ||
216 | kfree(data); | ||
217 | return 0; | ||
218 | } | ||
219 | |||
220 | static const struct i2c_device_id lm75_ids[] = { | ||
221 | { "ds1775", ds1775, }, | ||
222 | { "ds75", ds75, }, | ||
223 | { "lm75", lm75, }, | ||
224 | { "lm75a", lm75a, }, | ||
225 | { "max6625", max6625, }, | ||
226 | { "max6626", max6626, }, | ||
227 | { "mcp980x", mcp980x, }, | ||
228 | { "stds75", stds75, }, | ||
229 | { "tcn75", tcn75, }, | ||
230 | { "tmp100", tmp100, }, | ||
231 | { "tmp101", tmp101, }, | ||
232 | { "tmp175", tmp175, }, | ||
233 | { "tmp275", tmp275, }, | ||
234 | { "tmp75", tmp75, }, | ||
235 | { /* LIST END */ } | ||
236 | }; | ||
237 | MODULE_DEVICE_TABLE(i2c, lm75_ids); | ||
238 | |||
239 | static struct i2c_driver lm75_driver = { | ||
240 | .driver = { | ||
241 | .name = "lm75", | ||
242 | }, | ||
243 | .probe = lm75_probe, | ||
244 | .remove = lm75_remove, | ||
245 | .id_table = lm75_ids, | ||
246 | }; | ||
247 | |||
248 | /*-----------------------------------------------------------------------*/ | ||
249 | |||
250 | /* "Legacy" I2C driver binding */ | ||
251 | |||
252 | static struct i2c_driver lm75_legacy_driver; | ||
253 | |||
131 | /* This function is called by i2c_probe */ | 254 | /* This function is called by i2c_probe */ |
132 | static int lm75_detect(struct i2c_adapter *adapter, int address, int kind) | 255 | static int lm75_detect(struct i2c_adapter *adapter, int address, int kind) |
133 | { | 256 | { |
134 | int i; | 257 | int i; |
135 | struct i2c_client *new_client; | 258 | struct i2c_client *new_client; |
136 | struct lm75_data *data; | ||
137 | int err = 0; | 259 | int err = 0; |
138 | const char *name = ""; | ||
139 | 260 | ||
140 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | | 261 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | |
141 | I2C_FUNC_SMBUS_WORD_DATA)) | 262 | I2C_FUNC_SMBUS_WORD_DATA)) |
142 | goto exit; | 263 | goto exit; |
143 | 264 | ||
144 | /* OK. For now, we presume we have a valid client. We now create the | 265 | /* OK. For now, we presume we have a valid address. We create the |
145 | client structure, even though we cannot fill it completely yet. | 266 | client structure, even though there may be no sensor present. |
146 | But it allows us to access lm75_{read,write}_value. */ | 267 | But it allows us to use i2c_smbus_read_*_data() calls. */ |
147 | if (!(data = kzalloc(sizeof(struct lm75_data), GFP_KERNEL))) { | 268 | new_client = kzalloc(sizeof *new_client, GFP_KERNEL); |
269 | if (!new_client) { | ||
148 | err = -ENOMEM; | 270 | err = -ENOMEM; |
149 | goto exit; | 271 | goto exit; |
150 | } | 272 | } |
151 | 273 | ||
152 | new_client = &data->client; | ||
153 | i2c_set_clientdata(new_client, data); | ||
154 | new_client->addr = address; | 274 | new_client->addr = address; |
155 | new_client->adapter = adapter; | 275 | new_client->adapter = adapter; |
156 | new_client->driver = &lm75_driver; | 276 | new_client->driver = &lm75_legacy_driver; |
157 | new_client->flags = 0; | 277 | new_client->flags = 0; |
158 | 278 | ||
159 | /* Now, we do the remaining detection. There is no identification- | 279 | /* Now, we do the remaining detection. There is no identification- |
@@ -174,17 +294,17 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind) | |||
174 | || i2c_smbus_read_word_data(new_client, 5) != hyst | 294 | || i2c_smbus_read_word_data(new_client, 5) != hyst |
175 | || i2c_smbus_read_word_data(new_client, 6) != hyst | 295 | || i2c_smbus_read_word_data(new_client, 6) != hyst |
176 | || i2c_smbus_read_word_data(new_client, 7) != hyst) | 296 | || i2c_smbus_read_word_data(new_client, 7) != hyst) |
177 | goto exit_free; | 297 | goto exit_free; |
178 | os = i2c_smbus_read_word_data(new_client, 3); | 298 | os = i2c_smbus_read_word_data(new_client, 3); |
179 | if (i2c_smbus_read_word_data(new_client, 4) != os | 299 | if (i2c_smbus_read_word_data(new_client, 4) != os |
180 | || i2c_smbus_read_word_data(new_client, 5) != os | 300 | || i2c_smbus_read_word_data(new_client, 5) != os |
181 | || i2c_smbus_read_word_data(new_client, 6) != os | 301 | || i2c_smbus_read_word_data(new_client, 6) != os |
182 | || i2c_smbus_read_word_data(new_client, 7) != os) | 302 | || i2c_smbus_read_word_data(new_client, 7) != os) |
183 | goto exit_free; | 303 | goto exit_free; |
184 | 304 | ||
185 | /* Unused bits */ | 305 | /* Unused bits */ |
186 | if (conf & 0xe0) | 306 | if (conf & 0xe0) |
187 | goto exit_free; | 307 | goto exit_free; |
188 | 308 | ||
189 | /* Addresses cycling */ | 309 | /* Addresses cycling */ |
190 | for (i = 8; i < 0xff; i += 8) | 310 | for (i = 8; i < 0xff; i += 8) |
@@ -194,58 +314,57 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind) | |||
194 | goto exit_free; | 314 | goto exit_free; |
195 | } | 315 | } |
196 | 316 | ||
197 | /* Determine the chip type - only one kind supported! */ | 317 | /* NOTE: we treat "force=..." and "force_lm75=..." the same. |
198 | if (kind <= 0) | 318 | * Only new-style driver binding distinguishes chip types. |
199 | kind = lm75; | 319 | */ |
200 | 320 | strlcpy(new_client->name, "lm75", I2C_NAME_SIZE); | |
201 | if (kind == lm75) { | ||
202 | name = "lm75"; | ||
203 | } | ||
204 | |||
205 | /* Fill in the remaining client fields and put it into the global list */ | ||
206 | strlcpy(new_client->name, name, I2C_NAME_SIZE); | ||
207 | data->valid = 0; | ||
208 | mutex_init(&data->update_lock); | ||
209 | 321 | ||
210 | /* Tell the I2C layer a new client has arrived */ | 322 | /* Tell the I2C layer a new client has arrived */ |
211 | if ((err = i2c_attach_client(new_client))) | 323 | err = i2c_attach_client(new_client); |
324 | if (err) | ||
212 | goto exit_free; | 325 | goto exit_free; |
213 | 326 | ||
214 | /* Initialize the LM75 chip */ | 327 | err = lm75_probe(new_client, NULL); |
215 | lm75_init_client(new_client); | 328 | if (err < 0) |
216 | |||
217 | /* Register sysfs hooks */ | ||
218 | if ((err = sysfs_create_group(&new_client->dev.kobj, &lm75_group))) | ||
219 | goto exit_detach; | 329 | goto exit_detach; |
220 | 330 | ||
221 | data->hwmon_dev = hwmon_device_register(&new_client->dev); | ||
222 | if (IS_ERR(data->hwmon_dev)) { | ||
223 | err = PTR_ERR(data->hwmon_dev); | ||
224 | goto exit_remove; | ||
225 | } | ||
226 | |||
227 | return 0; | 331 | return 0; |
228 | 332 | ||
229 | exit_remove: | ||
230 | sysfs_remove_group(&new_client->dev.kobj, &lm75_group); | ||
231 | exit_detach: | 333 | exit_detach: |
232 | i2c_detach_client(new_client); | 334 | i2c_detach_client(new_client); |
233 | exit_free: | 335 | exit_free: |
234 | kfree(data); | 336 | kfree(new_client); |
235 | exit: | 337 | exit: |
236 | return err; | 338 | return err; |
237 | } | 339 | } |
238 | 340 | ||
341 | static int lm75_attach_adapter(struct i2c_adapter *adapter) | ||
342 | { | ||
343 | if (!(adapter->class & I2C_CLASS_HWMON)) | ||
344 | return 0; | ||
345 | return i2c_probe(adapter, &addr_data, lm75_detect); | ||
346 | } | ||
347 | |||
239 | static int lm75_detach_client(struct i2c_client *client) | 348 | static int lm75_detach_client(struct i2c_client *client) |
240 | { | 349 | { |
241 | struct lm75_data *data = i2c_get_clientdata(client); | 350 | lm75_remove(client); |
242 | hwmon_device_unregister(data->hwmon_dev); | ||
243 | sysfs_remove_group(&client->dev.kobj, &lm75_group); | ||
244 | i2c_detach_client(client); | 351 | i2c_detach_client(client); |
245 | kfree(data); | 352 | kfree(client); |
246 | return 0; | 353 | return 0; |
247 | } | 354 | } |
248 | 355 | ||
356 | static struct i2c_driver lm75_legacy_driver = { | ||
357 | .driver = { | ||
358 | .name = "lm75_legacy", | ||
359 | }, | ||
360 | .attach_adapter = lm75_attach_adapter, | ||
361 | .detach_client = lm75_detach_client, | ||
362 | }; | ||
363 | |||
364 | /*-----------------------------------------------------------------------*/ | ||
365 | |||
366 | /* register access */ | ||
367 | |||
249 | /* All registers are word-sized, except for the configuration register. | 368 | /* All registers are word-sized, except for the configuration register. |
250 | LM75 uses a high-byte first convention, which is exactly opposite to | 369 | LM75 uses a high-byte first convention, which is exactly opposite to |
251 | the SMBus standard. */ | 370 | the SMBus standard. */ |
@@ -268,16 +387,6 @@ static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value) | |||
268 | return i2c_smbus_write_word_data(client, reg, swab16(value)); | 387 | return i2c_smbus_write_word_data(client, reg, swab16(value)); |
269 | } | 388 | } |
270 | 389 | ||
271 | static void lm75_init_client(struct i2c_client *client) | ||
272 | { | ||
273 | int reg; | ||
274 | |||
275 | /* Enable if in shutdown mode */ | ||
276 | reg = lm75_read_value(client, LM75_REG_CONF); | ||
277 | if (reg >= 0 && (reg & 0x01)) | ||
278 | lm75_write_value(client, LM75_REG_CONF, reg & 0xfe); | ||
279 | } | ||
280 | |||
281 | static struct lm75_data *lm75_update_device(struct device *dev) | 390 | static struct lm75_data *lm75_update_device(struct device *dev) |
282 | { | 391 | { |
283 | struct i2c_client *client = to_i2c_client(dev); | 392 | struct i2c_client *client = to_i2c_client(dev); |
@@ -309,13 +418,28 @@ static struct lm75_data *lm75_update_device(struct device *dev) | |||
309 | return data; | 418 | return data; |
310 | } | 419 | } |
311 | 420 | ||
421 | /*-----------------------------------------------------------------------*/ | ||
422 | |||
423 | /* module glue */ | ||
424 | |||
312 | static int __init sensors_lm75_init(void) | 425 | static int __init sensors_lm75_init(void) |
313 | { | 426 | { |
314 | return i2c_add_driver(&lm75_driver); | 427 | int status; |
428 | |||
429 | status = i2c_add_driver(&lm75_driver); | ||
430 | if (status < 0) | ||
431 | return status; | ||
432 | |||
433 | status = i2c_add_driver(&lm75_legacy_driver); | ||
434 | if (status < 0) | ||
435 | i2c_del_driver(&lm75_driver); | ||
436 | |||
437 | return status; | ||
315 | } | 438 | } |
316 | 439 | ||
317 | static void __exit sensors_lm75_exit(void) | 440 | static void __exit sensors_lm75_exit(void) |
318 | { | 441 | { |
442 | i2c_del_driver(&lm75_legacy_driver); | ||
319 | i2c_del_driver(&lm75_driver); | 443 | i2c_del_driver(&lm75_driver); |
320 | } | 444 | } |
321 | 445 | ||
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index ee5eca1c1921..12d446f54f97 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | lm85.c - Part of lm_sensors, Linux kernel modules for hardware | 2 | lm85.c - Part of lm_sensors, Linux kernel modules for hardware |
3 | monitoring | 3 | monitoring |
4 | Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> | 4 | Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> |
5 | Copyright (c) 2002, 2003 Philip Pokorny <ppokorny@penguincomputing.com> | 5 | Copyright (c) 2002, 2003 Philip Pokorny <ppokorny@penguincomputing.com> |
6 | Copyright (c) 2003 Margit Schubert-While <margitsw@t-online.de> | 6 | Copyright (c) 2003 Margit Schubert-While <margitsw@t-online.de> |
7 | Copyright (c) 2004 Justin Thiessen <jthiessen@penguincomputing.com> | 7 | Copyright (c) 2004 Justin Thiessen <jthiessen@penguincomputing.com> |
@@ -51,24 +51,17 @@ I2C_CLIENT_INSMOD_6(lm85b, lm85c, adm1027, adt7463, emc6d100, emc6d102); | |||
51 | #define LM85_REG_TEMP_MAX(nr) (0x4f + (nr) * 2) | 51 | #define LM85_REG_TEMP_MAX(nr) (0x4f + (nr) * 2) |
52 | 52 | ||
53 | /* Fan speeds are LSB, MSB (2 bytes) */ | 53 | /* Fan speeds are LSB, MSB (2 bytes) */ |
54 | #define LM85_REG_FAN(nr) (0x28 + (nr) *2) | 54 | #define LM85_REG_FAN(nr) (0x28 + (nr) * 2) |
55 | #define LM85_REG_FAN_MIN(nr) (0x54 + (nr) *2) | 55 | #define LM85_REG_FAN_MIN(nr) (0x54 + (nr) * 2) |
56 | 56 | ||
57 | #define LM85_REG_PWM(nr) (0x30 + (nr)) | 57 | #define LM85_REG_PWM(nr) (0x30 + (nr)) |
58 | 58 | ||
59 | #define ADT7463_REG_OPPOINT(nr) (0x33 + (nr)) | ||
60 | |||
61 | #define ADT7463_REG_TMIN_CTL1 0x36 | ||
62 | #define ADT7463_REG_TMIN_CTL2 0x37 | ||
63 | |||
64 | #define LM85_REG_DEVICE 0x3d | ||
65 | #define LM85_REG_COMPANY 0x3e | 59 | #define LM85_REG_COMPANY 0x3e |
66 | #define LM85_REG_VERSTEP 0x3f | 60 | #define LM85_REG_VERSTEP 0x3f |
67 | /* These are the recognized values for the above regs */ | 61 | /* These are the recognized values for the above regs */ |
68 | #define LM85_DEVICE_ADX 0x27 | ||
69 | #define LM85_COMPANY_NATIONAL 0x01 | 62 | #define LM85_COMPANY_NATIONAL 0x01 |
70 | #define LM85_COMPANY_ANALOG_DEV 0x41 | 63 | #define LM85_COMPANY_ANALOG_DEV 0x41 |
71 | #define LM85_COMPANY_SMSC 0x5c | 64 | #define LM85_COMPANY_SMSC 0x5c |
72 | #define LM85_VERSTEP_VMASK 0xf0 | 65 | #define LM85_VERSTEP_VMASK 0xf0 |
73 | #define LM85_VERSTEP_GENERIC 0x60 | 66 | #define LM85_VERSTEP_GENERIC 0x60 |
74 | #define LM85_VERSTEP_LM85C 0x60 | 67 | #define LM85_VERSTEP_LM85C 0x60 |
@@ -91,58 +84,45 @@ I2C_CLIENT_INSMOD_6(lm85b, lm85c, adm1027, adt7463, emc6d100, emc6d102); | |||
91 | #define LM85_REG_AFAN_CONFIG(nr) (0x5c + (nr)) | 84 | #define LM85_REG_AFAN_CONFIG(nr) (0x5c + (nr)) |
92 | #define LM85_REG_AFAN_RANGE(nr) (0x5f + (nr)) | 85 | #define LM85_REG_AFAN_RANGE(nr) (0x5f + (nr)) |
93 | #define LM85_REG_AFAN_SPIKE1 0x62 | 86 | #define LM85_REG_AFAN_SPIKE1 0x62 |
94 | #define LM85_REG_AFAN_SPIKE2 0x63 | ||
95 | #define LM85_REG_AFAN_MINPWM(nr) (0x64 + (nr)) | 87 | #define LM85_REG_AFAN_MINPWM(nr) (0x64 + (nr)) |
96 | #define LM85_REG_AFAN_LIMIT(nr) (0x67 + (nr)) | 88 | #define LM85_REG_AFAN_LIMIT(nr) (0x67 + (nr)) |
97 | #define LM85_REG_AFAN_CRITICAL(nr) (0x6a + (nr)) | 89 | #define LM85_REG_AFAN_CRITICAL(nr) (0x6a + (nr)) |
98 | #define LM85_REG_AFAN_HYST1 0x6d | 90 | #define LM85_REG_AFAN_HYST1 0x6d |
99 | #define LM85_REG_AFAN_HYST2 0x6e | 91 | #define LM85_REG_AFAN_HYST2 0x6e |
100 | 92 | ||
101 | #define LM85_REG_TACH_MODE 0x74 | ||
102 | #define LM85_REG_SPINUP_CTL 0x75 | ||
103 | |||
104 | #define ADM1027_REG_TEMP_OFFSET(nr) (0x70 + (nr)) | ||
105 | #define ADM1027_REG_CONFIG2 0x73 | ||
106 | #define ADM1027_REG_INTMASK1 0x74 | ||
107 | #define ADM1027_REG_INTMASK2 0x75 | ||
108 | #define ADM1027_REG_EXTEND_ADC1 0x76 | 93 | #define ADM1027_REG_EXTEND_ADC1 0x76 |
109 | #define ADM1027_REG_EXTEND_ADC2 0x77 | 94 | #define ADM1027_REG_EXTEND_ADC2 0x77 |
110 | #define ADM1027_REG_CONFIG3 0x78 | ||
111 | #define ADM1027_REG_FAN_PPR 0x7b | ||
112 | |||
113 | #define ADT7463_REG_THERM 0x79 | ||
114 | #define ADT7463_REG_THERM_LIMIT 0x7A | ||
115 | 95 | ||
116 | #define EMC6D100_REG_ALARM3 0x7d | 96 | #define EMC6D100_REG_ALARM3 0x7d |
117 | /* IN5, IN6 and IN7 */ | 97 | /* IN5, IN6 and IN7 */ |
118 | #define EMC6D100_REG_IN(nr) (0x70 + ((nr)-5)) | 98 | #define EMC6D100_REG_IN(nr) (0x70 + ((nr) - 5)) |
119 | #define EMC6D100_REG_IN_MIN(nr) (0x73 + ((nr)-5) * 2) | 99 | #define EMC6D100_REG_IN_MIN(nr) (0x73 + ((nr) - 5) * 2) |
120 | #define EMC6D100_REG_IN_MAX(nr) (0x74 + ((nr)-5) * 2) | 100 | #define EMC6D100_REG_IN_MAX(nr) (0x74 + ((nr) - 5) * 2) |
121 | #define EMC6D102_REG_EXTEND_ADC1 0x85 | 101 | #define EMC6D102_REG_EXTEND_ADC1 0x85 |
122 | #define EMC6D102_REG_EXTEND_ADC2 0x86 | 102 | #define EMC6D102_REG_EXTEND_ADC2 0x86 |
123 | #define EMC6D102_REG_EXTEND_ADC3 0x87 | 103 | #define EMC6D102_REG_EXTEND_ADC3 0x87 |
124 | #define EMC6D102_REG_EXTEND_ADC4 0x88 | 104 | #define EMC6D102_REG_EXTEND_ADC4 0x88 |
125 | 105 | ||
126 | 106 | ||
127 | /* Conversions. Rounding and limit checking is only done on the TO_REG | 107 | /* Conversions. Rounding and limit checking is only done on the TO_REG |
128 | variants. Note that you should be a bit careful with which arguments | 108 | variants. Note that you should be a bit careful with which arguments |
129 | these macros are called: arguments may be evaluated more than once. | 109 | these macros are called: arguments may be evaluated more than once. |
130 | */ | 110 | */ |
131 | 111 | ||
132 | /* IN are scaled acording to built-in resistors */ | 112 | /* IN are scaled acording to built-in resistors */ |
133 | static int lm85_scaling[] = { /* .001 Volts */ | 113 | static const int lm85_scaling[] = { /* .001 Volts */ |
134 | 2500, 2250, 3300, 5000, 12000, | 114 | 2500, 2250, 3300, 5000, 12000, |
135 | 3300, 1500, 1800 /*EMC6D100*/ | 115 | 3300, 1500, 1800 /*EMC6D100*/ |
136 | }; | 116 | }; |
137 | #define SCALE(val,from,to) (((val)*(to) + ((from)/2))/(from)) | 117 | #define SCALE(val, from, to) (((val) * (to) + ((from) / 2)) / (from)) |
138 | 118 | ||
139 | #define INS_TO_REG(n,val) \ | 119 | #define INS_TO_REG(n, val) \ |
140 | SENSORS_LIMIT(SCALE(val,lm85_scaling[n],192),0,255) | 120 | SENSORS_LIMIT(SCALE(val, lm85_scaling[n], 192), 0, 255) |
141 | 121 | ||
142 | #define INSEXT_FROM_REG(n,val,ext) \ | 122 | #define INSEXT_FROM_REG(n, val, ext) \ |
143 | SCALE(((val) << 4) + (ext), 192 << 4, lm85_scaling[n]) | 123 | SCALE(((val) << 4) + (ext), 192 << 4, lm85_scaling[n]) |
144 | 124 | ||
145 | #define INS_FROM_REG(n,val) SCALE((val), 192, lm85_scaling[n]) | 125 | #define INS_FROM_REG(n, val) SCALE((val), 192, lm85_scaling[n]) |
146 | 126 | ||
147 | /* FAN speed is measured using 90kHz clock */ | 127 | /* FAN speed is measured using 90kHz clock */ |
148 | static inline u16 FAN_TO_REG(unsigned long val) | 128 | static inline u16 FAN_TO_REG(unsigned long val) |
@@ -151,16 +131,17 @@ static inline u16 FAN_TO_REG(unsigned long val) | |||
151 | return 0xffff; | 131 | return 0xffff; |
152 | return SENSORS_LIMIT(5400000 / val, 1, 0xfffe); | 132 | return SENSORS_LIMIT(5400000 / val, 1, 0xfffe); |
153 | } | 133 | } |
154 | #define FAN_FROM_REG(val) ((val)==0?-1:(val)==0xffff?0:5400000/(val)) | 134 | #define FAN_FROM_REG(val) ((val) == 0 ? -1 : (val) == 0xffff ? 0 : \ |
135 | 5400000 / (val)) | ||
155 | 136 | ||
156 | /* Temperature is reported in .001 degC increments */ | 137 | /* Temperature is reported in .001 degC increments */ |
157 | #define TEMP_TO_REG(val) \ | 138 | #define TEMP_TO_REG(val) \ |
158 | SENSORS_LIMIT(SCALE(val,1000,1),-127,127) | 139 | SENSORS_LIMIT(SCALE(val, 1000, 1), -127, 127) |
159 | #define TEMPEXT_FROM_REG(val,ext) \ | 140 | #define TEMPEXT_FROM_REG(val, ext) \ |
160 | SCALE(((val) << 4) + (ext), 16, 1000) | 141 | SCALE(((val) << 4) + (ext), 16, 1000) |
161 | #define TEMP_FROM_REG(val) ((val) * 1000) | 142 | #define TEMP_FROM_REG(val) ((val) * 1000) |
162 | 143 | ||
163 | #define PWM_TO_REG(val) (SENSORS_LIMIT(val,0,255)) | 144 | #define PWM_TO_REG(val) SENSORS_LIMIT(val, 0, 255) |
164 | #define PWM_FROM_REG(val) (val) | 145 | #define PWM_FROM_REG(val) (val) |
165 | 146 | ||
166 | 147 | ||
@@ -183,17 +164,17 @@ static inline u16 FAN_TO_REG(unsigned long val) | |||
183 | */ | 164 | */ |
184 | 165 | ||
185 | /* These are the zone temperature range encodings in .001 degree C */ | 166 | /* These are the zone temperature range encodings in .001 degree C */ |
186 | static int lm85_range_map[] = { | 167 | static const int lm85_range_map[] = { |
187 | 2000, 2500, 3300, 4000, 5000, 6600, | 168 | 2000, 2500, 3300, 4000, 5000, 6600, 8000, 10000, |
188 | 8000, 10000, 13300, 16000, 20000, 26600, | 169 | 13300, 16000, 20000, 26600, 32000, 40000, 53300, 80000 |
189 | 32000, 40000, 53300, 80000 | 170 | }; |
190 | }; | 171 | |
191 | static int RANGE_TO_REG( int range ) | 172 | static int RANGE_TO_REG(int range) |
192 | { | 173 | { |
193 | int i; | 174 | int i; |
194 | 175 | ||
195 | if (range >= lm85_range_map[15]) | 176 | if (range >= lm85_range_map[15]) |
196 | return 15 ; | 177 | return 15; |
197 | 178 | ||
198 | /* Find the closest match */ | 179 | /* Find the closest match */ |
199 | for (i = 14; i >= 0; --i) { | 180 | for (i = 14; i >= 0; --i) { |
@@ -207,28 +188,25 @@ static int RANGE_TO_REG( int range ) | |||
207 | 188 | ||
208 | return 0; | 189 | return 0; |
209 | } | 190 | } |
210 | #define RANGE_FROM_REG(val) (lm85_range_map[(val)&0x0f]) | 191 | #define RANGE_FROM_REG(val) lm85_range_map[(val) & 0x0f] |
211 | 192 | ||
212 | /* These are the Acoustic Enhancement, or Temperature smoothing encodings | ||
213 | * NOTE: The enable/disable bit is INCLUDED in these encodings as the | ||
214 | * MSB (bit 3, value 8). If the enable bit is 0, the encoded value | ||
215 | * is ignored, or set to 0. | ||
216 | */ | ||
217 | /* These are the PWM frequency encodings */ | 193 | /* These are the PWM frequency encodings */ |
218 | static int lm85_freq_map[] = { /* .1 Hz */ | 194 | static const int lm85_freq_map[] = { /* .1 Hz */ |
219 | 100, 150, 230, 300, 380, 470, 620, 940 | 195 | 100, 150, 230, 300, 380, 470, 620, 940 |
220 | }; | 196 | }; |
221 | static int FREQ_TO_REG( int freq ) | 197 | |
198 | static int FREQ_TO_REG(int freq) | ||
222 | { | 199 | { |
223 | int i; | 200 | int i; |
224 | 201 | ||
225 | if( freq >= lm85_freq_map[7] ) { return 7 ; } | 202 | if (freq >= lm85_freq_map[7]) |
226 | for( i = 0 ; i < 7 ; ++i ) | 203 | return 7; |
227 | if( freq <= lm85_freq_map[i] ) | 204 | for (i = 0; i < 7; ++i) |
228 | break ; | 205 | if (freq <= lm85_freq_map[i]) |
229 | return( i & 0x07 ); | 206 | break; |
207 | return i; | ||
230 | } | 208 | } |
231 | #define FREQ_FROM_REG(val) (lm85_freq_map[(val)&0x07]) | 209 | #define FREQ_FROM_REG(val) lm85_freq_map[(val) & 0x07] |
232 | 210 | ||
233 | /* Since we can't use strings, I'm abusing these numbers | 211 | /* Since we can't use strings, I'm abusing these numbers |
234 | * to stand in for the following meanings: | 212 | * to stand in for the following meanings: |
@@ -242,30 +220,23 @@ static int FREQ_TO_REG( int freq ) | |||
242 | * -2 -- PWM responds to manual control | 220 | * -2 -- PWM responds to manual control |
243 | */ | 221 | */ |
244 | 222 | ||
245 | static int lm85_zone_map[] = { 1, 2, 3, -1, 0, 23, 123, -2 }; | 223 | static const int lm85_zone_map[] = { 1, 2, 3, -1, 0, 23, 123, -2 }; |
246 | #define ZONE_FROM_REG(val) (lm85_zone_map[((val)>>5)&0x07]) | 224 | #define ZONE_FROM_REG(val) lm85_zone_map[(val) >> 5] |
247 | 225 | ||
248 | static int ZONE_TO_REG( int zone ) | 226 | static int ZONE_TO_REG(int zone) |
249 | { | 227 | { |
250 | int i; | 228 | int i; |
251 | 229 | ||
252 | for( i = 0 ; i <= 7 ; ++i ) | 230 | for (i = 0; i <= 7; ++i) |
253 | if( zone == lm85_zone_map[i] ) | 231 | if (zone == lm85_zone_map[i]) |
254 | break ; | 232 | break; |
255 | if( i > 7 ) /* Not found. */ | 233 | if (i > 7) /* Not found. */ |
256 | i = 3; /* Always 100% */ | 234 | i = 3; /* Always 100% */ |
257 | return( (i & 0x07)<<5 ); | 235 | return i << 5; |
258 | } | 236 | } |
259 | 237 | ||
260 | #define HYST_TO_REG(val) (SENSORS_LIMIT(((val)+500)/1000,0,15)) | 238 | #define HYST_TO_REG(val) SENSORS_LIMIT(((val) + 500) / 1000, 0, 15) |
261 | #define HYST_FROM_REG(val) ((val)*1000) | 239 | #define HYST_FROM_REG(val) ((val) * 1000) |
262 | |||
263 | #define OFFSET_TO_REG(val) (SENSORS_LIMIT((val)/25,-127,127)) | ||
264 | #define OFFSET_FROM_REG(val) ((val)*25) | ||
265 | |||
266 | #define PPR_MASK(fan) (0x03<<(fan *2)) | ||
267 | #define PPR_TO_REG(val,fan) (SENSORS_LIMIT((val)-1,0,3)<<(fan *2)) | ||
268 | #define PPR_FROM_REG(val,fan) ((((val)>>(fan * 2))&0x03)+1) | ||
269 | 240 | ||
270 | /* Chip sampling rates | 241 | /* Chip sampling rates |
271 | * | 242 | * |
@@ -292,11 +263,11 @@ struct lm85_zone { | |||
292 | u8 hyst; /* Low limit hysteresis. (0-15) */ | 263 | u8 hyst; /* Low limit hysteresis. (0-15) */ |
293 | u8 range; /* Temp range, encoded */ | 264 | u8 range; /* Temp range, encoded */ |
294 | s8 critical; /* "All fans ON" temp limit */ | 265 | s8 critical; /* "All fans ON" temp limit */ |
295 | u8 off_desired; /* Actual "off" temperature specified. Preserved | 266 | u8 off_desired; /* Actual "off" temperature specified. Preserved |
296 | * to prevent "drift" as other autofan control | 267 | * to prevent "drift" as other autofan control |
297 | * values change. | 268 | * values change. |
298 | */ | 269 | */ |
299 | u8 max_desired; /* Actual "max" temperature specified. Preserved | 270 | u8 max_desired; /* Actual "max" temperature specified. Preserved |
300 | * to prevent "drift" as other autofan control | 271 | * to prevent "drift" as other autofan control |
301 | * values change. | 272 | * values change. |
302 | */ | 273 | */ |
@@ -327,23 +298,13 @@ struct lm85_data { | |||
327 | s8 temp[3]; /* Register value */ | 298 | s8 temp[3]; /* Register value */ |
328 | s8 temp_min[3]; /* Register value */ | 299 | s8 temp_min[3]; /* Register value */ |
329 | s8 temp_max[3]; /* Register value */ | 300 | s8 temp_max[3]; /* Register value */ |
330 | s8 temp_offset[3]; /* Register value */ | ||
331 | u16 fan[4]; /* Register value */ | 301 | u16 fan[4]; /* Register value */ |
332 | u16 fan_min[4]; /* Register value */ | 302 | u16 fan_min[4]; /* Register value */ |
333 | u8 pwm[3]; /* Register value */ | 303 | u8 pwm[3]; /* Register value */ |
334 | u8 spinup_ctl; /* Register encoding, combined */ | ||
335 | u8 tach_mode; /* Register encoding, combined */ | ||
336 | u8 temp_ext[3]; /* Decoded values */ | 304 | u8 temp_ext[3]; /* Decoded values */ |
337 | u8 in_ext[8]; /* Decoded values */ | 305 | u8 in_ext[8]; /* Decoded values */ |
338 | u8 fan_ppr; /* Register value */ | ||
339 | u8 smooth[3]; /* Register encoding */ | ||
340 | u8 vid; /* Register value */ | 306 | u8 vid; /* Register value */ |
341 | u8 vrm; /* VRM version */ | 307 | u8 vrm; /* VRM version */ |
342 | u8 syncpwm3; /* Saved PWM3 for TACH 2,3,4 config */ | ||
343 | u8 oppoint[3]; /* Register value */ | ||
344 | u16 tmin_ctl; /* Register value */ | ||
345 | unsigned long therm_total; /* Cummulative therm count */ | ||
346 | u8 therm_limit; /* Register value */ | ||
347 | u32 alarms; /* Register encoding, combined */ | 308 | u32 alarms; /* Register encoding, combined */ |
348 | struct lm85_autofan autofan[3]; | 309 | struct lm85_autofan autofan[3]; |
349 | struct lm85_zone zone[3]; | 310 | struct lm85_zone zone[3]; |
@@ -355,9 +316,8 @@ static int lm85_detect(struct i2c_adapter *adapter, int address, | |||
355 | static int lm85_detach_client(struct i2c_client *client); | 316 | static int lm85_detach_client(struct i2c_client *client); |
356 | 317 | ||
357 | static int lm85_read_value(struct i2c_client *client, u8 reg); | 318 | static int lm85_read_value(struct i2c_client *client, u8 reg); |
358 | static int lm85_write_value(struct i2c_client *client, u8 reg, int value); | 319 | static void lm85_write_value(struct i2c_client *client, u8 reg, int value); |
359 | static struct lm85_data *lm85_update_device(struct device *dev); | 320 | static struct lm85_data *lm85_update_device(struct device *dev); |
360 | static void lm85_init_client(struct i2c_client *client); | ||
361 | 321 | ||
362 | 322 | ||
363 | static struct i2c_driver lm85_driver = { | 323 | static struct i2c_driver lm85_driver = { |
@@ -375,7 +335,7 @@ static ssize_t show_fan(struct device *dev, struct device_attribute *attr, | |||
375 | { | 335 | { |
376 | int nr = to_sensor_dev_attr(attr)->index; | 336 | int nr = to_sensor_dev_attr(attr)->index; |
377 | struct lm85_data *data = lm85_update_device(dev); | 337 | struct lm85_data *data = lm85_update_device(dev); |
378 | return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan[nr]) ); | 338 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr])); |
379 | } | 339 | } |
380 | 340 | ||
381 | static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, | 341 | static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, |
@@ -383,7 +343,7 @@ static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, | |||
383 | { | 343 | { |
384 | int nr = to_sensor_dev_attr(attr)->index; | 344 | int nr = to_sensor_dev_attr(attr)->index; |
385 | struct lm85_data *data = lm85_update_device(dev); | 345 | struct lm85_data *data = lm85_update_device(dev); |
386 | return sprintf(buf,"%d\n", FAN_FROM_REG(data->fan_min[nr]) ); | 346 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr])); |
387 | } | 347 | } |
388 | 348 | ||
389 | static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, | 349 | static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, |
@@ -414,7 +374,8 @@ show_fan_offset(4); | |||
414 | 374 | ||
415 | /* vid, vrm, alarms */ | 375 | /* vid, vrm, alarms */ |
416 | 376 | ||
417 | static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf) | 377 | static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, |
378 | char *buf) | ||
418 | { | 379 | { |
419 | struct lm85_data *data = lm85_update_device(dev); | 380 | struct lm85_data *data = lm85_update_device(dev); |
420 | int vid; | 381 | int vid; |
@@ -432,13 +393,15 @@ static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, c | |||
432 | 393 | ||
433 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); | 394 | static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); |
434 | 395 | ||
435 | static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) | 396 | static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, |
397 | char *buf) | ||
436 | { | 398 | { |
437 | struct lm85_data *data = dev_get_drvdata(dev); | 399 | struct lm85_data *data = dev_get_drvdata(dev); |
438 | return sprintf(buf, "%ld\n", (long) data->vrm); | 400 | return sprintf(buf, "%ld\n", (long) data->vrm); |
439 | } | 401 | } |
440 | 402 | ||
441 | static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 403 | static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr, |
404 | const char *buf, size_t count) | ||
442 | { | 405 | { |
443 | struct lm85_data *data = dev_get_drvdata(dev); | 406 | struct lm85_data *data = dev_get_drvdata(dev); |
444 | data->vrm = simple_strtoul(buf, NULL, 10); | 407 | data->vrm = simple_strtoul(buf, NULL, 10); |
@@ -447,7 +410,8 @@ static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr, | |||
447 | 410 | ||
448 | static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg); | 411 | static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg); |
449 | 412 | ||
450 | static ssize_t show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) | 413 | static ssize_t show_alarms_reg(struct device *dev, struct device_attribute |
414 | *attr, char *buf) | ||
451 | { | 415 | { |
452 | struct lm85_data *data = lm85_update_device(dev); | 416 | struct lm85_data *data = lm85_update_device(dev); |
453 | return sprintf(buf, "%u\n", data->alarms); | 417 | return sprintf(buf, "%u\n", data->alarms); |
@@ -488,7 +452,7 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *attr, | |||
488 | { | 452 | { |
489 | int nr = to_sensor_dev_attr(attr)->index; | 453 | int nr = to_sensor_dev_attr(attr)->index; |
490 | struct lm85_data *data = lm85_update_device(dev); | 454 | struct lm85_data *data = lm85_update_device(dev); |
491 | return sprintf(buf,"%d\n", PWM_FROM_REG(data->pwm[nr]) ); | 455 | return sprintf(buf, "%d\n", PWM_FROM_REG(data->pwm[nr])); |
492 | } | 456 | } |
493 | 457 | ||
494 | static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, | 458 | static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, |
@@ -581,17 +545,16 @@ static ssize_t show_in(struct device *dev, struct device_attribute *attr, | |||
581 | { | 545 | { |
582 | int nr = to_sensor_dev_attr(attr)->index; | 546 | int nr = to_sensor_dev_attr(attr)->index; |
583 | struct lm85_data *data = lm85_update_device(dev); | 547 | struct lm85_data *data = lm85_update_device(dev); |
584 | return sprintf( buf, "%d\n", INSEXT_FROM_REG(nr, | 548 | return sprintf(buf, "%d\n", INSEXT_FROM_REG(nr, data->in[nr], |
585 | data->in[nr], | 549 | data->in_ext[nr])); |
586 | data->in_ext[nr])); | ||
587 | } | 550 | } |
588 | 551 | ||
589 | static ssize_t show_in_min(struct device *dev, struct device_attribute *attr, | 552 | static ssize_t show_in_min(struct device *dev, struct device_attribute *attr, |
590 | char *buf) | 553 | char *buf) |
591 | { | 554 | { |
592 | int nr = to_sensor_dev_attr(attr)->index; | 555 | int nr = to_sensor_dev_attr(attr)->index; |
593 | struct lm85_data *data = lm85_update_device(dev); | 556 | struct lm85_data *data = lm85_update_device(dev); |
594 | return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in_min[nr]) ); | 557 | return sprintf(buf, "%d\n", INS_FROM_REG(nr, data->in_min[nr])); |
595 | } | 558 | } |
596 | 559 | ||
597 | static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, | 560 | static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, |
@@ -614,7 +577,7 @@ static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, | |||
614 | { | 577 | { |
615 | int nr = to_sensor_dev_attr(attr)->index; | 578 | int nr = to_sensor_dev_attr(attr)->index; |
616 | struct lm85_data *data = lm85_update_device(dev); | 579 | struct lm85_data *data = lm85_update_device(dev); |
617 | return sprintf(buf,"%d\n", INS_FROM_REG(nr, data->in_max[nr]) ); | 580 | return sprintf(buf, "%d\n", INS_FROM_REG(nr, data->in_max[nr])); |
618 | } | 581 | } |
619 | 582 | ||
620 | static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, | 583 | static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, |
@@ -656,8 +619,8 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *attr, | |||
656 | { | 619 | { |
657 | int nr = to_sensor_dev_attr(attr)->index; | 620 | int nr = to_sensor_dev_attr(attr)->index; |
658 | struct lm85_data *data = lm85_update_device(dev); | 621 | struct lm85_data *data = lm85_update_device(dev); |
659 | return sprintf(buf,"%d\n", TEMPEXT_FROM_REG(data->temp[nr], | 622 | return sprintf(buf, "%d\n", TEMPEXT_FROM_REG(data->temp[nr], |
660 | data->temp_ext[nr])); | 623 | data->temp_ext[nr])); |
661 | } | 624 | } |
662 | 625 | ||
663 | static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr, | 626 | static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr, |
@@ -665,7 +628,7 @@ static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr, | |||
665 | { | 628 | { |
666 | int nr = to_sensor_dev_attr(attr)->index; | 629 | int nr = to_sensor_dev_attr(attr)->index; |
667 | struct lm85_data *data = lm85_update_device(dev); | 630 | struct lm85_data *data = lm85_update_device(dev); |
668 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_min[nr]) ); | 631 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[nr])); |
669 | } | 632 | } |
670 | 633 | ||
671 | static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | 634 | static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, |
@@ -688,7 +651,7 @@ static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr, | |||
688 | { | 651 | { |
689 | int nr = to_sensor_dev_attr(attr)->index; | 652 | int nr = to_sensor_dev_attr(attr)->index; |
690 | struct lm85_data *data = lm85_update_device(dev); | 653 | struct lm85_data *data = lm85_update_device(dev); |
691 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->temp_max[nr]) ); | 654 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[nr])); |
692 | } | 655 | } |
693 | 656 | ||
694 | static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, | 657 | static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, |
@@ -697,7 +660,7 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, | |||
697 | int nr = to_sensor_dev_attr(attr)->index; | 660 | int nr = to_sensor_dev_attr(attr)->index; |
698 | struct i2c_client *client = to_i2c_client(dev); | 661 | struct i2c_client *client = to_i2c_client(dev); |
699 | struct lm85_data *data = i2c_get_clientdata(client); | 662 | struct lm85_data *data = i2c_get_clientdata(client); |
700 | long val = simple_strtol(buf, NULL, 10); | 663 | long val = simple_strtol(buf, NULL, 10); |
701 | 664 | ||
702 | mutex_lock(&data->update_lock); | 665 | mutex_lock(&data->update_lock); |
703 | data->temp_max[nr] = TEMP_TO_REG(val); | 666 | data->temp_max[nr] = TEMP_TO_REG(val); |
@@ -726,7 +689,7 @@ static ssize_t show_pwm_auto_channels(struct device *dev, | |||
726 | { | 689 | { |
727 | int nr = to_sensor_dev_attr(attr)->index; | 690 | int nr = to_sensor_dev_attr(attr)->index; |
728 | struct lm85_data *data = lm85_update_device(dev); | 691 | struct lm85_data *data = lm85_update_device(dev); |
729 | return sprintf(buf,"%d\n", ZONE_FROM_REG(data->autofan[nr].config)); | 692 | return sprintf(buf, "%d\n", ZONE_FROM_REG(data->autofan[nr].config)); |
730 | } | 693 | } |
731 | 694 | ||
732 | static ssize_t set_pwm_auto_channels(struct device *dev, | 695 | static ssize_t set_pwm_auto_channels(struct device *dev, |
@@ -735,11 +698,11 @@ static ssize_t set_pwm_auto_channels(struct device *dev, | |||
735 | int nr = to_sensor_dev_attr(attr)->index; | 698 | int nr = to_sensor_dev_attr(attr)->index; |
736 | struct i2c_client *client = to_i2c_client(dev); | 699 | struct i2c_client *client = to_i2c_client(dev); |
737 | struct lm85_data *data = i2c_get_clientdata(client); | 700 | struct lm85_data *data = i2c_get_clientdata(client); |
738 | long val = simple_strtol(buf, NULL, 10); | 701 | long val = simple_strtol(buf, NULL, 10); |
739 | 702 | ||
740 | mutex_lock(&data->update_lock); | 703 | mutex_lock(&data->update_lock); |
741 | data->autofan[nr].config = (data->autofan[nr].config & (~0xe0)) | 704 | data->autofan[nr].config = (data->autofan[nr].config & (~0xe0)) |
742 | | ZONE_TO_REG(val) ; | 705 | | ZONE_TO_REG(val); |
743 | lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr), | 706 | lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr), |
744 | data->autofan[nr].config); | 707 | data->autofan[nr].config); |
745 | mutex_unlock(&data->update_lock); | 708 | mutex_unlock(&data->update_lock); |
@@ -751,7 +714,7 @@ static ssize_t show_pwm_auto_pwm_min(struct device *dev, | |||
751 | { | 714 | { |
752 | int nr = to_sensor_dev_attr(attr)->index; | 715 | int nr = to_sensor_dev_attr(attr)->index; |
753 | struct lm85_data *data = lm85_update_device(dev); | 716 | struct lm85_data *data = lm85_update_device(dev); |
754 | return sprintf(buf,"%d\n", PWM_FROM_REG(data->autofan[nr].min_pwm)); | 717 | return sprintf(buf, "%d\n", PWM_FROM_REG(data->autofan[nr].min_pwm)); |
755 | } | 718 | } |
756 | 719 | ||
757 | static ssize_t set_pwm_auto_pwm_min(struct device *dev, | 720 | static ssize_t set_pwm_auto_pwm_min(struct device *dev, |
@@ -775,7 +738,7 @@ static ssize_t show_pwm_auto_pwm_minctl(struct device *dev, | |||
775 | { | 738 | { |
776 | int nr = to_sensor_dev_attr(attr)->index; | 739 | int nr = to_sensor_dev_attr(attr)->index; |
777 | struct lm85_data *data = lm85_update_device(dev); | 740 | struct lm85_data *data = lm85_update_device(dev); |
778 | return sprintf(buf,"%d\n", data->autofan[nr].min_off); | 741 | return sprintf(buf, "%d\n", data->autofan[nr].min_off); |
779 | } | 742 | } |
780 | 743 | ||
781 | static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, | 744 | static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, |
@@ -785,15 +748,15 @@ static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, | |||
785 | struct i2c_client *client = to_i2c_client(dev); | 748 | struct i2c_client *client = to_i2c_client(dev); |
786 | struct lm85_data *data = i2c_get_clientdata(client); | 749 | struct lm85_data *data = i2c_get_clientdata(client); |
787 | long val = simple_strtol(buf, NULL, 10); | 750 | long val = simple_strtol(buf, NULL, 10); |
751 | u8 tmp; | ||
788 | 752 | ||
789 | mutex_lock(&data->update_lock); | 753 | mutex_lock(&data->update_lock); |
790 | data->autofan[nr].min_off = val; | 754 | data->autofan[nr].min_off = val; |
791 | lm85_write_value(client, LM85_REG_AFAN_SPIKE1, data->smooth[0] | 755 | tmp = lm85_read_value(client, LM85_REG_AFAN_SPIKE1); |
792 | | data->syncpwm3 | 756 | tmp &= ~(0x20 << nr); |
793 | | (data->autofan[0].min_off ? 0x20 : 0) | 757 | if (data->autofan[nr].min_off) |
794 | | (data->autofan[1].min_off ? 0x40 : 0) | 758 | tmp |= 0x20 << nr; |
795 | | (data->autofan[2].min_off ? 0x80 : 0) | 759 | lm85_write_value(client, LM85_REG_AFAN_SPIKE1, tmp); |
796 | ); | ||
797 | mutex_unlock(&data->update_lock); | 760 | mutex_unlock(&data->update_lock); |
798 | return count; | 761 | return count; |
799 | } | 762 | } |
@@ -803,7 +766,7 @@ static ssize_t show_pwm_auto_pwm_freq(struct device *dev, | |||
803 | { | 766 | { |
804 | int nr = to_sensor_dev_attr(attr)->index; | 767 | int nr = to_sensor_dev_attr(attr)->index; |
805 | struct lm85_data *data = lm85_update_device(dev); | 768 | struct lm85_data *data = lm85_update_device(dev); |
806 | return sprintf(buf,"%d\n", FREQ_FROM_REG(data->autofan[nr].freq)); | 769 | return sprintf(buf, "%d\n", FREQ_FROM_REG(data->autofan[nr].freq)); |
807 | } | 770 | } |
808 | 771 | ||
809 | static ssize_t set_pwm_auto_pwm_freq(struct device *dev, | 772 | static ssize_t set_pwm_auto_pwm_freq(struct device *dev, |
@@ -818,8 +781,7 @@ static ssize_t set_pwm_auto_pwm_freq(struct device *dev, | |||
818 | data->autofan[nr].freq = FREQ_TO_REG(val); | 781 | data->autofan[nr].freq = FREQ_TO_REG(val); |
819 | lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), | 782 | lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), |
820 | (data->zone[nr].range << 4) | 783 | (data->zone[nr].range << 4) |
821 | | data->autofan[nr].freq | 784 | | data->autofan[nr].freq); |
822 | ); | ||
823 | mutex_unlock(&data->update_lock); | 785 | mutex_unlock(&data->update_lock); |
824 | return count; | 786 | return count; |
825 | } | 787 | } |
@@ -849,7 +811,7 @@ static ssize_t show_temp_auto_temp_off(struct device *dev, | |||
849 | { | 811 | { |
850 | int nr = to_sensor_dev_attr(attr)->index; | 812 | int nr = to_sensor_dev_attr(attr)->index; |
851 | struct lm85_data *data = lm85_update_device(dev); | 813 | struct lm85_data *data = lm85_update_device(dev); |
852 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->zone[nr].limit) - | 814 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->zone[nr].limit) - |
853 | HYST_FROM_REG(data->zone[nr].hyst)); | 815 | HYST_FROM_REG(data->zone[nr].hyst)); |
854 | } | 816 | } |
855 | 817 | ||
@@ -866,15 +828,13 @@ static ssize_t set_temp_auto_temp_off(struct device *dev, | |||
866 | min = TEMP_FROM_REG(data->zone[nr].limit); | 828 | min = TEMP_FROM_REG(data->zone[nr].limit); |
867 | data->zone[nr].off_desired = TEMP_TO_REG(val); | 829 | data->zone[nr].off_desired = TEMP_TO_REG(val); |
868 | data->zone[nr].hyst = HYST_TO_REG(min - val); | 830 | data->zone[nr].hyst = HYST_TO_REG(min - val); |
869 | if ( nr == 0 || nr == 1 ) { | 831 | if (nr == 0 || nr == 1) { |
870 | lm85_write_value(client, LM85_REG_AFAN_HYST1, | 832 | lm85_write_value(client, LM85_REG_AFAN_HYST1, |
871 | (data->zone[0].hyst << 4) | 833 | (data->zone[0].hyst << 4) |
872 | | data->zone[1].hyst | 834 | | data->zone[1].hyst); |
873 | ); | ||
874 | } else { | 835 | } else { |
875 | lm85_write_value(client, LM85_REG_AFAN_HYST2, | 836 | lm85_write_value(client, LM85_REG_AFAN_HYST2, |
876 | (data->zone[2].hyst << 4) | 837 | (data->zone[2].hyst << 4)); |
877 | ); | ||
878 | } | 838 | } |
879 | mutex_unlock(&data->update_lock); | 839 | mutex_unlock(&data->update_lock); |
880 | return count; | 840 | return count; |
@@ -885,7 +845,7 @@ static ssize_t show_temp_auto_temp_min(struct device *dev, | |||
885 | { | 845 | { |
886 | int nr = to_sensor_dev_attr(attr)->index; | 846 | int nr = to_sensor_dev_attr(attr)->index; |
887 | struct lm85_data *data = lm85_update_device(dev); | 847 | struct lm85_data *data = lm85_update_device(dev); |
888 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->zone[nr].limit) ); | 848 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->zone[nr].limit)); |
889 | } | 849 | } |
890 | 850 | ||
891 | static ssize_t set_temp_auto_temp_min(struct device *dev, | 851 | static ssize_t set_temp_auto_temp_min(struct device *dev, |
@@ -913,15 +873,13 @@ static ssize_t set_temp_auto_temp_min(struct device *dev, | |||
913 | data->zone[nr].hyst = HYST_TO_REG(TEMP_FROM_REG( | 873 | data->zone[nr].hyst = HYST_TO_REG(TEMP_FROM_REG( |
914 | data->zone[nr].limit) - TEMP_FROM_REG( | 874 | data->zone[nr].limit) - TEMP_FROM_REG( |
915 | data->zone[nr].off_desired)); | 875 | data->zone[nr].off_desired)); |
916 | if ( nr == 0 || nr == 1 ) { | 876 | if (nr == 0 || nr == 1) { |
917 | lm85_write_value(client, LM85_REG_AFAN_HYST1, | 877 | lm85_write_value(client, LM85_REG_AFAN_HYST1, |
918 | (data->zone[0].hyst << 4) | 878 | (data->zone[0].hyst << 4) |
919 | | data->zone[1].hyst | 879 | | data->zone[1].hyst); |
920 | ); | ||
921 | } else { | 880 | } else { |
922 | lm85_write_value(client, LM85_REG_AFAN_HYST2, | 881 | lm85_write_value(client, LM85_REG_AFAN_HYST2, |
923 | (data->zone[2].hyst << 4) | 882 | (data->zone[2].hyst << 4)); |
924 | ); | ||
925 | } | 883 | } |
926 | mutex_unlock(&data->update_lock); | 884 | mutex_unlock(&data->update_lock); |
927 | return count; | 885 | return count; |
@@ -932,7 +890,7 @@ static ssize_t show_temp_auto_temp_max(struct device *dev, | |||
932 | { | 890 | { |
933 | int nr = to_sensor_dev_attr(attr)->index; | 891 | int nr = to_sensor_dev_attr(attr)->index; |
934 | struct lm85_data *data = lm85_update_device(dev); | 892 | struct lm85_data *data = lm85_update_device(dev); |
935 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->zone[nr].limit) + | 893 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->zone[nr].limit) + |
936 | RANGE_FROM_REG(data->zone[nr].range)); | 894 | RANGE_FROM_REG(data->zone[nr].range)); |
937 | } | 895 | } |
938 | 896 | ||
@@ -962,11 +920,11 @@ static ssize_t show_temp_auto_temp_crit(struct device *dev, | |||
962 | { | 920 | { |
963 | int nr = to_sensor_dev_attr(attr)->index; | 921 | int nr = to_sensor_dev_attr(attr)->index; |
964 | struct lm85_data *data = lm85_update_device(dev); | 922 | struct lm85_data *data = lm85_update_device(dev); |
965 | return sprintf(buf,"%d\n", TEMP_FROM_REG(data->zone[nr].critical)); | 923 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->zone[nr].critical)); |
966 | } | 924 | } |
967 | 925 | ||
968 | static ssize_t set_temp_auto_temp_crit(struct device *dev, | 926 | static ssize_t set_temp_auto_temp_crit(struct device *dev, |
969 | struct device_attribute *attr,const char *buf, size_t count) | 927 | struct device_attribute *attr, const char *buf, size_t count) |
970 | { | 928 | { |
971 | int nr = to_sensor_dev_attr(attr)->index; | 929 | int nr = to_sensor_dev_attr(attr)->index; |
972 | struct i2c_client *client = to_i2c_client(dev); | 930 | struct i2c_client *client = to_i2c_client(dev); |
@@ -1127,20 +1085,37 @@ static const struct attribute_group lm85_group_in567 = { | |||
1127 | .attrs = lm85_attributes_in567, | 1085 | .attrs = lm85_attributes_in567, |
1128 | }; | 1086 | }; |
1129 | 1087 | ||
1088 | static void lm85_init_client(struct i2c_client *client) | ||
1089 | { | ||
1090 | int value; | ||
1091 | |||
1092 | /* Start monitoring if needed */ | ||
1093 | value = lm85_read_value(client, LM85_REG_CONFIG); | ||
1094 | if (!(value & 0x01)) { | ||
1095 | dev_info(&client->dev, "Starting monitoring\n"); | ||
1096 | lm85_write_value(client, LM85_REG_CONFIG, value | 0x01); | ||
1097 | } | ||
1098 | |||
1099 | /* Warn about unusual configuration bits */ | ||
1100 | if (value & 0x02) | ||
1101 | dev_warn(&client->dev, "Device configuration is locked\n"); | ||
1102 | if (!(value & 0x04)) | ||
1103 | dev_warn(&client->dev, "Device is not ready\n"); | ||
1104 | } | ||
1105 | |||
1130 | static int lm85_detect(struct i2c_adapter *adapter, int address, | 1106 | static int lm85_detect(struct i2c_adapter *adapter, int address, |
1131 | int kind) | 1107 | int kind) |
1132 | { | 1108 | { |
1133 | int company, verstep ; | 1109 | int company, verstep; |
1134 | struct i2c_client *new_client = NULL; | 1110 | struct i2c_client *client; |
1135 | struct lm85_data *data; | 1111 | struct lm85_data *data; |
1136 | int err = 0; | 1112 | int err = 0; |
1137 | const char *type_name = ""; | 1113 | const char *type_name; |
1138 | 1114 | ||
1139 | if (!i2c_check_functionality(adapter, | 1115 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { |
1140 | I2C_FUNC_SMBUS_BYTE_DATA)) { | ||
1141 | /* We need to be able to do byte I/O */ | 1116 | /* We need to be able to do byte I/O */ |
1142 | goto ERROR0 ; | 1117 | goto ERROR0; |
1143 | }; | 1118 | } |
1144 | 1119 | ||
1145 | /* OK. For now, we presume we have a valid client. We now create the | 1120 | /* OK. For now, we presume we have a valid client. We now create the |
1146 | client structure, even though we cannot fill it completely yet. | 1121 | client structure, even though we cannot fill it completely yet. |
@@ -1151,138 +1126,145 @@ static int lm85_detect(struct i2c_adapter *adapter, int address, | |||
1151 | goto ERROR0; | 1126 | goto ERROR0; |
1152 | } | 1127 | } |
1153 | 1128 | ||
1154 | new_client = &data->client; | 1129 | client = &data->client; |
1155 | i2c_set_clientdata(new_client, data); | 1130 | i2c_set_clientdata(client, data); |
1156 | new_client->addr = address; | 1131 | client->addr = address; |
1157 | new_client->adapter = adapter; | 1132 | client->adapter = adapter; |
1158 | new_client->driver = &lm85_driver; | 1133 | client->driver = &lm85_driver; |
1159 | new_client->flags = 0; | ||
1160 | 1134 | ||
1161 | /* Now, we do the remaining detection. */ | 1135 | /* Now, we do the remaining detection. */ |
1162 | 1136 | ||
1163 | company = lm85_read_value(new_client, LM85_REG_COMPANY); | 1137 | company = lm85_read_value(client, LM85_REG_COMPANY); |
1164 | verstep = lm85_read_value(new_client, LM85_REG_VERSTEP); | 1138 | verstep = lm85_read_value(client, LM85_REG_VERSTEP); |
1165 | 1139 | ||
1166 | dev_dbg(&adapter->dev, "Detecting device at %d,0x%02x with" | 1140 | dev_dbg(&adapter->dev, "Detecting device at %d,0x%02x with" |
1167 | " COMPANY: 0x%02x and VERSTEP: 0x%02x\n", | 1141 | " COMPANY: 0x%02x and VERSTEP: 0x%02x\n", |
1168 | i2c_adapter_id(new_client->adapter), new_client->addr, | 1142 | i2c_adapter_id(client->adapter), client->addr, |
1169 | company, verstep); | 1143 | company, verstep); |
1170 | 1144 | ||
1171 | /* If auto-detecting, Determine the chip type. */ | 1145 | /* If auto-detecting, Determine the chip type. */ |
1172 | if (kind <= 0) { | 1146 | if (kind <= 0) { |
1173 | dev_dbg(&adapter->dev, "Autodetecting device at %d,0x%02x ...\n", | 1147 | dev_dbg(&adapter->dev, "Autodetecting device at %d,0x%02x ...\n", |
1174 | i2c_adapter_id(adapter), address ); | 1148 | i2c_adapter_id(adapter), address); |
1175 | if( company == LM85_COMPANY_NATIONAL | 1149 | if (company == LM85_COMPANY_NATIONAL |
1176 | && verstep == LM85_VERSTEP_LM85C ) { | 1150 | && verstep == LM85_VERSTEP_LM85C) { |
1177 | kind = lm85c ; | 1151 | kind = lm85c; |
1178 | } else if( company == LM85_COMPANY_NATIONAL | 1152 | } else if (company == LM85_COMPANY_NATIONAL |
1179 | && verstep == LM85_VERSTEP_LM85B ) { | 1153 | && verstep == LM85_VERSTEP_LM85B) { |
1180 | kind = lm85b ; | 1154 | kind = lm85b; |
1181 | } else if( company == LM85_COMPANY_NATIONAL | 1155 | } else if (company == LM85_COMPANY_NATIONAL |
1182 | && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC ) { | 1156 | && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC) { |
1183 | dev_err(&adapter->dev, "Unrecognized version/stepping 0x%02x" | 1157 | dev_err(&adapter->dev, "Unrecognized version/stepping 0x%02x" |
1184 | " Defaulting to LM85.\n", verstep); | 1158 | " Defaulting to LM85.\n", verstep); |
1185 | kind = any_chip ; | 1159 | kind = any_chip; |
1186 | } else if( company == LM85_COMPANY_ANALOG_DEV | 1160 | } else if (company == LM85_COMPANY_ANALOG_DEV |
1187 | && verstep == LM85_VERSTEP_ADM1027 ) { | 1161 | && verstep == LM85_VERSTEP_ADM1027) { |
1188 | kind = adm1027 ; | 1162 | kind = adm1027; |
1189 | } else if( company == LM85_COMPANY_ANALOG_DEV | 1163 | } else if (company == LM85_COMPANY_ANALOG_DEV |
1190 | && (verstep == LM85_VERSTEP_ADT7463 | 1164 | && (verstep == LM85_VERSTEP_ADT7463 |
1191 | || verstep == LM85_VERSTEP_ADT7463C) ) { | 1165 | || verstep == LM85_VERSTEP_ADT7463C)) { |
1192 | kind = adt7463 ; | 1166 | kind = adt7463; |
1193 | } else if( company == LM85_COMPANY_ANALOG_DEV | 1167 | } else if (company == LM85_COMPANY_ANALOG_DEV |
1194 | && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC ) { | 1168 | && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC) { |
1195 | dev_err(&adapter->dev, "Unrecognized version/stepping 0x%02x" | 1169 | dev_err(&adapter->dev, "Unrecognized version/stepping 0x%02x" |
1196 | " Defaulting to Generic LM85.\n", verstep ); | 1170 | " Defaulting to Generic LM85.\n", verstep); |
1197 | kind = any_chip ; | 1171 | kind = any_chip; |
1198 | } else if( company == LM85_COMPANY_SMSC | 1172 | } else if (company == LM85_COMPANY_SMSC |
1199 | && (verstep == LM85_VERSTEP_EMC6D100_A0 | 1173 | && (verstep == LM85_VERSTEP_EMC6D100_A0 |
1200 | || verstep == LM85_VERSTEP_EMC6D100_A1) ) { | 1174 | || verstep == LM85_VERSTEP_EMC6D100_A1)) { |
1201 | /* Unfortunately, we can't tell a '100 from a '101 | 1175 | /* Unfortunately, we can't tell a '100 from a '101 |
1202 | * from the registers. Since a '101 is a '100 | 1176 | * from the registers. Since a '101 is a '100 |
1203 | * in a package with fewer pins and therefore no | 1177 | * in a package with fewer pins and therefore no |
1204 | * 3.3V, 1.5V or 1.8V inputs, perhaps if those | 1178 | * 3.3V, 1.5V or 1.8V inputs, perhaps if those |
1205 | * inputs read 0, then it's a '101. | 1179 | * inputs read 0, then it's a '101. |
1206 | */ | 1180 | */ |
1207 | kind = emc6d100 ; | 1181 | kind = emc6d100; |
1208 | } else if( company == LM85_COMPANY_SMSC | 1182 | } else if (company == LM85_COMPANY_SMSC |
1209 | && verstep == LM85_VERSTEP_EMC6D102) { | 1183 | && verstep == LM85_VERSTEP_EMC6D102) { |
1210 | kind = emc6d102 ; | 1184 | kind = emc6d102; |
1211 | } else if( company == LM85_COMPANY_SMSC | 1185 | } else if (company == LM85_COMPANY_SMSC |
1212 | && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC) { | 1186 | && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC) { |
1213 | dev_err(&adapter->dev, "lm85: Detected SMSC chip\n"); | 1187 | dev_err(&adapter->dev, "lm85: Detected SMSC chip\n"); |
1214 | dev_err(&adapter->dev, "lm85: Unrecognized version/stepping 0x%02x" | 1188 | dev_err(&adapter->dev, "lm85: Unrecognized version/stepping 0x%02x" |
1215 | " Defaulting to Generic LM85.\n", verstep ); | 1189 | " Defaulting to Generic LM85.\n", verstep); |
1216 | kind = any_chip ; | 1190 | kind = any_chip; |
1217 | } else if( kind == any_chip | 1191 | } else if (kind == any_chip |
1218 | && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC) { | 1192 | && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC) { |
1219 | dev_err(&adapter->dev, "Generic LM85 Version 6 detected\n"); | 1193 | dev_err(&adapter->dev, "Generic LM85 Version 6 detected\n"); |
1220 | /* Leave kind as "any_chip" */ | 1194 | /* Leave kind as "any_chip" */ |
1221 | } else { | 1195 | } else { |
1222 | dev_dbg(&adapter->dev, "Autodetection failed\n"); | 1196 | dev_dbg(&adapter->dev, "Autodetection failed\n"); |
1223 | /* Not an LM85 ... */ | 1197 | /* Not an LM85... */ |
1224 | if( kind == any_chip ) { /* User used force=x,y */ | 1198 | if (kind == any_chip) { /* User used force=x,y */ |
1225 | dev_err(&adapter->dev, "Generic LM85 Version 6 not" | 1199 | dev_err(&adapter->dev, "Generic LM85 Version 6 not" |
1226 | " found at %d,0x%02x. Try force_lm85c.\n", | 1200 | " found at %d,0x%02x. Try force_lm85c.\n", |
1227 | i2c_adapter_id(adapter), address ); | 1201 | i2c_adapter_id(adapter), address); |
1228 | } | 1202 | } |
1229 | err = 0 ; | 1203 | err = 0; |
1230 | goto ERROR1; | 1204 | goto ERROR1; |
1231 | } | 1205 | } |
1232 | } | 1206 | } |
1233 | 1207 | ||
1234 | /* Fill in the chip specific driver values */ | 1208 | /* Fill in the chip specific driver values */ |
1235 | if ( kind == any_chip ) { | 1209 | switch (kind) { |
1236 | type_name = "lm85"; | 1210 | case lm85b: |
1237 | } else if ( kind == lm85b ) { | ||
1238 | type_name = "lm85b"; | 1211 | type_name = "lm85b"; |
1239 | } else if ( kind == lm85c ) { | 1212 | break; |
1213 | case lm85c: | ||
1240 | type_name = "lm85c"; | 1214 | type_name = "lm85c"; |
1241 | } else if ( kind == adm1027 ) { | 1215 | break; |
1216 | case adm1027: | ||
1242 | type_name = "adm1027"; | 1217 | type_name = "adm1027"; |
1243 | } else if ( kind == adt7463 ) { | 1218 | break; |
1219 | case adt7463: | ||
1244 | type_name = "adt7463"; | 1220 | type_name = "adt7463"; |
1245 | } else if ( kind == emc6d100){ | 1221 | break; |
1222 | case emc6d100: | ||
1246 | type_name = "emc6d100"; | 1223 | type_name = "emc6d100"; |
1247 | } else if ( kind == emc6d102 ) { | 1224 | break; |
1225 | case emc6d102: | ||
1248 | type_name = "emc6d102"; | 1226 | type_name = "emc6d102"; |
1227 | break; | ||
1228 | default: | ||
1229 | type_name = "lm85"; | ||
1249 | } | 1230 | } |
1250 | strlcpy(new_client->name, type_name, I2C_NAME_SIZE); | 1231 | strlcpy(client->name, type_name, I2C_NAME_SIZE); |
1251 | 1232 | ||
1252 | /* Fill in the remaining client fields */ | 1233 | /* Fill in the remaining client fields */ |
1253 | data->type = kind; | 1234 | data->type = kind; |
1254 | data->valid = 0; | ||
1255 | mutex_init(&data->update_lock); | 1235 | mutex_init(&data->update_lock); |
1256 | 1236 | ||
1257 | /* Tell the I2C layer a new client has arrived */ | 1237 | /* Tell the I2C layer a new client has arrived */ |
1258 | if ((err = i2c_attach_client(new_client))) | 1238 | err = i2c_attach_client(client); |
1239 | if (err) | ||
1259 | goto ERROR1; | 1240 | goto ERROR1; |
1260 | 1241 | ||
1261 | /* Set the VRM version */ | 1242 | /* Set the VRM version */ |
1262 | data->vrm = vid_which_vrm(); | 1243 | data->vrm = vid_which_vrm(); |
1263 | 1244 | ||
1264 | /* Initialize the LM85 chip */ | 1245 | /* Initialize the LM85 chip */ |
1265 | lm85_init_client(new_client); | 1246 | lm85_init_client(client); |
1266 | 1247 | ||
1267 | /* Register sysfs hooks */ | 1248 | /* Register sysfs hooks */ |
1268 | if ((err = sysfs_create_group(&new_client->dev.kobj, &lm85_group))) | 1249 | err = sysfs_create_group(&client->dev.kobj, &lm85_group); |
1250 | if (err) | ||
1269 | goto ERROR2; | 1251 | goto ERROR2; |
1270 | 1252 | ||
1271 | /* The ADT7463 has an optional VRM 10 mode where pin 21 is used | 1253 | /* The ADT7463 has an optional VRM 10 mode where pin 21 is used |
1272 | as a sixth digital VID input rather than an analog input. */ | 1254 | as a sixth digital VID input rather than an analog input. */ |
1273 | data->vid = lm85_read_value(new_client, LM85_REG_VID); | 1255 | data->vid = lm85_read_value(client, LM85_REG_VID); |
1274 | if (!(kind == adt7463 && (data->vid & 0x80))) | 1256 | if (!(kind == adt7463 && (data->vid & 0x80))) |
1275 | if ((err = sysfs_create_group(&new_client->dev.kobj, | 1257 | if ((err = sysfs_create_group(&client->dev.kobj, |
1276 | &lm85_group_in4))) | 1258 | &lm85_group_in4))) |
1277 | goto ERROR3; | 1259 | goto ERROR3; |
1278 | 1260 | ||
1279 | /* The EMC6D100 has 3 additional voltage inputs */ | 1261 | /* The EMC6D100 has 3 additional voltage inputs */ |
1280 | if (kind == emc6d100) | 1262 | if (kind == emc6d100) |
1281 | if ((err = sysfs_create_group(&new_client->dev.kobj, | 1263 | if ((err = sysfs_create_group(&client->dev.kobj, |
1282 | &lm85_group_in567))) | 1264 | &lm85_group_in567))) |
1283 | goto ERROR3; | 1265 | goto ERROR3; |
1284 | 1266 | ||
1285 | data->hwmon_dev = hwmon_device_register(&new_client->dev); | 1267 | data->hwmon_dev = hwmon_device_register(&client->dev); |
1286 | if (IS_ERR(data->hwmon_dev)) { | 1268 | if (IS_ERR(data->hwmon_dev)) { |
1287 | err = PTR_ERR(data->hwmon_dev); | 1269 | err = PTR_ERR(data->hwmon_dev); |
1288 | goto ERROR3; | 1270 | goto ERROR3; |
@@ -1291,16 +1273,16 @@ static int lm85_detect(struct i2c_adapter *adapter, int address, | |||
1291 | return 0; | 1273 | return 0; |
1292 | 1274 | ||
1293 | /* Error out and cleanup code */ | 1275 | /* Error out and cleanup code */ |
1294 | ERROR3: | 1276 | ERROR3: |
1295 | sysfs_remove_group(&new_client->dev.kobj, &lm85_group); | 1277 | sysfs_remove_group(&client->dev.kobj, &lm85_group); |
1296 | sysfs_remove_group(&new_client->dev.kobj, &lm85_group_in4); | 1278 | sysfs_remove_group(&client->dev.kobj, &lm85_group_in4); |
1297 | if (kind == emc6d100) | 1279 | if (kind == emc6d100) |
1298 | sysfs_remove_group(&new_client->dev.kobj, &lm85_group_in567); | 1280 | sysfs_remove_group(&client->dev.kobj, &lm85_group_in567); |
1299 | ERROR2: | 1281 | ERROR2: |
1300 | i2c_detach_client(new_client); | 1282 | i2c_detach_client(client); |
1301 | ERROR1: | 1283 | ERROR1: |
1302 | kfree(data); | 1284 | kfree(data); |
1303 | ERROR0: | 1285 | ERROR0: |
1304 | return err; | 1286 | return err; |
1305 | } | 1287 | } |
1306 | 1288 | ||
@@ -1323,100 +1305,46 @@ static int lm85_read_value(struct i2c_client *client, u8 reg) | |||
1323 | int res; | 1305 | int res; |
1324 | 1306 | ||
1325 | /* What size location is it? */ | 1307 | /* What size location is it? */ |
1326 | switch( reg ) { | 1308 | switch (reg) { |
1327 | case LM85_REG_FAN(0) : /* Read WORD data */ | 1309 | case LM85_REG_FAN(0): /* Read WORD data */ |
1328 | case LM85_REG_FAN(1) : | 1310 | case LM85_REG_FAN(1): |
1329 | case LM85_REG_FAN(2) : | 1311 | case LM85_REG_FAN(2): |
1330 | case LM85_REG_FAN(3) : | 1312 | case LM85_REG_FAN(3): |
1331 | case LM85_REG_FAN_MIN(0) : | 1313 | case LM85_REG_FAN_MIN(0): |
1332 | case LM85_REG_FAN_MIN(1) : | 1314 | case LM85_REG_FAN_MIN(1): |
1333 | case LM85_REG_FAN_MIN(2) : | 1315 | case LM85_REG_FAN_MIN(2): |
1334 | case LM85_REG_FAN_MIN(3) : | 1316 | case LM85_REG_FAN_MIN(3): |
1335 | case LM85_REG_ALARM1 : /* Read both bytes at once */ | 1317 | case LM85_REG_ALARM1: /* Read both bytes at once */ |
1336 | res = i2c_smbus_read_byte_data(client, reg) & 0xff ; | 1318 | res = i2c_smbus_read_byte_data(client, reg) & 0xff; |
1337 | res |= i2c_smbus_read_byte_data(client, reg+1) << 8 ; | 1319 | res |= i2c_smbus_read_byte_data(client, reg + 1) << 8; |
1338 | break ; | 1320 | break; |
1339 | case ADT7463_REG_TMIN_CTL1 : /* Read WORD MSB, LSB */ | ||
1340 | res = i2c_smbus_read_byte_data(client, reg) << 8 ; | ||
1341 | res |= i2c_smbus_read_byte_data(client, reg+1) & 0xff ; | ||
1342 | break ; | ||
1343 | default: /* Read BYTE data */ | 1321 | default: /* Read BYTE data */ |
1344 | res = i2c_smbus_read_byte_data(client, reg); | 1322 | res = i2c_smbus_read_byte_data(client, reg); |
1345 | break ; | 1323 | break; |
1346 | } | 1324 | } |
1347 | 1325 | ||
1348 | return res ; | 1326 | return res; |
1349 | } | 1327 | } |
1350 | 1328 | ||
1351 | static int lm85_write_value(struct i2c_client *client, u8 reg, int value) | 1329 | static void lm85_write_value(struct i2c_client *client, u8 reg, int value) |
1352 | { | 1330 | { |
1353 | int res ; | 1331 | switch (reg) { |
1354 | 1332 | case LM85_REG_FAN(0): /* Write WORD data */ | |
1355 | switch( reg ) { | 1333 | case LM85_REG_FAN(1): |
1356 | case LM85_REG_FAN(0) : /* Write WORD data */ | 1334 | case LM85_REG_FAN(2): |
1357 | case LM85_REG_FAN(1) : | 1335 | case LM85_REG_FAN(3): |
1358 | case LM85_REG_FAN(2) : | 1336 | case LM85_REG_FAN_MIN(0): |
1359 | case LM85_REG_FAN(3) : | 1337 | case LM85_REG_FAN_MIN(1): |
1360 | case LM85_REG_FAN_MIN(0) : | 1338 | case LM85_REG_FAN_MIN(2): |
1361 | case LM85_REG_FAN_MIN(1) : | 1339 | case LM85_REG_FAN_MIN(3): |
1362 | case LM85_REG_FAN_MIN(2) : | ||
1363 | case LM85_REG_FAN_MIN(3) : | ||
1364 | /* NOTE: ALARM is read only, so not included here */ | 1340 | /* NOTE: ALARM is read only, so not included here */ |
1365 | res = i2c_smbus_write_byte_data(client, reg, value & 0xff) ; | 1341 | i2c_smbus_write_byte_data(client, reg, value & 0xff); |
1366 | res |= i2c_smbus_write_byte_data(client, reg+1, (value>>8) & 0xff) ; | 1342 | i2c_smbus_write_byte_data(client, reg + 1, value >> 8); |
1367 | break ; | 1343 | break; |
1368 | case ADT7463_REG_TMIN_CTL1 : /* Write WORD MSB, LSB */ | ||
1369 | res = i2c_smbus_write_byte_data(client, reg, (value>>8) & 0xff); | ||
1370 | res |= i2c_smbus_write_byte_data(client, reg+1, value & 0xff) ; | ||
1371 | break ; | ||
1372 | default: /* Write BYTE data */ | 1344 | default: /* Write BYTE data */ |
1373 | res = i2c_smbus_write_byte_data(client, reg, value); | 1345 | i2c_smbus_write_byte_data(client, reg, value); |
1374 | break ; | 1346 | break; |
1375 | } | 1347 | } |
1376 | |||
1377 | return res ; | ||
1378 | } | ||
1379 | |||
1380 | static void lm85_init_client(struct i2c_client *client) | ||
1381 | { | ||
1382 | int value; | ||
1383 | struct lm85_data *data = i2c_get_clientdata(client); | ||
1384 | |||
1385 | dev_dbg(&client->dev, "Initializing device\n"); | ||
1386 | |||
1387 | /* Warn if part was not "READY" */ | ||
1388 | value = lm85_read_value(client, LM85_REG_CONFIG); | ||
1389 | dev_dbg(&client->dev, "LM85_REG_CONFIG is: 0x%02x\n", value); | ||
1390 | if( value & 0x02 ) { | ||
1391 | dev_err(&client->dev, "Client (%d,0x%02x) config is locked.\n", | ||
1392 | i2c_adapter_id(client->adapter), client->addr ); | ||
1393 | }; | ||
1394 | if( ! (value & 0x04) ) { | ||
1395 | dev_err(&client->dev, "Client (%d,0x%02x) is not ready.\n", | ||
1396 | i2c_adapter_id(client->adapter), client->addr ); | ||
1397 | }; | ||
1398 | if( value & 0x10 | ||
1399 | && ( data->type == adm1027 | ||
1400 | || data->type == adt7463 ) ) { | ||
1401 | dev_err(&client->dev, "Client (%d,0x%02x) VxI mode is set. " | ||
1402 | "Please report this to the lm85 maintainer.\n", | ||
1403 | i2c_adapter_id(client->adapter), client->addr ); | ||
1404 | }; | ||
1405 | |||
1406 | /* WE INTENTIONALLY make no changes to the limits, | ||
1407 | * offsets, pwms, fans and zones. If they were | ||
1408 | * configured, we don't want to mess with them. | ||
1409 | * If they weren't, the default is 100% PWM, no | ||
1410 | * control and will suffice until 'sensors -s' | ||
1411 | * can be run by the user. | ||
1412 | */ | ||
1413 | |||
1414 | /* Start monitoring */ | ||
1415 | value = lm85_read_value(client, LM85_REG_CONFIG); | ||
1416 | /* Try to clear LOCK, Set START, save everything else */ | ||
1417 | value = (value & ~ 0x02) | 0x01 ; | ||
1418 | dev_dbg(&client->dev, "Setting CONFIG to: 0x%02x\n", value); | ||
1419 | lm85_write_value(client, LM85_REG_CONFIG, value); | ||
1420 | } | 1348 | } |
1421 | 1349 | ||
1422 | static struct lm85_data *lm85_update_device(struct device *dev) | 1350 | static struct lm85_data *lm85_update_device(struct device *dev) |
@@ -1427,28 +1355,30 @@ static struct lm85_data *lm85_update_device(struct device *dev) | |||
1427 | 1355 | ||
1428 | mutex_lock(&data->update_lock); | 1356 | mutex_lock(&data->update_lock); |
1429 | 1357 | ||
1430 | if ( !data->valid || | 1358 | if (!data->valid || |
1431 | time_after(jiffies, data->last_reading + LM85_DATA_INTERVAL) ) { | 1359 | time_after(jiffies, data->last_reading + LM85_DATA_INTERVAL)) { |
1432 | /* Things that change quickly */ | 1360 | /* Things that change quickly */ |
1433 | dev_dbg(&client->dev, "Reading sensor values\n"); | 1361 | dev_dbg(&client->dev, "Reading sensor values\n"); |
1434 | 1362 | ||
1435 | /* Have to read extended bits first to "freeze" the | 1363 | /* Have to read extended bits first to "freeze" the |
1436 | * more significant bits that are read later. | 1364 | * more significant bits that are read later. |
1437 | * There are 2 additional resolution bits per channel and we | 1365 | * There are 2 additional resolution bits per channel and we |
1438 | * have room for 4, so we shift them to the left. | 1366 | * have room for 4, so we shift them to the left. |
1439 | */ | 1367 | */ |
1440 | if ( (data->type == adm1027) || (data->type == adt7463) ) { | 1368 | if (data->type == adm1027 || data->type == adt7463) { |
1441 | int ext1 = lm85_read_value(client, | 1369 | int ext1 = lm85_read_value(client, |
1442 | ADM1027_REG_EXTEND_ADC1); | 1370 | ADM1027_REG_EXTEND_ADC1); |
1443 | int ext2 = lm85_read_value(client, | 1371 | int ext2 = lm85_read_value(client, |
1444 | ADM1027_REG_EXTEND_ADC2); | 1372 | ADM1027_REG_EXTEND_ADC2); |
1445 | int val = (ext1 << 8) + ext2; | 1373 | int val = (ext1 << 8) + ext2; |
1446 | 1374 | ||
1447 | for(i = 0; i <= 4; i++) | 1375 | for (i = 0; i <= 4; i++) |
1448 | data->in_ext[i] = ((val>>(i * 2))&0x03) << 2; | 1376 | data->in_ext[i] = |
1377 | ((val >> (i * 2)) & 0x03) << 2; | ||
1449 | 1378 | ||
1450 | for(i = 0; i <= 2; i++) | 1379 | for (i = 0; i <= 2; i++) |
1451 | data->temp_ext[i] = (val>>((i + 4) * 2))&0x0c; | 1380 | data->temp_ext[i] = |
1381 | (val >> ((i + 4) * 2)) & 0x0c; | ||
1452 | } | 1382 | } |
1453 | 1383 | ||
1454 | data->vid = lm85_read_value(client, LM85_REG_VID); | 1384 | data->vid = lm85_read_value(client, LM85_REG_VID); |
@@ -1456,6 +1386,8 @@ static struct lm85_data *lm85_update_device(struct device *dev) | |||
1456 | for (i = 0; i <= 3; ++i) { | 1386 | for (i = 0; i <= 3; ++i) { |
1457 | data->in[i] = | 1387 | data->in[i] = |
1458 | lm85_read_value(client, LM85_REG_IN(i)); | 1388 | lm85_read_value(client, LM85_REG_IN(i)); |
1389 | data->fan[i] = | ||
1390 | lm85_read_value(client, LM85_REG_FAN(i)); | ||
1459 | } | 1391 | } |
1460 | 1392 | ||
1461 | if (!(data->type == adt7463 && (data->vid & 0x80))) { | 1393 | if (!(data->type == adt7463 && (data->vid & 0x80))) { |
@@ -1463,38 +1395,25 @@ static struct lm85_data *lm85_update_device(struct device *dev) | |||
1463 | LM85_REG_IN(4)); | 1395 | LM85_REG_IN(4)); |
1464 | } | 1396 | } |
1465 | 1397 | ||
1466 | for (i = 0; i <= 3; ++i) { | ||
1467 | data->fan[i] = | ||
1468 | lm85_read_value(client, LM85_REG_FAN(i)); | ||
1469 | } | ||
1470 | |||
1471 | for (i = 0; i <= 2; ++i) { | 1398 | for (i = 0; i <= 2; ++i) { |
1472 | data->temp[i] = | 1399 | data->temp[i] = |
1473 | lm85_read_value(client, LM85_REG_TEMP(i)); | 1400 | lm85_read_value(client, LM85_REG_TEMP(i)); |
1474 | } | ||
1475 | |||
1476 | for (i = 0; i <= 2; ++i) { | ||
1477 | data->pwm[i] = | 1401 | data->pwm[i] = |
1478 | lm85_read_value(client, LM85_REG_PWM(i)); | 1402 | lm85_read_value(client, LM85_REG_PWM(i)); |
1479 | } | 1403 | } |
1480 | 1404 | ||
1481 | data->alarms = lm85_read_value(client, LM85_REG_ALARM1); | 1405 | data->alarms = lm85_read_value(client, LM85_REG_ALARM1); |
1482 | 1406 | ||
1483 | if ( data->type == adt7463 ) { | 1407 | if (data->type == emc6d100) { |
1484 | if( data->therm_total < ULONG_MAX - 256 ) { | ||
1485 | data->therm_total += | ||
1486 | lm85_read_value(client, ADT7463_REG_THERM ); | ||
1487 | } | ||
1488 | } else if ( data->type == emc6d100 ) { | ||
1489 | /* Three more voltage sensors */ | 1408 | /* Three more voltage sensors */ |
1490 | for (i = 5; i <= 7; ++i) { | 1409 | for (i = 5; i <= 7; ++i) { |
1491 | data->in[i] = | 1410 | data->in[i] = lm85_read_value(client, |
1492 | lm85_read_value(client, EMC6D100_REG_IN(i)); | 1411 | EMC6D100_REG_IN(i)); |
1493 | } | 1412 | } |
1494 | /* More alarm bits */ | 1413 | /* More alarm bits */ |
1495 | data->alarms |= | 1414 | data->alarms |= lm85_read_value(client, |
1496 | lm85_read_value(client, EMC6D100_REG_ALARM3) << 16; | 1415 | EMC6D100_REG_ALARM3) << 16; |
1497 | } else if (data->type == emc6d102 ) { | 1416 | } else if (data->type == emc6d102) { |
1498 | /* Have to read LSB bits after the MSB ones because | 1417 | /* Have to read LSB bits after the MSB ones because |
1499 | the reading of the MSB bits has frozen the | 1418 | the reading of the MSB bits has frozen the |
1500 | LSBs (backward from the ADM1027). | 1419 | LSBs (backward from the ADM1027). |
@@ -1509,20 +1428,20 @@ static struct lm85_data *lm85_update_device(struct device *dev) | |||
1509 | EMC6D102_REG_EXTEND_ADC4); | 1428 | EMC6D102_REG_EXTEND_ADC4); |
1510 | data->in_ext[0] = ext3 & 0x0f; | 1429 | data->in_ext[0] = ext3 & 0x0f; |
1511 | data->in_ext[1] = ext4 & 0x0f; | 1430 | data->in_ext[1] = ext4 & 0x0f; |
1512 | data->in_ext[2] = (ext4 >> 4) & 0x0f; | 1431 | data->in_ext[2] = ext4 >> 4; |
1513 | data->in_ext[3] = (ext3 >> 4) & 0x0f; | 1432 | data->in_ext[3] = ext3 >> 4; |
1514 | data->in_ext[4] = (ext2 >> 4) & 0x0f; | 1433 | data->in_ext[4] = ext2 >> 4; |
1515 | 1434 | ||
1516 | data->temp_ext[0] = ext1 & 0x0f; | 1435 | data->temp_ext[0] = ext1 & 0x0f; |
1517 | data->temp_ext[1] = ext2 & 0x0f; | 1436 | data->temp_ext[1] = ext2 & 0x0f; |
1518 | data->temp_ext[2] = (ext1 >> 4) & 0x0f; | 1437 | data->temp_ext[2] = ext1 >> 4; |
1519 | } | 1438 | } |
1520 | 1439 | ||
1521 | data->last_reading = jiffies ; | 1440 | data->last_reading = jiffies; |
1522 | }; /* last_reading */ | 1441 | } /* last_reading */ |
1523 | 1442 | ||
1524 | if ( !data->valid || | 1443 | if (!data->valid || |
1525 | time_after(jiffies, data->last_config + LM85_CONFIG_INTERVAL) ) { | 1444 | time_after(jiffies, data->last_config + LM85_CONFIG_INTERVAL)) { |
1526 | /* Things that don't change often */ | 1445 | /* Things that don't change often */ |
1527 | dev_dbg(&client->dev, "Reading config values\n"); | 1446 | dev_dbg(&client->dev, "Reading config values\n"); |
1528 | 1447 | ||
@@ -1531,6 +1450,8 @@ static struct lm85_data *lm85_update_device(struct device *dev) | |||
1531 | lm85_read_value(client, LM85_REG_IN_MIN(i)); | 1450 | lm85_read_value(client, LM85_REG_IN_MIN(i)); |
1532 | data->in_max[i] = | 1451 | data->in_max[i] = |
1533 | lm85_read_value(client, LM85_REG_IN_MAX(i)); | 1452 | lm85_read_value(client, LM85_REG_IN_MAX(i)); |
1453 | data->fan_min[i] = | ||
1454 | lm85_read_value(client, LM85_REG_FAN_MIN(i)); | ||
1534 | } | 1455 | } |
1535 | 1456 | ||
1536 | if (!(data->type == adt7463 && (data->vid & 0x80))) { | 1457 | if (!(data->type == adt7463 && (data->vid & 0x80))) { |
@@ -1540,34 +1461,28 @@ static struct lm85_data *lm85_update_device(struct device *dev) | |||
1540 | LM85_REG_IN_MAX(4)); | 1461 | LM85_REG_IN_MAX(4)); |
1541 | } | 1462 | } |
1542 | 1463 | ||
1543 | if ( data->type == emc6d100 ) { | 1464 | if (data->type == emc6d100) { |
1544 | for (i = 5; i <= 7; ++i) { | 1465 | for (i = 5; i <= 7; ++i) { |
1545 | data->in_min[i] = | 1466 | data->in_min[i] = lm85_read_value(client, |
1546 | lm85_read_value(client, EMC6D100_REG_IN_MIN(i)); | 1467 | EMC6D100_REG_IN_MIN(i)); |
1547 | data->in_max[i] = | 1468 | data->in_max[i] = lm85_read_value(client, |
1548 | lm85_read_value(client, EMC6D100_REG_IN_MAX(i)); | 1469 | EMC6D100_REG_IN_MAX(i)); |
1549 | } | 1470 | } |
1550 | } | 1471 | } |
1551 | 1472 | ||
1552 | for (i = 0; i <= 3; ++i) { | ||
1553 | data->fan_min[i] = | ||
1554 | lm85_read_value(client, LM85_REG_FAN_MIN(i)); | ||
1555 | } | ||
1556 | |||
1557 | for (i = 0; i <= 2; ++i) { | 1473 | for (i = 0; i <= 2; ++i) { |
1474 | int val; | ||
1475 | |||
1558 | data->temp_min[i] = | 1476 | data->temp_min[i] = |
1559 | lm85_read_value(client, LM85_REG_TEMP_MIN(i)); | 1477 | lm85_read_value(client, LM85_REG_TEMP_MIN(i)); |
1560 | data->temp_max[i] = | 1478 | data->temp_max[i] = |
1561 | lm85_read_value(client, LM85_REG_TEMP_MAX(i)); | 1479 | lm85_read_value(client, LM85_REG_TEMP_MAX(i)); |
1562 | } | ||
1563 | 1480 | ||
1564 | for (i = 0; i <= 2; ++i) { | ||
1565 | int val ; | ||
1566 | data->autofan[i].config = | 1481 | data->autofan[i].config = |
1567 | lm85_read_value(client, LM85_REG_AFAN_CONFIG(i)); | 1482 | lm85_read_value(client, LM85_REG_AFAN_CONFIG(i)); |
1568 | val = lm85_read_value(client, LM85_REG_AFAN_RANGE(i)); | 1483 | val = lm85_read_value(client, LM85_REG_AFAN_RANGE(i)); |
1569 | data->autofan[i].freq = val & 0x07 ; | 1484 | data->autofan[i].freq = val & 0x07; |
1570 | data->zone[i].range = (val >> 4) & 0x0f ; | 1485 | data->zone[i].range = val >> 4; |
1571 | data->autofan[i].min_pwm = | 1486 | data->autofan[i].min_pwm = |
1572 | lm85_read_value(client, LM85_REG_AFAN_MINPWM(i)); | 1487 | lm85_read_value(client, LM85_REG_AFAN_MINPWM(i)); |
1573 | data->zone[i].limit = | 1488 | data->zone[i].limit = |
@@ -1577,50 +1492,19 @@ static struct lm85_data *lm85_update_device(struct device *dev) | |||
1577 | } | 1492 | } |
1578 | 1493 | ||
1579 | i = lm85_read_value(client, LM85_REG_AFAN_SPIKE1); | 1494 | i = lm85_read_value(client, LM85_REG_AFAN_SPIKE1); |
1580 | data->smooth[0] = i & 0x0f ; | 1495 | data->autofan[0].min_off = (i & 0x20) != 0; |
1581 | data->syncpwm3 = i & 0x10 ; /* Save PWM3 config */ | 1496 | data->autofan[1].min_off = (i & 0x40) != 0; |
1582 | data->autofan[0].min_off = (i & 0x20) != 0 ; | 1497 | data->autofan[2].min_off = (i & 0x80) != 0; |
1583 | data->autofan[1].min_off = (i & 0x40) != 0 ; | ||
1584 | data->autofan[2].min_off = (i & 0x80) != 0 ; | ||
1585 | i = lm85_read_value(client, LM85_REG_AFAN_SPIKE2); | ||
1586 | data->smooth[1] = (i>>4) & 0x0f ; | ||
1587 | data->smooth[2] = i & 0x0f ; | ||
1588 | 1498 | ||
1589 | i = lm85_read_value(client, LM85_REG_AFAN_HYST1); | 1499 | i = lm85_read_value(client, LM85_REG_AFAN_HYST1); |
1590 | data->zone[0].hyst = (i>>4) & 0x0f ; | 1500 | data->zone[0].hyst = i >> 4; |
1591 | data->zone[1].hyst = i & 0x0f ; | 1501 | data->zone[1].hyst = i & 0x0f; |
1592 | 1502 | ||
1593 | i = lm85_read_value(client, LM85_REG_AFAN_HYST2); | 1503 | i = lm85_read_value(client, LM85_REG_AFAN_HYST2); |
1594 | data->zone[2].hyst = (i>>4) & 0x0f ; | 1504 | data->zone[2].hyst = i >> 4; |
1595 | 1505 | ||
1596 | if ( (data->type == lm85b) || (data->type == lm85c) ) { | ||
1597 | data->tach_mode = lm85_read_value(client, | ||
1598 | LM85_REG_TACH_MODE ); | ||
1599 | data->spinup_ctl = lm85_read_value(client, | ||
1600 | LM85_REG_SPINUP_CTL ); | ||
1601 | } else if ( (data->type == adt7463) || (data->type == adm1027) ) { | ||
1602 | if ( data->type == adt7463 ) { | ||
1603 | for (i = 0; i <= 2; ++i) { | ||
1604 | data->oppoint[i] = lm85_read_value(client, | ||
1605 | ADT7463_REG_OPPOINT(i) ); | ||
1606 | } | ||
1607 | data->tmin_ctl = lm85_read_value(client, | ||
1608 | ADT7463_REG_TMIN_CTL1 ); | ||
1609 | data->therm_limit = lm85_read_value(client, | ||
1610 | ADT7463_REG_THERM_LIMIT ); | ||
1611 | } | ||
1612 | for (i = 0; i <= 2; ++i) { | ||
1613 | data->temp_offset[i] = lm85_read_value(client, | ||
1614 | ADM1027_REG_TEMP_OFFSET(i) ); | ||
1615 | } | ||
1616 | data->tach_mode = lm85_read_value(client, | ||
1617 | ADM1027_REG_CONFIG3 ); | ||
1618 | data->fan_ppr = lm85_read_value(client, | ||
1619 | ADM1027_REG_FAN_PPR ); | ||
1620 | } | ||
1621 | |||
1622 | data->last_config = jiffies; | 1506 | data->last_config = jiffies; |
1623 | }; /* last_config */ | 1507 | } /* last_config */ |
1624 | 1508 | ||
1625 | data->valid = 1; | 1509 | data->valid = 1; |
1626 | 1510 | ||
@@ -1635,17 +1519,15 @@ static int __init sm_lm85_init(void) | |||
1635 | return i2c_add_driver(&lm85_driver); | 1519 | return i2c_add_driver(&lm85_driver); |
1636 | } | 1520 | } |
1637 | 1521 | ||
1638 | static void __exit sm_lm85_exit(void) | 1522 | static void __exit sm_lm85_exit(void) |
1639 | { | 1523 | { |
1640 | i2c_del_driver(&lm85_driver); | 1524 | i2c_del_driver(&lm85_driver); |
1641 | } | 1525 | } |
1642 | 1526 | ||
1643 | /* Thanks to Richard Barrington for adding the LM85 to sensors-detect. | ||
1644 | * Thanks to Margit Schubert-While <margitsw@t-online.de> for help with | ||
1645 | * post 2.7.0 CVS changes. | ||
1646 | */ | ||
1647 | MODULE_LICENSE("GPL"); | 1527 | MODULE_LICENSE("GPL"); |
1648 | MODULE_AUTHOR("Philip Pokorny <ppokorny@penguincomputing.com>, Margit Schubert-While <margitsw@t-online.de>, Justin Thiessen <jthiessen@penguincomputing.com"); | 1528 | MODULE_AUTHOR("Philip Pokorny <ppokorny@penguincomputing.com>, " |
1529 | "Margit Schubert-While <margitsw@t-online.de>, " | ||
1530 | "Justin Thiessen <jthiessen@penguincomputing.com>"); | ||
1649 | MODULE_DESCRIPTION("LM85-B, LM85-C driver"); | 1531 | MODULE_DESCRIPTION("LM85-B, LM85-C driver"); |
1650 | 1532 | ||
1651 | module_init(sm_lm85_init); | 1533 | module_init(sm_lm85_init); |
diff --git a/drivers/hwmon/thmc50.c b/drivers/hwmon/thmc50.c index 3b01001108c1..7d97431e132f 100644 --- a/drivers/hwmon/thmc50.c +++ b/drivers/hwmon/thmc50.c | |||
@@ -55,8 +55,11 @@ I2C_CLIENT_MODULE_PARM(adm1022_temp3, "List of adapter,address pairs " | |||
55 | static const u8 THMC50_REG_TEMP[] = { 0x27, 0x26, 0x20 }; | 55 | static const u8 THMC50_REG_TEMP[] = { 0x27, 0x26, 0x20 }; |
56 | static const u8 THMC50_REG_TEMP_MIN[] = { 0x3A, 0x38, 0x2C }; | 56 | static const u8 THMC50_REG_TEMP_MIN[] = { 0x3A, 0x38, 0x2C }; |
57 | static const u8 THMC50_REG_TEMP_MAX[] = { 0x39, 0x37, 0x2B }; | 57 | static const u8 THMC50_REG_TEMP_MAX[] = { 0x39, 0x37, 0x2B }; |
58 | static const u8 THMC50_REG_TEMP_CRITICAL[] = { 0x13, 0x14, 0x14 }; | ||
59 | static const u8 THMC50_REG_TEMP_DEFAULT[] = { 0x17, 0x18, 0x18 }; | ||
58 | 60 | ||
59 | #define THMC50_REG_CONF_nFANOFF 0x20 | 61 | #define THMC50_REG_CONF_nFANOFF 0x20 |
62 | #define THMC50_REG_CONF_PROGRAMMED 0x08 | ||
60 | 63 | ||
61 | /* Each client has this additional data */ | 64 | /* Each client has this additional data */ |
62 | struct thmc50_data { | 65 | struct thmc50_data { |
@@ -72,6 +75,7 @@ struct thmc50_data { | |||
72 | s8 temp_input[3]; | 75 | s8 temp_input[3]; |
73 | s8 temp_max[3]; | 76 | s8 temp_max[3]; |
74 | s8 temp_min[3]; | 77 | s8 temp_min[3]; |
78 | s8 temp_critical[3]; | ||
75 | u8 analog_out; | 79 | u8 analog_out; |
76 | u8 alarms; | 80 | u8 alarms; |
77 | }; | 81 | }; |
@@ -199,6 +203,15 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, | |||
199 | return count; | 203 | return count; |
200 | } | 204 | } |
201 | 205 | ||
206 | static ssize_t show_temp_critical(struct device *dev, | ||
207 | struct device_attribute *attr, | ||
208 | char *buf) | ||
209 | { | ||
210 | int nr = to_sensor_dev_attr(attr)->index; | ||
211 | struct thmc50_data *data = thmc50_update_device(dev); | ||
212 | return sprintf(buf, "%d\n", data->temp_critical[nr] * 1000); | ||
213 | } | ||
214 | |||
202 | static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, | 215 | static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, |
203 | char *buf) | 216 | char *buf) |
204 | { | 217 | { |
@@ -214,7 +227,9 @@ static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp, \ | |||
214 | static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ | 227 | static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ |
215 | show_temp_min, set_temp_min, offset - 1); \ | 228 | show_temp_min, set_temp_min, offset - 1); \ |
216 | static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ | 229 | static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ |
217 | show_temp_max, set_temp_max, offset - 1); | 230 | show_temp_max, set_temp_max, offset - 1); \ |
231 | static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IRUGO, \ | ||
232 | show_temp_critical, NULL, offset - 1); | ||
218 | 233 | ||
219 | temp_reg(1); | 234 | temp_reg(1); |
220 | temp_reg(2); | 235 | temp_reg(2); |
@@ -234,10 +249,12 @@ static struct attribute *thmc50_attributes[] = { | |||
234 | &sensor_dev_attr_temp1_max.dev_attr.attr, | 249 | &sensor_dev_attr_temp1_max.dev_attr.attr, |
235 | &sensor_dev_attr_temp1_min.dev_attr.attr, | 250 | &sensor_dev_attr_temp1_min.dev_attr.attr, |
236 | &sensor_dev_attr_temp1_input.dev_attr.attr, | 251 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
252 | &sensor_dev_attr_temp1_crit.dev_attr.attr, | ||
237 | &sensor_dev_attr_temp1_alarm.dev_attr.attr, | 253 | &sensor_dev_attr_temp1_alarm.dev_attr.attr, |
238 | &sensor_dev_attr_temp2_max.dev_attr.attr, | 254 | &sensor_dev_attr_temp2_max.dev_attr.attr, |
239 | &sensor_dev_attr_temp2_min.dev_attr.attr, | 255 | &sensor_dev_attr_temp2_min.dev_attr.attr, |
240 | &sensor_dev_attr_temp2_input.dev_attr.attr, | 256 | &sensor_dev_attr_temp2_input.dev_attr.attr, |
257 | &sensor_dev_attr_temp2_crit.dev_attr.attr, | ||
241 | &sensor_dev_attr_temp2_alarm.dev_attr.attr, | 258 | &sensor_dev_attr_temp2_alarm.dev_attr.attr, |
242 | &sensor_dev_attr_temp2_fault.dev_attr.attr, | 259 | &sensor_dev_attr_temp2_fault.dev_attr.attr, |
243 | &sensor_dev_attr_pwm1.dev_attr.attr, | 260 | &sensor_dev_attr_pwm1.dev_attr.attr, |
@@ -254,6 +271,7 @@ static struct attribute *temp3_attributes[] = { | |||
254 | &sensor_dev_attr_temp3_max.dev_attr.attr, | 271 | &sensor_dev_attr_temp3_max.dev_attr.attr, |
255 | &sensor_dev_attr_temp3_min.dev_attr.attr, | 272 | &sensor_dev_attr_temp3_min.dev_attr.attr, |
256 | &sensor_dev_attr_temp3_input.dev_attr.attr, | 273 | &sensor_dev_attr_temp3_input.dev_attr.attr, |
274 | &sensor_dev_attr_temp3_crit.dev_attr.attr, | ||
257 | &sensor_dev_attr_temp3_alarm.dev_attr.attr, | 275 | &sensor_dev_attr_temp3_alarm.dev_attr.attr, |
258 | &sensor_dev_attr_temp3_fault.dev_attr.attr, | 276 | &sensor_dev_attr_temp3_fault.dev_attr.attr, |
259 | NULL | 277 | NULL |
@@ -429,6 +447,10 @@ static struct thmc50_data *thmc50_update_device(struct device *dev) | |||
429 | 447 | ||
430 | int temps = data->has_temp3 ? 3 : 2; | 448 | int temps = data->has_temp3 ? 3 : 2; |
431 | int i; | 449 | int i; |
450 | int prog = i2c_smbus_read_byte_data(client, THMC50_REG_CONF); | ||
451 | |||
452 | prog &= THMC50_REG_CONF_PROGRAMMED; | ||
453 | |||
432 | for (i = 0; i < temps; i++) { | 454 | for (i = 0; i < temps; i++) { |
433 | data->temp_input[i] = i2c_smbus_read_byte_data(client, | 455 | data->temp_input[i] = i2c_smbus_read_byte_data(client, |
434 | THMC50_REG_TEMP[i]); | 456 | THMC50_REG_TEMP[i]); |
@@ -436,6 +458,10 @@ static struct thmc50_data *thmc50_update_device(struct device *dev) | |||
436 | THMC50_REG_TEMP_MAX[i]); | 458 | THMC50_REG_TEMP_MAX[i]); |
437 | data->temp_min[i] = i2c_smbus_read_byte_data(client, | 459 | data->temp_min[i] = i2c_smbus_read_byte_data(client, |
438 | THMC50_REG_TEMP_MIN[i]); | 460 | THMC50_REG_TEMP_MIN[i]); |
461 | data->temp_critical[i] = | ||
462 | i2c_smbus_read_byte_data(client, | ||
463 | prog ? THMC50_REG_TEMP_CRITICAL[i] | ||
464 | : THMC50_REG_TEMP_DEFAULT[i]); | ||
439 | } | 465 | } |
440 | data->analog_out = | 466 | data->analog_out = |
441 | i2c_smbus_read_byte_data(client, THMC50_REG_ANALOG_OUT); | 467 | i2c_smbus_read_byte_data(client, THMC50_REG_ANALOG_OUT); |
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index 9564fb069957..b30e5796cb26 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c | |||
@@ -67,10 +67,6 @@ module_param(force_i2c, byte, 0); | |||
67 | MODULE_PARM_DESC(force_i2c, | 67 | MODULE_PARM_DESC(force_i2c, |
68 | "Initialize the i2c address of the sensors"); | 68 | "Initialize the i2c address of the sensors"); |
69 | 69 | ||
70 | static int reset; | ||
71 | module_param(reset, bool, 0); | ||
72 | MODULE_PARM_DESC(reset, "Set to one to reset chip on load"); | ||
73 | |||
74 | static int init = 1; | 70 | static int init = 1; |
75 | module_param(init, bool, 0); | 71 | module_param(init, bool, 0); |
76 | MODULE_PARM_DESC(init, "Set to zero to bypass chip initialization"); | 72 | MODULE_PARM_DESC(init, "Set to zero to bypass chip initialization"); |
@@ -209,6 +205,13 @@ static const u16 w83627hf_reg_temp_over[] = { 0x39, 0x155, 0x255 }; | |||
209 | #define W83627HF_REG_PWM1 0x5A | 205 | #define W83627HF_REG_PWM1 0x5A |
210 | #define W83627HF_REG_PWM2 0x5B | 206 | #define W83627HF_REG_PWM2 0x5B |
211 | 207 | ||
208 | static const u8 W83627THF_REG_PWM_ENABLE[] = { | ||
209 | 0x04, /* FAN 1 mode */ | ||
210 | 0x04, /* FAN 2 mode */ | ||
211 | 0x12, /* FAN AUX mode */ | ||
212 | }; | ||
213 | static const u8 W83627THF_PWM_ENABLE_SHIFT[] = { 2, 4, 1 }; | ||
214 | |||
212 | #define W83627THF_REG_PWM1 0x01 /* 697HF/637HF/687THF too */ | 215 | #define W83627THF_REG_PWM1 0x01 /* 697HF/637HF/687THF too */ |
213 | #define W83627THF_REG_PWM2 0x03 /* 697HF/637HF/687THF too */ | 216 | #define W83627THF_REG_PWM2 0x03 /* 697HF/637HF/687THF too */ |
214 | #define W83627THF_REG_PWM3 0x11 /* 637HF/687THF too */ | 217 | #define W83627THF_REG_PWM3 0x11 /* 637HF/687THF too */ |
@@ -366,6 +369,9 @@ struct w83627hf_data { | |||
366 | u32 alarms; /* Register encoding, combined */ | 369 | u32 alarms; /* Register encoding, combined */ |
367 | u32 beep_mask; /* Register encoding, combined */ | 370 | u32 beep_mask; /* Register encoding, combined */ |
368 | u8 pwm[3]; /* Register value */ | 371 | u8 pwm[3]; /* Register value */ |
372 | u8 pwm_enable[3]; /* 1 = manual | ||
373 | 2 = thermal cruise (also called SmartFan I) | ||
374 | 3 = fan speed cruise */ | ||
369 | u8 pwm_freq[3]; /* Register value */ | 375 | u8 pwm_freq[3]; /* Register value */ |
370 | u16 sens[3]; /* 1 = pentium diode; 2 = 3904 diode; | 376 | u16 sens[3]; /* 1 = pentium diode; 2 = 3904 diode; |
371 | 4 = thermistor */ | 377 | 4 = thermistor */ |
@@ -957,6 +963,42 @@ static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 1); | |||
957 | static SENSOR_DEVICE_ATTR(pwm3, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 2); | 963 | static SENSOR_DEVICE_ATTR(pwm3, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 2); |
958 | 964 | ||
959 | static ssize_t | 965 | static ssize_t |
966 | show_pwm_enable(struct device *dev, struct device_attribute *devattr, char *buf) | ||
967 | { | ||
968 | int nr = to_sensor_dev_attr(devattr)->index; | ||
969 | struct w83627hf_data *data = w83627hf_update_device(dev); | ||
970 | return sprintf(buf, "%d\n", data->pwm_enable[nr]); | ||
971 | } | ||
972 | |||
973 | static ssize_t | ||
974 | store_pwm_enable(struct device *dev, struct device_attribute *devattr, | ||
975 | const char *buf, size_t count) | ||
976 | { | ||
977 | int nr = to_sensor_dev_attr(devattr)->index; | ||
978 | struct w83627hf_data *data = dev_get_drvdata(dev); | ||
979 | unsigned long val = simple_strtoul(buf, NULL, 10); | ||
980 | u8 reg; | ||
981 | |||
982 | if (!val || (val > 3)) /* modes 1, 2 and 3 are supported */ | ||
983 | return -EINVAL; | ||
984 | mutex_lock(&data->update_lock); | ||
985 | data->pwm_enable[nr] = val; | ||
986 | reg = w83627hf_read_value(data, W83627THF_REG_PWM_ENABLE[nr]); | ||
987 | reg &= ~(0x03 << W83627THF_PWM_ENABLE_SHIFT[nr]); | ||
988 | reg |= (val - 1) << W83627THF_PWM_ENABLE_SHIFT[nr]; | ||
989 | w83627hf_write_value(data, W83627THF_REG_PWM_ENABLE[nr], reg); | ||
990 | mutex_unlock(&data->update_lock); | ||
991 | return count; | ||
992 | } | ||
993 | |||
994 | static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO|S_IWUSR, show_pwm_enable, | ||
995 | store_pwm_enable, 0); | ||
996 | static SENSOR_DEVICE_ATTR(pwm2_enable, S_IRUGO|S_IWUSR, show_pwm_enable, | ||
997 | store_pwm_enable, 1); | ||
998 | static SENSOR_DEVICE_ATTR(pwm3_enable, S_IRUGO|S_IWUSR, show_pwm_enable, | ||
999 | store_pwm_enable, 2); | ||
1000 | |||
1001 | static ssize_t | ||
960 | show_pwm_freq(struct device *dev, struct device_attribute *devattr, char *buf) | 1002 | show_pwm_freq(struct device *dev, struct device_attribute *devattr, char *buf) |
961 | { | 1003 | { |
962 | int nr = to_sensor_dev_attr(devattr)->index; | 1004 | int nr = to_sensor_dev_attr(devattr)->index; |
@@ -1223,6 +1265,11 @@ static struct attribute *w83627hf_attributes_opt[] = { | |||
1223 | &sensor_dev_attr_pwm1_freq.dev_attr.attr, | 1265 | &sensor_dev_attr_pwm1_freq.dev_attr.attr, |
1224 | &sensor_dev_attr_pwm2_freq.dev_attr.attr, | 1266 | &sensor_dev_attr_pwm2_freq.dev_attr.attr, |
1225 | &sensor_dev_attr_pwm3_freq.dev_attr.attr, | 1267 | &sensor_dev_attr_pwm3_freq.dev_attr.attr, |
1268 | |||
1269 | &sensor_dev_attr_pwm1_enable.dev_attr.attr, | ||
1270 | &sensor_dev_attr_pwm2_enable.dev_attr.attr, | ||
1271 | &sensor_dev_attr_pwm3_enable.dev_attr.attr, | ||
1272 | |||
1226 | NULL | 1273 | NULL |
1227 | }; | 1274 | }; |
1228 | 1275 | ||
@@ -1366,6 +1413,19 @@ static int __devinit w83627hf_probe(struct platform_device *pdev) | |||
1366 | &sensor_dev_attr_pwm3_freq.dev_attr))) | 1413 | &sensor_dev_attr_pwm3_freq.dev_attr))) |
1367 | goto ERROR4; | 1414 | goto ERROR4; |
1368 | 1415 | ||
1416 | if (data->type != w83627hf) | ||
1417 | if ((err = device_create_file(dev, | ||
1418 | &sensor_dev_attr_pwm1_enable.dev_attr)) | ||
1419 | || (err = device_create_file(dev, | ||
1420 | &sensor_dev_attr_pwm2_enable.dev_attr))) | ||
1421 | goto ERROR4; | ||
1422 | |||
1423 | if (data->type == w83627thf || data->type == w83637hf | ||
1424 | || data->type == w83687thf) | ||
1425 | if ((err = device_create_file(dev, | ||
1426 | &sensor_dev_attr_pwm3_enable.dev_attr))) | ||
1427 | goto ERROR4; | ||
1428 | |||
1369 | data->hwmon_dev = hwmon_device_register(dev); | 1429 | data->hwmon_dev = hwmon_device_register(dev); |
1370 | if (IS_ERR(data->hwmon_dev)) { | 1430 | if (IS_ERR(data->hwmon_dev)) { |
1371 | err = PTR_ERR(data->hwmon_dev); | 1431 | err = PTR_ERR(data->hwmon_dev); |
@@ -1536,29 +1596,6 @@ static void __devinit w83627hf_init_device(struct platform_device *pdev) | |||
1536 | enum chips type = data->type; | 1596 | enum chips type = data->type; |
1537 | u8 tmp; | 1597 | u8 tmp; |
1538 | 1598 | ||
1539 | if (reset) { | ||
1540 | /* Resetting the chip has been the default for a long time, | ||
1541 | but repeatedly caused problems (fans going to full | ||
1542 | speed...) so it is now optional. It might even go away if | ||
1543 | nobody reports it as being useful, as I see very little | ||
1544 | reason why this would be needed at all. */ | ||
1545 | dev_info(&pdev->dev, "If reset=1 solved a problem you were " | ||
1546 | "having, please report!\n"); | ||
1547 | |||
1548 | /* save this register */ | ||
1549 | i = w83627hf_read_value(data, W83781D_REG_BEEP_CONFIG); | ||
1550 | /* Reset all except Watchdog values and last conversion values | ||
1551 | This sets fan-divs to 2, among others */ | ||
1552 | w83627hf_write_value(data, W83781D_REG_CONFIG, 0x80); | ||
1553 | /* Restore the register and disable power-on abnormal beep. | ||
1554 | This saves FAN 1/2/3 input/output values set by BIOS. */ | ||
1555 | w83627hf_write_value(data, W83781D_REG_BEEP_CONFIG, i | 0x80); | ||
1556 | /* Disable master beep-enable (reset turns it on). | ||
1557 | Individual beeps should be reset to off but for some reason | ||
1558 | disabling this bit helps some people not get beeped */ | ||
1559 | w83627hf_write_value(data, W83781D_REG_BEEP_INTS2, 0); | ||
1560 | } | ||
1561 | |||
1562 | /* Minimize conflicts with other winbond i2c-only clients... */ | 1599 | /* Minimize conflicts with other winbond i2c-only clients... */ |
1563 | /* disable i2c subclients... how to disable main i2c client?? */ | 1600 | /* disable i2c subclients... how to disable main i2c client?? */ |
1564 | /* force i2c address to relatively uncommon address */ | 1601 | /* force i2c address to relatively uncommon address */ |
@@ -1655,6 +1692,7 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev) | |||
1655 | { | 1692 | { |
1656 | struct w83627hf_data *data = dev_get_drvdata(dev); | 1693 | struct w83627hf_data *data = dev_get_drvdata(dev); |
1657 | int i, num_temps = (data->type == w83697hf) ? 2 : 3; | 1694 | int i, num_temps = (data->type == w83697hf) ? 2 : 3; |
1695 | int num_pwms = (data->type == w83697hf) ? 2 : 3; | ||
1658 | 1696 | ||
1659 | mutex_lock(&data->update_lock); | 1697 | mutex_lock(&data->update_lock); |
1660 | 1698 | ||
@@ -1707,6 +1745,15 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev) | |||
1707 | break; | 1745 | break; |
1708 | } | 1746 | } |
1709 | } | 1747 | } |
1748 | if (data->type != w83627hf) { | ||
1749 | for (i = 0; i < num_pwms; i++) { | ||
1750 | u8 tmp = w83627hf_read_value(data, | ||
1751 | W83627THF_REG_PWM_ENABLE[i]); | ||
1752 | data->pwm_enable[i] = | ||
1753 | ((tmp >> W83627THF_PWM_ENABLE_SHIFT[i]) | ||
1754 | & 0x03) + 1; | ||
1755 | } | ||
1756 | } | ||
1710 | for (i = 0; i < num_temps; i++) { | 1757 | for (i = 0; i < num_temps; i++) { |
1711 | data->temp[i] = w83627hf_read_value( | 1758 | data->temp[i] = w83627hf_read_value( |
1712 | data, w83627hf_reg_temp[i]); | 1759 | data, w83627hf_reg_temp[i]); |
diff --git a/drivers/hwmon/w83791d.c b/drivers/hwmon/w83791d.c index e4e91c9d480a..daa7d121483b 100644 --- a/drivers/hwmon/w83791d.c +++ b/drivers/hwmon/w83791d.c | |||
@@ -233,11 +233,9 @@ static u8 fan_to_reg(long rpm, int div) | |||
233 | static u8 div_to_reg(int nr, long val) | 233 | static u8 div_to_reg(int nr, long val) |
234 | { | 234 | { |
235 | int i; | 235 | int i; |
236 | int max; | ||
237 | 236 | ||
238 | /* first three fan's divisor max out at 8, rest max out at 128 */ | 237 | /* fan divisors max out at 128 */ |
239 | max = (nr < 3) ? 8 : 128; | 238 | val = SENSORS_LIMIT(val, 1, 128) >> 1; |
240 | val = SENSORS_LIMIT(val, 1, max) >> 1; | ||
241 | for (i = 0; i < 7; i++) { | 239 | for (i = 0; i < 7; i++) { |
242 | if (val == 0) | 240 | if (val == 0) |
243 | break; | 241 | break; |
@@ -530,6 +528,7 @@ static ssize_t store_fan_div(struct device *dev, struct device_attribute *attr, | |||
530 | unsigned long min; | 528 | unsigned long min; |
531 | u8 tmp_fan_div; | 529 | u8 tmp_fan_div; |
532 | u8 fan_div_reg; | 530 | u8 fan_div_reg; |
531 | u8 vbat_reg; | ||
533 | int indx = 0; | 532 | int indx = 0; |
534 | u8 keep_mask = 0; | 533 | u8 keep_mask = 0; |
535 | u8 new_shift = 0; | 534 | u8 new_shift = 0; |
@@ -581,6 +580,16 @@ static ssize_t store_fan_div(struct device *dev, struct device_attribute *attr, | |||
581 | w83791d_write(client, W83791D_REG_FAN_DIV[indx], | 580 | w83791d_write(client, W83791D_REG_FAN_DIV[indx], |
582 | fan_div_reg | tmp_fan_div); | 581 | fan_div_reg | tmp_fan_div); |
583 | 582 | ||
583 | /* Bit 2 of fans 0-2 is stored in the vbat register (bits 5-7) */ | ||
584 | if (nr < 3) { | ||
585 | keep_mask = ~(1 << (nr + 5)); | ||
586 | vbat_reg = w83791d_read(client, W83791D_REG_VBAT) | ||
587 | & keep_mask; | ||
588 | tmp_fan_div = (data->fan_div[nr] << (3 + nr)) & ~keep_mask; | ||
589 | w83791d_write(client, W83791D_REG_VBAT, | ||
590 | vbat_reg | tmp_fan_div); | ||
591 | } | ||
592 | |||
584 | /* Restore fan_min */ | 593 | /* Restore fan_min */ |
585 | data->fan_min[nr] = fan_to_reg(min, DIV_FROM_REG(data->fan_div[nr])); | 594 | data->fan_min[nr] = fan_to_reg(min, DIV_FROM_REG(data->fan_div[nr])); |
586 | w83791d_write(client, W83791D_REG_FAN_MIN[nr], data->fan_min[nr]); | 595 | w83791d_write(client, W83791D_REG_FAN_MIN[nr], data->fan_min[nr]); |
@@ -1182,6 +1191,7 @@ static struct w83791d_data *w83791d_update_device(struct device *dev) | |||
1182 | struct w83791d_data *data = i2c_get_clientdata(client); | 1191 | struct w83791d_data *data = i2c_get_clientdata(client); |
1183 | int i, j; | 1192 | int i, j; |
1184 | u8 reg_array_tmp[3]; | 1193 | u8 reg_array_tmp[3]; |
1194 | u8 vbat_reg; | ||
1185 | 1195 | ||
1186 | mutex_lock(&data->update_lock); | 1196 | mutex_lock(&data->update_lock); |
1187 | 1197 | ||
@@ -1219,6 +1229,12 @@ static struct w83791d_data *w83791d_update_device(struct device *dev) | |||
1219 | data->fan_div[3] = reg_array_tmp[2] & 0x07; | 1229 | data->fan_div[3] = reg_array_tmp[2] & 0x07; |
1220 | data->fan_div[4] = (reg_array_tmp[2] >> 4) & 0x07; | 1230 | data->fan_div[4] = (reg_array_tmp[2] >> 4) & 0x07; |
1221 | 1231 | ||
1232 | /* The fan divisor for fans 0-2 get bit 2 from | ||
1233 | bits 5-7 respectively of vbat register */ | ||
1234 | vbat_reg = w83791d_read(client, W83791D_REG_VBAT); | ||
1235 | for (i = 0; i < 3; i++) | ||
1236 | data->fan_div[i] |= (vbat_reg >> (3 + i)) & 0x04; | ||
1237 | |||
1222 | /* Update the first temperature sensor */ | 1238 | /* Update the first temperature sensor */ |
1223 | for (i = 0; i < 3; i++) { | 1239 | for (i = 0; i < 3; i++) { |
1224 | data->temp1[i] = w83791d_read(client, | 1240 | data->temp1[i] = w83791d_read(client, |