2 * lm90.c - Part of lm_sensors, Linux kernel modules for hardware
4 * Copyright (C) 2003-2010 Jean Delvare <khali@linux-fr.org>
6 * Based on the lm83 driver. The LM90 is a sensor chip made by National
7 * Semiconductor. It reports up to two temperatures (its own plus up to
8 * one external one) with a 0.125 deg resolution (1 deg for local
9 * temperature) and a 3-4 deg accuracy.
11 * This driver also supports the LM89 and LM99, two other sensor chips
12 * made by National Semiconductor. Both have an increased remote
13 * temperature measurement accuracy (1 degree), and the LM99
14 * additionally shifts remote temperatures (measured and limits) by 16
15 * degrees, which allows for higher temperatures measurement.
16 * Note that there is no way to differentiate between both chips.
17 * When device is auto-detected, the driver will assume an LM99.
19 * This driver also supports the LM86, another sensor chip made by
20 * National Semiconductor. It is exactly similar to the LM90 except it
21 * has a higher accuracy.
23 * This driver also supports the ADM1032, a sensor chip made by Analog
24 * Devices. That chip is similar to the LM90, with a few differences
25 * that are not handled by this driver. Among others, it has a higher
26 * accuracy than the LM90, much like the LM86 does.
28 * This driver also supports the MAX6657, MAX6658 and MAX6659 sensor
29 * chips made by Maxim. These chips are similar to the LM86.
30 * Note that there is no easy way to differentiate between the three
31 * variants. We use the device address to detect MAX6659, which will result
32 * in a detection as max6657 if it is on address 0x4c. The extra address
33 * and features of the MAX6659 are only supported if the chip is configured
34 * explicitly as max6659, or if its address is not 0x4c.
35 * These chips lack the remote temperature offset feature.
37 * This driver also supports the MAX6646, MAX6647, MAX6648, MAX6649 and
38 * MAX6692 chips made by Maxim. These are again similar to the LM86,
39 * but they use unsigned temperature values and can report temperatures
40 * from 0 to 145 degrees.
42 * This driver also supports the MAX6680 and MAX6681, two other sensor
43 * chips made by Maxim. These are quite similar to the other Maxim
44 * chips. The MAX6680 and MAX6681 only differ in the pinout so they can
45 * be treated identically.
47 * This driver also supports the MAX6695 and MAX6696, two other sensor
48 * chips made by Maxim. These are also quite similar to other Maxim
49 * chips, but support three temperature sensors instead of two. MAX6695
50 * and MAX6696 only differ in the pinout so they can be treated identically.
52 * This driver also supports the ADT7461 chip from Analog Devices.
53 * It's supported in both compatibility and extended mode. It is mostly
54 * compatible with LM90 except for a data format difference for the
55 * temperature value registers.
57 * Since the LM90 was the first chipset supported by this driver, most
58 * comments will refer to this chipset, but are actually general and
59 * concern all supported chipsets, unless mentioned otherwise.
61 * This program is free software; you can redistribute it and/or modify
62 * it under the terms of the GNU General Public License as published by
63 * the Free Software Foundation; either version 2 of the License, or
64 * (at your option) any later version.
66 * This program is distributed in the hope that it will be useful,
67 * but WITHOUT ANY WARRANTY; without even the implied warranty of
68 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
69 * GNU General Public License for more details.
71 * You should have received a copy of the GNU General Public License
72 * along with this program; if not, write to the Free Software
73 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
76 #include <linux/module.h>
77 #include <linux/init.h>
78 #include <linux/slab.h>
79 #include <linux/jiffies.h>
80 #include <linux/i2c.h>
81 #include <linux/hwmon-sysfs.h>
82 #include <linux/hwmon.h>
83 #include <linux/err.h>
84 #include <linux/mutex.h>
85 #include <linux/sysfs.h>
89 * Address is fully defined internally and cannot be changed except for
90 * MAX6659, MAX6680 and MAX6681.
91 * LM86, LM89, LM90, LM99, ADM1032, ADM1032-1, ADT7461, MAX6649, MAX6657
92 * and MAX6658 have address 0x4c.
93 * ADM1032-2, ADT7461-2, LM89-1, LM99-1 and MAX6646 have address 0x4d.
94 * MAX6647 has address 0x4e.
95 * MAX6659 can have address 0x4c, 0x4d or 0x4e.
96 * MAX6680 and MAX6681 can have address 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b,
100 static const unsigned short normal_i2c[] = {
101 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e, I2C_CLIENT_END };
103 enum chips { lm90, adm1032, lm99, lm86, max6657, max6659, adt7461, max6680,
104 max6646, w83l771, max6696 };
110 #define LM90_REG_R_MAN_ID 0xFE
111 #define LM90_REG_R_CHIP_ID 0xFF
112 #define LM90_REG_R_CONFIG1 0x03
113 #define LM90_REG_W_CONFIG1 0x09
114 #define LM90_REG_R_CONFIG2 0xBF
115 #define LM90_REG_W_CONFIG2 0xBF
116 #define LM90_REG_R_CONVRATE 0x04
117 #define LM90_REG_W_CONVRATE 0x0A
118 #define LM90_REG_R_STATUS 0x02
119 #define LM90_REG_R_LOCAL_TEMP 0x00
120 #define LM90_REG_R_LOCAL_HIGH 0x05
121 #define LM90_REG_W_LOCAL_HIGH 0x0B
122 #define LM90_REG_R_LOCAL_LOW 0x06
123 #define LM90_REG_W_LOCAL_LOW 0x0C
124 #define LM90_REG_R_LOCAL_CRIT 0x20
125 #define LM90_REG_W_LOCAL_CRIT 0x20
126 #define LM90_REG_R_REMOTE_TEMPH 0x01
127 #define LM90_REG_R_REMOTE_TEMPL 0x10
128 #define LM90_REG_R_REMOTE_OFFSH 0x11
129 #define LM90_REG_W_REMOTE_OFFSH 0x11
130 #define LM90_REG_R_REMOTE_OFFSL 0x12
131 #define LM90_REG_W_REMOTE_OFFSL 0x12
132 #define LM90_REG_R_REMOTE_HIGHH 0x07
133 #define LM90_REG_W_REMOTE_HIGHH 0x0D
134 #define LM90_REG_R_REMOTE_HIGHL 0x13
135 #define LM90_REG_W_REMOTE_HIGHL 0x13
136 #define LM90_REG_R_REMOTE_LOWH 0x08
137 #define LM90_REG_W_REMOTE_LOWH 0x0E
138 #define LM90_REG_R_REMOTE_LOWL 0x14
139 #define LM90_REG_W_REMOTE_LOWL 0x14
140 #define LM90_REG_R_REMOTE_CRIT 0x19
141 #define LM90_REG_W_REMOTE_CRIT 0x19
142 #define LM90_REG_R_TCRIT_HYST 0x21
143 #define LM90_REG_W_TCRIT_HYST 0x21
145 /* MAX6646/6647/6649/6657/6658/6659/6695/6696 registers */
147 #define MAX6657_REG_R_LOCAL_TEMPL 0x11
148 #define MAX6696_REG_R_STATUS2 0x12
149 #define MAX6659_REG_R_REMOTE_EMERG 0x16
150 #define MAX6659_REG_W_REMOTE_EMERG 0x16
151 #define MAX6659_REG_R_LOCAL_EMERG 0x17
152 #define MAX6659_REG_W_LOCAL_EMERG 0x17
157 #define LM90_FLAG_ADT7461_EXT (1 << 0) /* ADT7461 extended mode */
158 /* Device features */
159 #define LM90_HAVE_OFFSET (1 << 1) /* temperature offset register */
160 #define LM90_HAVE_LOCAL_EXT (1 << 2) /* extended local temperature */
161 #define LM90_HAVE_REM_LIMIT_EXT (1 << 3) /* extended remote limit */
162 #define LM90_HAVE_EMERGENCY (1 << 4) /* 3rd upper (emergency) limit */
163 #define LM90_HAVE_EMERGENCY_ALARM (1 << 5)/* emergency alarm */
164 #define LM90_HAVE_TEMP3 (1 << 6) /* 3rd temperature sensor */
165 #define LM90_HAVE_BROKEN_ALERT (1 << 7) /* Broken alert */
168 * Driver data (common to all clients)
171 static const struct i2c_device_id lm90_id[] = {
172 { "adm1032", adm1032 },
173 { "adt7461", adt7461 },
178 { "max6646", max6646 },
179 { "max6647", max6646 },
180 { "max6649", max6646 },
181 { "max6657", max6657 },
182 { "max6658", max6657 },
183 { "max6659", max6659 },
184 { "max6680", max6680 },
185 { "max6681", max6680 },
186 { "max6695", max6696 },
187 { "max6696", max6696 },
188 { "w83l771", w83l771 },
191 MODULE_DEVICE_TABLE(i2c, lm90_id);
194 * chip type specific parameters
197 u32 flags; /* Capabilities */
198 u16 alert_alarms; /* Which alarm bits trigger ALERT# */
199 /* Upper 8 bits for max6695/96 */
202 static const struct lm90_params lm90_params[] = {
204 .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT
205 | LM90_HAVE_BROKEN_ALERT,
206 .alert_alarms = 0x7c,
209 .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT
210 | LM90_HAVE_BROKEN_ALERT,
211 .alert_alarms = 0x7c,
214 .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT,
215 .alert_alarms = 0x7b,
218 .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT,
219 .alert_alarms = 0x7b,
222 .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT,
223 .alert_alarms = 0x7b,
226 .flags = LM90_HAVE_LOCAL_EXT,
227 .alert_alarms = 0x7c,
230 .flags = LM90_HAVE_LOCAL_EXT,
231 .alert_alarms = 0x7c,
234 .flags = LM90_HAVE_LOCAL_EXT | LM90_HAVE_EMERGENCY,
235 .alert_alarms = 0x7c,
238 .flags = LM90_HAVE_OFFSET,
239 .alert_alarms = 0x7c,
242 .flags = LM90_HAVE_LOCAL_EXT | LM90_HAVE_EMERGENCY
243 | LM90_HAVE_EMERGENCY_ALARM | LM90_HAVE_TEMP3,
244 .alert_alarms = 0x187c,
247 .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT,
248 .alert_alarms = 0x7c,
253 * Client data (each client gets its own)
257 struct device *hwmon_dev;
258 struct mutex update_lock;
259 char valid; /* zero until following fields are valid */
260 unsigned long last_updated; /* in jiffies */
264 u8 config_orig; /* Original configuration register value */
265 u16 alert_alarms; /* Which alarm bits trigger ALERT# */
266 /* Upper 8 bits for max6695/96 */
268 /* registers values */
269 s8 temp8[8]; /* 0: local low limit
271 2: local critical limit
272 3: remote critical limit
273 4: local emergency limit (max6659 and max6695/96)
274 5: remote emergency limit (max6659 and max6695/96)
275 6: remote 2 critical limit (max6695/96 only)
276 7: remote 2 emergency limit (max6695/96 only) */
277 s16 temp11[8]; /* 0: remote input
280 3: remote offset (except max6646, max6657/58/59,
283 5: remote 2 input (max6695/96 only)
284 6: remote 2 low limit (max6695/96 only)
285 7: remote 2 high limit (ma6695/96 only) */
287 u16 alarms; /* bitvector (upper 8 bits for max6695/96) */
295 * The ADM1032 supports PEC but not on write byte transactions, so we need
296 * to explicitly ask for a transaction without PEC.
298 static inline s32 adm1032_write_byte(struct i2c_client *client, u8 value)
300 return i2c_smbus_xfer(client->adapter, client->addr,
301 client->flags & ~I2C_CLIENT_PEC,
302 I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL);
306 * It is assumed that client->update_lock is held (unless we are in
307 * detection or initialization steps). This matters when PEC is enabled,
308 * because we don't want the address pointer to change between the write
309 * byte and the read byte transactions.
311 static int lm90_read_reg(struct i2c_client *client, u8 reg, u8 *value)
315 if (client->flags & I2C_CLIENT_PEC) {
316 err = adm1032_write_byte(client, reg);
318 err = i2c_smbus_read_byte(client);
320 err = i2c_smbus_read_byte_data(client, reg);
323 dev_warn(&client->dev, "Register %#02x read failed (%d)\n",
332 static int lm90_read16(struct i2c_client *client, u8 regh, u8 regl, u16 *value)
338 * There is a trick here. We have to read two registers to have the
339 * sensor temperature, but we have to beware a conversion could occur
340 * inbetween the readings. The datasheet says we should either use
341 * the one-shot conversion register, which we don't want to do
342 * (disables hardware monitoring) or monitor the busy bit, which is
343 * impossible (we can't read the values and monitor that bit at the
344 * exact same time). So the solution used here is to read the high
345 * byte once, then the low byte, then the high byte again. If the new
346 * high byte matches the old one, then we have a valid reading. Else
347 * we have to read the low byte again, and now we believe we have a
350 if ((err = lm90_read_reg(client, regh, &oldh))
351 || (err = lm90_read_reg(client, regl, &l))
352 || (err = lm90_read_reg(client, regh, &newh)))
355 err = lm90_read_reg(client, regl, &l);
359 *value = (newh << 8) | l;
365 * client->update_lock must be held when calling this function (unless we are
366 * in detection or initialization steps), and while a remote channel other
367 * than channel 0 is selected. Also, calling code must make sure to re-select
368 * external channel 0 before releasing the lock. This is necessary because
369 * various registers have different meanings as a result of selecting a
370 * non-default remote channel.
372 static inline void lm90_select_remote_channel(struct i2c_client *client,
373 struct lm90_data *data,
378 if (data->kind == max6696) {
379 lm90_read_reg(client, LM90_REG_R_CONFIG1, &config);
383 i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
388 static struct lm90_data *lm90_update_device(struct device *dev)
390 struct i2c_client *client = to_i2c_client(dev);
391 struct lm90_data *data = i2c_get_clientdata(client);
393 mutex_lock(&data->update_lock);
395 if (time_after(jiffies, data->last_updated + HZ / 2 + HZ / 10)
400 dev_dbg(&client->dev, "Updating lm90 data.\n");
401 lm90_read_reg(client, LM90_REG_R_LOCAL_LOW, &data->temp8[0]);
402 lm90_read_reg(client, LM90_REG_R_LOCAL_HIGH, &data->temp8[1]);
403 lm90_read_reg(client, LM90_REG_R_LOCAL_CRIT, &data->temp8[2]);
404 lm90_read_reg(client, LM90_REG_R_REMOTE_CRIT, &data->temp8[3]);
405 lm90_read_reg(client, LM90_REG_R_TCRIT_HYST, &data->temp_hyst);
407 if (data->flags & LM90_HAVE_LOCAL_EXT) {
408 lm90_read16(client, LM90_REG_R_LOCAL_TEMP,
409 MAX6657_REG_R_LOCAL_TEMPL,
412 if (lm90_read_reg(client, LM90_REG_R_LOCAL_TEMP,
414 data->temp11[4] = h << 8;
416 lm90_read16(client, LM90_REG_R_REMOTE_TEMPH,
417 LM90_REG_R_REMOTE_TEMPL, &data->temp11[0]);
419 if (lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH, &h) == 0) {
420 data->temp11[1] = h << 8;
421 if ((data->flags & LM90_HAVE_REM_LIMIT_EXT)
422 && lm90_read_reg(client, LM90_REG_R_REMOTE_LOWL,
424 data->temp11[1] |= l;
426 if (lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHH, &h) == 0) {
427 data->temp11[2] = h << 8;
428 if ((data->flags & LM90_HAVE_REM_LIMIT_EXT)
429 && lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHL,
431 data->temp11[2] |= l;
434 if (data->flags & LM90_HAVE_OFFSET) {
435 if (lm90_read_reg(client, LM90_REG_R_REMOTE_OFFSH,
437 && lm90_read_reg(client, LM90_REG_R_REMOTE_OFFSL,
439 data->temp11[3] = (h << 8) | l;
441 if (data->flags & LM90_HAVE_EMERGENCY) {
442 lm90_read_reg(client, MAX6659_REG_R_LOCAL_EMERG,
444 lm90_read_reg(client, MAX6659_REG_R_REMOTE_EMERG,
447 lm90_read_reg(client, LM90_REG_R_STATUS, &alarms);
448 data->alarms = alarms; /* save as 16 bit value */
450 if (data->kind == max6696) {
451 lm90_select_remote_channel(client, data, 1);
452 lm90_read_reg(client, LM90_REG_R_REMOTE_CRIT,
454 lm90_read_reg(client, MAX6659_REG_R_REMOTE_EMERG,
456 lm90_read16(client, LM90_REG_R_REMOTE_TEMPH,
457 LM90_REG_R_REMOTE_TEMPL, &data->temp11[5]);
458 if (!lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH, &h))
459 data->temp11[6] = h << 8;
460 if (!lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHH, &h))
461 data->temp11[7] = h << 8;
462 lm90_select_remote_channel(client, data, 0);
464 if (!lm90_read_reg(client, MAX6696_REG_R_STATUS2,
466 data->alarms |= alarms << 8;
469 /* Re-enable ALERT# output if it was originally enabled and
470 * relevant alarms are all clear */
471 if ((data->config_orig & 0x80) == 0
472 && (data->alarms & data->alert_alarms) == 0) {
475 lm90_read_reg(client, LM90_REG_R_CONFIG1, &config);
477 dev_dbg(&client->dev, "Re-enabling ALERT#\n");
478 i2c_smbus_write_byte_data(client,
484 data->last_updated = jiffies;
488 mutex_unlock(&data->update_lock);
495 * For local temperatures and limits, critical limits and the hysteresis
496 * value, the LM90 uses signed 8-bit values with LSB = 1 degree Celsius.
497 * For remote temperatures and limits, it uses signed 11-bit values with
498 * LSB = 0.125 degree Celsius, left-justified in 16-bit registers. Some
499 * Maxim chips use unsigned values.
502 static inline int temp_from_s8(s8 val)
507 static inline int temp_from_u8(u8 val)
512 static inline int temp_from_s16(s16 val)
514 return val / 32 * 125;
517 static inline int temp_from_u16(u16 val)
519 return val / 32 * 125;
522 static s8 temp_to_s8(long val)
529 return (val - 500) / 1000;
530 return (val + 500) / 1000;
533 static u8 temp_to_u8(long val)
539 return (val + 500) / 1000;
542 static s16 temp_to_s16(long val)
549 return (val - 62) / 125 * 32;
550 return (val + 62) / 125 * 32;
553 static u8 hyst_to_reg(long val)
559 return (val + 500) / 1000;
563 * ADT7461 in compatibility mode is almost identical to LM90 except that
564 * attempts to write values that are outside the range 0 < temp < 127 are
565 * treated as the boundary value.
567 * ADT7461 in "extended mode" operation uses unsigned integers offset by
568 * 64 (e.g., 0 -> -64 degC). The range is restricted to -64..191 degC.
570 static inline int temp_from_u8_adt7461(struct lm90_data *data, u8 val)
572 if (data->flags & LM90_FLAG_ADT7461_EXT)
573 return (val - 64) * 1000;
575 return temp_from_s8(val);
578 static inline int temp_from_u16_adt7461(struct lm90_data *data, u16 val)
580 if (data->flags & LM90_FLAG_ADT7461_EXT)
581 return (val - 0x4000) / 64 * 250;
583 return temp_from_s16(val);
586 static u8 temp_to_u8_adt7461(struct lm90_data *data, long val)
588 if (data->flags & LM90_FLAG_ADT7461_EXT) {
593 return (val + 500 + 64000) / 1000;
599 return (val + 500) / 1000;
603 static u16 temp_to_u16_adt7461(struct lm90_data *data, long val)
605 if (data->flags & LM90_FLAG_ADT7461_EXT) {
610 return (val + 64000 + 125) / 250 * 64;
616 return (val + 125) / 250 * 64;
624 static ssize_t show_temp8(struct device *dev, struct device_attribute *devattr,
627 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
628 struct lm90_data *data = lm90_update_device(dev);
631 if (data->kind == adt7461)
632 temp = temp_from_u8_adt7461(data, data->temp8[attr->index]);
633 else if (data->kind == max6646)
634 temp = temp_from_u8(data->temp8[attr->index]);
636 temp = temp_from_s8(data->temp8[attr->index]);
638 /* +16 degrees offset for temp2 for the LM99 */
639 if (data->kind == lm99 && attr->index == 3)
642 return sprintf(buf, "%d\n", temp);
645 static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr,
646 const char *buf, size_t count)
648 static const u8 reg[8] = {
649 LM90_REG_W_LOCAL_LOW,
650 LM90_REG_W_LOCAL_HIGH,
651 LM90_REG_W_LOCAL_CRIT,
652 LM90_REG_W_REMOTE_CRIT,
653 MAX6659_REG_W_LOCAL_EMERG,
654 MAX6659_REG_W_REMOTE_EMERG,
655 LM90_REG_W_REMOTE_CRIT,
656 MAX6659_REG_W_REMOTE_EMERG,
659 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
660 struct i2c_client *client = to_i2c_client(dev);
661 struct lm90_data *data = i2c_get_clientdata(client);
662 int nr = attr->index;
666 err = strict_strtol(buf, 10, &val);
670 /* +16 degrees offset for temp2 for the LM99 */
671 if (data->kind == lm99 && attr->index == 3)
674 mutex_lock(&data->update_lock);
675 if (data->kind == adt7461)
676 data->temp8[nr] = temp_to_u8_adt7461(data, val);
677 else if (data->kind == max6646)
678 data->temp8[nr] = temp_to_u8(val);
680 data->temp8[nr] = temp_to_s8(val);
682 lm90_select_remote_channel(client, data, nr >= 6);
683 i2c_smbus_write_byte_data(client, reg[nr], data->temp8[nr]);
684 lm90_select_remote_channel(client, data, 0);
686 mutex_unlock(&data->update_lock);
690 static ssize_t show_temp11(struct device *dev, struct device_attribute *devattr,
693 struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr);
694 struct lm90_data *data = lm90_update_device(dev);
697 if (data->kind == adt7461)
698 temp = temp_from_u16_adt7461(data, data->temp11[attr->index]);
699 else if (data->kind == max6646)
700 temp = temp_from_u16(data->temp11[attr->index]);
702 temp = temp_from_s16(data->temp11[attr->index]);
704 /* +16 degrees offset for temp2 for the LM99 */
705 if (data->kind == lm99 && attr->index <= 2)
708 return sprintf(buf, "%d\n", temp);
711 static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
712 const char *buf, size_t count)
719 { LM90_REG_W_REMOTE_LOWH, LM90_REG_W_REMOTE_LOWL, 0 },
720 { LM90_REG_W_REMOTE_HIGHH, LM90_REG_W_REMOTE_HIGHL, 0 },
721 { LM90_REG_W_REMOTE_OFFSH, LM90_REG_W_REMOTE_OFFSL, 0 },
722 { LM90_REG_W_REMOTE_LOWH, LM90_REG_W_REMOTE_LOWL, 1 },
723 { LM90_REG_W_REMOTE_HIGHH, LM90_REG_W_REMOTE_HIGHL, 1 }
726 struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr);
727 struct i2c_client *client = to_i2c_client(dev);
728 struct lm90_data *data = i2c_get_clientdata(client);
730 int index = attr->index;
734 err = strict_strtol(buf, 10, &val);
738 /* +16 degrees offset for temp2 for the LM99 */
739 if (data->kind == lm99 && index <= 2)
742 mutex_lock(&data->update_lock);
743 if (data->kind == adt7461)
744 data->temp11[index] = temp_to_u16_adt7461(data, val);
745 else if (data->kind == max6646)
746 data->temp11[index] = temp_to_u8(val) << 8;
747 else if (data->flags & LM90_HAVE_REM_LIMIT_EXT)
748 data->temp11[index] = temp_to_s16(val);
750 data->temp11[index] = temp_to_s8(val) << 8;
752 lm90_select_remote_channel(client, data, reg[nr].channel);
753 i2c_smbus_write_byte_data(client, reg[nr].high,
754 data->temp11[index] >> 8);
755 if (data->flags & LM90_HAVE_REM_LIMIT_EXT)
756 i2c_smbus_write_byte_data(client, reg[nr].low,
757 data->temp11[index] & 0xff);
758 lm90_select_remote_channel(client, data, 0);
760 mutex_unlock(&data->update_lock);
764 static ssize_t show_temphyst(struct device *dev,
765 struct device_attribute *devattr,
768 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
769 struct lm90_data *data = lm90_update_device(dev);
772 if (data->kind == adt7461)
773 temp = temp_from_u8_adt7461(data, data->temp8[attr->index]);
774 else if (data->kind == max6646)
775 temp = temp_from_u8(data->temp8[attr->index]);
777 temp = temp_from_s8(data->temp8[attr->index]);
779 /* +16 degrees offset for temp2 for the LM99 */
780 if (data->kind == lm99 && attr->index == 3)
783 return sprintf(buf, "%d\n", temp - temp_from_s8(data->temp_hyst));
786 static ssize_t set_temphyst(struct device *dev, struct device_attribute *dummy,
787 const char *buf, size_t count)
789 struct i2c_client *client = to_i2c_client(dev);
790 struct lm90_data *data = i2c_get_clientdata(client);
795 err = strict_strtol(buf, 10, &val);
799 mutex_lock(&data->update_lock);
800 if (data->kind == adt7461)
801 temp = temp_from_u8_adt7461(data, data->temp8[2]);
802 else if (data->kind == max6646)
803 temp = temp_from_u8(data->temp8[2]);
805 temp = temp_from_s8(data->temp8[2]);
807 data->temp_hyst = hyst_to_reg(temp - val);
808 i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST,
810 mutex_unlock(&data->update_lock);
814 static ssize_t show_alarms(struct device *dev, struct device_attribute *dummy,
817 struct lm90_data *data = lm90_update_device(dev);
818 return sprintf(buf, "%d\n", data->alarms);
821 static ssize_t show_alarm(struct device *dev, struct device_attribute
824 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
825 struct lm90_data *data = lm90_update_device(dev);
826 int bitnr = attr->index;
828 return sprintf(buf, "%d\n", (data->alarms >> bitnr) & 1);
831 static SENSOR_DEVICE_ATTR_2(temp1_input, S_IRUGO, show_temp11, NULL, 0, 4);
832 static SENSOR_DEVICE_ATTR_2(temp2_input, S_IRUGO, show_temp11, NULL, 0, 0);
833 static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp8,
835 static SENSOR_DEVICE_ATTR_2(temp2_min, S_IWUSR | S_IRUGO, show_temp11,
837 static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp8,
839 static SENSOR_DEVICE_ATTR_2(temp2_max, S_IWUSR | S_IRUGO, show_temp11,
841 static SENSOR_DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp8,
843 static SENSOR_DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_temp8,
845 static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temphyst,
847 static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temphyst, NULL, 3);
848 static SENSOR_DEVICE_ATTR_2(temp2_offset, S_IWUSR | S_IRUGO, show_temp11,
851 /* Individual alarm files */
852 static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 0);
853 static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL, 1);
854 static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 2);
855 static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, show_alarm, NULL, 3);
856 static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 4);
857 static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, 5);
858 static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6);
859 /* Raw alarm file for compatibility */
860 static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
862 static struct attribute *lm90_attributes[] = {
863 &sensor_dev_attr_temp1_input.dev_attr.attr,
864 &sensor_dev_attr_temp2_input.dev_attr.attr,
865 &sensor_dev_attr_temp1_min.dev_attr.attr,
866 &sensor_dev_attr_temp2_min.dev_attr.attr,
867 &sensor_dev_attr_temp1_max.dev_attr.attr,
868 &sensor_dev_attr_temp2_max.dev_attr.attr,
869 &sensor_dev_attr_temp1_crit.dev_attr.attr,
870 &sensor_dev_attr_temp2_crit.dev_attr.attr,
871 &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr,
872 &sensor_dev_attr_temp2_crit_hyst.dev_attr.attr,
874 &sensor_dev_attr_temp1_crit_alarm.dev_attr.attr,
875 &sensor_dev_attr_temp2_crit_alarm.dev_attr.attr,
876 &sensor_dev_attr_temp2_fault.dev_attr.attr,
877 &sensor_dev_attr_temp2_min_alarm.dev_attr.attr,
878 &sensor_dev_attr_temp2_max_alarm.dev_attr.attr,
879 &sensor_dev_attr_temp1_min_alarm.dev_attr.attr,
880 &sensor_dev_attr_temp1_max_alarm.dev_attr.attr,
881 &dev_attr_alarms.attr,
885 static const struct attribute_group lm90_group = {
886 .attrs = lm90_attributes,
890 * Additional attributes for devices with emergency sensors
892 static SENSOR_DEVICE_ATTR(temp1_emergency, S_IWUSR | S_IRUGO, show_temp8,
894 static SENSOR_DEVICE_ATTR(temp2_emergency, S_IWUSR | S_IRUGO, show_temp8,
896 static SENSOR_DEVICE_ATTR(temp1_emergency_hyst, S_IRUGO, show_temphyst,
898 static SENSOR_DEVICE_ATTR(temp2_emergency_hyst, S_IRUGO, show_temphyst,
901 static struct attribute *lm90_emergency_attributes[] = {
902 &sensor_dev_attr_temp1_emergency.dev_attr.attr,
903 &sensor_dev_attr_temp2_emergency.dev_attr.attr,
904 &sensor_dev_attr_temp1_emergency_hyst.dev_attr.attr,
905 &sensor_dev_attr_temp2_emergency_hyst.dev_attr.attr,
909 static const struct attribute_group lm90_emergency_group = {
910 .attrs = lm90_emergency_attributes,
913 static SENSOR_DEVICE_ATTR(temp1_emergency_alarm, S_IRUGO, show_alarm, NULL, 15);
914 static SENSOR_DEVICE_ATTR(temp2_emergency_alarm, S_IRUGO, show_alarm, NULL, 13);
916 static struct attribute *lm90_emergency_alarm_attributes[] = {
917 &sensor_dev_attr_temp1_emergency_alarm.dev_attr.attr,
918 &sensor_dev_attr_temp2_emergency_alarm.dev_attr.attr,
922 static const struct attribute_group lm90_emergency_alarm_group = {
923 .attrs = lm90_emergency_alarm_attributes,
927 * Additional attributes for devices with 3 temperature sensors
929 static SENSOR_DEVICE_ATTR_2(temp3_input, S_IRUGO, show_temp11, NULL, 0, 5);
930 static SENSOR_DEVICE_ATTR_2(temp3_min, S_IWUSR | S_IRUGO, show_temp11,
932 static SENSOR_DEVICE_ATTR_2(temp3_max, S_IWUSR | S_IRUGO, show_temp11,
934 static SENSOR_DEVICE_ATTR(temp3_crit, S_IWUSR | S_IRUGO, show_temp8,
936 static SENSOR_DEVICE_ATTR(temp3_crit_hyst, S_IRUGO, show_temphyst, NULL, 6);
937 static SENSOR_DEVICE_ATTR(temp3_emergency, S_IWUSR | S_IRUGO, show_temp8,
939 static SENSOR_DEVICE_ATTR(temp3_emergency_hyst, S_IRUGO, show_temphyst,
942 static SENSOR_DEVICE_ATTR(temp3_crit_alarm, S_IRUGO, show_alarm, NULL, 9);
943 static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_alarm, NULL, 10);
944 static SENSOR_DEVICE_ATTR(temp3_min_alarm, S_IRUGO, show_alarm, NULL, 11);
945 static SENSOR_DEVICE_ATTR(temp3_max_alarm, S_IRUGO, show_alarm, NULL, 12);
946 static SENSOR_DEVICE_ATTR(temp3_emergency_alarm, S_IRUGO, show_alarm, NULL, 14);
948 static struct attribute *lm90_temp3_attributes[] = {
949 &sensor_dev_attr_temp3_input.dev_attr.attr,
950 &sensor_dev_attr_temp3_min.dev_attr.attr,
951 &sensor_dev_attr_temp3_max.dev_attr.attr,
952 &sensor_dev_attr_temp3_crit.dev_attr.attr,
953 &sensor_dev_attr_temp3_crit_hyst.dev_attr.attr,
954 &sensor_dev_attr_temp3_emergency.dev_attr.attr,
955 &sensor_dev_attr_temp3_emergency_hyst.dev_attr.attr,
957 &sensor_dev_attr_temp3_fault.dev_attr.attr,
958 &sensor_dev_attr_temp3_min_alarm.dev_attr.attr,
959 &sensor_dev_attr_temp3_max_alarm.dev_attr.attr,
960 &sensor_dev_attr_temp3_crit_alarm.dev_attr.attr,
961 &sensor_dev_attr_temp3_emergency_alarm.dev_attr.attr,
965 static const struct attribute_group lm90_temp3_group = {
966 .attrs = lm90_temp3_attributes,
969 /* pec used for ADM1032 only */
970 static ssize_t show_pec(struct device *dev, struct device_attribute *dummy,
973 struct i2c_client *client = to_i2c_client(dev);
974 return sprintf(buf, "%d\n", !!(client->flags & I2C_CLIENT_PEC));
977 static ssize_t set_pec(struct device *dev, struct device_attribute *dummy,
978 const char *buf, size_t count)
980 struct i2c_client *client = to_i2c_client(dev);
984 err = strict_strtol(buf, 10, &val);
990 client->flags &= ~I2C_CLIENT_PEC;
993 client->flags |= I2C_CLIENT_PEC;
1002 static DEVICE_ATTR(pec, S_IWUSR | S_IRUGO, show_pec, set_pec);
1008 /* Return 0 if detection is successful, -ENODEV otherwise */
1009 static int lm90_detect(struct i2c_client *new_client,
1010 struct i2c_board_info *info)
1012 struct i2c_adapter *adapter = new_client->adapter;
1013 int address = new_client->addr;
1014 const char *name = NULL;
1015 int man_id, chip_id, reg_config1, reg_convrate;
1017 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
1020 /* detection and identification */
1021 if ((man_id = i2c_smbus_read_byte_data(new_client,
1022 LM90_REG_R_MAN_ID)) < 0
1023 || (chip_id = i2c_smbus_read_byte_data(new_client,
1024 LM90_REG_R_CHIP_ID)) < 0
1025 || (reg_config1 = i2c_smbus_read_byte_data(new_client,
1026 LM90_REG_R_CONFIG1)) < 0
1027 || (reg_convrate = i2c_smbus_read_byte_data(new_client,
1028 LM90_REG_R_CONVRATE)) < 0)
1031 if ((address == 0x4C || address == 0x4D)
1032 && man_id == 0x01) { /* National Semiconductor */
1035 reg_config2 = i2c_smbus_read_byte_data(new_client,
1036 LM90_REG_R_CONFIG2);
1037 if (reg_config2 < 0)
1040 if ((reg_config1 & 0x2A) == 0x00
1041 && (reg_config2 & 0xF8) == 0x00
1042 && reg_convrate <= 0x09) {
1044 && (chip_id & 0xF0) == 0x20) { /* LM90 */
1047 if ((chip_id & 0xF0) == 0x30) { /* LM89/LM99 */
1049 dev_info(&adapter->dev,
1050 "Assuming LM99 chip at 0x%02x\n",
1052 dev_info(&adapter->dev,
1053 "If it is an LM89, instantiate it "
1054 "with the new_device sysfs "
1058 && (chip_id & 0xF0) == 0x10) { /* LM86 */
1063 if ((address == 0x4C || address == 0x4D)
1064 && man_id == 0x41) { /* Analog Devices */
1065 if ((chip_id & 0xF0) == 0x40 /* ADM1032 */
1066 && (reg_config1 & 0x3F) == 0x00
1067 && reg_convrate <= 0x0A) {
1069 /* The ADM1032 supports PEC, but only if combined
1070 transactions are not used. */
1071 if (i2c_check_functionality(adapter,
1072 I2C_FUNC_SMBUS_BYTE))
1073 info->flags |= I2C_CLIENT_PEC;
1075 if (chip_id == 0x51 /* ADT7461 */
1076 && (reg_config1 & 0x1B) == 0x00
1077 && reg_convrate <= 0x0A) {
1081 if (man_id == 0x4D) { /* Maxim */
1082 int reg_emerg, reg_emerg2, reg_status2;
1085 * We read MAX6659_REG_R_REMOTE_EMERG twice, and re-read
1086 * LM90_REG_R_MAN_ID in between. If MAX6659_REG_R_REMOTE_EMERG
1087 * exists, both readings will reflect the same value. Otherwise,
1088 * the readings will be different.
1090 if ((reg_emerg = i2c_smbus_read_byte_data(new_client,
1091 MAX6659_REG_R_REMOTE_EMERG)) < 0
1092 || i2c_smbus_read_byte_data(new_client, LM90_REG_R_MAN_ID) < 0
1093 || (reg_emerg2 = i2c_smbus_read_byte_data(new_client,
1094 MAX6659_REG_R_REMOTE_EMERG)) < 0
1095 || (reg_status2 = i2c_smbus_read_byte_data(new_client,
1096 MAX6696_REG_R_STATUS2)) < 0)
1100 * The MAX6657, MAX6658 and MAX6659 do NOT have a chip_id
1101 * register. Reading from that address will return the last
1102 * read value, which in our case is those of the man_id
1103 * register. Likewise, the config1 register seems to lack a
1104 * low nibble, so the value will be those of the previous
1105 * read, so in our case those of the man_id register.
1106 * MAX6659 has a third set of upper temperature limit registers.
1107 * Those registers also return values on MAX6657 and MAX6658,
1108 * thus the only way to detect MAX6659 is by its address.
1109 * For this reason it will be mis-detected as MAX6657 if its
1112 if (chip_id == man_id
1113 && (address == 0x4C || address == 0x4D || address == 0x4E)
1114 && (reg_config1 & 0x1F) == (man_id & 0x0F)
1115 && reg_convrate <= 0x09) {
1116 if (address == 0x4C)
1122 * Even though MAX6695 and MAX6696 do not have a chip ID
1123 * register, reading it returns 0x01. Bit 4 of the config1
1124 * register is unused and should return zero when read. Bit 0 of
1125 * the status2 register is unused and should return zero when
1128 * MAX6695 and MAX6696 have an additional set of temperature
1129 * limit registers. We can detect those chips by checking if
1130 * one of those registers exists.
1133 && (reg_config1 & 0x10) == 0x00
1134 && (reg_status2 & 0x01) == 0x00
1135 && reg_emerg == reg_emerg2
1136 && reg_convrate <= 0x07) {
1140 * The chip_id register of the MAX6680 and MAX6681 holds the
1141 * revision of the chip. The lowest bit of the config1 register
1142 * is unused and should return zero when read, so should the
1143 * second to last bit of config1 (software reset).
1146 && (reg_config1 & 0x03) == 0x00
1147 && reg_convrate <= 0x07) {
1151 * The chip_id register of the MAX6646/6647/6649 holds the
1152 * revision of the chip. The lowest 6 bits of the config1
1153 * register are unused and should return zero when read.
1156 && (reg_config1 & 0x3f) == 0x00
1157 && reg_convrate <= 0x07) {
1162 && man_id == 0x5C) { /* Winbond/Nuvoton */
1163 if ((chip_id & 0xFE) == 0x10 /* W83L771AWG/ASG */
1164 && (reg_config1 & 0x2A) == 0x00
1165 && reg_convrate <= 0x08) {
1170 if (!name) { /* identification failed */
1171 dev_dbg(&adapter->dev,
1172 "Unsupported chip at 0x%02x (man_id=0x%02X, "
1173 "chip_id=0x%02X)\n", address, man_id, chip_id);
1177 strlcpy(info->type, name, I2C_NAME_SIZE);
1182 static void lm90_remove_files(struct i2c_client *client, struct lm90_data *data)
1184 if (data->flags & LM90_HAVE_TEMP3)
1185 sysfs_remove_group(&client->dev.kobj, &lm90_temp3_group);
1186 if (data->flags & LM90_HAVE_EMERGENCY_ALARM)
1187 sysfs_remove_group(&client->dev.kobj,
1188 &lm90_emergency_alarm_group);
1189 if (data->flags & LM90_HAVE_EMERGENCY)
1190 sysfs_remove_group(&client->dev.kobj,
1191 &lm90_emergency_group);
1192 if (data->flags & LM90_HAVE_OFFSET)
1193 device_remove_file(&client->dev,
1194 &sensor_dev_attr_temp2_offset.dev_attr);
1195 device_remove_file(&client->dev, &dev_attr_pec);
1196 sysfs_remove_group(&client->dev.kobj, &lm90_group);
1199 static void lm90_init_client(struct i2c_client *client)
1202 struct lm90_data *data = i2c_get_clientdata(client);
1205 * Start the conversions.
1207 i2c_smbus_write_byte_data(client, LM90_REG_W_CONVRATE,
1209 if (lm90_read_reg(client, LM90_REG_R_CONFIG1, &config) < 0) {
1210 dev_warn(&client->dev, "Initialization failed!\n");
1213 data->config_orig = config;
1215 /* Check Temperature Range Select */
1216 if (data->kind == adt7461) {
1218 data->flags |= LM90_FLAG_ADT7461_EXT;
1222 * Put MAX6680/MAX8881 into extended resolution (bit 0x10,
1223 * 0.125 degree resolution) and range (0x08, extend range
1224 * to -64 degree) mode for the remote temperature sensor.
1226 if (data->kind == max6680)
1230 * Select external channel 0 for max6695/96
1232 if (data->kind == max6696)
1235 config &= 0xBF; /* run */
1236 if (config != data->config_orig) /* Only write if changed */
1237 i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, config);
1240 static int lm90_probe(struct i2c_client *new_client,
1241 const struct i2c_device_id *id)
1243 struct i2c_adapter *adapter = to_i2c_adapter(new_client->dev.parent);
1244 struct lm90_data *data;
1247 data = kzalloc(sizeof(struct lm90_data), GFP_KERNEL);
1252 i2c_set_clientdata(new_client, data);
1253 mutex_init(&data->update_lock);
1255 /* Set the device type */
1256 data->kind = id->driver_data;
1257 if (data->kind == adm1032) {
1258 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE))
1259 new_client->flags &= ~I2C_CLIENT_PEC;
1262 /* Different devices have different alarm bits triggering the
1264 data->alert_alarms = lm90_params[data->kind].alert_alarms;
1266 /* Set chip capabilities */
1267 data->flags = lm90_params[data->kind].flags;
1269 /* Initialize the LM90 chip */
1270 lm90_init_client(new_client);
1272 /* Register sysfs hooks */
1273 err = sysfs_create_group(&new_client->dev.kobj, &lm90_group);
1276 if (new_client->flags & I2C_CLIENT_PEC) {
1277 err = device_create_file(&new_client->dev, &dev_attr_pec);
1279 goto exit_remove_files;
1281 if (data->flags & LM90_HAVE_OFFSET) {
1282 err = device_create_file(&new_client->dev,
1283 &sensor_dev_attr_temp2_offset.dev_attr);
1285 goto exit_remove_files;
1287 if (data->flags & LM90_HAVE_EMERGENCY) {
1288 err = sysfs_create_group(&new_client->dev.kobj,
1289 &lm90_emergency_group);
1291 goto exit_remove_files;
1293 if (data->flags & LM90_HAVE_EMERGENCY_ALARM) {
1294 err = sysfs_create_group(&new_client->dev.kobj,
1295 &lm90_emergency_alarm_group);
1297 goto exit_remove_files;
1299 if (data->flags & LM90_HAVE_TEMP3) {
1300 err = sysfs_create_group(&new_client->dev.kobj,
1303 goto exit_remove_files;
1306 data->hwmon_dev = hwmon_device_register(&new_client->dev);
1307 if (IS_ERR(data->hwmon_dev)) {
1308 err = PTR_ERR(data->hwmon_dev);
1309 goto exit_remove_files;
1315 lm90_remove_files(new_client, data);
1322 static int lm90_remove(struct i2c_client *client)
1324 struct lm90_data *data = i2c_get_clientdata(client);
1326 hwmon_device_unregister(data->hwmon_dev);
1327 lm90_remove_files(client, data);
1329 /* Restore initial configuration */
1330 i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
1337 static void lm90_alert(struct i2c_client *client, unsigned int flag)
1339 struct lm90_data *data = i2c_get_clientdata(client);
1340 u8 config, alarms, alarms2 = 0;
1342 lm90_read_reg(client, LM90_REG_R_STATUS, &alarms);
1344 if (data->kind == max6696)
1345 lm90_read_reg(client, MAX6696_REG_R_STATUS2, &alarms2);
1347 if ((alarms & 0x7f) == 0 && (alarms2 & 0xfe) == 0) {
1348 dev_info(&client->dev, "Everything OK\n");
1351 dev_warn(&client->dev,
1352 "temp%d out of range, please check!\n", 1);
1354 dev_warn(&client->dev,
1355 "temp%d out of range, please check!\n", 2);
1357 dev_warn(&client->dev,
1358 "temp%d diode open, please check!\n", 2);
1361 dev_warn(&client->dev,
1362 "temp%d out of range, please check!\n", 3);
1364 /* Disable ALERT# output, because these chips don't implement
1365 SMBus alert correctly; they should only hold the alert line
1367 if ((data->flags & LM90_HAVE_BROKEN_ALERT)
1368 && (alarms & data->alert_alarms)) {
1369 dev_dbg(&client->dev, "Disabling ALERT#\n");
1370 lm90_read_reg(client, LM90_REG_R_CONFIG1, &config);
1371 i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
1377 static struct i2c_driver lm90_driver = {
1378 .class = I2C_CLASS_HWMON,
1382 .probe = lm90_probe,
1383 .remove = lm90_remove,
1384 .alert = lm90_alert,
1385 .id_table = lm90_id,
1386 .detect = lm90_detect,
1387 .address_list = normal_i2c,
1390 static int __init sensors_lm90_init(void)
1392 return i2c_add_driver(&lm90_driver);
1395 static void __exit sensors_lm90_exit(void)
1397 i2c_del_driver(&lm90_driver);
1400 MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>");
1401 MODULE_DESCRIPTION("LM90/ADM1032 driver");
1402 MODULE_LICENSE("GPL");
1404 module_init(sensors_lm90_init);
1405 module_exit(sensors_lm90_exit);