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 /* Insmod parameters */
36 I2C_CLIENT_INSMOD_1(adt7462
);
38 /* ADT7462 registers */
39 #define ADT7462_REG_DEVICE 0x3D
40 #define ADT7462_REG_VENDOR 0x3E
41 #define ADT7462_REG_REVISION 0x3F
43 #define ADT7462_REG_MIN_TEMP_BASE_ADDR 0x44
44 #define ADT7462_REG_MIN_TEMP_MAX_ADDR 0x47
45 #define ADT7462_REG_MAX_TEMP_BASE_ADDR 0x48
46 #define ADT7462_REG_MAX_TEMP_MAX_ADDR 0x4B
47 #define ADT7462_REG_TEMP_BASE_ADDR 0x88
48 #define ADT7462_REG_TEMP_MAX_ADDR 0x8F
50 #define ADT7462_REG_FAN_BASE_ADDR 0x98
51 #define ADT7462_REG_FAN_MAX_ADDR 0x9F
52 #define ADT7462_REG_FAN2_BASE_ADDR 0xA2
53 #define ADT7462_REG_FAN2_MAX_ADDR 0xA9
54 #define ADT7462_REG_FAN_ENABLE 0x07
55 #define ADT7462_REG_FAN_MIN_BASE_ADDR 0x78
56 #define ADT7462_REG_FAN_MIN_MAX_ADDR 0x7F
58 #define ADT7462_REG_CFG2 0x02
59 #define ADT7462_FSPD_MASK 0x20
61 #define ADT7462_REG_PWM_BASE_ADDR 0xAA
62 #define ADT7462_REG_PWM_MAX_ADDR 0xAD
63 #define ADT7462_REG_PWM_MIN_BASE_ADDR 0x28
64 #define ADT7462_REG_PWM_MIN_MAX_ADDR 0x2B
65 #define ADT7462_REG_PWM_MAX 0x2C
66 #define ADT7462_REG_PWM_TEMP_MIN_BASE_ADDR 0x5C
67 #define ADT7462_REG_PWM_TEMP_MIN_MAX_ADDR 0x5F
68 #define ADT7462_REG_PWM_TEMP_RANGE_BASE_ADDR 0x60
69 #define ADT7462_REG_PWM_TEMP_RANGE_MAX_ADDR 0x63
70 #define ADT7462_PWM_HYST_MASK 0x0F
71 #define ADT7462_PWM_RANGE_MASK 0xF0
72 #define ADT7462_PWM_RANGE_SHIFT 4
73 #define ADT7462_REG_PWM_CFG_BASE_ADDR 0x21
74 #define ADT7462_REG_PWM_CFG_MAX_ADDR 0x24
75 #define ADT7462_PWM_CHANNEL_MASK 0xE0
76 #define ADT7462_PWM_CHANNEL_SHIFT 5
78 #define ADT7462_REG_PIN_CFG_BASE_ADDR 0x10
79 #define ADT7462_REG_PIN_CFG_MAX_ADDR 0x13
80 #define ADT7462_PIN7_INPUT 0x01 /* cfg0 */
81 #define ADT7462_DIODE3_INPUT 0x20
82 #define ADT7462_DIODE1_INPUT 0x40
83 #define ADT7462_VID_INPUT 0x80
84 #define ADT7462_PIN22_INPUT 0x04 /* cfg1 */
85 #define ADT7462_PIN21_INPUT 0x08
86 #define ADT7462_PIN19_INPUT 0x10
87 #define ADT7462_PIN15_INPUT 0x20
88 #define ADT7462_PIN13_INPUT 0x40
89 #define ADT7462_PIN8_INPUT 0x80
90 #define ADT7462_PIN23_MASK 0x03
91 #define ADT7462_PIN23_SHIFT 0
92 #define ADT7462_PIN26_MASK 0x0C /* cfg2 */
93 #define ADT7462_PIN26_SHIFT 2
94 #define ADT7462_PIN25_MASK 0x30
95 #define ADT7462_PIN25_SHIFT 4
96 #define ADT7462_PIN24_MASK 0xC0
97 #define ADT7462_PIN24_SHIFT 6
98 #define ADT7462_PIN26_VOLT_INPUT 0x08
99 #define ADT7462_PIN25_VOLT_INPUT 0x20
100 #define ADT7462_PIN28_SHIFT 6 /* cfg3 */
101 #define ADT7462_PIN28_VOLT 0x5
103 #define ADT7462_REG_ALARM1 0xB8
104 #define ADT7462_LT_ALARM 0x02
105 #define ADT7462_R1T_ALARM 0x04
106 #define ADT7462_R2T_ALARM 0x08
107 #define ADT7462_R3T_ALARM 0x10
108 #define ADT7462_REG_ALARM2 0xBB
109 #define ADT7462_V0_ALARM 0x01
110 #define ADT7462_V1_ALARM 0x02
111 #define ADT7462_V2_ALARM 0x04
112 #define ADT7462_V3_ALARM 0x08
113 #define ADT7462_V4_ALARM 0x10
114 #define ADT7462_V5_ALARM 0x20
115 #define ADT7462_V6_ALARM 0x40
116 #define ADT7462_V7_ALARM 0x80
117 #define ADT7462_REG_ALARM3 0xBC
118 #define ADT7462_V8_ALARM 0x08
119 #define ADT7462_V9_ALARM 0x10
120 #define ADT7462_V10_ALARM 0x20
121 #define ADT7462_V11_ALARM 0x40
122 #define ADT7462_V12_ALARM 0x80
123 #define ADT7462_REG_ALARM4 0xBD
124 #define ADT7462_F0_ALARM 0x01
125 #define ADT7462_F1_ALARM 0x02
126 #define ADT7462_F2_ALARM 0x04
127 #define ADT7462_F3_ALARM 0x08
128 #define ADT7462_F4_ALARM 0x10
129 #define ADT7462_F5_ALARM 0x20
130 #define ADT7462_F6_ALARM 0x40
131 #define ADT7462_F7_ALARM 0x80
132 #define ADT7462_ALARM1 0x0000
133 #define ADT7462_ALARM2 0x0100
134 #define ADT7462_ALARM3 0x0200
135 #define ADT7462_ALARM4 0x0300
136 #define ADT7462_ALARM_REG_SHIFT 8
137 #define ADT7462_ALARM_FLAG_MASK 0x0F
139 #define ADT7462_TEMP_COUNT 4
140 #define ADT7462_TEMP_REG(x) (ADT7462_REG_TEMP_BASE_ADDR + (x * 2))
141 #define ADT7462_TEMP_MIN_REG(x) (ADT7462_REG_MIN_TEMP_BASE_ADDR + (x))
142 #define ADT7462_TEMP_MAX_REG(x) (ADT7462_REG_MAX_TEMP_BASE_ADDR + (x))
143 #define TEMP_FRAC_OFFSET 6
145 #define ADT7462_FAN_COUNT 8
146 #define ADT7462_REG_FAN_MIN(x) (ADT7462_REG_FAN_MIN_BASE_ADDR + (x))
148 #define ADT7462_PWM_COUNT 4
149 #define ADT7462_REG_PWM(x) (ADT7462_REG_PWM_BASE_ADDR + (x))
150 #define ADT7462_REG_PWM_MIN(x) (ADT7462_REG_PWM_MIN_BASE_ADDR + (x))
151 #define ADT7462_REG_PWM_TMIN(x) \
152 (ADT7462_REG_PWM_TEMP_MIN_BASE_ADDR + (x))
153 #define ADT7462_REG_PWM_TRANGE(x) \
154 (ADT7462_REG_PWM_TEMP_RANGE_BASE_ADDR + (x))
156 #define ADT7462_PIN_CFG_REG_COUNT 4
157 #define ADT7462_REG_PIN_CFG(x) (ADT7462_REG_PIN_CFG_BASE_ADDR + (x))
158 #define ADT7462_REG_PWM_CFG(x) (ADT7462_REG_PWM_CFG_BASE_ADDR + (x))
160 #define ADT7462_ALARM_REG_COUNT 4
163 * The chip can measure 13 different voltage sources:
166 * 2. Vccp1/+2.5V/+1.8V/+1.5V (pin 23)
169 * 5. +1.25V/+0.9V (pin 19)
170 * 6. +2.5V/+1.8V (pin 15)
173 * 9. Vbatt/FSB_Vtt (pin 26)
174 * A. +3.3V/+1.2V1 (pin 25)
175 * B. Vccp2/+2.5V/+1.8V/+1.5V (pin 24)
176 * C. +1.5V ICH (only if BOTH pin 28/29 are set to +1.5V)
177 * D. +1.5V 3GPIO (only if BOTH pin 28/29 are set to +1.5V)
179 * Each of these 13 has a factor to convert raw to voltage. Even better,
180 * the pins can be connected to other sensors (tach/gpio/hot/etc), which
181 * makes the bookkeeping tricky.
183 * Some, but not all, of these voltages have low/high limits.
185 #define ADT7462_VOLT_COUNT 12
187 #define ADT7462_VENDOR 0x41
188 #define ADT7462_DEVICE 0x62
189 /* datasheet only mentions a revision 4 */
190 #define ADT7462_REVISION 0x04
192 /* How often do we reread sensors values? (In jiffies) */
193 #define SENSOR_REFRESH_INTERVAL (2 * HZ)
195 /* How often do we reread sensor limit values? (In jiffies) */
196 #define LIMIT_REFRESH_INTERVAL (60 * HZ)
198 /* datasheet says to divide this number by the fan reading to get fan rpm */
199 #define FAN_PERIOD_TO_RPM(x) ((90000 * 60) / (x))
200 #define FAN_RPM_TO_PERIOD FAN_PERIOD_TO_RPM
201 #define FAN_PERIOD_INVALID 65535
202 #define FAN_DATA_VALID(x) ((x) && (x) != FAN_PERIOD_INVALID)
204 #define MASK_AND_SHIFT(value, prefix) \
205 (((value) & prefix##_MASK) >> prefix##_SHIFT)
207 #define ROUND_DIV(x, divisor) (((x) + ((divisor) / 2)) / (divisor))
209 struct adt7462_data
{
210 struct device
*hwmon_dev
;
211 struct attribute_group attrs
;
215 unsigned long sensors_last_updated
; /* In jiffies */
216 unsigned long limits_last_updated
; /* In jiffies */
218 u8 temp
[ADT7462_TEMP_COUNT
];
219 /* bits 6-7 are quarter pieces of temp */
220 u8 temp_frac
[ADT7462_TEMP_COUNT
];
221 u8 temp_min
[ADT7462_TEMP_COUNT
];
222 u8 temp_max
[ADT7462_TEMP_COUNT
];
223 u16 fan
[ADT7462_FAN_COUNT
];
225 u8 fan_min
[ADT7462_FAN_COUNT
];
227 u8 pwm
[ADT7462_PWM_COUNT
];
228 u8 pin_cfg
[ADT7462_PIN_CFG_REG_COUNT
];
229 u8 voltages
[ADT7462_VOLT_COUNT
];
230 u8 volt_max
[ADT7462_VOLT_COUNT
];
231 u8 volt_min
[ADT7462_VOLT_COUNT
];
232 u8 pwm_min
[ADT7462_PWM_COUNT
];
233 u8 pwm_tmin
[ADT7462_PWM_COUNT
];
234 u8 pwm_trange
[ADT7462_PWM_COUNT
];
235 u8 pwm_max
; /* only one per chip */
236 u8 pwm_cfg
[ADT7462_PWM_COUNT
];
237 u8 alarms
[ADT7462_ALARM_REG_COUNT
];
240 static int adt7462_probe(struct i2c_client
*client
,
241 const struct i2c_device_id
*id
);
242 static int adt7462_detect(struct i2c_client
*client
, int kind
,
243 struct i2c_board_info
*info
);
244 static int adt7462_remove(struct i2c_client
*client
);
246 static const struct i2c_device_id adt7462_id
[] = {
247 { "adt7462", adt7462
},
250 MODULE_DEVICE_TABLE(i2c
, adt7462_id
);
252 static struct i2c_driver adt7462_driver
= {
253 .class = I2C_CLASS_HWMON
,
257 .probe
= adt7462_probe
,
258 .remove
= adt7462_remove
,
259 .id_table
= adt7462_id
,
260 .detect
= adt7462_detect
,
261 .address_data
= &addr_data
,
265 * 16-bit registers on the ADT7462 are low-byte first. The data sheet says
266 * that the low byte must be read before the high byte.
268 static inline int adt7462_read_word_data(struct i2c_client
*client
, u8 reg
)
271 foo
= i2c_smbus_read_byte_data(client
, reg
);
272 foo
|= ((u16
)i2c_smbus_read_byte_data(client
, reg
+ 1) << 8);
276 /* For some reason these registers are not contiguous. */
277 static int ADT7462_REG_FAN(int fan
)
280 return ADT7462_REG_FAN_BASE_ADDR
+ (2 * fan
);
281 return ADT7462_REG_FAN2_BASE_ADDR
+ (2 * (fan
- 4));
284 /* Voltage registers are scattered everywhere */
285 static int ADT7462_REG_VOLT_MAX(struct adt7462_data
*data
, int which
)
289 if (!(data
->pin_cfg
[0] & ADT7462_PIN7_INPUT
))
295 if (!(data
->pin_cfg
[1] & ADT7462_PIN22_INPUT
))
299 if (!(data
->pin_cfg
[1] & ADT7462_PIN21_INPUT
))
303 if (!(data
->pin_cfg
[0] & ADT7462_DIODE3_INPUT
))
307 if (!(data
->pin_cfg
[0] & ADT7462_DIODE1_INPUT
))
311 if (!(data
->pin_cfg
[1] & ADT7462_PIN13_INPUT
))
315 if (!(data
->pin_cfg
[1] & ADT7462_PIN8_INPUT
))
319 if (!(data
->pin_cfg
[2] & ADT7462_PIN26_VOLT_INPUT
))
323 if (!(data
->pin_cfg
[2] & ADT7462_PIN25_VOLT_INPUT
))
329 if (data
->pin_cfg
[3] >> ADT7462_PIN28_SHIFT
==
330 ADT7462_PIN28_VOLT
&&
331 !(data
->pin_cfg
[0] & ADT7462_VID_INPUT
))
335 if (data
->pin_cfg
[3] >> ADT7462_PIN28_SHIFT
==
336 ADT7462_PIN28_VOLT
&&
337 !(data
->pin_cfg
[0] & ADT7462_VID_INPUT
))
344 static int ADT7462_REG_VOLT_MIN(struct adt7462_data
*data
, int which
)
348 if (!(data
->pin_cfg
[0] & ADT7462_PIN7_INPUT
))
354 if (!(data
->pin_cfg
[1] & ADT7462_PIN22_INPUT
))
358 if (!(data
->pin_cfg
[1] & ADT7462_PIN21_INPUT
))
362 if (!(data
->pin_cfg
[0] & ADT7462_DIODE3_INPUT
))
366 if (!(data
->pin_cfg
[0] & ADT7462_DIODE1_INPUT
))
370 if (!(data
->pin_cfg
[1] & ADT7462_PIN13_INPUT
))
374 if (!(data
->pin_cfg
[1] & ADT7462_PIN8_INPUT
))
378 if (!(data
->pin_cfg
[2] & ADT7462_PIN26_VOLT_INPUT
))
382 if (!(data
->pin_cfg
[2] & ADT7462_PIN25_VOLT_INPUT
))
388 if (data
->pin_cfg
[3] >> ADT7462_PIN28_SHIFT
==
389 ADT7462_PIN28_VOLT
&&
390 !(data
->pin_cfg
[0] & ADT7462_VID_INPUT
))
394 if (data
->pin_cfg
[3] >> ADT7462_PIN28_SHIFT
==
395 ADT7462_PIN28_VOLT
&&
396 !(data
->pin_cfg
[0] & ADT7462_VID_INPUT
))
403 static int ADT7462_REG_VOLT(struct adt7462_data
*data
, int which
)
407 if (!(data
->pin_cfg
[0] & ADT7462_PIN7_INPUT
))
413 if (!(data
->pin_cfg
[1] & ADT7462_PIN22_INPUT
))
417 if (!(data
->pin_cfg
[1] & ADT7462_PIN21_INPUT
))
421 if (!(data
->pin_cfg
[0] & ADT7462_DIODE3_INPUT
))
425 if (!(data
->pin_cfg
[0] & ADT7462_DIODE1_INPUT
))
429 if (!(data
->pin_cfg
[1] & ADT7462_PIN13_INPUT
))
433 if (!(data
->pin_cfg
[1] & ADT7462_PIN8_INPUT
))
437 if (!(data
->pin_cfg
[2] & ADT7462_PIN26_VOLT_INPUT
))
441 if (!(data
->pin_cfg
[2] & ADT7462_PIN25_VOLT_INPUT
))
447 if (data
->pin_cfg
[3] >> ADT7462_PIN28_SHIFT
==
448 ADT7462_PIN28_VOLT
&&
449 !(data
->pin_cfg
[0] & ADT7462_VID_INPUT
))
453 if (data
->pin_cfg
[3] >> ADT7462_PIN28_SHIFT
==
454 ADT7462_PIN28_VOLT
&&
455 !(data
->pin_cfg
[0] & ADT7462_VID_INPUT
))
462 /* Provide labels for sysfs */
463 static const char *voltage_label(struct adt7462_data
*data
, int which
)
467 if (!(data
->pin_cfg
[0] & ADT7462_PIN7_INPUT
))
471 switch (MASK_AND_SHIFT(data
->pin_cfg
[1], ADT7462_PIN23
)) {
482 if (!(data
->pin_cfg
[1] & ADT7462_PIN22_INPUT
))
486 if (!(data
->pin_cfg
[1] & ADT7462_PIN21_INPUT
))
490 if (!(data
->pin_cfg
[0] & ADT7462_DIODE3_INPUT
)) {
491 if (data
->pin_cfg
[1] & ADT7462_PIN19_INPUT
)
497 if (!(data
->pin_cfg
[0] & ADT7462_DIODE1_INPUT
)) {
498 if (data
->pin_cfg
[1] & ADT7462_PIN19_INPUT
)
504 if (!(data
->pin_cfg
[1] & ADT7462_PIN13_INPUT
))
508 if (!(data
->pin_cfg
[1] & ADT7462_PIN8_INPUT
))
512 switch (MASK_AND_SHIFT(data
->pin_cfg
[2], ADT7462_PIN26
)) {
520 switch (MASK_AND_SHIFT(data
->pin_cfg
[2], ADT7462_PIN25
)) {
528 switch (MASK_AND_SHIFT(data
->pin_cfg
[2], ADT7462_PIN24
)) {
539 if (data
->pin_cfg
[3] >> ADT7462_PIN28_SHIFT
==
540 ADT7462_PIN28_VOLT
&&
541 !(data
->pin_cfg
[0] & ADT7462_VID_INPUT
))
545 if (data
->pin_cfg
[3] >> ADT7462_PIN28_SHIFT
==
546 ADT7462_PIN28_VOLT
&&
547 !(data
->pin_cfg
[0] & ADT7462_VID_INPUT
))
548 return "+1.5V 3GPIO";
554 /* Multipliers are actually in uV, not mV. */
555 static int voltage_multiplier(struct adt7462_data
*data
, int which
)
559 if (!(data
->pin_cfg
[0] & ADT7462_PIN7_INPUT
))
563 switch (MASK_AND_SHIFT(data
->pin_cfg
[1], ADT7462_PIN23
)) {
565 if (data
->pin_cfg
[0] & ADT7462_VID_INPUT
)
576 if (!(data
->pin_cfg
[1] & ADT7462_PIN22_INPUT
))
580 if (!(data
->pin_cfg
[1] & ADT7462_PIN21_INPUT
))
584 if (!(data
->pin_cfg
[0] & ADT7462_DIODE3_INPUT
)) {
585 if (data
->pin_cfg
[1] & ADT7462_PIN19_INPUT
)
591 if (!(data
->pin_cfg
[0] & ADT7462_DIODE1_INPUT
)) {
592 if (data
->pin_cfg
[1] & ADT7462_PIN15_INPUT
)
598 if (!(data
->pin_cfg
[1] & ADT7462_PIN13_INPUT
))
602 if (!(data
->pin_cfg
[1] & ADT7462_PIN8_INPUT
))
606 switch (MASK_AND_SHIFT(data
->pin_cfg
[2], ADT7462_PIN26
)) {
614 switch (MASK_AND_SHIFT(data
->pin_cfg
[2], ADT7462_PIN25
)) {
622 switch (MASK_AND_SHIFT(data
->pin_cfg
[2], ADT7462_PIN24
)) {
634 if (data
->pin_cfg
[3] >> ADT7462_PIN28_SHIFT
==
635 ADT7462_PIN28_VOLT
&&
636 !(data
->pin_cfg
[0] & ADT7462_VID_INPUT
))
642 static int temp_enabled(struct adt7462_data
*data
, int which
)
649 if (data
->pin_cfg
[0] & ADT7462_DIODE1_INPUT
)
653 if (data
->pin_cfg
[0] & ADT7462_DIODE3_INPUT
)
660 static const char *temp_label(struct adt7462_data
*data
, int which
)
666 if (data
->pin_cfg
[0] & ADT7462_DIODE1_INPUT
)
672 if (data
->pin_cfg
[0] & ADT7462_DIODE3_INPUT
)
679 /* Map Trange register values to mC */
680 #define NUM_TRANGE_VALUES 16
681 static const int trange_values
[NUM_TRANGE_VALUES
] = {
700 static int find_trange_value(int trange
)
704 for (i
= 0; i
< NUM_TRANGE_VALUES
; i
++)
705 if (trange_values
[i
] == trange
)
711 static struct adt7462_data
*adt7462_update_device(struct device
*dev
)
713 struct i2c_client
*client
= to_i2c_client(dev
);
714 struct adt7462_data
*data
= i2c_get_clientdata(client
);
715 unsigned long local_jiffies
= jiffies
;
718 mutex_lock(&data
->lock
);
719 if (time_before(local_jiffies
, data
->sensors_last_updated
+
720 SENSOR_REFRESH_INTERVAL
)
721 && data
->sensors_valid
)
722 goto no_sensor_update
;
724 for (i
= 0; i
< ADT7462_TEMP_COUNT
; i
++) {
726 * Reading the fractional register locks the integral
727 * register until both have been read.
729 data
->temp_frac
[i
] = i2c_smbus_read_byte_data(client
,
730 ADT7462_TEMP_REG(i
));
731 data
->temp
[i
] = i2c_smbus_read_byte_data(client
,
732 ADT7462_TEMP_REG(i
) + 1);
735 for (i
= 0; i
< ADT7462_FAN_COUNT
; i
++)
736 data
->fan
[i
] = adt7462_read_word_data(client
,
739 data
->fan_enabled
= i2c_smbus_read_byte_data(client
,
740 ADT7462_REG_FAN_ENABLE
);
742 for (i
= 0; i
< ADT7462_PWM_COUNT
; i
++)
743 data
->pwm
[i
] = i2c_smbus_read_byte_data(client
,
746 for (i
= 0; i
< ADT7462_PIN_CFG_REG_COUNT
; i
++)
747 data
->pin_cfg
[i
] = i2c_smbus_read_byte_data(client
,
748 ADT7462_REG_PIN_CFG(i
));
750 for (i
= 0; i
< ADT7462_VOLT_COUNT
; i
++) {
751 int reg
= ADT7462_REG_VOLT(data
, i
);
753 data
->voltages
[i
] = 0;
755 data
->voltages
[i
] = i2c_smbus_read_byte_data(client
,
759 data
->alarms
[0] = i2c_smbus_read_byte_data(client
, ADT7462_REG_ALARM1
);
760 data
->alarms
[1] = i2c_smbus_read_byte_data(client
, ADT7462_REG_ALARM2
);
761 data
->alarms
[2] = i2c_smbus_read_byte_data(client
, ADT7462_REG_ALARM3
);
762 data
->alarms
[3] = i2c_smbus_read_byte_data(client
, ADT7462_REG_ALARM4
);
764 data
->sensors_last_updated
= local_jiffies
;
765 data
->sensors_valid
= 1;
768 if (time_before(local_jiffies
, data
->limits_last_updated
+
769 LIMIT_REFRESH_INTERVAL
)
770 && data
->limits_valid
)
773 for (i
= 0; i
< ADT7462_TEMP_COUNT
; i
++) {
774 data
->temp_min
[i
] = i2c_smbus_read_byte_data(client
,
775 ADT7462_TEMP_MIN_REG(i
));
776 data
->temp_max
[i
] = i2c_smbus_read_byte_data(client
,
777 ADT7462_TEMP_MAX_REG(i
));
780 for (i
= 0; i
< ADT7462_FAN_COUNT
; i
++)
781 data
->fan_min
[i
] = i2c_smbus_read_byte_data(client
,
782 ADT7462_REG_FAN_MIN(i
));
784 for (i
= 0; i
< ADT7462_VOLT_COUNT
; i
++) {
785 int reg
= ADT7462_REG_VOLT_MAX(data
, i
);
787 (reg
? i2c_smbus_read_byte_data(client
, reg
) : 0);
789 reg
= ADT7462_REG_VOLT_MIN(data
, i
);
791 (reg
? i2c_smbus_read_byte_data(client
, reg
) : 0);
794 for (i
= 0; i
< ADT7462_PWM_COUNT
; i
++) {
795 data
->pwm_min
[i
] = i2c_smbus_read_byte_data(client
,
796 ADT7462_REG_PWM_MIN(i
));
797 data
->pwm_tmin
[i
] = i2c_smbus_read_byte_data(client
,
798 ADT7462_REG_PWM_TMIN(i
));
799 data
->pwm_trange
[i
] = i2c_smbus_read_byte_data(client
,
800 ADT7462_REG_PWM_TRANGE(i
));
801 data
->pwm_cfg
[i
] = i2c_smbus_read_byte_data(client
,
802 ADT7462_REG_PWM_CFG(i
));
805 data
->pwm_max
= i2c_smbus_read_byte_data(client
, ADT7462_REG_PWM_MAX
);
807 data
->cfg2
= i2c_smbus_read_byte_data(client
, ADT7462_REG_CFG2
);
809 data
->limits_last_updated
= local_jiffies
;
810 data
->limits_valid
= 1;
813 mutex_unlock(&data
->lock
);
817 static ssize_t
show_temp_min(struct device
*dev
,
818 struct device_attribute
*devattr
,
821 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
822 struct adt7462_data
*data
= adt7462_update_device(dev
);
824 if (!temp_enabled(data
, attr
->index
))
825 return sprintf(buf
, "0\n");
827 return sprintf(buf
, "%d\n", 1000 * (data
->temp_min
[attr
->index
] - 64));
830 static ssize_t
set_temp_min(struct device
*dev
,
831 struct device_attribute
*devattr
,
835 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
836 struct i2c_client
*client
= to_i2c_client(dev
);
837 struct adt7462_data
*data
= i2c_get_clientdata(client
);
840 if (strict_strtol(buf
, 10, &temp
) || !temp_enabled(data
, attr
->index
))
843 temp
= ROUND_DIV(temp
, 1000) + 64;
844 temp
= SENSORS_LIMIT(temp
, 0, 255);
846 mutex_lock(&data
->lock
);
847 data
->temp_min
[attr
->index
] = temp
;
848 i2c_smbus_write_byte_data(client
, ADT7462_TEMP_MIN_REG(attr
->index
),
850 mutex_unlock(&data
->lock
);
855 static ssize_t
show_temp_max(struct device
*dev
,
856 struct device_attribute
*devattr
,
859 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
860 struct adt7462_data
*data
= adt7462_update_device(dev
);
862 if (!temp_enabled(data
, attr
->index
))
863 return sprintf(buf
, "0\n");
865 return sprintf(buf
, "%d\n", 1000 * (data
->temp_max
[attr
->index
] - 64));
868 static ssize_t
set_temp_max(struct device
*dev
,
869 struct device_attribute
*devattr
,
873 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
874 struct i2c_client
*client
= to_i2c_client(dev
);
875 struct adt7462_data
*data
= i2c_get_clientdata(client
);
878 if (strict_strtol(buf
, 10, &temp
) || !temp_enabled(data
, attr
->index
))
881 temp
= ROUND_DIV(temp
, 1000) + 64;
882 temp
= SENSORS_LIMIT(temp
, 0, 255);
884 mutex_lock(&data
->lock
);
885 data
->temp_max
[attr
->index
] = temp
;
886 i2c_smbus_write_byte_data(client
, ADT7462_TEMP_MAX_REG(attr
->index
),
888 mutex_unlock(&data
->lock
);
893 static ssize_t
show_temp(struct device
*dev
, struct device_attribute
*devattr
,
896 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
897 struct adt7462_data
*data
= adt7462_update_device(dev
);
898 u8 frac
= data
->temp_frac
[attr
->index
] >> TEMP_FRAC_OFFSET
;
900 if (!temp_enabled(data
, attr
->index
))
901 return sprintf(buf
, "0\n");
903 return sprintf(buf
, "%d\n", 1000 * (data
->temp
[attr
->index
] - 64) +
907 static ssize_t
show_temp_label(struct device
*dev
,
908 struct device_attribute
*devattr
,
911 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
912 struct adt7462_data
*data
= adt7462_update_device(dev
);
914 return sprintf(buf
, "%s\n", temp_label(data
, attr
->index
));
917 static ssize_t
show_volt_max(struct device
*dev
,
918 struct device_attribute
*devattr
,
921 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
922 struct adt7462_data
*data
= adt7462_update_device(dev
);
923 int x
= voltage_multiplier(data
, attr
->index
);
925 x
*= data
->volt_max
[attr
->index
];
926 x
/= 1000; /* convert from uV to mV */
928 return sprintf(buf
, "%d\n", x
);
931 static ssize_t
set_volt_max(struct device
*dev
,
932 struct device_attribute
*devattr
,
936 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
937 struct i2c_client
*client
= to_i2c_client(dev
);
938 struct adt7462_data
*data
= i2c_get_clientdata(client
);
939 int x
= voltage_multiplier(data
, attr
->index
);
942 if (strict_strtol(buf
, 10, &temp
) || !x
)
945 temp
*= 1000; /* convert mV to uV */
946 temp
= ROUND_DIV(temp
, x
);
947 temp
= SENSORS_LIMIT(temp
, 0, 255);
949 mutex_lock(&data
->lock
);
950 data
->volt_max
[attr
->index
] = temp
;
951 i2c_smbus_write_byte_data(client
,
952 ADT7462_REG_VOLT_MAX(data
, attr
->index
),
954 mutex_unlock(&data
->lock
);
959 static ssize_t
show_volt_min(struct device
*dev
,
960 struct device_attribute
*devattr
,
963 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
964 struct adt7462_data
*data
= adt7462_update_device(dev
);
965 int x
= voltage_multiplier(data
, attr
->index
);
967 x
*= data
->volt_min
[attr
->index
];
968 x
/= 1000; /* convert from uV to mV */
970 return sprintf(buf
, "%d\n", x
);
973 static ssize_t
set_volt_min(struct device
*dev
,
974 struct device_attribute
*devattr
,
978 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
979 struct i2c_client
*client
= to_i2c_client(dev
);
980 struct adt7462_data
*data
= i2c_get_clientdata(client
);
981 int x
= voltage_multiplier(data
, attr
->index
);
984 if (strict_strtol(buf
, 10, &temp
) || !x
)
987 temp
*= 1000; /* convert mV to uV */
988 temp
= ROUND_DIV(temp
, x
);
989 temp
= SENSORS_LIMIT(temp
, 0, 255);
991 mutex_lock(&data
->lock
);
992 data
->volt_min
[attr
->index
] = temp
;
993 i2c_smbus_write_byte_data(client
,
994 ADT7462_REG_VOLT_MIN(data
, attr
->index
),
996 mutex_unlock(&data
->lock
);
1001 static ssize_t
show_voltage(struct device
*dev
,
1002 struct device_attribute
*devattr
,
1005 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1006 struct adt7462_data
*data
= adt7462_update_device(dev
);
1007 int x
= voltage_multiplier(data
, attr
->index
);
1009 x
*= data
->voltages
[attr
->index
];
1010 x
/= 1000; /* convert from uV to mV */
1012 return sprintf(buf
, "%d\n", x
);
1015 static ssize_t
show_voltage_label(struct device
*dev
,
1016 struct device_attribute
*devattr
,
1019 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1020 struct adt7462_data
*data
= adt7462_update_device(dev
);
1022 return sprintf(buf
, "%s\n", voltage_label(data
, attr
->index
));
1025 static ssize_t
show_alarm(struct device
*dev
,
1026 struct device_attribute
*devattr
,
1029 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1030 struct adt7462_data
*data
= adt7462_update_device(dev
);
1031 int reg
= attr
->index
>> ADT7462_ALARM_REG_SHIFT
;
1032 int mask
= attr
->index
& ADT7462_ALARM_FLAG_MASK
;
1034 if (data
->alarms
[reg
] & mask
)
1035 return sprintf(buf
, "1\n");
1037 return sprintf(buf
, "0\n");
1040 static int fan_enabled(struct adt7462_data
*data
, int fan
)
1042 return data
->fan_enabled
& (1 << fan
);
1045 static ssize_t
show_fan_min(struct device
*dev
,
1046 struct device_attribute
*devattr
,
1049 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1050 struct adt7462_data
*data
= adt7462_update_device(dev
);
1053 /* Only the MSB of the min fan period is stored... */
1054 temp
= data
->fan_min
[attr
->index
];
1057 if (!fan_enabled(data
, attr
->index
) ||
1058 !FAN_DATA_VALID(temp
))
1059 return sprintf(buf
, "0\n");
1061 return sprintf(buf
, "%d\n", FAN_PERIOD_TO_RPM(temp
));
1064 static ssize_t
set_fan_min(struct device
*dev
,
1065 struct device_attribute
*devattr
,
1066 const char *buf
, size_t count
)
1068 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1069 struct i2c_client
*client
= to_i2c_client(dev
);
1070 struct adt7462_data
*data
= i2c_get_clientdata(client
);
1073 if (strict_strtol(buf
, 10, &temp
) || !temp
||
1074 !fan_enabled(data
, attr
->index
))
1077 temp
= FAN_RPM_TO_PERIOD(temp
);
1079 temp
= SENSORS_LIMIT(temp
, 1, 255);
1081 mutex_lock(&data
->lock
);
1082 data
->fan_min
[attr
->index
] = temp
;
1083 i2c_smbus_write_byte_data(client
, ADT7462_REG_FAN_MIN(attr
->index
),
1085 mutex_unlock(&data
->lock
);
1090 static ssize_t
show_fan(struct device
*dev
, struct device_attribute
*devattr
,
1093 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1094 struct adt7462_data
*data
= adt7462_update_device(dev
);
1096 if (!fan_enabled(data
, attr
->index
) ||
1097 !FAN_DATA_VALID(data
->fan
[attr
->index
]))
1098 return sprintf(buf
, "0\n");
1100 return sprintf(buf
, "%d\n",
1101 FAN_PERIOD_TO_RPM(data
->fan
[attr
->index
]));
1104 static ssize_t
show_force_pwm_max(struct device
*dev
,
1105 struct device_attribute
*devattr
,
1108 struct adt7462_data
*data
= adt7462_update_device(dev
);
1109 return sprintf(buf
, "%d\n", (data
->cfg2
& ADT7462_FSPD_MASK
? 1 : 0));
1112 static ssize_t
set_force_pwm_max(struct device
*dev
,
1113 struct device_attribute
*devattr
,
1117 struct i2c_client
*client
= to_i2c_client(dev
);
1118 struct adt7462_data
*data
= i2c_get_clientdata(client
);
1122 if (strict_strtol(buf
, 10, &temp
))
1125 mutex_lock(&data
->lock
);
1126 reg
= i2c_smbus_read_byte_data(client
, ADT7462_REG_CFG2
);
1128 reg
|= ADT7462_FSPD_MASK
;
1130 reg
&= ~ADT7462_FSPD_MASK
;
1132 i2c_smbus_write_byte_data(client
, ADT7462_REG_CFG2
, reg
);
1133 mutex_unlock(&data
->lock
);
1138 static ssize_t
show_pwm(struct device
*dev
, struct device_attribute
*devattr
,
1141 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1142 struct adt7462_data
*data
= adt7462_update_device(dev
);
1143 return sprintf(buf
, "%d\n", data
->pwm
[attr
->index
]);
1146 static ssize_t
set_pwm(struct device
*dev
, struct device_attribute
*devattr
,
1147 const char *buf
, size_t count
)
1149 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1150 struct i2c_client
*client
= to_i2c_client(dev
);
1151 struct adt7462_data
*data
= i2c_get_clientdata(client
);
1154 if (strict_strtol(buf
, 10, &temp
))
1157 temp
= SENSORS_LIMIT(temp
, 0, 255);
1159 mutex_lock(&data
->lock
);
1160 data
->pwm
[attr
->index
] = temp
;
1161 i2c_smbus_write_byte_data(client
, ADT7462_REG_PWM(attr
->index
), temp
);
1162 mutex_unlock(&data
->lock
);
1167 static ssize_t
show_pwm_max(struct device
*dev
,
1168 struct device_attribute
*devattr
,
1171 struct adt7462_data
*data
= adt7462_update_device(dev
);
1172 return sprintf(buf
, "%d\n", data
->pwm_max
);
1175 static ssize_t
set_pwm_max(struct device
*dev
,
1176 struct device_attribute
*devattr
,
1180 struct i2c_client
*client
= to_i2c_client(dev
);
1181 struct adt7462_data
*data
= i2c_get_clientdata(client
);
1184 if (strict_strtol(buf
, 10, &temp
))
1187 temp
= SENSORS_LIMIT(temp
, 0, 255);
1189 mutex_lock(&data
->lock
);
1190 data
->pwm_max
= temp
;
1191 i2c_smbus_write_byte_data(client
, ADT7462_REG_PWM_MAX
, temp
);
1192 mutex_unlock(&data
->lock
);
1197 static ssize_t
show_pwm_min(struct device
*dev
,
1198 struct device_attribute
*devattr
,
1201 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1202 struct adt7462_data
*data
= adt7462_update_device(dev
);
1203 return sprintf(buf
, "%d\n", data
->pwm_min
[attr
->index
]);
1206 static ssize_t
set_pwm_min(struct device
*dev
,
1207 struct device_attribute
*devattr
,
1211 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1212 struct i2c_client
*client
= to_i2c_client(dev
);
1213 struct adt7462_data
*data
= i2c_get_clientdata(client
);
1216 if (strict_strtol(buf
, 10, &temp
))
1219 temp
= SENSORS_LIMIT(temp
, 0, 255);
1221 mutex_lock(&data
->lock
);
1222 data
->pwm_min
[attr
->index
] = temp
;
1223 i2c_smbus_write_byte_data(client
, ADT7462_REG_PWM_MIN(attr
->index
),
1225 mutex_unlock(&data
->lock
);
1230 static ssize_t
show_pwm_hyst(struct device
*dev
,
1231 struct device_attribute
*devattr
,
1234 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1235 struct adt7462_data
*data
= adt7462_update_device(dev
);
1236 return sprintf(buf
, "%d\n", 1000 *
1237 (data
->pwm_trange
[attr
->index
] & ADT7462_PWM_HYST_MASK
));
1240 static ssize_t
set_pwm_hyst(struct device
*dev
,
1241 struct device_attribute
*devattr
,
1245 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1246 struct i2c_client
*client
= to_i2c_client(dev
);
1247 struct adt7462_data
*data
= i2c_get_clientdata(client
);
1250 if (strict_strtol(buf
, 10, &temp
))
1253 temp
= ROUND_DIV(temp
, 1000);
1254 temp
= SENSORS_LIMIT(temp
, 0, 15);
1256 /* package things up */
1257 temp
&= ADT7462_PWM_HYST_MASK
;
1258 temp
|= data
->pwm_trange
[attr
->index
] & ADT7462_PWM_RANGE_MASK
;
1260 mutex_lock(&data
->lock
);
1261 data
->pwm_trange
[attr
->index
] = temp
;
1262 i2c_smbus_write_byte_data(client
, ADT7462_REG_PWM_TRANGE(attr
->index
),
1264 mutex_unlock(&data
->lock
);
1269 static ssize_t
show_pwm_tmax(struct device
*dev
,
1270 struct device_attribute
*devattr
,
1273 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1274 struct adt7462_data
*data
= adt7462_update_device(dev
);
1276 /* tmax = tmin + trange */
1277 int trange
= trange_values
[data
->pwm_trange
[attr
->index
] >>
1278 ADT7462_PWM_RANGE_SHIFT
];
1279 int tmin
= (data
->pwm_tmin
[attr
->index
] - 64) * 1000;
1281 return sprintf(buf
, "%d\n", tmin
+ trange
);
1284 static ssize_t
set_pwm_tmax(struct device
*dev
,
1285 struct device_attribute
*devattr
,
1290 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1291 struct i2c_client
*client
= to_i2c_client(dev
);
1292 struct adt7462_data
*data
= i2c_get_clientdata(client
);
1293 int tmin
, trange_value
;
1296 if (strict_strtol(buf
, 10, &trange
))
1299 /* trange = tmax - tmin */
1300 tmin
= (data
->pwm_tmin
[attr
->index
] - 64) * 1000;
1301 trange_value
= find_trange_value(trange
- tmin
);
1303 if (trange_value
< 0)
1306 temp
= trange_value
<< ADT7462_PWM_RANGE_SHIFT
;
1307 temp
|= data
->pwm_trange
[attr
->index
] & ADT7462_PWM_HYST_MASK
;
1309 mutex_lock(&data
->lock
);
1310 data
->pwm_trange
[attr
->index
] = temp
;
1311 i2c_smbus_write_byte_data(client
, ADT7462_REG_PWM_TRANGE(attr
->index
),
1313 mutex_unlock(&data
->lock
);
1318 static ssize_t
show_pwm_tmin(struct device
*dev
,
1319 struct device_attribute
*devattr
,
1322 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1323 struct adt7462_data
*data
= adt7462_update_device(dev
);
1324 return sprintf(buf
, "%d\n", 1000 * (data
->pwm_tmin
[attr
->index
] - 64));
1327 static ssize_t
set_pwm_tmin(struct device
*dev
,
1328 struct device_attribute
*devattr
,
1332 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1333 struct i2c_client
*client
= to_i2c_client(dev
);
1334 struct adt7462_data
*data
= i2c_get_clientdata(client
);
1337 if (strict_strtol(buf
, 10, &temp
))
1340 temp
= ROUND_DIV(temp
, 1000) + 64;
1341 temp
= SENSORS_LIMIT(temp
, 0, 255);
1343 mutex_lock(&data
->lock
);
1344 data
->pwm_tmin
[attr
->index
] = temp
;
1345 i2c_smbus_write_byte_data(client
, ADT7462_REG_PWM_TMIN(attr
->index
),
1347 mutex_unlock(&data
->lock
);
1352 static ssize_t
show_pwm_auto(struct device
*dev
,
1353 struct device_attribute
*devattr
,
1356 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1357 struct adt7462_data
*data
= adt7462_update_device(dev
);
1358 int cfg
= data
->pwm_cfg
[attr
->index
] >> ADT7462_PWM_CHANNEL_SHIFT
;
1362 return sprintf(buf
, "0\n");
1363 case 7: /* manual */
1364 return sprintf(buf
, "1\n");
1365 default: /* automatic */
1366 return sprintf(buf
, "2\n");
1370 static void set_pwm_channel(struct i2c_client
*client
,
1371 struct adt7462_data
*data
,
1375 int temp
= data
->pwm_cfg
[which
] & ~ADT7462_PWM_CHANNEL_MASK
;
1376 temp
|= value
<< ADT7462_PWM_CHANNEL_SHIFT
;
1378 mutex_lock(&data
->lock
);
1379 data
->pwm_cfg
[which
] = temp
;
1380 i2c_smbus_write_byte_data(client
, ADT7462_REG_PWM_CFG(which
), temp
);
1381 mutex_unlock(&data
->lock
);
1384 static ssize_t
set_pwm_auto(struct device
*dev
,
1385 struct device_attribute
*devattr
,
1389 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1390 struct i2c_client
*client
= to_i2c_client(dev
);
1391 struct adt7462_data
*data
= i2c_get_clientdata(client
);
1394 if (strict_strtol(buf
, 10, &temp
))
1399 set_pwm_channel(client
, data
, attr
->index
, 4);
1401 case 1: /* manual */
1402 set_pwm_channel(client
, data
, attr
->index
, 7);
1409 static ssize_t
show_pwm_auto_temp(struct device
*dev
,
1410 struct device_attribute
*devattr
,
1413 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1414 struct adt7462_data
*data
= adt7462_update_device(dev
);
1415 int channel
= data
->pwm_cfg
[attr
->index
] >> ADT7462_PWM_CHANNEL_SHIFT
;
1418 case 0: /* temp[1234] only */
1422 return sprintf(buf
, "%d\n", (1 << channel
));
1423 case 5: /* temp1 & temp4 */
1424 return sprintf(buf
, "9\n");
1426 return sprintf(buf
, "15\n");
1428 return sprintf(buf
, "0\n");
1432 static int cvt_auto_temp(int input
)
1438 if (input
< 1 || !is_power_of_2(input
))
1440 return ilog2(input
);
1443 static ssize_t
set_pwm_auto_temp(struct device
*dev
,
1444 struct device_attribute
*devattr
,
1448 struct sensor_device_attribute
*attr
= to_sensor_dev_attr(devattr
);
1449 struct i2c_client
*client
= to_i2c_client(dev
);
1450 struct adt7462_data
*data
= i2c_get_clientdata(client
);
1453 if (strict_strtol(buf
, 10, &temp
))
1456 temp
= cvt_auto_temp(temp
);
1460 set_pwm_channel(client
, data
, attr
->index
, temp
);
1465 static SENSOR_DEVICE_ATTR(temp1_max
, S_IWUSR
| S_IRUGO
, show_temp_max
,
1467 static SENSOR_DEVICE_ATTR(temp2_max
, S_IWUSR
| S_IRUGO
, show_temp_max
,
1469 static SENSOR_DEVICE_ATTR(temp3_max
, S_IWUSR
| S_IRUGO
, show_temp_max
,
1471 static SENSOR_DEVICE_ATTR(temp4_max
, S_IWUSR
| S_IRUGO
, show_temp_max
,
1474 static SENSOR_DEVICE_ATTR(temp1_min
, S_IWUSR
| S_IRUGO
, show_temp_min
,
1476 static SENSOR_DEVICE_ATTR(temp2_min
, S_IWUSR
| S_IRUGO
, show_temp_min
,
1478 static SENSOR_DEVICE_ATTR(temp3_min
, S_IWUSR
| S_IRUGO
, show_temp_min
,
1480 static SENSOR_DEVICE_ATTR(temp4_min
, S_IWUSR
| S_IRUGO
, show_temp_min
,
1483 static SENSOR_DEVICE_ATTR(temp1_input
, S_IRUGO
, show_temp
, NULL
, 0);
1484 static SENSOR_DEVICE_ATTR(temp2_input
, S_IRUGO
, show_temp
, NULL
, 1);
1485 static SENSOR_DEVICE_ATTR(temp3_input
, S_IRUGO
, show_temp
, NULL
, 2);
1486 static SENSOR_DEVICE_ATTR(temp4_input
, S_IRUGO
, show_temp
, NULL
, 3);
1488 static SENSOR_DEVICE_ATTR(temp1_label
, S_IRUGO
, show_temp_label
, NULL
, 0);
1489 static SENSOR_DEVICE_ATTR(temp2_label
, S_IRUGO
, show_temp_label
, NULL
, 1);
1490 static SENSOR_DEVICE_ATTR(temp3_label
, S_IRUGO
, show_temp_label
, NULL
, 2);
1491 static SENSOR_DEVICE_ATTR(temp4_label
, S_IRUGO
, show_temp_label
, NULL
, 3);
1493 static SENSOR_DEVICE_ATTR(temp1_alarm
, S_IRUGO
, show_alarm
, NULL
,
1494 ADT7462_ALARM1
| ADT7462_LT_ALARM
);
1495 static SENSOR_DEVICE_ATTR(temp2_alarm
, S_IRUGO
, show_alarm
, NULL
,
1496 ADT7462_ALARM1
| ADT7462_R1T_ALARM
);
1497 static SENSOR_DEVICE_ATTR(temp3_alarm
, S_IRUGO
, show_alarm
, NULL
,
1498 ADT7462_ALARM1
| ADT7462_R2T_ALARM
);
1499 static SENSOR_DEVICE_ATTR(temp4_alarm
, S_IRUGO
, show_alarm
, NULL
,
1500 ADT7462_ALARM1
| ADT7462_R3T_ALARM
);
1502 static SENSOR_DEVICE_ATTR(in1_max
, S_IWUSR
| S_IRUGO
, show_volt_max
,
1504 static SENSOR_DEVICE_ATTR(in2_max
, S_IWUSR
| S_IRUGO
, show_volt_max
,
1506 static SENSOR_DEVICE_ATTR(in3_max
, S_IWUSR
| S_IRUGO
, show_volt_max
,
1508 static SENSOR_DEVICE_ATTR(in4_max
, S_IWUSR
| S_IRUGO
, show_volt_max
,
1510 static SENSOR_DEVICE_ATTR(in5_max
, S_IWUSR
| S_IRUGO
, show_volt_max
,
1512 static SENSOR_DEVICE_ATTR(in6_max
, S_IWUSR
| S_IRUGO
, show_volt_max
,
1514 static SENSOR_DEVICE_ATTR(in7_max
, S_IWUSR
| S_IRUGO
, show_volt_max
,
1516 static SENSOR_DEVICE_ATTR(in8_max
, S_IWUSR
| S_IRUGO
, show_volt_max
,
1518 static SENSOR_DEVICE_ATTR(in9_max
, S_IWUSR
| S_IRUGO
, show_volt_max
,
1520 static SENSOR_DEVICE_ATTR(in10_max
, S_IWUSR
| S_IRUGO
, show_volt_max
,
1522 static SENSOR_DEVICE_ATTR(in11_max
, S_IWUSR
| S_IRUGO
, show_volt_max
,
1524 static SENSOR_DEVICE_ATTR(in12_max
, S_IWUSR
| S_IRUGO
, show_volt_max
,
1526 static SENSOR_DEVICE_ATTR(in13_max
, S_IWUSR
| S_IRUGO
, show_volt_max
,
1529 static SENSOR_DEVICE_ATTR(in1_min
, S_IWUSR
| S_IRUGO
, show_volt_min
,
1531 static SENSOR_DEVICE_ATTR(in2_min
, S_IWUSR
| S_IRUGO
, show_volt_min
,
1533 static SENSOR_DEVICE_ATTR(in3_min
, S_IWUSR
| S_IRUGO
, show_volt_min
,
1535 static SENSOR_DEVICE_ATTR(in4_min
, S_IWUSR
| S_IRUGO
, show_volt_min
,
1537 static SENSOR_DEVICE_ATTR(in5_min
, S_IWUSR
| S_IRUGO
, show_volt_min
,
1539 static SENSOR_DEVICE_ATTR(in6_min
, S_IWUSR
| S_IRUGO
, show_volt_min
,
1541 static SENSOR_DEVICE_ATTR(in7_min
, S_IWUSR
| S_IRUGO
, show_volt_min
,
1543 static SENSOR_DEVICE_ATTR(in8_min
, S_IWUSR
| S_IRUGO
, show_volt_min
,
1545 static SENSOR_DEVICE_ATTR(in9_min
, S_IWUSR
| S_IRUGO
, show_volt_min
,
1547 static SENSOR_DEVICE_ATTR(in10_min
, S_IWUSR
| S_IRUGO
, show_volt_min
,
1549 static SENSOR_DEVICE_ATTR(in11_min
, S_IWUSR
| S_IRUGO
, show_volt_min
,
1551 static SENSOR_DEVICE_ATTR(in12_min
, S_IWUSR
| S_IRUGO
, show_volt_min
,
1553 static SENSOR_DEVICE_ATTR(in13_min
, S_IWUSR
| S_IRUGO
, show_volt_min
,
1556 static SENSOR_DEVICE_ATTR(in1_input
, S_IRUGO
, show_voltage
, NULL
, 0);
1557 static SENSOR_DEVICE_ATTR(in2_input
, S_IRUGO
, show_voltage
, NULL
, 1);
1558 static SENSOR_DEVICE_ATTR(in3_input
, S_IRUGO
, show_voltage
, NULL
, 2);
1559 static SENSOR_DEVICE_ATTR(in4_input
, S_IRUGO
, show_voltage
, NULL
, 3);
1560 static SENSOR_DEVICE_ATTR(in5_input
, S_IRUGO
, show_voltage
, NULL
, 4);
1561 static SENSOR_DEVICE_ATTR(in6_input
, S_IRUGO
, show_voltage
, NULL
, 5);
1562 static SENSOR_DEVICE_ATTR(in7_input
, S_IRUGO
, show_voltage
, NULL
, 6);
1563 static SENSOR_DEVICE_ATTR(in8_input
, S_IRUGO
, show_voltage
, NULL
, 7);
1564 static SENSOR_DEVICE_ATTR(in9_input
, S_IRUGO
, show_voltage
, NULL
, 8);
1565 static SENSOR_DEVICE_ATTR(in10_input
, S_IRUGO
, show_voltage
, NULL
, 9);
1566 static SENSOR_DEVICE_ATTR(in11_input
, S_IRUGO
, show_voltage
, NULL
, 10);
1567 static SENSOR_DEVICE_ATTR(in12_input
, S_IRUGO
, show_voltage
, NULL
, 11);
1568 static SENSOR_DEVICE_ATTR(in13_input
, S_IRUGO
, show_voltage
, NULL
, 12);
1570 static SENSOR_DEVICE_ATTR(in1_label
, S_IRUGO
, show_voltage_label
, NULL
, 0);
1571 static SENSOR_DEVICE_ATTR(in2_label
, S_IRUGO
, show_voltage_label
, NULL
, 1);
1572 static SENSOR_DEVICE_ATTR(in3_label
, S_IRUGO
, show_voltage_label
, NULL
, 2);
1573 static SENSOR_DEVICE_ATTR(in4_label
, S_IRUGO
, show_voltage_label
, NULL
, 3);
1574 static SENSOR_DEVICE_ATTR(in5_label
, S_IRUGO
, show_voltage_label
, NULL
, 4);
1575 static SENSOR_DEVICE_ATTR(in6_label
, S_IRUGO
, show_voltage_label
, NULL
, 5);
1576 static SENSOR_DEVICE_ATTR(in7_label
, S_IRUGO
, show_voltage_label
, NULL
, 6);
1577 static SENSOR_DEVICE_ATTR(in8_label
, S_IRUGO
, show_voltage_label
, NULL
, 7);
1578 static SENSOR_DEVICE_ATTR(in9_label
, S_IRUGO
, show_voltage_label
, NULL
, 8);
1579 static SENSOR_DEVICE_ATTR(in10_label
, S_IRUGO
, show_voltage_label
, NULL
, 9);
1580 static SENSOR_DEVICE_ATTR(in11_label
, S_IRUGO
, show_voltage_label
, NULL
, 10);
1581 static SENSOR_DEVICE_ATTR(in12_label
, S_IRUGO
, show_voltage_label
, NULL
, 11);
1582 static SENSOR_DEVICE_ATTR(in13_label
, S_IRUGO
, show_voltage_label
, NULL
, 12);
1584 static SENSOR_DEVICE_ATTR(in1_alarm
, S_IRUGO
, show_alarm
, NULL
,
1585 ADT7462_ALARM2
| ADT7462_V0_ALARM
);
1586 static SENSOR_DEVICE_ATTR(in2_alarm
, S_IRUGO
, show_alarm
, NULL
,
1587 ADT7462_ALARM2
| ADT7462_V7_ALARM
);
1588 static SENSOR_DEVICE_ATTR(in3_alarm
, S_IRUGO
, show_alarm
, NULL
,
1589 ADT7462_ALARM2
| ADT7462_V2_ALARM
);
1590 static SENSOR_DEVICE_ATTR(in4_alarm
, S_IRUGO
, show_alarm
, NULL
,
1591 ADT7462_ALARM2
| ADT7462_V6_ALARM
);
1592 static SENSOR_DEVICE_ATTR(in5_alarm
, S_IRUGO
, show_alarm
, NULL
,
1593 ADT7462_ALARM2
| ADT7462_V5_ALARM
);
1594 static SENSOR_DEVICE_ATTR(in6_alarm
, S_IRUGO
, show_alarm
, NULL
,
1595 ADT7462_ALARM2
| ADT7462_V4_ALARM
);
1596 static SENSOR_DEVICE_ATTR(in7_alarm
, S_IRUGO
, show_alarm
, NULL
,
1597 ADT7462_ALARM2
| ADT7462_V3_ALARM
);
1598 static SENSOR_DEVICE_ATTR(in8_alarm
, S_IRUGO
, show_alarm
, NULL
,
1599 ADT7462_ALARM2
| ADT7462_V1_ALARM
);
1600 static SENSOR_DEVICE_ATTR(in9_alarm
, S_IRUGO
, show_alarm
, NULL
,
1601 ADT7462_ALARM3
| ADT7462_V10_ALARM
);
1602 static SENSOR_DEVICE_ATTR(in10_alarm
, S_IRUGO
, show_alarm
, NULL
,
1603 ADT7462_ALARM3
| ADT7462_V9_ALARM
);
1604 static SENSOR_DEVICE_ATTR(in11_alarm
, S_IRUGO
, show_alarm
, NULL
,
1605 ADT7462_ALARM3
| ADT7462_V8_ALARM
);
1606 static SENSOR_DEVICE_ATTR(in12_alarm
, S_IRUGO
, show_alarm
, NULL
,
1607 ADT7462_ALARM3
| ADT7462_V11_ALARM
);
1608 static SENSOR_DEVICE_ATTR(in13_alarm
, S_IRUGO
, show_alarm
, NULL
,
1609 ADT7462_ALARM3
| ADT7462_V12_ALARM
);
1611 static SENSOR_DEVICE_ATTR(fan1_min
, S_IWUSR
| S_IRUGO
, show_fan_min
,
1613 static SENSOR_DEVICE_ATTR(fan2_min
, S_IWUSR
| S_IRUGO
, show_fan_min
,
1615 static SENSOR_DEVICE_ATTR(fan3_min
, S_IWUSR
| S_IRUGO
, show_fan_min
,
1617 static SENSOR_DEVICE_ATTR(fan4_min
, S_IWUSR
| S_IRUGO
, show_fan_min
,
1619 static SENSOR_DEVICE_ATTR(fan5_min
, S_IWUSR
| S_IRUGO
, show_fan_min
,
1621 static SENSOR_DEVICE_ATTR(fan6_min
, S_IWUSR
| S_IRUGO
, show_fan_min
,
1623 static SENSOR_DEVICE_ATTR(fan7_min
, S_IWUSR
| S_IRUGO
, show_fan_min
,
1625 static SENSOR_DEVICE_ATTR(fan8_min
, S_IWUSR
| S_IRUGO
, show_fan_min
,
1628 static SENSOR_DEVICE_ATTR(fan1_input
, S_IRUGO
, show_fan
, NULL
, 0);
1629 static SENSOR_DEVICE_ATTR(fan2_input
, S_IRUGO
, show_fan
, NULL
, 1);
1630 static SENSOR_DEVICE_ATTR(fan3_input
, S_IRUGO
, show_fan
, NULL
, 2);
1631 static SENSOR_DEVICE_ATTR(fan4_input
, S_IRUGO
, show_fan
, NULL
, 3);
1632 static SENSOR_DEVICE_ATTR(fan5_input
, S_IRUGO
, show_fan
, NULL
, 4);
1633 static SENSOR_DEVICE_ATTR(fan6_input
, S_IRUGO
, show_fan
, NULL
, 5);
1634 static SENSOR_DEVICE_ATTR(fan7_input
, S_IRUGO
, show_fan
, NULL
, 6);
1635 static SENSOR_DEVICE_ATTR(fan8_input
, S_IRUGO
, show_fan
, NULL
, 7);
1637 static SENSOR_DEVICE_ATTR(fan1_alarm
, S_IRUGO
, show_alarm
, NULL
,
1638 ADT7462_ALARM4
| ADT7462_F0_ALARM
);
1639 static SENSOR_DEVICE_ATTR(fan2_alarm
, S_IRUGO
, show_alarm
, NULL
,
1640 ADT7462_ALARM4
| ADT7462_F1_ALARM
);
1641 static SENSOR_DEVICE_ATTR(fan3_alarm
, S_IRUGO
, show_alarm
, NULL
,
1642 ADT7462_ALARM4
| ADT7462_F2_ALARM
);
1643 static SENSOR_DEVICE_ATTR(fan4_alarm
, S_IRUGO
, show_alarm
, NULL
,
1644 ADT7462_ALARM4
| ADT7462_F3_ALARM
);
1645 static SENSOR_DEVICE_ATTR(fan5_alarm
, S_IRUGO
, show_alarm
, NULL
,
1646 ADT7462_ALARM4
| ADT7462_F4_ALARM
);
1647 static SENSOR_DEVICE_ATTR(fan6_alarm
, S_IRUGO
, show_alarm
, NULL
,
1648 ADT7462_ALARM4
| ADT7462_F5_ALARM
);
1649 static SENSOR_DEVICE_ATTR(fan7_alarm
, S_IRUGO
, show_alarm
, NULL
,
1650 ADT7462_ALARM4
| ADT7462_F6_ALARM
);
1651 static SENSOR_DEVICE_ATTR(fan8_alarm
, S_IRUGO
, show_alarm
, NULL
,
1652 ADT7462_ALARM4
| ADT7462_F7_ALARM
);
1654 static SENSOR_DEVICE_ATTR(force_pwm_max
, S_IWUSR
| S_IRUGO
,
1655 show_force_pwm_max
, set_force_pwm_max
, 0);
1657 static SENSOR_DEVICE_ATTR(pwm1
, S_IWUSR
| S_IRUGO
, show_pwm
, set_pwm
, 0);
1658 static SENSOR_DEVICE_ATTR(pwm2
, S_IWUSR
| S_IRUGO
, show_pwm
, set_pwm
, 1);
1659 static SENSOR_DEVICE_ATTR(pwm3
, S_IWUSR
| S_IRUGO
, show_pwm
, set_pwm
, 2);
1660 static SENSOR_DEVICE_ATTR(pwm4
, S_IWUSR
| S_IRUGO
, show_pwm
, set_pwm
, 3);
1662 static SENSOR_DEVICE_ATTR(pwm1_auto_point1_pwm
, S_IWUSR
| S_IRUGO
,
1663 show_pwm_min
, set_pwm_min
, 0);
1664 static SENSOR_DEVICE_ATTR(pwm2_auto_point1_pwm
, S_IWUSR
| S_IRUGO
,
1665 show_pwm_min
, set_pwm_min
, 1);
1666 static SENSOR_DEVICE_ATTR(pwm3_auto_point1_pwm
, S_IWUSR
| S_IRUGO
,
1667 show_pwm_min
, set_pwm_min
, 2);
1668 static SENSOR_DEVICE_ATTR(pwm4_auto_point1_pwm
, S_IWUSR
| S_IRUGO
,
1669 show_pwm_min
, set_pwm_min
, 3);
1671 static SENSOR_DEVICE_ATTR(pwm1_auto_point2_pwm
, S_IWUSR
| S_IRUGO
,
1672 show_pwm_max
, set_pwm_max
, 0);
1673 static SENSOR_DEVICE_ATTR(pwm2_auto_point2_pwm
, S_IWUSR
| S_IRUGO
,
1674 show_pwm_max
, set_pwm_max
, 1);
1675 static SENSOR_DEVICE_ATTR(pwm3_auto_point2_pwm
, S_IWUSR
| S_IRUGO
,
1676 show_pwm_max
, set_pwm_max
, 2);
1677 static SENSOR_DEVICE_ATTR(pwm4_auto_point2_pwm
, S_IWUSR
| S_IRUGO
,
1678 show_pwm_max
, set_pwm_max
, 3);
1680 static SENSOR_DEVICE_ATTR(temp1_auto_point1_hyst
, S_IWUSR
| S_IRUGO
,
1681 show_pwm_hyst
, set_pwm_hyst
, 0);
1682 static SENSOR_DEVICE_ATTR(temp2_auto_point1_hyst
, S_IWUSR
| S_IRUGO
,
1683 show_pwm_hyst
, set_pwm_hyst
, 1);
1684 static SENSOR_DEVICE_ATTR(temp3_auto_point1_hyst
, S_IWUSR
| S_IRUGO
,
1685 show_pwm_hyst
, set_pwm_hyst
, 2);
1686 static SENSOR_DEVICE_ATTR(temp4_auto_point1_hyst
, S_IWUSR
| S_IRUGO
,
1687 show_pwm_hyst
, set_pwm_hyst
, 3);
1689 static SENSOR_DEVICE_ATTR(temp1_auto_point2_hyst
, S_IWUSR
| S_IRUGO
,
1690 show_pwm_hyst
, set_pwm_hyst
, 0);
1691 static SENSOR_DEVICE_ATTR(temp2_auto_point2_hyst
, S_IWUSR
| S_IRUGO
,
1692 show_pwm_hyst
, set_pwm_hyst
, 1);
1693 static SENSOR_DEVICE_ATTR(temp3_auto_point2_hyst
, S_IWUSR
| S_IRUGO
,
1694 show_pwm_hyst
, set_pwm_hyst
, 2);
1695 static SENSOR_DEVICE_ATTR(temp4_auto_point2_hyst
, S_IWUSR
| S_IRUGO
,
1696 show_pwm_hyst
, set_pwm_hyst
, 3);
1698 static SENSOR_DEVICE_ATTR(temp1_auto_point1_temp
, S_IWUSR
| S_IRUGO
,
1699 show_pwm_tmin
, set_pwm_tmin
, 0);
1700 static SENSOR_DEVICE_ATTR(temp2_auto_point1_temp
, S_IWUSR
| S_IRUGO
,
1701 show_pwm_tmin
, set_pwm_tmin
, 1);
1702 static SENSOR_DEVICE_ATTR(temp3_auto_point1_temp
, S_IWUSR
| S_IRUGO
,
1703 show_pwm_tmin
, set_pwm_tmin
, 2);
1704 static SENSOR_DEVICE_ATTR(temp4_auto_point1_temp
, S_IWUSR
| S_IRUGO
,
1705 show_pwm_tmin
, set_pwm_tmin
, 3);
1707 static SENSOR_DEVICE_ATTR(temp1_auto_point2_temp
, S_IWUSR
| S_IRUGO
,
1708 show_pwm_tmax
, set_pwm_tmax
, 0);
1709 static SENSOR_DEVICE_ATTR(temp2_auto_point2_temp
, S_IWUSR
| S_IRUGO
,
1710 show_pwm_tmax
, set_pwm_tmax
, 1);
1711 static SENSOR_DEVICE_ATTR(temp3_auto_point2_temp
, S_IWUSR
| S_IRUGO
,
1712 show_pwm_tmax
, set_pwm_tmax
, 2);
1713 static SENSOR_DEVICE_ATTR(temp4_auto_point2_temp
, S_IWUSR
| S_IRUGO
,
1714 show_pwm_tmax
, set_pwm_tmax
, 3);
1716 static SENSOR_DEVICE_ATTR(pwm1_enable
, S_IWUSR
| S_IRUGO
, show_pwm_auto
,
1718 static SENSOR_DEVICE_ATTR(pwm2_enable
, S_IWUSR
| S_IRUGO
, show_pwm_auto
,
1720 static SENSOR_DEVICE_ATTR(pwm3_enable
, S_IWUSR
| S_IRUGO
, show_pwm_auto
,
1722 static SENSOR_DEVICE_ATTR(pwm4_enable
, S_IWUSR
| S_IRUGO
, show_pwm_auto
,
1725 static SENSOR_DEVICE_ATTR(pwm1_auto_channels_temp
, S_IWUSR
| S_IRUGO
,
1726 show_pwm_auto_temp
, set_pwm_auto_temp
, 0);
1727 static SENSOR_DEVICE_ATTR(pwm2_auto_channels_temp
, S_IWUSR
| S_IRUGO
,
1728 show_pwm_auto_temp
, set_pwm_auto_temp
, 1);
1729 static SENSOR_DEVICE_ATTR(pwm3_auto_channels_temp
, S_IWUSR
| S_IRUGO
,
1730 show_pwm_auto_temp
, set_pwm_auto_temp
, 2);
1731 static SENSOR_DEVICE_ATTR(pwm4_auto_channels_temp
, S_IWUSR
| S_IRUGO
,
1732 show_pwm_auto_temp
, set_pwm_auto_temp
, 3);
1734 static struct attribute
*adt7462_attr
[] =
1736 &sensor_dev_attr_temp1_max
.dev_attr
.attr
,
1737 &sensor_dev_attr_temp2_max
.dev_attr
.attr
,
1738 &sensor_dev_attr_temp3_max
.dev_attr
.attr
,
1739 &sensor_dev_attr_temp4_max
.dev_attr
.attr
,
1741 &sensor_dev_attr_temp1_min
.dev_attr
.attr
,
1742 &sensor_dev_attr_temp2_min
.dev_attr
.attr
,
1743 &sensor_dev_attr_temp3_min
.dev_attr
.attr
,
1744 &sensor_dev_attr_temp4_min
.dev_attr
.attr
,
1746 &sensor_dev_attr_temp1_input
.dev_attr
.attr
,
1747 &sensor_dev_attr_temp2_input
.dev_attr
.attr
,
1748 &sensor_dev_attr_temp3_input
.dev_attr
.attr
,
1749 &sensor_dev_attr_temp4_input
.dev_attr
.attr
,
1751 &sensor_dev_attr_temp1_label
.dev_attr
.attr
,
1752 &sensor_dev_attr_temp2_label
.dev_attr
.attr
,
1753 &sensor_dev_attr_temp3_label
.dev_attr
.attr
,
1754 &sensor_dev_attr_temp4_label
.dev_attr
.attr
,
1756 &sensor_dev_attr_temp1_alarm
.dev_attr
.attr
,
1757 &sensor_dev_attr_temp2_alarm
.dev_attr
.attr
,
1758 &sensor_dev_attr_temp3_alarm
.dev_attr
.attr
,
1759 &sensor_dev_attr_temp4_alarm
.dev_attr
.attr
,
1761 &sensor_dev_attr_in1_max
.dev_attr
.attr
,
1762 &sensor_dev_attr_in2_max
.dev_attr
.attr
,
1763 &sensor_dev_attr_in3_max
.dev_attr
.attr
,
1764 &sensor_dev_attr_in4_max
.dev_attr
.attr
,
1765 &sensor_dev_attr_in5_max
.dev_attr
.attr
,
1766 &sensor_dev_attr_in6_max
.dev_attr
.attr
,
1767 &sensor_dev_attr_in7_max
.dev_attr
.attr
,
1768 &sensor_dev_attr_in8_max
.dev_attr
.attr
,
1769 &sensor_dev_attr_in9_max
.dev_attr
.attr
,
1770 &sensor_dev_attr_in10_max
.dev_attr
.attr
,
1771 &sensor_dev_attr_in11_max
.dev_attr
.attr
,
1772 &sensor_dev_attr_in12_max
.dev_attr
.attr
,
1773 &sensor_dev_attr_in13_max
.dev_attr
.attr
,
1775 &sensor_dev_attr_in1_min
.dev_attr
.attr
,
1776 &sensor_dev_attr_in2_min
.dev_attr
.attr
,
1777 &sensor_dev_attr_in3_min
.dev_attr
.attr
,
1778 &sensor_dev_attr_in4_min
.dev_attr
.attr
,
1779 &sensor_dev_attr_in5_min
.dev_attr
.attr
,
1780 &sensor_dev_attr_in6_min
.dev_attr
.attr
,
1781 &sensor_dev_attr_in7_min
.dev_attr
.attr
,
1782 &sensor_dev_attr_in8_min
.dev_attr
.attr
,
1783 &sensor_dev_attr_in9_min
.dev_attr
.attr
,
1784 &sensor_dev_attr_in10_min
.dev_attr
.attr
,
1785 &sensor_dev_attr_in11_min
.dev_attr
.attr
,
1786 &sensor_dev_attr_in12_min
.dev_attr
.attr
,
1787 &sensor_dev_attr_in13_min
.dev_attr
.attr
,
1789 &sensor_dev_attr_in1_input
.dev_attr
.attr
,
1790 &sensor_dev_attr_in2_input
.dev_attr
.attr
,
1791 &sensor_dev_attr_in3_input
.dev_attr
.attr
,
1792 &sensor_dev_attr_in4_input
.dev_attr
.attr
,
1793 &sensor_dev_attr_in5_input
.dev_attr
.attr
,
1794 &sensor_dev_attr_in6_input
.dev_attr
.attr
,
1795 &sensor_dev_attr_in7_input
.dev_attr
.attr
,
1796 &sensor_dev_attr_in8_input
.dev_attr
.attr
,
1797 &sensor_dev_attr_in9_input
.dev_attr
.attr
,
1798 &sensor_dev_attr_in10_input
.dev_attr
.attr
,
1799 &sensor_dev_attr_in11_input
.dev_attr
.attr
,
1800 &sensor_dev_attr_in12_input
.dev_attr
.attr
,
1801 &sensor_dev_attr_in13_input
.dev_attr
.attr
,
1803 &sensor_dev_attr_in1_label
.dev_attr
.attr
,
1804 &sensor_dev_attr_in2_label
.dev_attr
.attr
,
1805 &sensor_dev_attr_in3_label
.dev_attr
.attr
,
1806 &sensor_dev_attr_in4_label
.dev_attr
.attr
,
1807 &sensor_dev_attr_in5_label
.dev_attr
.attr
,
1808 &sensor_dev_attr_in6_label
.dev_attr
.attr
,
1809 &sensor_dev_attr_in7_label
.dev_attr
.attr
,
1810 &sensor_dev_attr_in8_label
.dev_attr
.attr
,
1811 &sensor_dev_attr_in9_label
.dev_attr
.attr
,
1812 &sensor_dev_attr_in10_label
.dev_attr
.attr
,
1813 &sensor_dev_attr_in11_label
.dev_attr
.attr
,
1814 &sensor_dev_attr_in12_label
.dev_attr
.attr
,
1815 &sensor_dev_attr_in13_label
.dev_attr
.attr
,
1817 &sensor_dev_attr_in1_alarm
.dev_attr
.attr
,
1818 &sensor_dev_attr_in2_alarm
.dev_attr
.attr
,
1819 &sensor_dev_attr_in3_alarm
.dev_attr
.attr
,
1820 &sensor_dev_attr_in4_alarm
.dev_attr
.attr
,
1821 &sensor_dev_attr_in5_alarm
.dev_attr
.attr
,
1822 &sensor_dev_attr_in6_alarm
.dev_attr
.attr
,
1823 &sensor_dev_attr_in7_alarm
.dev_attr
.attr
,
1824 &sensor_dev_attr_in8_alarm
.dev_attr
.attr
,
1825 &sensor_dev_attr_in9_alarm
.dev_attr
.attr
,
1826 &sensor_dev_attr_in10_alarm
.dev_attr
.attr
,
1827 &sensor_dev_attr_in11_alarm
.dev_attr
.attr
,
1828 &sensor_dev_attr_in12_alarm
.dev_attr
.attr
,
1829 &sensor_dev_attr_in13_alarm
.dev_attr
.attr
,
1831 &sensor_dev_attr_fan1_min
.dev_attr
.attr
,
1832 &sensor_dev_attr_fan2_min
.dev_attr
.attr
,
1833 &sensor_dev_attr_fan3_min
.dev_attr
.attr
,
1834 &sensor_dev_attr_fan4_min
.dev_attr
.attr
,
1835 &sensor_dev_attr_fan5_min
.dev_attr
.attr
,
1836 &sensor_dev_attr_fan6_min
.dev_attr
.attr
,
1837 &sensor_dev_attr_fan7_min
.dev_attr
.attr
,
1838 &sensor_dev_attr_fan8_min
.dev_attr
.attr
,
1840 &sensor_dev_attr_fan1_input
.dev_attr
.attr
,
1841 &sensor_dev_attr_fan2_input
.dev_attr
.attr
,
1842 &sensor_dev_attr_fan3_input
.dev_attr
.attr
,
1843 &sensor_dev_attr_fan4_input
.dev_attr
.attr
,
1844 &sensor_dev_attr_fan5_input
.dev_attr
.attr
,
1845 &sensor_dev_attr_fan6_input
.dev_attr
.attr
,
1846 &sensor_dev_attr_fan7_input
.dev_attr
.attr
,
1847 &sensor_dev_attr_fan8_input
.dev_attr
.attr
,
1849 &sensor_dev_attr_fan1_alarm
.dev_attr
.attr
,
1850 &sensor_dev_attr_fan2_alarm
.dev_attr
.attr
,
1851 &sensor_dev_attr_fan3_alarm
.dev_attr
.attr
,
1852 &sensor_dev_attr_fan4_alarm
.dev_attr
.attr
,
1853 &sensor_dev_attr_fan5_alarm
.dev_attr
.attr
,
1854 &sensor_dev_attr_fan6_alarm
.dev_attr
.attr
,
1855 &sensor_dev_attr_fan7_alarm
.dev_attr
.attr
,
1856 &sensor_dev_attr_fan8_alarm
.dev_attr
.attr
,
1858 &sensor_dev_attr_force_pwm_max
.dev_attr
.attr
,
1859 &sensor_dev_attr_pwm1
.dev_attr
.attr
,
1860 &sensor_dev_attr_pwm2
.dev_attr
.attr
,
1861 &sensor_dev_attr_pwm3
.dev_attr
.attr
,
1862 &sensor_dev_attr_pwm4
.dev_attr
.attr
,
1864 &sensor_dev_attr_pwm1_auto_point1_pwm
.dev_attr
.attr
,
1865 &sensor_dev_attr_pwm2_auto_point1_pwm
.dev_attr
.attr
,
1866 &sensor_dev_attr_pwm3_auto_point1_pwm
.dev_attr
.attr
,
1867 &sensor_dev_attr_pwm4_auto_point1_pwm
.dev_attr
.attr
,
1869 &sensor_dev_attr_pwm1_auto_point2_pwm
.dev_attr
.attr
,
1870 &sensor_dev_attr_pwm2_auto_point2_pwm
.dev_attr
.attr
,
1871 &sensor_dev_attr_pwm3_auto_point2_pwm
.dev_attr
.attr
,
1872 &sensor_dev_attr_pwm4_auto_point2_pwm
.dev_attr
.attr
,
1874 &sensor_dev_attr_temp1_auto_point1_hyst
.dev_attr
.attr
,
1875 &sensor_dev_attr_temp2_auto_point1_hyst
.dev_attr
.attr
,
1876 &sensor_dev_attr_temp3_auto_point1_hyst
.dev_attr
.attr
,
1877 &sensor_dev_attr_temp4_auto_point1_hyst
.dev_attr
.attr
,
1879 &sensor_dev_attr_temp1_auto_point2_hyst
.dev_attr
.attr
,
1880 &sensor_dev_attr_temp2_auto_point2_hyst
.dev_attr
.attr
,
1881 &sensor_dev_attr_temp3_auto_point2_hyst
.dev_attr
.attr
,
1882 &sensor_dev_attr_temp4_auto_point2_hyst
.dev_attr
.attr
,
1884 &sensor_dev_attr_temp1_auto_point1_temp
.dev_attr
.attr
,
1885 &sensor_dev_attr_temp2_auto_point1_temp
.dev_attr
.attr
,
1886 &sensor_dev_attr_temp3_auto_point1_temp
.dev_attr
.attr
,
1887 &sensor_dev_attr_temp4_auto_point1_temp
.dev_attr
.attr
,
1889 &sensor_dev_attr_temp1_auto_point2_temp
.dev_attr
.attr
,
1890 &sensor_dev_attr_temp2_auto_point2_temp
.dev_attr
.attr
,
1891 &sensor_dev_attr_temp3_auto_point2_temp
.dev_attr
.attr
,
1892 &sensor_dev_attr_temp4_auto_point2_temp
.dev_attr
.attr
,
1894 &sensor_dev_attr_pwm1_enable
.dev_attr
.attr
,
1895 &sensor_dev_attr_pwm2_enable
.dev_attr
.attr
,
1896 &sensor_dev_attr_pwm3_enable
.dev_attr
.attr
,
1897 &sensor_dev_attr_pwm4_enable
.dev_attr
.attr
,
1899 &sensor_dev_attr_pwm1_auto_channels_temp
.dev_attr
.attr
,
1900 &sensor_dev_attr_pwm2_auto_channels_temp
.dev_attr
.attr
,
1901 &sensor_dev_attr_pwm3_auto_channels_temp
.dev_attr
.attr
,
1902 &sensor_dev_attr_pwm4_auto_channels_temp
.dev_attr
.attr
,
1906 /* Return 0 if detection is successful, -ENODEV otherwise */
1907 static int adt7462_detect(struct i2c_client
*client
, int kind
,
1908 struct i2c_board_info
*info
)
1910 struct i2c_adapter
*adapter
= client
->adapter
;
1912 if (!i2c_check_functionality(adapter
, I2C_FUNC_SMBUS_BYTE_DATA
))
1916 int vendor
, device
, revision
;
1918 vendor
= i2c_smbus_read_byte_data(client
, ADT7462_REG_VENDOR
);
1919 if (vendor
!= ADT7462_VENDOR
)
1922 device
= i2c_smbus_read_byte_data(client
, ADT7462_REG_DEVICE
);
1923 if (device
!= ADT7462_DEVICE
)
1926 revision
= i2c_smbus_read_byte_data(client
,
1927 ADT7462_REG_REVISION
);
1928 if (revision
!= ADT7462_REVISION
)
1931 dev_dbg(&adapter
->dev
, "detection forced\n");
1933 strlcpy(info
->type
, "adt7462", I2C_NAME_SIZE
);
1938 static int adt7462_probe(struct i2c_client
*client
,
1939 const struct i2c_device_id
*id
)
1941 struct adt7462_data
*data
;
1944 data
= kzalloc(sizeof(struct adt7462_data
), GFP_KERNEL
);
1950 i2c_set_clientdata(client
, data
);
1951 mutex_init(&data
->lock
);
1953 dev_info(&client
->dev
, "%s chip found\n", client
->name
);
1955 /* Register sysfs hooks */
1956 data
->attrs
.attrs
= adt7462_attr
;
1957 err
= sysfs_create_group(&client
->dev
.kobj
, &data
->attrs
);
1961 data
->hwmon_dev
= hwmon_device_register(&client
->dev
);
1962 if (IS_ERR(data
->hwmon_dev
)) {
1963 err
= PTR_ERR(data
->hwmon_dev
);
1970 sysfs_remove_group(&client
->dev
.kobj
, &data
->attrs
);
1977 static int adt7462_remove(struct i2c_client
*client
)
1979 struct adt7462_data
*data
= i2c_get_clientdata(client
);
1981 hwmon_device_unregister(data
->hwmon_dev
);
1982 sysfs_remove_group(&client
->dev
.kobj
, &data
->attrs
);
1987 static int __init
adt7462_init(void)
1989 return i2c_add_driver(&adt7462_driver
);
1992 static void __exit
adt7462_exit(void)
1994 i2c_del_driver(&adt7462_driver
);
1997 MODULE_AUTHOR("Darrick J. Wong <djwong@us.ibm.com>");
1998 MODULE_DESCRIPTION("ADT7462 driver");
1999 MODULE_LICENSE("GPL");
2001 module_init(adt7462_init
);
2002 module_exit(adt7462_exit
);