2 * A hwmon driver for the Analog Devices ADT7462
3 * Copyright (C) 2008 IBM
5 * Author: Darrick J. Wong <djwong@us.ibm.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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/delay.h>
30 #include <linux/log2.h>
32 /* Addresses to scan */
33 static const unsigned short normal_i2c
[] = { 0x58, 0x5C, I2C_CLIENT_END
};
35 /* ADT7462 registers */
36 #define ADT7462_REG_DEVICE 0x3D
37 #define ADT7462_REG_VENDOR 0x3E
38 #define ADT7462_REG_REVISION 0x3F
40 #define ADT7462_REG_MIN_TEMP_BASE_ADDR 0x44
41 #define ADT7462_REG_MIN_TEMP_MAX_ADDR 0x47
42 #define ADT7462_REG_MAX_TEMP_BASE_ADDR 0x48
43 #define ADT7462_REG_MAX_TEMP_MAX_ADDR 0x4B
44 #define ADT7462_REG_TEMP_BASE_ADDR 0x88
45 #define ADT7462_REG_TEMP_MAX_ADDR 0x8F
47 #define ADT7462_REG_FAN_BASE_ADDR 0x98
48 #define ADT7462_REG_FAN_MAX_ADDR 0x9F
49 #define ADT7462_REG_FAN2_BASE_ADDR 0xA2
50 #define ADT7462_REG_FAN2_MAX_ADDR 0xA9
51 #define ADT7462_REG_FAN_ENABLE 0x07
52 #define ADT7462_REG_FAN_MIN_BASE_ADDR 0x78
53 #define ADT7462_REG_FAN_MIN_MAX_ADDR 0x7F
55 #define ADT7462_REG_CFG2 0x02
56 #define ADT7462_FSPD_MASK 0x20
58 #define ADT7462_REG_PWM_BASE_ADDR 0xAA
59 #define ADT7462_REG_PWM_MAX_ADDR 0xAD
60 #define ADT7462_REG_PWM_MIN_BASE_ADDR 0x28
61 #define ADT7462_REG_PWM_MIN_MAX_ADDR 0x2B
62 #define ADT7462_REG_PWM_MAX 0x2C
63 #define ADT7462_REG_PWM_TEMP_MIN_BASE_ADDR 0x5C
64 #define ADT7462_REG_PWM_TEMP_MIN_MAX_ADDR 0x5F
65 #define ADT7462_REG_PWM_TEMP_RANGE_BASE_ADDR 0x60
66 #define ADT7462_REG_PWM_TEMP_RANGE_MAX_ADDR 0x63
67 #define ADT7462_PWM_HYST_MASK 0x0F
68 #define ADT7462_PWM_RANGE_MASK 0xF0
69 #define ADT7462_PWM_RANGE_SHIFT 4
70 #define ADT7462_REG_PWM_CFG_BASE_ADDR 0x21
71 #define ADT7462_REG_PWM_CFG_MAX_ADDR 0x24
72 #define ADT7462_PWM_CHANNEL_MASK 0xE0
73 #define ADT7462_PWM_CHANNEL_SHIFT 5
75 #define ADT7462_REG_PIN_CFG_BASE_ADDR 0x10
76 #define ADT7462_REG_PIN_CFG_MAX_ADDR 0x13
77 #define ADT7462_PIN7_INPUT 0x01 /* cfg0 */
78 #define ADT7462_DIODE3_INPUT 0x20
79 #define ADT7462_DIODE1_INPUT 0x40
80 #define ADT7462_VID_INPUT 0x80
81 #define ADT7462_PIN22_INPUT 0x04 /* cfg1 */
82 #define ADT7462_PIN21_INPUT 0x08
83 #define ADT7462_PIN19_INPUT 0x10
84 #define ADT7462_PIN15_INPUT 0x20
85 #define ADT7462_PIN13_INPUT 0x40
86 #define ADT7462_PIN8_INPUT 0x80
87 #define ADT7462_PIN23_MASK 0x03
88 #define ADT7462_PIN23_SHIFT 0
89 #define ADT7462_PIN26_MASK 0x0C /* cfg2 */
90 #define ADT7462_PIN26_SHIFT 2
91 #define ADT7462_PIN25_MASK 0x30
92 #define ADT7462_PIN25_SHIFT 4
93 #define ADT7462_PIN24_MASK 0xC0
94 #define ADT7462_PIN24_SHIFT 6
95 #define ADT7462_PIN26_VOLT_INPUT 0x08
96 #define ADT7462_PIN25_VOLT_INPUT 0x20
97 #define ADT7462_PIN28_SHIFT 4 /* cfg3 */
98 #define ADT7462_PIN28_VOLT 0x5
100 #define ADT7462_REG_ALARM1 0xB8
101 #define ADT7462_LT_ALARM 0x02
102 #define ADT7462_R1T_ALARM 0x04
103 #define ADT7462_R2T_ALARM 0x08
104 #define ADT7462_R3T_ALARM 0x10
105 #define ADT7462_REG_ALARM2 0xBB
106 #define ADT7462_V0_ALARM 0x01
107 #define ADT7462_V1_ALARM 0x02
108 #define ADT7462_V2_ALARM 0x04
109 #define ADT7462_V3_ALARM 0x08
110 #define ADT7462_V4_ALARM 0x10
111 #define ADT7462_V5_ALARM 0x20
112 #define ADT7462_V6_ALARM 0x40
113 #define ADT7462_V7_ALARM 0x80
114 #define ADT7462_REG_ALARM3 0xBC
115 #define ADT7462_V8_ALARM 0x08
116 #define ADT7462_V9_ALARM 0x10
117 #define ADT7462_V10_ALARM 0x20
118 #define ADT7462_V11_ALARM 0x40
119 #define ADT7462_V12_ALARM 0x80
120 #define ADT7462_REG_ALARM4 0xBD
121 #define ADT7462_F0_ALARM 0x01
122 #define ADT7462_F1_ALARM 0x02
123 #define ADT7462_F2_ALARM 0x04
124 #define ADT7462_F3_ALARM 0x08
125 #define ADT7462_F4_ALARM 0x10
126 #define ADT7462_F5_ALARM 0x20
127 #define ADT7462_F6_ALARM 0x40
128 #define ADT7462_F7_ALARM 0x80
129 #define ADT7462_ALARM1 0x0000
130 #define ADT7462_ALARM2 0x0100
131 #define ADT7462_ALARM3 0x0200
132 #define ADT7462_ALARM4 0x0300
133 #define ADT7462_ALARM_REG_SHIFT 8
134 #define ADT7462_ALARM_FLAG_MASK 0x0F
136 #define ADT7462_TEMP_COUNT 4
137 #define ADT7462_TEMP_REG(x) (ADT7462_REG_TEMP_BASE_ADDR + (x * 2))
138 #define ADT7462_TEMP_MIN_REG(x) (ADT7462_REG_MIN_TEMP_BASE_ADDR + (x))
139 #define ADT7462_TEMP_MAX_REG(x) (ADT7462_REG_MAX_TEMP_BASE_ADDR + (x))
140 #define TEMP_FRAC_OFFSET 6
142 #define ADT7462_FAN_COUNT 8
143 #define ADT7462_REG_FAN_MIN(x) (ADT7462_REG_FAN_MIN_BASE_ADDR + (x))
145 #define ADT7462_PWM_COUNT 4
146 #define ADT7462_REG_PWM(x) (ADT7462_REG_PWM_BASE_ADDR + (x))
147 #define ADT7462_REG_PWM_MIN(x) (ADT7462_REG_PWM_MIN_BASE_ADDR + (x))
148 #define ADT7462_REG_PWM_TMIN(x) \
149 (ADT7462_REG_PWM_TEMP_MIN_BASE_ADDR + (x))
150 #define ADT7462_REG_PWM_TRANGE(x) \
151 (ADT7462_REG_PWM_TEMP_RANGE_BASE_ADDR + (x))
153 #define ADT7462_PIN_CFG_REG_COUNT 4
154 #define ADT7462_REG_PIN_CFG(x) (ADT7462_REG_PIN_CFG_BASE_ADDR + (x))
155 #define ADT7462_REG_PWM_CFG(x) (ADT7462_REG_PWM_CFG_BASE_ADDR + (x))
157 #define ADT7462_ALARM_REG_COUNT 4
160 * The chip can measure 13 different voltage sources:
163 * 2. Vccp1/+2.5V/+1.8V/+1.5V (pin 23)
166 * 5. +1.25V/+0.9V (pin 19)
167 * 6. +2.5V/+1.8V (pin 15)
170 * 9. Vbatt/FSB_Vtt (pin 26)
171 * A. +3.3V/+1.2V1 (pin 25)
172 * B. Vccp2/+2.5V/+1.8V/+1.5V (pin 24)
173 * C. +1.5V ICH (only if BOTH pin 28/29 are set to +1.5V)
174 * D. +1.5V 3GPIO (only if BOTH pin 28/29 are set to +1.5V)
176 * Each of these 13 has a factor to convert raw to voltage. Even better,
177 * the pins can be connected to other sensors (tach/gpio/hot/etc), which
178 * makes the bookkeeping tricky.
180 * Some, but not all, of these voltages have low/high limits.
182 #define ADT7462_VOLT_COUNT 13
184 #define ADT7462_VENDOR 0x41
185 #define ADT7462_DEVICE 0x62
186 /* datasheet only mentions a revision 4 */
187 #define ADT7462_REVISION 0x04
189 /* How often do we reread sensors values? (In jiffies) */
190 #define SENSOR_REFRESH_INTERVAL (2 * HZ)
192 /* How often do we reread sensor limit values? (In jiffies) */
193 #define LIMIT_REFRESH_INTERVAL (60 * HZ)
195 /* datasheet says to divide this number by the fan reading to get fan rpm */
196 #define FAN_PERIOD_TO_RPM(x) ((90000 * 60) / (x))
197 #define FAN_RPM_TO_PERIOD FAN_PERIOD_TO_RPM
198 #define FAN_PERIOD_INVALID 65535
199 #define FAN_DATA_VALID(x) ((x) && (x) != FAN_PERIOD_INVALID)
201 #define MASK_AND_SHIFT(value, prefix) \
202 (((value) & prefix##_MASK) >> prefix##_SHIFT)
204 struct adt7462_data
{
205 struct device
*hwmon_dev
;
206 struct attribute_group attrs
;
210 unsigned long sensors_last_updated
; /* In jiffies */
211 unsigned long limits_last_updated
; /* In jiffies */
213 u8 temp
[ADT7462_TEMP_COUNT
];
214 /* bits 6-7 are quarter pieces of temp */
215 u8 temp_frac
[ADT7462_TEMP_COUNT
];
216 u8 temp_min
[ADT7462_TEMP_COUNT
];
217 u8 temp_max
[ADT7462_TEMP_COUNT
];
218 u16 fan
[ADT7462_FAN_COUNT
];
220 u8 fan_min
[ADT7462_FAN_COUNT
];
222 u8 pwm
[ADT7462_PWM_COUNT
];
223 u8 pin_cfg
[ADT7462_PIN_CFG_REG_COUNT
];
224 u8 voltages
[ADT7462_VOLT_COUNT
];
225 u8 volt_max
[ADT7462_VOLT_COUNT
];
226 u8 volt_min
[ADT7462_VOLT_COUNT
];
227 u8 pwm_min
[ADT7462_PWM_COUNT
];
228 u8 pwm_tmin
[ADT7462_PWM_COUNT
];
229 u8 pwm_trange
[ADT7462_PWM_COUNT
];
230 u8 pwm_max
; /* only one per chip */
231 u8 pwm_cfg
[ADT7462_PWM_COUNT
];
232 u8 alarms
[ADT7462_ALARM_REG_COUNT
];
235 static int adt7462_probe(struct i2c_client
*client
,
236 const struct i2c_device_id
*id
);
237 static int adt7462_detect(struct i2c_client
*client
,
238 struct i2c_board_info
*info
);
239 static int adt7462_remove(struct i2c_client
*client
);
241 static const struct i2c_device_id adt7462_id
[] = {
245 MODULE_DEVICE_TABLE(i2c
, adt7462_id
);
247 static struct i2c_driver adt7462_driver
= {
248 .class = I2C_CLASS_HWMON
,
252 .probe
= adt7462_probe
,
253 .remove
= adt7462_remove
,
254 .id_table
= adt7462_id
,
255 .detect
= adt7462_detect
,
256 .address_list
= normal_i2c
,
260 * 16-bit registers on the ADT7462 are low-byte first. The data sheet says
261 * that the low byte must be read before the high byte.
263 static inline int adt7462_read_word_data(struct i2c_client
*client
, u8 reg
)
266 foo
= i2c_smbus_read_byte_data(client
, reg
);
267 foo
|= ((u16
)i2c_smbus_read_byte_data(client
, reg
+ 1) << 8);
271 /* For some reason these registers are not contiguous. */
272 static int ADT7462_REG_FAN(int fan
)
275 return ADT7462_REG_FAN_BASE_ADDR
+ (2 * fan
);
276 return ADT7462_REG_FAN2_BASE_ADDR
+ (2 * (fan
- 4));
279 /* Voltage registers are scattered everywhere */
280 static int ADT7462_REG_VOLT_MAX(struct adt7462_data
*data
, int which
)
284 if (!(data
->pin_cfg
[0] & ADT7462_PIN7_INPUT
))
290 if (!(data
->pin_cfg
[1] & ADT7462_PIN22_INPUT
))
294 if (!(data
->pin_cfg
[1] & ADT7462_PIN21_INPUT
))
298 if (!(data
->pin_cfg
[0] & ADT7462_DIODE3_INPUT
))
302 if (!(data
->pin_cfg
[0] & ADT7462_DIODE1_INPUT
))
306 if (!(data
->pin_cfg
[1] & ADT7462_PIN13_INPUT
))
310 if (!(data
->pin_cfg
[1] & ADT7462_PIN8_INPUT
))
314 if (!(data
->pin_cfg
[2] & ADT7462_PIN26_VOLT_INPUT
))
318 if (!(data
->pin_cfg
[2] & ADT7462_PIN25_VOLT_INPUT
))
324 if (data
->pin_cfg
[3] >> ADT7462_PIN28_SHIFT
==
325 ADT7462_PIN28_VOLT
&&
326 !(data
->pin_cfg
[0] & ADT7462_VID_INPUT
))
330 if (data
->pin_cfg
[3] >> ADT7462_PIN28_SHIFT
==
331 ADT7462_PIN28_VOLT
&&
332 !(data
->pin_cfg
[0] & ADT7462_VID_INPUT
))
339 static int ADT7462_REG_VOLT_MIN(struct adt7462_data
*data
, int which
)
343 if (!(data
->pin_cfg
[0] & ADT7462_PIN7_INPUT
))
349 if (!(data
->pin_cfg
[1] & ADT7462_PIN22_INPUT
))
353 if (!(data
->pin_cfg
[1] & ADT7462_PIN21_INPUT
))
357 if (!(data
->pin_cfg
[0] & ADT7462_DIODE3_INPUT
))
361 if (!(data
->pin_cfg
[0] & ADT7462_DIODE1_INPUT
))
365 if (!(data
->pin_cfg
[1] & ADT7462_PIN13_INPUT
))
369 if (!(data
->pin_cfg
[1] & ADT7462_PIN8_INPUT
))
373 if (!(data
->pin_cfg
[2] & ADT7462_PIN26_VOLT_INPUT
))
377 if (!(data
->pin_cfg
[2] & ADT7462_PIN25_VOLT_INPUT
))
383 if (data
->pin_cfg
[3] >> ADT7462_PIN28_SHIFT
==
384 ADT7462_PIN28_VOLT
&&
385 !(data
->pin_cfg
[0] & ADT7462_VID_INPUT
))
389 if (data
->pin_cfg
[3] >> ADT7462_PIN28_SHIFT
==
390 ADT7462_PIN28_VOLT
&&
391 !(data
->pin_cfg
[0] & ADT7462_VID_INPUT
))
398 static int ADT7462_REG_VOLT(struct adt7462_data
*data
, int which
)
402 if (!(data
->pin_cfg
[0] & ADT7462_PIN7_INPUT
))
408 if (!(data
->pin_cfg
[1] & ADT7462_PIN22_INPUT
))
412 if (!(data
->pin_cfg
[1] & ADT7462_PIN21_INPUT
))
416 if (!(data
->pin_cfg
[0] & ADT7462_DIODE3_INPUT
))
420 if (!(data
->pin_cfg
[0] & ADT7462_DIODE1_INPUT
))
424 if (!(data
->pin_cfg
[1] & ADT7462_PIN13_INPUT
))
428 if (!(data
->pin_cfg
[1] & ADT7462_PIN8_INPUT
))
432 if (!(data
->pin_cfg
[2] & ADT7462_PIN26_VOLT_INPUT
))
436 if (!(data
->pin_cfg
[2] & ADT7462_PIN25_VOLT_INPUT
))
442 if (data
->pin_cfg
[3] >> ADT7462_PIN28_SHIFT
==
443 ADT7462_PIN28_VOLT
&&
444 !(data
->pin_cfg
[0] & ADT7462_VID_INPUT
))
448 if (data
->pin_cfg
[3] >> ADT7462_PIN28_SHIFT
==
449 ADT7462_PIN28_VOLT
&&
450 !(data
->pin_cfg
[0] & ADT7462_VID_INPUT
))
457 /* Provide labels for sysfs */
458 static const char *voltage_label(struct adt7462_data
*data
, int which
)
462 if (!(data
->pin_cfg
[0] & ADT7462_PIN7_INPUT
))
466 switch (MASK_AND_SHIFT(data
->pin_cfg
[1], ADT7462_PIN23
)) {
477 if (!(data
->pin_cfg
[1] & ADT7462_PIN22_INPUT
))
481 if (!(data
->pin_cfg
[1] & ADT7462_PIN21_INPUT
))
485 if (!(data
->pin_cfg
[0] & ADT7462_DIODE3_INPUT
)) {
486 if (data
->pin_cfg
[1] & ADT7462_PIN19_INPUT
)
492 if (!(data
->pin_cfg
[0] & ADT7462_DIODE1_INPUT
)) {
493 if (data
->pin_cfg
[1] & ADT7462_PIN19_INPUT
)
499 if (!(data
->pin_cfg
[1] & ADT7462_PIN13_INPUT
))
503 if (!(data
->pin_cfg
[1] & ADT7462_PIN8_INPUT
))
507 switch (MASK_AND_SHIFT(data
->pin_cfg
[2], ADT7462_PIN26
)) {
515 switch (MASK_AND_SHIFT(data
->pin_cfg
[2], ADT7462_PIN25
)) {
523 switch (MASK_AND_SHIFT(data
->pin_cfg
[2], ADT7462_PIN24
)) {
534 if (data
->pin_cfg
[3] >> ADT7462_PIN28_SHIFT
==
535 ADT7462_PIN28_VOLT
&&
536 !(data
->pin_cfg
[0] & ADT7462_VID_INPUT
))
540 if (data
->pin_cfg
[3] >> ADT7462_PIN28_SHIFT
==
541 ADT7462_PIN28_VOLT
&&
542 !(data
->pin_cfg
[0] & ADT7462_VID_INPUT
))
543 return "+1.5V 3GPIO";
549 /* Multipliers are actually in uV, not mV. */
550 static int voltage_multiplier(struct adt7462_data
*data
, int which
)
554 if (!(data
->pin_cfg
[0] & ADT7462_PIN7_INPUT
))
558 switch (MASK_AND_SHIFT(data
->pin_cfg
[1], ADT7462_PIN23
)) {
560 if (data
->pin_cfg
[0] & ADT7462_VID_INPUT
)
571 if (!(data
->pin_cfg
[1] & ADT7462_PIN22_INPUT
))
575 if (!(data
->pin_cfg
[1] & ADT7462_PIN21_INPUT
))
579 if (!(data
->pin_cfg
[0] & ADT7462_DIODE3_INPUT
)) {
580 if (data
->pin_cfg
[1] & ADT7462_PIN19_INPUT
)
586 if (!(data
->pin_cfg
[0] & ADT7462_DIODE1_INPUT
)) {
587 if (data
->pin_cfg
[1] & ADT7462_PIN15_INPUT
)
593 if (!(data
->pin_cfg
[1] & ADT7462_PIN13_INPUT
))
597 if (!(data
->pin_cfg
[1] & ADT7462_PIN8_INPUT
))
601 switch (MASK_AND_SHIFT(data
->pin_cfg
[2], ADT7462_PIN26
)) {
609 switch (MASK_AND_SHIFT(data
->pin_cfg
[2], ADT7462_PIN25
)) {
617 switch (MASK_AND_SHIFT(data
->pin_cfg
[2], ADT7462_PIN24
)) {
629 if (data
->pin_cfg
[3] >> ADT7462_PIN28_SHIFT
==
630 ADT7462_PIN28_VOLT
&&
631 !(data
->pin_cfg
[0] & ADT7462_VID_INPUT
))
637 static int temp_enabled(struct adt7462_data
*data
, int which
)
644 if (data
->pin_cfg
[0] & ADT7462_DIODE1_INPUT
)
648 if (data
->pin_cfg
[0] & ADT7462_DIODE3_INPUT
)
655 static const char *temp_label(struct adt7462_data
*data
, int which
)
661 if (data
->pin_cfg
[0] & ADT7462_DIODE1_INPUT
)
667 if (data
->pin_cfg
[0] & ADT7462_DIODE3_INPUT
)
674 /* Map Trange register values to mC */
675 #define NUM_TRANGE_VALUES 16
676 static const int trange_values
[NUM_TRANGE_VALUES
] = {
695 static int find_trange_value(int trange
)
699 for (i
= 0; i
< NUM_TRANGE_VALUES
; i
++)
700 if (trange_values
[i
] == trange
)
706 static struct adt7462_data
*adt7462_update_device(struct device
*dev
)
708 struct i2c_client
*client
= to_i2c_client(dev
);
709 struct adt7462_data
*data
= i2c_get_clientdata(client
);
710 unsigned long local_jiffies
= jiffies
;
713 mutex_lock(&data
->lock
);
714 if (time_before(local_jiffies
, data
->sensors_last_updated
+
715 SENSOR_REFRESH_INTERVAL
)
716 && data
->sensors_valid
)
717 goto no_sensor_update
;
719 for (i
= 0; i
< ADT7462_TEMP_COUNT
; i
++) {
721 * Reading the fractional register locks the integral
722 * register until both have been read.
724 data
->temp_frac
[i
] = i2c_smbus_read_byte_data(client
,
725 ADT7462_TEMP_REG(i
));
726 data
->temp
[i
] = i2c_smbus_read_byte_data(client
,
727 ADT7462_TEMP_REG(i
) + 1);
730 for (i
= 0; i
< ADT7462_FAN_COUNT
; i
++)
731 data
->fan
[i
] = adt7462_read_word_data(client
,
734 data
->fan_enabled
= i2c_smbus_read_byte_data(client
,
735 ADT7462_REG_FAN_ENABLE
);
737 for (i
= 0; i
< ADT7462_PWM_COUNT
; i
++)
738 data
->pwm
[i
] = i2c_smbus_read_byte_data(client
,
741 for (i
= 0; i
< ADT7462_PIN_CFG_REG_COUNT
; i
++)
742 data
->pin_cfg
[i
] = i2c_smbus_read_byte_data(client
,
743 ADT7462_REG_PIN_CFG(i
));
745 for (i
= 0; i
< ADT7462_VOLT_COUNT
; i
++) {
746 int reg
= ADT7462_REG_VOLT(data
, i
);
748 data
->voltages
[i
] = 0;
750 data
->voltages
[i
] = i2c_smbus_read_byte_data(client
,
754 data
->alarms
[0] = i2c_smbus_read_byte_data(client
, ADT7462_REG_ALARM1
);
755 data
->alarms
[1] = i2c_smbus_read_byte_data(client
, ADT7462_REG_ALARM2
);
756 data
->alarms
[2] = i2c_smbus_read_byte_data(client
, ADT7462_REG_ALARM3
);
757 data
->alarms
[3] = i2c_smbus_read_byte_data(client
, ADT7462_REG_ALARM4
);
759 data
->sensors_last_updated
= local_jiffies
;
760 data
->sensors_valid
= 1;
763 if (time_before(local_jiffies
, data
->limits_last_updated
+
764 LIMIT_REFRESH_INTERVAL
)
765 && data
->limits_valid
)
768 for (i
= 0; i
< ADT7462_TEMP_COUNT
; i
++) {
769 data
->temp_min
[i
] = i2c_smbus_read_byte_data(client
,
770 ADT7462_TEMP_MIN_REG(i
));
771 data
->temp_max
[i
] = i2c_smbus_read_byte_data(client
,
772 ADT7462_TEMP_MAX_REG(i
));
775 for (i
= 0; i
< ADT7462_FAN_COUNT
; i
++)
776 data
->fan_min
[i
] = i2c_smbus_read_byte_data(client
,
777 ADT7462_REG_FAN_MIN(i
));
779 for (i
= 0; i
< ADT7462_VOLT_COUNT
; i
++) {
780 int reg
= ADT7462_REG_VOLT_MAX(data
, i
);
782 (reg
? i2c_smbus_read_byte_data(client
, reg
) : 0);
784 reg
= ADT7462_REG_VOLT_MIN(data
, i
);
786 (reg
? i2c_smbus_read_byte_data(client
, reg
) : 0);
789 for (i
= 0; i
< ADT7462_PWM_COUNT
; i
++) {
790 data
->pwm_min
[i
] = i2c_smbus_read_byte_data(client
,
791 ADT7462_REG_PWM_MIN(i
));
792 data
->pwm_tmin
[i
] = i2c_smbus_read_byte_data(client
,
793 ADT7462_REG_PWM_TMIN(i
));
794 data
->pwm_trange
[i
] = i2c_smbus_read_byte_data(client
,
795 ADT7462_REG_PWM_TRANGE(i
));
796 data
->pwm_cfg
[i
] = i2c_smbus_read_byte_data(client
,
797 ADT7462_REG_PWM_CFG(i
));
800 data
->pwm_max
= i2c_smbus_read_byte_data(client
, ADT7462_REG_PWM_MAX
);
802 data
->cfg2
= i2c_smbus_read_byte_data(client
, ADT7462_REG_CFG2
);
804 data
->limits_last_updated
= local_jiffies
;
805 data
->limits_valid
= 1;
808 mutex_unlock(&data
->lock
);
812 static ssize_t
show_temp_min(struct device
*dev
,
813 struct device_attribute
*devattr
,
816 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
817 struct adt7462_data
*data
= adt7462_update_device(dev
);
819 if (!temp_enabled(data
, attr
->index
))
820 return sprintf(buf
, "0\n");
822 return sprintf(buf
, "%d\n", 1000 * (data
->temp_min
[attr
->index
] - 64));
825 static ssize_t
set_temp_min(struct device
*dev
,
826 struct device_attribute
*devattr
,
830 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
831 struct i2c_client
*client
= to_i2c_client(dev
);
832 struct adt7462_data
*data
= i2c_get_clientdata(client
);
835 if (strict_strtol(buf
, 10, &temp
) || !temp_enabled(data
, attr
->index
))
838 temp
= DIV_ROUND_CLOSEST(temp
, 1000) + 64;
839 temp
= SENSORS_LIMIT(temp
, 0, 255);
841 mutex_lock(&data
->lock
);
842 data
->temp_min
[attr
->index
] = temp
;
843 i2c_smbus_write_byte_data(client
, ADT7462_TEMP_MIN_REG(attr
->index
),
845 mutex_unlock(&data
->lock
);
850 static ssize_t
show_temp_max(struct device
*dev
,
851 struct device_attribute
*devattr
,
854 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
855 struct adt7462_data
*data
= adt7462_update_device(dev
);
857 if (!temp_enabled(data
, attr
->index
))
858 return sprintf(buf
, "0\n");
860 return sprintf(buf
, "%d\n", 1000 * (data
->temp_max
[attr
->index
] - 64));
863 static ssize_t
set_temp_max(struct device
*dev
,
864 struct device_attribute
*devattr
,
868 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
869 struct i2c_client
*client
= to_i2c_client(dev
);
870 struct adt7462_data
*data
= i2c_get_clientdata(client
);
873 if (strict_strtol(buf
, 10, &temp
) || !temp_enabled(data
, attr
->index
))
876 temp
= DIV_ROUND_CLOSEST(temp
, 1000) + 64;
877 temp
= SENSORS_LIMIT(temp
, 0, 255);
879 mutex_lock(&data
->lock
);
880 data
->temp_max
[attr
->index
] = temp
;
881 i2c_smbus_write_byte_data(client
, ADT7462_TEMP_MAX_REG(attr
->index
),
883 mutex_unlock(&data
->lock
);
888 static ssize_t
show_temp(struct device
*dev
, struct device_attribute
*devattr
,
891 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
892 struct adt7462_data
*data
= adt7462_update_device(dev
);
893 u8 frac
= data
->temp_frac
[attr
->index
] >> TEMP_FRAC_OFFSET
;
895 if (!temp_enabled(data
, attr
->index
))
896 return sprintf(buf
, "0\n");
898 return sprintf(buf
, "%d\n", 1000 * (data
->temp
[attr
->index
] - 64) +
902 static ssize_t
show_temp_label(struct device
*dev
,
903 struct device_attribute
*devattr
,
906 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
907 struct adt7462_data
*data
= adt7462_update_device(dev
);
909 return sprintf(buf
, "%s\n", temp_label(data
, attr
->index
));
912 static ssize_t
show_volt_max(struct device
*dev
,
913 struct device_attribute
*devattr
,
916 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
917 struct adt7462_data
*data
= adt7462_update_device(dev
);
918 int x
= voltage_multiplier(data
, attr
->index
);
920 x
*= data
->volt_max
[attr
->index
];
921 x
/= 1000; /* convert from uV to mV */
923 return sprintf(buf
, "%d\n", x
);
926 static ssize_t
set_volt_max(struct device
*dev
,
927 struct device_attribute
*devattr
,
931 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
932 struct i2c_client
*client
= to_i2c_client(dev
);
933 struct adt7462_data
*data
= i2c_get_clientdata(client
);
934 int x
= voltage_multiplier(data
, attr
->index
);
937 if (strict_strtol(buf
, 10, &temp
) || !x
)
940 temp
*= 1000; /* convert mV to uV */
941 temp
= DIV_ROUND_CLOSEST(temp
, x
);
942 temp
= SENSORS_LIMIT(temp
, 0, 255);
944 mutex_lock(&data
->lock
);
945 data
->volt_max
[attr
->index
] = temp
;
946 i2c_smbus_write_byte_data(client
,
947 ADT7462_REG_VOLT_MAX(data
, attr
->index
),
949 mutex_unlock(&data
->lock
);
954 static ssize_t
show_volt_min(struct device
*dev
,
955 struct device_attribute
*devattr
,
958 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
959 struct adt7462_data
*data
= adt7462_update_device(dev
);
960 int x
= voltage_multiplier(data
, attr
->index
);
962 x
*= data
->volt_min
[attr
->index
];
963 x
/= 1000; /* convert from uV to mV */
965 return sprintf(buf
, "%d\n", x
);
968 static ssize_t
set_volt_min(struct device
*dev
,
969 struct device_attribute
*devattr
,
973 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
974 struct i2c_client
*client
= to_i2c_client(dev
);
975 struct adt7462_data
*data
= i2c_get_clientdata(client
);
976 int x
= voltage_multiplier(data
, attr
->index
);
979 if (strict_strtol(buf
, 10, &temp
) || !x
)
982 temp
*= 1000; /* convert mV to uV */
983 temp
= DIV_ROUND_CLOSEST(temp
, x
);
984 temp
= SENSORS_LIMIT(temp
, 0, 255);
986 mutex_lock(&data
->lock
);
987 data
->volt_min
[attr
->index
] = temp
;
988 i2c_smbus_write_byte_data(client
,
989 ADT7462_REG_VOLT_MIN(data
, attr
->index
),
991 mutex_unlock(&data
->lock
);
996 static ssize_t
show_voltage(struct device
*dev
,
997 struct device_attribute
*devattr
,
1000 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1001 struct adt7462_data
*data
= adt7462_update_device(dev
);
1002 int x
= voltage_multiplier(data
, attr
->index
);
1004 x
*= data
->voltages
[attr
->index
];
1005 x
/= 1000; /* convert from uV to mV */
1007 return sprintf(buf
, "%d\n", x
);
1010 static ssize_t
show_voltage_label(struct device
*dev
,
1011 struct device_attribute
*devattr
,
1014 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1015 struct adt7462_data
*data
= adt7462_update_device(dev
);
1017 return sprintf(buf
, "%s\n", voltage_label(data
, attr
->index
));
1020 static ssize_t
show_alarm(struct device
*dev
,
1021 struct device_attribute
*devattr
,
1024 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1025 struct adt7462_data
*data
= adt7462_update_device(dev
);
1026 int reg
= attr
->index
>> ADT7462_ALARM_REG_SHIFT
;
1027 int mask
= attr
->index
& ADT7462_ALARM_FLAG_MASK
;
1029 if (data
->alarms
[reg
] & mask
)
1030 return sprintf(buf
, "1\n");
1032 return sprintf(buf
, "0\n");
1035 static int fan_enabled(struct adt7462_data
*data
, int fan
)
1037 return data
->fan_enabled
& (1 << fan
);
1040 static ssize_t
show_fan_min(struct device
*dev
,
1041 struct device_attribute
*devattr
,
1044 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1045 struct adt7462_data
*data
= adt7462_update_device(dev
);
1048 /* Only the MSB of the min fan period is stored... */
1049 temp
= data
->fan_min
[attr
->index
];
1052 if (!fan_enabled(data
, attr
->index
) ||
1053 !FAN_DATA_VALID(temp
))
1054 return sprintf(buf
, "0\n");
1056 return sprintf(buf
, "%d\n", FAN_PERIOD_TO_RPM(temp
));
1059 static ssize_t
set_fan_min(struct device
*dev
,
1060 struct device_attribute
*devattr
,
1061 const char *buf
, size_t count
)
1063 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1064 struct i2c_client
*client
= to_i2c_client(dev
);
1065 struct adt7462_data
*data
= i2c_get_clientdata(client
);
1068 if (strict_strtol(buf
, 10, &temp
) || !temp
||
1069 !fan_enabled(data
, attr
->index
))
1072 temp
= FAN_RPM_TO_PERIOD(temp
);
1074 temp
= SENSORS_LIMIT(temp
, 1, 255);
1076 mutex_lock(&data
->lock
);
1077 data
->fan_min
[attr
->index
] = temp
;
1078 i2c_smbus_write_byte_data(client
, ADT7462_REG_FAN_MIN(attr
->index
),
1080 mutex_unlock(&data
->lock
);
1085 static ssize_t
show_fan(struct device
*dev
, struct device_attribute
*devattr
,
1088 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1089 struct adt7462_data
*data
= adt7462_update_device(dev
);
1091 if (!fan_enabled(data
, attr
->index
) ||
1092 !FAN_DATA_VALID(data
->fan
[attr
->index
]))
1093 return sprintf(buf
, "0\n");
1095 return sprintf(buf
, "%d\n",
1096 FAN_PERIOD_TO_RPM(data
->fan
[attr
->index
]));
1099 static ssize_t
show_force_pwm_max(struct device
*dev
,
1100 struct device_attribute
*devattr
,
1103 struct adt7462_data
*data
= adt7462_update_device(dev
);
1104 return sprintf(buf
, "%d\n", (data
->cfg2
& ADT7462_FSPD_MASK
? 1 : 0));
1107 static ssize_t
set_force_pwm_max(struct device
*dev
,
1108 struct device_attribute
*devattr
,
1112 struct i2c_client
*client
= to_i2c_client(dev
);
1113 struct adt7462_data
*data
= i2c_get_clientdata(client
);
1117 if (strict_strtol(buf
, 10, &temp
))
1120 mutex_lock(&data
->lock
);
1121 reg
= i2c_smbus_read_byte_data(client
, ADT7462_REG_CFG2
);
1123 reg
|= ADT7462_FSPD_MASK
;
1125 reg
&= ~ADT7462_FSPD_MASK
;
1127 i2c_smbus_write_byte_data(client
, ADT7462_REG_CFG2
, reg
);
1128 mutex_unlock(&data
->lock
);
1133 static ssize_t
show_pwm(struct device
*dev
, struct device_attribute
*devattr
,
1136 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1137 struct adt7462_data
*data
= adt7462_update_device(dev
);
1138 return sprintf(buf
, "%d\n", data
->pwm
[attr
->index
]);
1141 static ssize_t
set_pwm(struct device
*dev
, struct device_attribute
*devattr
,
1142 const char *buf
, size_t count
)
1144 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1145 struct i2c_client
*client
= to_i2c_client(dev
);
1146 struct adt7462_data
*data
= i2c_get_clientdata(client
);
1149 if (strict_strtol(buf
, 10, &temp
))
1152 temp
= SENSORS_LIMIT(temp
, 0, 255);
1154 mutex_lock(&data
->lock
);
1155 data
->pwm
[attr
->index
] = temp
;
1156 i2c_smbus_write_byte_data(client
, ADT7462_REG_PWM(attr
->index
), temp
);
1157 mutex_unlock(&data
->lock
);
1162 static ssize_t
show_pwm_max(struct device
*dev
,
1163 struct device_attribute
*devattr
,
1166 struct adt7462_data
*data
= adt7462_update_device(dev
);
1167 return sprintf(buf
, "%d\n", data
->pwm_max
);
1170 static ssize_t
set_pwm_max(struct device
*dev
,
1171 struct device_attribute
*devattr
,
1175 struct i2c_client
*client
= to_i2c_client(dev
);
1176 struct adt7462_data
*data
= i2c_get_clientdata(client
);
1179 if (strict_strtol(buf
, 10, &temp
))
1182 temp
= SENSORS_LIMIT(temp
, 0, 255);
1184 mutex_lock(&data
->lock
);
1185 data
->pwm_max
= temp
;
1186 i2c_smbus_write_byte_data(client
, ADT7462_REG_PWM_MAX
, temp
);
1187 mutex_unlock(&data
->lock
);
1192 static ssize_t
show_pwm_min(struct device
*dev
,
1193 struct device_attribute
*devattr
,
1196 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1197 struct adt7462_data
*data
= adt7462_update_device(dev
);
1198 return sprintf(buf
, "%d\n", data
->pwm_min
[attr
->index
]);
1201 static ssize_t
set_pwm_min(struct device
*dev
,
1202 struct device_attribute
*devattr
,
1206 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1207 struct i2c_client
*client
= to_i2c_client(dev
);
1208 struct adt7462_data
*data
= i2c_get_clientdata(client
);
1211 if (strict_strtol(buf
, 10, &temp
))
1214 temp
= SENSORS_LIMIT(temp
, 0, 255);
1216 mutex_lock(&data
->lock
);
1217 data
->pwm_min
[attr
->index
] = temp
;
1218 i2c_smbus_write_byte_data(client
, ADT7462_REG_PWM_MIN(attr
->index
),
1220 mutex_unlock(&data
->lock
);
1225 static ssize_t
show_pwm_hyst(struct device
*dev
,
1226 struct device_attribute
*devattr
,
1229 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1230 struct adt7462_data
*data
= adt7462_update_device(dev
);
1231 return sprintf(buf
, "%d\n", 1000 *
1232 (data
->pwm_trange
[attr
->index
] & ADT7462_PWM_HYST_MASK
));
1235 static ssize_t
set_pwm_hyst(struct device
*dev
,
1236 struct device_attribute
*devattr
,
1240 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1241 struct i2c_client
*client
= to_i2c_client(dev
);
1242 struct adt7462_data
*data
= i2c_get_clientdata(client
);
1245 if (strict_strtol(buf
, 10, &temp
))
1248 temp
= DIV_ROUND_CLOSEST(temp
, 1000);
1249 temp
= SENSORS_LIMIT(temp
, 0, 15);
1251 /* package things up */
1252 temp
&= ADT7462_PWM_HYST_MASK
;
1253 temp
|= data
->pwm_trange
[attr
->index
] & ADT7462_PWM_RANGE_MASK
;
1255 mutex_lock(&data
->lock
);
1256 data
->pwm_trange
[attr
->index
] = temp
;
1257 i2c_smbus_write_byte_data(client
, ADT7462_REG_PWM_TRANGE(attr
->index
),
1259 mutex_unlock(&data
->lock
);
1264 static ssize_t
show_pwm_tmax(struct device
*dev
,
1265 struct device_attribute
*devattr
,
1268 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1269 struct adt7462_data
*data
= adt7462_update_device(dev
);
1271 /* tmax = tmin + trange */
1272 int trange
= trange_values
[data
->pwm_trange
[attr
->index
] >>
1273 ADT7462_PWM_RANGE_SHIFT
];
1274 int tmin
= (data
->pwm_tmin
[attr
->index
] - 64) * 1000;
1276 return sprintf(buf
, "%d\n", tmin
+ trange
);
1279 static ssize_t
set_pwm_tmax(struct device
*dev
,
1280 struct device_attribute
*devattr
,
1285 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1286 struct i2c_client
*client
= to_i2c_client(dev
);
1287 struct adt7462_data
*data
= i2c_get_clientdata(client
);
1288 int tmin
, trange_value
;
1291 if (strict_strtol(buf
, 10, &trange
))
1294 /* trange = tmax - tmin */
1295 tmin
= (data
->pwm_tmin
[attr
->index
] - 64) * 1000;
1296 trange_value
= find_trange_value(trange
- tmin
);
1298 if (trange_value
< 0)
1301 temp
= trange_value
<< ADT7462_PWM_RANGE_SHIFT
;
1302 temp
|= data
->pwm_trange
[attr
->index
] & ADT7462_PWM_HYST_MASK
;
1304 mutex_lock(&data
->lock
);
1305 data
->pwm_trange
[attr
->index
] = temp
;
1306 i2c_smbus_write_byte_data(client
, ADT7462_REG_PWM_TRANGE(attr
->index
),
1308 mutex_unlock(&data
->lock
);
1313 static ssize_t
show_pwm_tmin(struct device
*dev
,
1314 struct device_attribute
*devattr
,
1317 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1318 struct adt7462_data
*data
= adt7462_update_device(dev
);
1319 return sprintf(buf
, "%d\n", 1000 * (data
->pwm_tmin
[attr
->index
] - 64));
1322 static ssize_t
set_pwm_tmin(struct device
*dev
,
1323 struct device_attribute
*devattr
,
1327 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1328 struct i2c_client
*client
= to_i2c_client(dev
);
1329 struct adt7462_data
*data
= i2c_get_clientdata(client
);
1332 if (strict_strtol(buf
, 10, &temp
))
1335 temp
= DIV_ROUND_CLOSEST(temp
, 1000) + 64;
1336 temp
= SENSORS_LIMIT(temp
, 0, 255);
1338 mutex_lock(&data
->lock
);
1339 data
->pwm_tmin
[attr
->index
] = temp
;
1340 i2c_smbus_write_byte_data(client
, ADT7462_REG_PWM_TMIN(attr
->index
),
1342 mutex_unlock(&data
->lock
);
1347 static ssize_t
show_pwm_auto(struct device
*dev
,
1348 struct device_attribute
*devattr
,
1351 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1352 struct adt7462_data
*data
= adt7462_update_device(dev
);
1353 int cfg
= data
->pwm_cfg
[attr
->index
] >> ADT7462_PWM_CHANNEL_SHIFT
;
1357 return sprintf(buf
, "0\n");
1358 case 7: /* manual */
1359 return sprintf(buf
, "1\n");
1360 default: /* automatic */
1361 return sprintf(buf
, "2\n");
1365 static void set_pwm_channel(struct i2c_client
*client
,
1366 struct adt7462_data
*data
,
1370 int temp
= data
->pwm_cfg
[which
] & ~ADT7462_PWM_CHANNEL_MASK
;
1371 temp
|= value
<< ADT7462_PWM_CHANNEL_SHIFT
;
1373 mutex_lock(&data
->lock
);
1374 data
->pwm_cfg
[which
] = temp
;
1375 i2c_smbus_write_byte_data(client
, ADT7462_REG_PWM_CFG(which
), temp
);
1376 mutex_unlock(&data
->lock
);
1379 static ssize_t
set_pwm_auto(struct device
*dev
,
1380 struct device_attribute
*devattr
,
1384 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1385 struct i2c_client
*client
= to_i2c_client(dev
);
1386 struct adt7462_data
*data
= i2c_get_clientdata(client
);
1389 if (strict_strtol(buf
, 10, &temp
))
1394 set_pwm_channel(client
, data
, attr
->index
, 4);
1396 case 1: /* manual */
1397 set_pwm_channel(client
, data
, attr
->index
, 7);
1404 static ssize_t
show_pwm_auto_temp(struct device
*dev
,
1405 struct device_attribute
*devattr
,
1408 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1409 struct adt7462_data
*data
= adt7462_update_device(dev
);
1410 int channel
= data
->pwm_cfg
[attr
->index
] >> ADT7462_PWM_CHANNEL_SHIFT
;
1413 case 0: /* temp[1234] only */
1417 return sprintf(buf
, "%d\n", (1 << channel
));
1418 case 5: /* temp1 & temp4 */
1419 return sprintf(buf
, "9\n");
1421 return sprintf(buf
, "15\n");
1423 return sprintf(buf
, "0\n");
1427 static int cvt_auto_temp(int input
)
1433 if (input
< 1 || !is_power_of_2(input
))
1435 return ilog2(input
);
1438 static ssize_t
set_pwm_auto_temp(struct device
*dev
,
1439 struct device_attribute
*devattr
,
1443 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1444 struct i2c_client
*client
= to_i2c_client(dev
);
1445 struct adt7462_data
*data
= i2c_get_clientdata(client
);
1448 if (strict_strtol(buf
, 10, &temp
))
1451 temp
= cvt_auto_temp(temp
);
1455 set_pwm_channel(client
, data
, attr
->index
, temp
);
1460 static SENSOR_DEVICE_ATTR(temp1_max
, S_IWUSR
| S_IRUGO
, show_temp_max
,
1462 static SENSOR_DEVICE_ATTR(temp2_max
, S_IWUSR
| S_IRUGO
, show_temp_max
,
1464 static SENSOR_DEVICE_ATTR(temp3_max
, S_IWUSR
| S_IRUGO
, show_temp_max
,
1466 static SENSOR_DEVICE_ATTR(temp4_max
, S_IWUSR
| S_IRUGO
, show_temp_max
,
1469 static SENSOR_DEVICE_ATTR(temp1_min
, S_IWUSR
| S_IRUGO
, show_temp_min
,
1471 static SENSOR_DEVICE_ATTR(temp2_min
, S_IWUSR
| S_IRUGO
, show_temp_min
,
1473 static SENSOR_DEVICE_ATTR(temp3_min
, S_IWUSR
| S_IRUGO
, show_temp_min
,
1475 static SENSOR_DEVICE_ATTR(temp4_min
, S_IWUSR
| S_IRUGO
, show_temp_min
,
1478 static SENSOR_DEVICE_ATTR(temp1_input
, S_IRUGO
, show_temp
, NULL
, 0);
1479 static SENSOR_DEVICE_ATTR(temp2_input
, S_IRUGO
, show_temp
, NULL
, 1);
1480 static SENSOR_DEVICE_ATTR(temp3_input
, S_IRUGO
, show_temp
, NULL
, 2);
1481 static SENSOR_DEVICE_ATTR(temp4_input
, S_IRUGO
, show_temp
, NULL
, 3);
1483 static SENSOR_DEVICE_ATTR(temp1_label
, S_IRUGO
, show_temp_label
, NULL
, 0);
1484 static SENSOR_DEVICE_ATTR(temp2_label
, S_IRUGO
, show_temp_label
, NULL
, 1);
1485 static SENSOR_DEVICE_ATTR(temp3_label
, S_IRUGO
, show_temp_label
, NULL
, 2);
1486 static SENSOR_DEVICE_ATTR(temp4_label
, S_IRUGO
, show_temp_label
, NULL
, 3);
1488 static SENSOR_DEVICE_ATTR(temp1_alarm
, S_IRUGO
, show_alarm
, NULL
,
1489 ADT7462_ALARM1
| ADT7462_LT_ALARM
);
1490 static SENSOR_DEVICE_ATTR(temp2_alarm
, S_IRUGO
, show_alarm
, NULL
,
1491 ADT7462_ALARM1
| ADT7462_R1T_ALARM
);
1492 static SENSOR_DEVICE_ATTR(temp3_alarm
, S_IRUGO
, show_alarm
, NULL
,
1493 ADT7462_ALARM1
| ADT7462_R2T_ALARM
);
1494 static SENSOR_DEVICE_ATTR(temp4_alarm
, S_IRUGO
, show_alarm
, NULL
,
1495 ADT7462_ALARM1
| ADT7462_R3T_ALARM
);
1497 static SENSOR_DEVICE_ATTR(in1_max
, S_IWUSR
| S_IRUGO
, show_volt_max
,
1499 static SENSOR_DEVICE_ATTR(in2_max
, S_IWUSR
| S_IRUGO
, show_volt_max
,
1501 static SENSOR_DEVICE_ATTR(in3_max
, S_IWUSR
| S_IRUGO
, show_volt_max
,
1503 static SENSOR_DEVICE_ATTR(in4_max
, S_IWUSR
| S_IRUGO
, show_volt_max
,
1505 static SENSOR_DEVICE_ATTR(in5_max
, S_IWUSR
| S_IRUGO
, show_volt_max
,
1507 static SENSOR_DEVICE_ATTR(in6_max
, S_IWUSR
| S_IRUGO
, show_volt_max
,
1509 static SENSOR_DEVICE_ATTR(in7_max
, S_IWUSR
| S_IRUGO
, show_volt_max
,
1511 static SENSOR_DEVICE_ATTR(in8_max
, S_IWUSR
| S_IRUGO
, show_volt_max
,
1513 static SENSOR_DEVICE_ATTR(in9_max
, S_IWUSR
| S_IRUGO
, show_volt_max
,
1515 static SENSOR_DEVICE_ATTR(in10_max
, S_IWUSR
| S_IRUGO
, show_volt_max
,
1517 static SENSOR_DEVICE_ATTR(in11_max
, S_IWUSR
| S_IRUGO
, show_volt_max
,
1519 static SENSOR_DEVICE_ATTR(in12_max
, S_IWUSR
| S_IRUGO
, show_volt_max
,
1521 static SENSOR_DEVICE_ATTR(in13_max
, S_IWUSR
| S_IRUGO
, show_volt_max
,
1524 static SENSOR_DEVICE_ATTR(in1_min
, S_IWUSR
| S_IRUGO
, show_volt_min
,
1526 static SENSOR_DEVICE_ATTR(in2_min
, S_IWUSR
| S_IRUGO
, show_volt_min
,
1528 static SENSOR_DEVICE_ATTR(in3_min
, S_IWUSR
| S_IRUGO
, show_volt_min
,
1530 static SENSOR_DEVICE_ATTR(in4_min
, S_IWUSR
| S_IRUGO
, show_volt_min
,
1532 static SENSOR_DEVICE_ATTR(in5_min
, S_IWUSR
| S_IRUGO
, show_volt_min
,
1534 static SENSOR_DEVICE_ATTR(in6_min
, S_IWUSR
| S_IRUGO
, show_volt_min
,
1536 static SENSOR_DEVICE_ATTR(in7_min
, S_IWUSR
| S_IRUGO
, show_volt_min
,
1538 static SENSOR_DEVICE_ATTR(in8_min
, S_IWUSR
| S_IRUGO
, show_volt_min
,
1540 static SENSOR_DEVICE_ATTR(in9_min
, S_IWUSR
| S_IRUGO
, show_volt_min
,
1542 static SENSOR_DEVICE_ATTR(in10_min
, S_IWUSR
| S_IRUGO
, show_volt_min
,
1544 static SENSOR_DEVICE_ATTR(in11_min
, S_IWUSR
| S_IRUGO
, show_volt_min
,
1546 static SENSOR_DEVICE_ATTR(in12_min
, S_IWUSR
| S_IRUGO
, show_volt_min
,
1548 static SENSOR_DEVICE_ATTR(in13_min
, S_IWUSR
| S_IRUGO
, show_volt_min
,
1551 static SENSOR_DEVICE_ATTR(in1_input
, S_IRUGO
, show_voltage
, NULL
, 0);
1552 static SENSOR_DEVICE_ATTR(in2_input
, S_IRUGO
, show_voltage
, NULL
, 1);
1553 static SENSOR_DEVICE_ATTR(in3_input
, S_IRUGO
, show_voltage
, NULL
, 2);
1554 static SENSOR_DEVICE_ATTR(in4_input
, S_IRUGO
, show_voltage
, NULL
, 3);
1555 static SENSOR_DEVICE_ATTR(in5_input
, S_IRUGO
, show_voltage
, NULL
, 4);
1556 static SENSOR_DEVICE_ATTR(in6_input
, S_IRUGO
, show_voltage
, NULL
, 5);
1557 static SENSOR_DEVICE_ATTR(in7_input
, S_IRUGO
, show_voltage
, NULL
, 6);
1558 static SENSOR_DEVICE_ATTR(in8_input
, S_IRUGO
, show_voltage
, NULL
, 7);
1559 static SENSOR_DEVICE_ATTR(in9_input
, S_IRUGO
, show_voltage
, NULL
, 8);
1560 static SENSOR_DEVICE_ATTR(in10_input
, S_IRUGO
, show_voltage
, NULL
, 9);
1561 static SENSOR_DEVICE_ATTR(in11_input
, S_IRUGO
, show_voltage
, NULL
, 10);
1562 static SENSOR_DEVICE_ATTR(in12_input
, S_IRUGO
, show_voltage
, NULL
, 11);
1563 static SENSOR_DEVICE_ATTR(in13_input
, S_IRUGO
, show_voltage
, NULL
, 12);
1565 static SENSOR_DEVICE_ATTR(in1_label
, S_IRUGO
, show_voltage_label
, NULL
, 0);
1566 static SENSOR_DEVICE_ATTR(in2_label
, S_IRUGO
, show_voltage_label
, NULL
, 1);
1567 static SENSOR_DEVICE_ATTR(in3_label
, S_IRUGO
, show_voltage_label
, NULL
, 2);
1568 static SENSOR_DEVICE_ATTR(in4_label
, S_IRUGO
, show_voltage_label
, NULL
, 3);
1569 static SENSOR_DEVICE_ATTR(in5_label
, S_IRUGO
, show_voltage_label
, NULL
, 4);
1570 static SENSOR_DEVICE_ATTR(in6_label
, S_IRUGO
, show_voltage_label
, NULL
, 5);
1571 static SENSOR_DEVICE_ATTR(in7_label
, S_IRUGO
, show_voltage_label
, NULL
, 6);
1572 static SENSOR_DEVICE_ATTR(in8_label
, S_IRUGO
, show_voltage_label
, NULL
, 7);
1573 static SENSOR_DEVICE_ATTR(in9_label
, S_IRUGO
, show_voltage_label
, NULL
, 8);
1574 static SENSOR_DEVICE_ATTR(in10_label
, S_IRUGO
, show_voltage_label
, NULL
, 9);
1575 static SENSOR_DEVICE_ATTR(in11_label
, S_IRUGO
, show_voltage_label
, NULL
, 10);
1576 static SENSOR_DEVICE_ATTR(in12_label
, S_IRUGO
, show_voltage_label
, NULL
, 11);
1577 static SENSOR_DEVICE_ATTR(in13_label
, S_IRUGO
, show_voltage_label
, NULL
, 12);
1579 static SENSOR_DEVICE_ATTR(in1_alarm
, S_IRUGO
, show_alarm
, NULL
,
1580 ADT7462_ALARM2
| ADT7462_V0_ALARM
);
1581 static SENSOR_DEVICE_ATTR(in2_alarm
, S_IRUGO
, show_alarm
, NULL
,
1582 ADT7462_ALARM2
| ADT7462_V7_ALARM
);
1583 static SENSOR_DEVICE_ATTR(in3_alarm
, S_IRUGO
, show_alarm
, NULL
,
1584 ADT7462_ALARM2
| ADT7462_V2_ALARM
);
1585 static SENSOR_DEVICE_ATTR(in4_alarm
, S_IRUGO
, show_alarm
, NULL
,
1586 ADT7462_ALARM2
| ADT7462_V6_ALARM
);
1587 static SENSOR_DEVICE_ATTR(in5_alarm
, S_IRUGO
, show_alarm
, NULL
,
1588 ADT7462_ALARM2
| ADT7462_V5_ALARM
);
1589 static SENSOR_DEVICE_ATTR(in6_alarm
, S_IRUGO
, show_alarm
, NULL
,
1590 ADT7462_ALARM2
| ADT7462_V4_ALARM
);
1591 static SENSOR_DEVICE_ATTR(in7_alarm
, S_IRUGO
, show_alarm
, NULL
,
1592 ADT7462_ALARM2
| ADT7462_V3_ALARM
);
1593 static SENSOR_DEVICE_ATTR(in8_alarm
, S_IRUGO
, show_alarm
, NULL
,
1594 ADT7462_ALARM2
| ADT7462_V1_ALARM
);
1595 static SENSOR_DEVICE_ATTR(in9_alarm
, S_IRUGO
, show_alarm
, NULL
,
1596 ADT7462_ALARM3
| ADT7462_V10_ALARM
);
1597 static SENSOR_DEVICE_ATTR(in10_alarm
, S_IRUGO
, show_alarm
, NULL
,
1598 ADT7462_ALARM3
| ADT7462_V9_ALARM
);
1599 static SENSOR_DEVICE_ATTR(in11_alarm
, S_IRUGO
, show_alarm
, NULL
,
1600 ADT7462_ALARM3
| ADT7462_V8_ALARM
);
1601 static SENSOR_DEVICE_ATTR(in12_alarm
, S_IRUGO
, show_alarm
, NULL
,
1602 ADT7462_ALARM3
| ADT7462_V11_ALARM
);
1603 static SENSOR_DEVICE_ATTR(in13_alarm
, S_IRUGO
, show_alarm
, NULL
,
1604 ADT7462_ALARM3
| ADT7462_V12_ALARM
);
1606 static SENSOR_DEVICE_ATTR(fan1_min
, S_IWUSR
| S_IRUGO
, show_fan_min
,
1608 static SENSOR_DEVICE_ATTR(fan2_min
, S_IWUSR
| S_IRUGO
, show_fan_min
,
1610 static SENSOR_DEVICE_ATTR(fan3_min
, S_IWUSR
| S_IRUGO
, show_fan_min
,
1612 static SENSOR_DEVICE_ATTR(fan4_min
, S_IWUSR
| S_IRUGO
, show_fan_min
,
1614 static SENSOR_DEVICE_ATTR(fan5_min
, S_IWUSR
| S_IRUGO
, show_fan_min
,
1616 static SENSOR_DEVICE_ATTR(fan6_min
, S_IWUSR
| S_IRUGO
, show_fan_min
,
1618 static SENSOR_DEVICE_ATTR(fan7_min
, S_IWUSR
| S_IRUGO
, show_fan_min
,
1620 static SENSOR_DEVICE_ATTR(fan8_min
, S_IWUSR
| S_IRUGO
, show_fan_min
,
1623 static SENSOR_DEVICE_ATTR(fan1_input
, S_IRUGO
, show_fan
, NULL
, 0);
1624 static SENSOR_DEVICE_ATTR(fan2_input
, S_IRUGO
, show_fan
, NULL
, 1);
1625 static SENSOR_DEVICE_ATTR(fan3_input
, S_IRUGO
, show_fan
, NULL
, 2);
1626 static SENSOR_DEVICE_ATTR(fan4_input
, S_IRUGO
, show_fan
, NULL
, 3);
1627 static SENSOR_DEVICE_ATTR(fan5_input
, S_IRUGO
, show_fan
, NULL
, 4);
1628 static SENSOR_DEVICE_ATTR(fan6_input
, S_IRUGO
, show_fan
, NULL
, 5);
1629 static SENSOR_DEVICE_ATTR(fan7_input
, S_IRUGO
, show_fan
, NULL
, 6);
1630 static SENSOR_DEVICE_ATTR(fan8_input
, S_IRUGO
, show_fan
, NULL
, 7);
1632 static SENSOR_DEVICE_ATTR(fan1_alarm
, S_IRUGO
, show_alarm
, NULL
,
1633 ADT7462_ALARM4
| ADT7462_F0_ALARM
);
1634 static SENSOR_DEVICE_ATTR(fan2_alarm
, S_IRUGO
, show_alarm
, NULL
,
1635 ADT7462_ALARM4
| ADT7462_F1_ALARM
);
1636 static SENSOR_DEVICE_ATTR(fan3_alarm
, S_IRUGO
, show_alarm
, NULL
,
1637 ADT7462_ALARM4
| ADT7462_F2_ALARM
);
1638 static SENSOR_DEVICE_ATTR(fan4_alarm
, S_IRUGO
, show_alarm
, NULL
,
1639 ADT7462_ALARM4
| ADT7462_F3_ALARM
);
1640 static SENSOR_DEVICE_ATTR(fan5_alarm
, S_IRUGO
, show_alarm
, NULL
,
1641 ADT7462_ALARM4
| ADT7462_F4_ALARM
);
1642 static SENSOR_DEVICE_ATTR(fan6_alarm
, S_IRUGO
, show_alarm
, NULL
,
1643 ADT7462_ALARM4
| ADT7462_F5_ALARM
);
1644 static SENSOR_DEVICE_ATTR(fan7_alarm
, S_IRUGO
, show_alarm
, NULL
,
1645 ADT7462_ALARM4
| ADT7462_F6_ALARM
);
1646 static SENSOR_DEVICE_ATTR(fan8_alarm
, S_IRUGO
, show_alarm
, NULL
,
1647 ADT7462_ALARM4
| ADT7462_F7_ALARM
);
1649 static SENSOR_DEVICE_ATTR(force_pwm_max
, S_IWUSR
| S_IRUGO
,
1650 show_force_pwm_max
, set_force_pwm_max
, 0);
1652 static SENSOR_DEVICE_ATTR(pwm1
, S_IWUSR
| S_IRUGO
, show_pwm
, set_pwm
, 0);
1653 static SENSOR_DEVICE_ATTR(pwm2
, S_IWUSR
| S_IRUGO
, show_pwm
, set_pwm
, 1);
1654 static SENSOR_DEVICE_ATTR(pwm3
, S_IWUSR
| S_IRUGO
, show_pwm
, set_pwm
, 2);
1655 static SENSOR_DEVICE_ATTR(pwm4
, S_IWUSR
| S_IRUGO
, show_pwm
, set_pwm
, 3);
1657 static SENSOR_DEVICE_ATTR(pwm1_auto_point1_pwm
, S_IWUSR
| S_IRUGO
,
1658 show_pwm_min
, set_pwm_min
, 0);
1659 static SENSOR_DEVICE_ATTR(pwm2_auto_point1_pwm
, S_IWUSR
| S_IRUGO
,
1660 show_pwm_min
, set_pwm_min
, 1);
1661 static SENSOR_DEVICE_ATTR(pwm3_auto_point1_pwm
, S_IWUSR
| S_IRUGO
,
1662 show_pwm_min
, set_pwm_min
, 2);
1663 static SENSOR_DEVICE_ATTR(pwm4_auto_point1_pwm
, S_IWUSR
| S_IRUGO
,
1664 show_pwm_min
, set_pwm_min
, 3);
1666 static SENSOR_DEVICE_ATTR(pwm1_auto_point2_pwm
, S_IWUSR
| S_IRUGO
,
1667 show_pwm_max
, set_pwm_max
, 0);
1668 static SENSOR_DEVICE_ATTR(pwm2_auto_point2_pwm
, S_IWUSR
| S_IRUGO
,
1669 show_pwm_max
, set_pwm_max
, 1);
1670 static SENSOR_DEVICE_ATTR(pwm3_auto_point2_pwm
, S_IWUSR
| S_IRUGO
,
1671 show_pwm_max
, set_pwm_max
, 2);
1672 static SENSOR_DEVICE_ATTR(pwm4_auto_point2_pwm
, S_IWUSR
| S_IRUGO
,
1673 show_pwm_max
, set_pwm_max
, 3);
1675 static SENSOR_DEVICE_ATTR(temp1_auto_point1_hyst
, S_IWUSR
| S_IRUGO
,
1676 show_pwm_hyst
, set_pwm_hyst
, 0);
1677 static SENSOR_DEVICE_ATTR(temp2_auto_point1_hyst
, S_IWUSR
| S_IRUGO
,
1678 show_pwm_hyst
, set_pwm_hyst
, 1);
1679 static SENSOR_DEVICE_ATTR(temp3_auto_point1_hyst
, S_IWUSR
| S_IRUGO
,
1680 show_pwm_hyst
, set_pwm_hyst
, 2);
1681 static SENSOR_DEVICE_ATTR(temp4_auto_point1_hyst
, S_IWUSR
| S_IRUGO
,
1682 show_pwm_hyst
, set_pwm_hyst
, 3);
1684 static SENSOR_DEVICE_ATTR(temp1_auto_point2_hyst
, S_IWUSR
| S_IRUGO
,
1685 show_pwm_hyst
, set_pwm_hyst
, 0);
1686 static SENSOR_DEVICE_ATTR(temp2_auto_point2_hyst
, S_IWUSR
| S_IRUGO
,
1687 show_pwm_hyst
, set_pwm_hyst
, 1);
1688 static SENSOR_DEVICE_ATTR(temp3_auto_point2_hyst
, S_IWUSR
| S_IRUGO
,
1689 show_pwm_hyst
, set_pwm_hyst
, 2);
1690 static SENSOR_DEVICE_ATTR(temp4_auto_point2_hyst
, S_IWUSR
| S_IRUGO
,
1691 show_pwm_hyst
, set_pwm_hyst
, 3);
1693 static SENSOR_DEVICE_ATTR(temp1_auto_point1_temp
, S_IWUSR
| S_IRUGO
,
1694 show_pwm_tmin
, set_pwm_tmin
, 0);
1695 static SENSOR_DEVICE_ATTR(temp2_auto_point1_temp
, S_IWUSR
| S_IRUGO
,
1696 show_pwm_tmin
, set_pwm_tmin
, 1);
1697 static SENSOR_DEVICE_ATTR(temp3_auto_point1_temp
, S_IWUSR
| S_IRUGO
,
1698 show_pwm_tmin
, set_pwm_tmin
, 2);
1699 static SENSOR_DEVICE_ATTR(temp4_auto_point1_temp
, S_IWUSR
| S_IRUGO
,
1700 show_pwm_tmin
, set_pwm_tmin
, 3);
1702 static SENSOR_DEVICE_ATTR(temp1_auto_point2_temp
, S_IWUSR
| S_IRUGO
,
1703 show_pwm_tmax
, set_pwm_tmax
, 0);
1704 static SENSOR_DEVICE_ATTR(temp2_auto_point2_temp
, S_IWUSR
| S_IRUGO
,
1705 show_pwm_tmax
, set_pwm_tmax
, 1);
1706 static SENSOR_DEVICE_ATTR(temp3_auto_point2_temp
, S_IWUSR
| S_IRUGO
,
1707 show_pwm_tmax
, set_pwm_tmax
, 2);
1708 static SENSOR_DEVICE_ATTR(temp4_auto_point2_temp
, S_IWUSR
| S_IRUGO
,
1709 show_pwm_tmax
, set_pwm_tmax
, 3);
1711 static SENSOR_DEVICE_ATTR(pwm1_enable
, S_IWUSR
| S_IRUGO
, show_pwm_auto
,
1713 static SENSOR_DEVICE_ATTR(pwm2_enable
, S_IWUSR
| S_IRUGO
, show_pwm_auto
,
1715 static SENSOR_DEVICE_ATTR(pwm3_enable
, S_IWUSR
| S_IRUGO
, show_pwm_auto
,
1717 static SENSOR_DEVICE_ATTR(pwm4_enable
, S_IWUSR
| S_IRUGO
, show_pwm_auto
,
1720 static SENSOR_DEVICE_ATTR(pwm1_auto_channels_temp
, S_IWUSR
| S_IRUGO
,
1721 show_pwm_auto_temp
, set_pwm_auto_temp
, 0);
1722 static SENSOR_DEVICE_ATTR(pwm2_auto_channels_temp
, S_IWUSR
| S_IRUGO
,
1723 show_pwm_auto_temp
, set_pwm_auto_temp
, 1);
1724 static SENSOR_DEVICE_ATTR(pwm3_auto_channels_temp
, S_IWUSR
| S_IRUGO
,
1725 show_pwm_auto_temp
, set_pwm_auto_temp
, 2);
1726 static SENSOR_DEVICE_ATTR(pwm4_auto_channels_temp
, S_IWUSR
| S_IRUGO
,
1727 show_pwm_auto_temp
, set_pwm_auto_temp
, 3);
1729 static struct attribute
*adt7462_attr
[] =
1731 &sensor_dev_attr_temp1_max
.dev_attr
.attr
,
1732 &sensor_dev_attr_temp2_max
.dev_attr
.attr
,
1733 &sensor_dev_attr_temp3_max
.dev_attr
.attr
,
1734 &sensor_dev_attr_temp4_max
.dev_attr
.attr
,
1736 &sensor_dev_attr_temp1_min
.dev_attr
.attr
,
1737 &sensor_dev_attr_temp2_min
.dev_attr
.attr
,
1738 &sensor_dev_attr_temp3_min
.dev_attr
.attr
,
1739 &sensor_dev_attr_temp4_min
.dev_attr
.attr
,
1741 &sensor_dev_attr_temp1_input
.dev_attr
.attr
,
1742 &sensor_dev_attr_temp2_input
.dev_attr
.attr
,
1743 &sensor_dev_attr_temp3_input
.dev_attr
.attr
,
1744 &sensor_dev_attr_temp4_input
.dev_attr
.attr
,
1746 &sensor_dev_attr_temp1_label
.dev_attr
.attr
,
1747 &sensor_dev_attr_temp2_label
.dev_attr
.attr
,
1748 &sensor_dev_attr_temp3_label
.dev_attr
.attr
,
1749 &sensor_dev_attr_temp4_label
.dev_attr
.attr
,
1751 &sensor_dev_attr_temp1_alarm
.dev_attr
.attr
,
1752 &sensor_dev_attr_temp2_alarm
.dev_attr
.attr
,
1753 &sensor_dev_attr_temp3_alarm
.dev_attr
.attr
,
1754 &sensor_dev_attr_temp4_alarm
.dev_attr
.attr
,
1756 &sensor_dev_attr_in1_max
.dev_attr
.attr
,
1757 &sensor_dev_attr_in2_max
.dev_attr
.attr
,
1758 &sensor_dev_attr_in3_max
.dev_attr
.attr
,
1759 &sensor_dev_attr_in4_max
.dev_attr
.attr
,
1760 &sensor_dev_attr_in5_max
.dev_attr
.attr
,
1761 &sensor_dev_attr_in6_max
.dev_attr
.attr
,
1762 &sensor_dev_attr_in7_max
.dev_attr
.attr
,
1763 &sensor_dev_attr_in8_max
.dev_attr
.attr
,
1764 &sensor_dev_attr_in9_max
.dev_attr
.attr
,
1765 &sensor_dev_attr_in10_max
.dev_attr
.attr
,
1766 &sensor_dev_attr_in11_max
.dev_attr
.attr
,
1767 &sensor_dev_attr_in12_max
.dev_attr
.attr
,
1768 &sensor_dev_attr_in13_max
.dev_attr
.attr
,
1770 &sensor_dev_attr_in1_min
.dev_attr
.attr
,
1771 &sensor_dev_attr_in2_min
.dev_attr
.attr
,
1772 &sensor_dev_attr_in3_min
.dev_attr
.attr
,
1773 &sensor_dev_attr_in4_min
.dev_attr
.attr
,
1774 &sensor_dev_attr_in5_min
.dev_attr
.attr
,
1775 &sensor_dev_attr_in6_min
.dev_attr
.attr
,
1776 &sensor_dev_attr_in7_min
.dev_attr
.attr
,
1777 &sensor_dev_attr_in8_min
.dev_attr
.attr
,
1778 &sensor_dev_attr_in9_min
.dev_attr
.attr
,
1779 &sensor_dev_attr_in10_min
.dev_attr
.attr
,
1780 &sensor_dev_attr_in11_min
.dev_attr
.attr
,
1781 &sensor_dev_attr_in12_min
.dev_attr
.attr
,
1782 &sensor_dev_attr_in13_min
.dev_attr
.attr
,
1784 &sensor_dev_attr_in1_input
.dev_attr
.attr
,
1785 &sensor_dev_attr_in2_input
.dev_attr
.attr
,
1786 &sensor_dev_attr_in3_input
.dev_attr
.attr
,
1787 &sensor_dev_attr_in4_input
.dev_attr
.attr
,
1788 &sensor_dev_attr_in5_input
.dev_attr
.attr
,
1789 &sensor_dev_attr_in6_input
.dev_attr
.attr
,
1790 &sensor_dev_attr_in7_input
.dev_attr
.attr
,
1791 &sensor_dev_attr_in8_input
.dev_attr
.attr
,
1792 &sensor_dev_attr_in9_input
.dev_attr
.attr
,
1793 &sensor_dev_attr_in10_input
.dev_attr
.attr
,
1794 &sensor_dev_attr_in11_input
.dev_attr
.attr
,
1795 &sensor_dev_attr_in12_input
.dev_attr
.attr
,
1796 &sensor_dev_attr_in13_input
.dev_attr
.attr
,
1798 &sensor_dev_attr_in1_label
.dev_attr
.attr
,
1799 &sensor_dev_attr_in2_label
.dev_attr
.attr
,
1800 &sensor_dev_attr_in3_label
.dev_attr
.attr
,
1801 &sensor_dev_attr_in4_label
.dev_attr
.attr
,
1802 &sensor_dev_attr_in5_label
.dev_attr
.attr
,
1803 &sensor_dev_attr_in6_label
.dev_attr
.attr
,
1804 &sensor_dev_attr_in7_label
.dev_attr
.attr
,
1805 &sensor_dev_attr_in8_label
.dev_attr
.attr
,
1806 &sensor_dev_attr_in9_label
.dev_attr
.attr
,
1807 &sensor_dev_attr_in10_label
.dev_attr
.attr
,
1808 &sensor_dev_attr_in11_label
.dev_attr
.attr
,
1809 &sensor_dev_attr_in12_label
.dev_attr
.attr
,
1810 &sensor_dev_attr_in13_label
.dev_attr
.attr
,
1812 &sensor_dev_attr_in1_alarm
.dev_attr
.attr
,
1813 &sensor_dev_attr_in2_alarm
.dev_attr
.attr
,
1814 &sensor_dev_attr_in3_alarm
.dev_attr
.attr
,
1815 &sensor_dev_attr_in4_alarm
.dev_attr
.attr
,
1816 &sensor_dev_attr_in5_alarm
.dev_attr
.attr
,
1817 &sensor_dev_attr_in6_alarm
.dev_attr
.attr
,
1818 &sensor_dev_attr_in7_alarm
.dev_attr
.attr
,
1819 &sensor_dev_attr_in8_alarm
.dev_attr
.attr
,
1820 &sensor_dev_attr_in9_alarm
.dev_attr
.attr
,
1821 &sensor_dev_attr_in10_alarm
.dev_attr
.attr
,
1822 &sensor_dev_attr_in11_alarm
.dev_attr
.attr
,
1823 &sensor_dev_attr_in12_alarm
.dev_attr
.attr
,
1824 &sensor_dev_attr_in13_alarm
.dev_attr
.attr
,
1826 &sensor_dev_attr_fan1_min
.dev_attr
.attr
,
1827 &sensor_dev_attr_fan2_min
.dev_attr
.attr
,
1828 &sensor_dev_attr_fan3_min
.dev_attr
.attr
,
1829 &sensor_dev_attr_fan4_min
.dev_attr
.attr
,
1830 &sensor_dev_attr_fan5_min
.dev_attr
.attr
,
1831 &sensor_dev_attr_fan6_min
.dev_attr
.attr
,
1832 &sensor_dev_attr_fan7_min
.dev_attr
.attr
,
1833 &sensor_dev_attr_fan8_min
.dev_attr
.attr
,
1835 &sensor_dev_attr_fan1_input
.dev_attr
.attr
,
1836 &sensor_dev_attr_fan2_input
.dev_attr
.attr
,
1837 &sensor_dev_attr_fan3_input
.dev_attr
.attr
,
1838 &sensor_dev_attr_fan4_input
.dev_attr
.attr
,
1839 &sensor_dev_attr_fan5_input
.dev_attr
.attr
,
1840 &sensor_dev_attr_fan6_input
.dev_attr
.attr
,
1841 &sensor_dev_attr_fan7_input
.dev_attr
.attr
,
1842 &sensor_dev_attr_fan8_input
.dev_attr
.attr
,
1844 &sensor_dev_attr_fan1_alarm
.dev_attr
.attr
,
1845 &sensor_dev_attr_fan2_alarm
.dev_attr
.attr
,
1846 &sensor_dev_attr_fan3_alarm
.dev_attr
.attr
,
1847 &sensor_dev_attr_fan4_alarm
.dev_attr
.attr
,
1848 &sensor_dev_attr_fan5_alarm
.dev_attr
.attr
,
1849 &sensor_dev_attr_fan6_alarm
.dev_attr
.attr
,
1850 &sensor_dev_attr_fan7_alarm
.dev_attr
.attr
,
1851 &sensor_dev_attr_fan8_alarm
.dev_attr
.attr
,
1853 &sensor_dev_attr_force_pwm_max
.dev_attr
.attr
,
1854 &sensor_dev_attr_pwm1
.dev_attr
.attr
,
1855 &sensor_dev_attr_pwm2
.dev_attr
.attr
,
1856 &sensor_dev_attr_pwm3
.dev_attr
.attr
,
1857 &sensor_dev_attr_pwm4
.dev_attr
.attr
,
1859 &sensor_dev_attr_pwm1_auto_point1_pwm
.dev_attr
.attr
,
1860 &sensor_dev_attr_pwm2_auto_point1_pwm
.dev_attr
.attr
,
1861 &sensor_dev_attr_pwm3_auto_point1_pwm
.dev_attr
.attr
,
1862 &sensor_dev_attr_pwm4_auto_point1_pwm
.dev_attr
.attr
,
1864 &sensor_dev_attr_pwm1_auto_point2_pwm
.dev_attr
.attr
,
1865 &sensor_dev_attr_pwm2_auto_point2_pwm
.dev_attr
.attr
,
1866 &sensor_dev_attr_pwm3_auto_point2_pwm
.dev_attr
.attr
,
1867 &sensor_dev_attr_pwm4_auto_point2_pwm
.dev_attr
.attr
,
1869 &sensor_dev_attr_temp1_auto_point1_hyst
.dev_attr
.attr
,
1870 &sensor_dev_attr_temp2_auto_point1_hyst
.dev_attr
.attr
,
1871 &sensor_dev_attr_temp3_auto_point1_hyst
.dev_attr
.attr
,
1872 &sensor_dev_attr_temp4_auto_point1_hyst
.dev_attr
.attr
,
1874 &sensor_dev_attr_temp1_auto_point2_hyst
.dev_attr
.attr
,
1875 &sensor_dev_attr_temp2_auto_point2_hyst
.dev_attr
.attr
,
1876 &sensor_dev_attr_temp3_auto_point2_hyst
.dev_attr
.attr
,
1877 &sensor_dev_attr_temp4_auto_point2_hyst
.dev_attr
.attr
,
1879 &sensor_dev_attr_temp1_auto_point1_temp
.dev_attr
.attr
,
1880 &sensor_dev_attr_temp2_auto_point1_temp
.dev_attr
.attr
,
1881 &sensor_dev_attr_temp3_auto_point1_temp
.dev_attr
.attr
,
1882 &sensor_dev_attr_temp4_auto_point1_temp
.dev_attr
.attr
,
1884 &sensor_dev_attr_temp1_auto_point2_temp
.dev_attr
.attr
,
1885 &sensor_dev_attr_temp2_auto_point2_temp
.dev_attr
.attr
,
1886 &sensor_dev_attr_temp3_auto_point2_temp
.dev_attr
.attr
,
1887 &sensor_dev_attr_temp4_auto_point2_temp
.dev_attr
.attr
,
1889 &sensor_dev_attr_pwm1_enable
.dev_attr
.attr
,
1890 &sensor_dev_attr_pwm2_enable
.dev_attr
.attr
,
1891 &sensor_dev_attr_pwm3_enable
.dev_attr
.attr
,
1892 &sensor_dev_attr_pwm4_enable
.dev_attr
.attr
,
1894 &sensor_dev_attr_pwm1_auto_channels_temp
.dev_attr
.attr
,
1895 &sensor_dev_attr_pwm2_auto_channels_temp
.dev_attr
.attr
,
1896 &sensor_dev_attr_pwm3_auto_channels_temp
.dev_attr
.attr
,
1897 &sensor_dev_attr_pwm4_auto_channels_temp
.dev_attr
.attr
,
1901 /* Return 0 if detection is successful, -ENODEV otherwise */
1902 static int adt7462_detect(struct i2c_client
*client
,
1903 struct i2c_board_info
*info
)
1905 struct i2c_adapter
*adapter
= client
->adapter
;
1906 int vendor
, device
, revision
;
1908 if (!i2c_check_functionality(adapter
, I2C_FUNC_SMBUS_BYTE_DATA
))
1911 vendor
= i2c_smbus_read_byte_data(client
, ADT7462_REG_VENDOR
);
1912 if (vendor
!= ADT7462_VENDOR
)
1915 device
= i2c_smbus_read_byte_data(client
, ADT7462_REG_DEVICE
);
1916 if (device
!= ADT7462_DEVICE
)
1919 revision
= i2c_smbus_read_byte_data(client
, ADT7462_REG_REVISION
);
1920 if (revision
!= ADT7462_REVISION
)
1923 strlcpy(info
->type
, "adt7462", I2C_NAME_SIZE
);
1928 static int adt7462_probe(struct i2c_client
*client
,
1929 const struct i2c_device_id
*id
)
1931 struct adt7462_data
*data
;
1934 data
= kzalloc(sizeof(struct adt7462_data
), GFP_KERNEL
);
1940 i2c_set_clientdata(client
, data
);
1941 mutex_init(&data
->lock
);
1943 dev_info(&client
->dev
, "%s chip found\n", client
->name
);
1945 /* Register sysfs hooks */
1946 data
->attrs
.attrs
= adt7462_attr
;
1947 err
= sysfs_create_group(&client
->dev
.kobj
, &data
->attrs
);
1951 data
->hwmon_dev
= hwmon_device_register(&client
->dev
);
1952 if (IS_ERR(data
->hwmon_dev
)) {
1953 err
= PTR_ERR(data
->hwmon_dev
);
1960 sysfs_remove_group(&client
->dev
.kobj
, &data
->attrs
);
1967 static int adt7462_remove(struct i2c_client
*client
)
1969 struct adt7462_data
*data
= i2c_get_clientdata(client
);
1971 hwmon_device_unregister(data
->hwmon_dev
);
1972 sysfs_remove_group(&client
->dev
.kobj
, &data
->attrs
);
1977 static int __init
adt7462_init(void)
1979 return i2c_add_driver(&adt7462_driver
);
1982 static void __exit
adt7462_exit(void)
1984 i2c_del_driver(&adt7462_driver
);
1987 MODULE_AUTHOR("Darrick J. Wong <djwong@us.ibm.com>");
1988 MODULE_DESCRIPTION("ADT7462 driver");
1989 MODULE_LICENSE("GPL");
1991 module_init(adt7462_init
);
1992 module_exit(adt7462_exit
);