Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * lm90.c - Part of lm_sensors, Linux kernel modules for hardware |
| 3 | * monitoring |
Jean Delvare | 6388a38 | 2008-10-17 17:51:09 +0200 | [diff] [blame] | 4 | * Copyright (C) 2003-2008 Jean Delvare <khali@linux-fr.org> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * |
| 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 |
Jean Delvare | a874a10 | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 9 | * temperature) and a 3-4 deg accuracy. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * |
| 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. The |
| 16 | * driver doesn't handle it since it can be done easily in user-space. |
Steven Cole | 44bbe87 | 2005-05-03 18:21:25 -0600 | [diff] [blame] | 17 | * Note that there is no way to differentiate between both chips. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | * |
| 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. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | * |
| 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 |
Jean Delvare | a874a10 | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 25 | * that are not handled by this driver. Among others, it has a higher |
| 26 | * accuracy than the LM90, much like the LM86 does. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | * |
| 28 | * This driver also supports the MAX6657, MAX6658 and MAX6659 sensor |
Jean Delvare | a874a10 | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 29 | * chips made by Maxim. These chips are similar to the LM86. |
Steven Cole | 44bbe87 | 2005-05-03 18:21:25 -0600 | [diff] [blame] | 30 | * Note that there is no easy way to differentiate between the three |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | * variants. The extra address and features of the MAX6659 are not |
Jean Delvare | 69f2f96 | 2007-09-05 14:15:37 +0200 | [diff] [blame] | 32 | * supported by this driver. These chips lack the remote temperature |
| 33 | * offset feature. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | * |
Rainer Birkenmaier | 32c82a9 | 2007-06-09 10:11:16 -0400 | [diff] [blame] | 35 | * This driver also supports the MAX6680 and MAX6681, two other sensor |
| 36 | * chips made by Maxim. These are quite similar to the other Maxim |
Jean Delvare | a874a10 | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 37 | * chips. The MAX6680 and MAX6681 only differ in the pinout so they can |
| 38 | * be treated identically. |
Rainer Birkenmaier | 32c82a9 | 2007-06-09 10:11:16 -0400 | [diff] [blame] | 39 | * |
Nate Case | 23b2d47 | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 40 | * This driver also supports the ADT7461 chip from Analog Devices. |
| 41 | * It's supported in both compatibility and extended mode. It is mostly |
| 42 | * compatible with LM90 except for a data format difference for the |
| 43 | * temperature value registers. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | * |
| 45 | * Since the LM90 was the first chipset supported by this driver, most |
| 46 | * comments will refer to this chipset, but are actually general and |
| 47 | * concern all supported chipsets, unless mentioned otherwise. |
| 48 | * |
| 49 | * This program is free software; you can redistribute it and/or modify |
| 50 | * it under the terms of the GNU General Public License as published by |
| 51 | * the Free Software Foundation; either version 2 of the License, or |
| 52 | * (at your option) any later version. |
| 53 | * |
| 54 | * This program is distributed in the hope that it will be useful, |
| 55 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 56 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 57 | * GNU General Public License for more details. |
| 58 | * |
| 59 | * You should have received a copy of the GNU General Public License |
| 60 | * along with this program; if not, write to the Free Software |
| 61 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 62 | */ |
| 63 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | #include <linux/module.h> |
| 65 | #include <linux/init.h> |
| 66 | #include <linux/slab.h> |
| 67 | #include <linux/jiffies.h> |
| 68 | #include <linux/i2c.h> |
Jean Delvare | 10c08f8 | 2005-06-06 19:34:45 +0200 | [diff] [blame] | 69 | #include <linux/hwmon-sysfs.h> |
Mark M. Hoffman | 943b083 | 2005-07-15 21:39:18 -0400 | [diff] [blame] | 70 | #include <linux/hwmon.h> |
| 71 | #include <linux/err.h> |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 72 | #include <linux/mutex.h> |
Jean Delvare | 0e39e01 | 2006-09-24 21:16:40 +0200 | [diff] [blame] | 73 | #include <linux/sysfs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | |
| 75 | /* |
| 76 | * Addresses to scan |
| 77 | * Address is fully defined internally and cannot be changed except for |
Rainer Birkenmaier | 32c82a9 | 2007-06-09 10:11:16 -0400 | [diff] [blame] | 78 | * MAX6659, MAX6680 and MAX6681. |
Jean Delvare | 90209b4 | 2005-10-26 22:20:21 +0200 | [diff] [blame] | 79 | * LM86, LM89, LM90, LM99, ADM1032, ADM1032-1, ADT7461, MAX6657 and MAX6658 |
| 80 | * have address 0x4c. |
| 81 | * ADM1032-2, ADT7461-2, LM89-1, and LM99-1 have address 0x4d. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | * MAX6659 can have address 0x4c, 0x4d or 0x4e (unsupported). |
Rainer Birkenmaier | 32c82a9 | 2007-06-09 10:11:16 -0400 | [diff] [blame] | 83 | * MAX6680 and MAX6681 can have address 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, |
| 84 | * 0x4c, 0x4d or 0x4e. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | */ |
| 86 | |
Mark M. Hoffman | 25e9c86 | 2008-02-17 22:28:03 -0500 | [diff] [blame] | 87 | static const unsigned short normal_i2c[] = { |
| 88 | 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e, I2C_CLIENT_END }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | |
| 90 | /* |
| 91 | * Insmod parameters |
| 92 | */ |
| 93 | |
Rainer Birkenmaier | 32c82a9 | 2007-06-09 10:11:16 -0400 | [diff] [blame] | 94 | I2C_CLIENT_INSMOD_7(lm90, adm1032, lm99, lm86, max6657, adt7461, max6680); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | |
| 96 | /* |
| 97 | * The LM90 registers |
| 98 | */ |
| 99 | |
| 100 | #define LM90_REG_R_MAN_ID 0xFE |
| 101 | #define LM90_REG_R_CHIP_ID 0xFF |
| 102 | #define LM90_REG_R_CONFIG1 0x03 |
| 103 | #define LM90_REG_W_CONFIG1 0x09 |
| 104 | #define LM90_REG_R_CONFIG2 0xBF |
| 105 | #define LM90_REG_W_CONFIG2 0xBF |
| 106 | #define LM90_REG_R_CONVRATE 0x04 |
| 107 | #define LM90_REG_W_CONVRATE 0x0A |
| 108 | #define LM90_REG_R_STATUS 0x02 |
| 109 | #define LM90_REG_R_LOCAL_TEMP 0x00 |
| 110 | #define LM90_REG_R_LOCAL_HIGH 0x05 |
| 111 | #define LM90_REG_W_LOCAL_HIGH 0x0B |
| 112 | #define LM90_REG_R_LOCAL_LOW 0x06 |
| 113 | #define LM90_REG_W_LOCAL_LOW 0x0C |
| 114 | #define LM90_REG_R_LOCAL_CRIT 0x20 |
| 115 | #define LM90_REG_W_LOCAL_CRIT 0x20 |
| 116 | #define LM90_REG_R_REMOTE_TEMPH 0x01 |
| 117 | #define LM90_REG_R_REMOTE_TEMPL 0x10 |
| 118 | #define LM90_REG_R_REMOTE_OFFSH 0x11 |
| 119 | #define LM90_REG_W_REMOTE_OFFSH 0x11 |
| 120 | #define LM90_REG_R_REMOTE_OFFSL 0x12 |
| 121 | #define LM90_REG_W_REMOTE_OFFSL 0x12 |
| 122 | #define LM90_REG_R_REMOTE_HIGHH 0x07 |
| 123 | #define LM90_REG_W_REMOTE_HIGHH 0x0D |
| 124 | #define LM90_REG_R_REMOTE_HIGHL 0x13 |
| 125 | #define LM90_REG_W_REMOTE_HIGHL 0x13 |
| 126 | #define LM90_REG_R_REMOTE_LOWH 0x08 |
| 127 | #define LM90_REG_W_REMOTE_LOWH 0x0E |
| 128 | #define LM90_REG_R_REMOTE_LOWL 0x14 |
| 129 | #define LM90_REG_W_REMOTE_LOWL 0x14 |
| 130 | #define LM90_REG_R_REMOTE_CRIT 0x19 |
| 131 | #define LM90_REG_W_REMOTE_CRIT 0x19 |
| 132 | #define LM90_REG_R_TCRIT_HYST 0x21 |
| 133 | #define LM90_REG_W_TCRIT_HYST 0x21 |
| 134 | |
Jean Delvare | f65e170 | 2008-10-17 17:51:09 +0200 | [diff] [blame] | 135 | /* MAX6657-specific registers */ |
| 136 | |
| 137 | #define MAX6657_REG_R_LOCAL_TEMPL 0x11 |
| 138 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | /* |
Nate Case | 23b2d47 | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 140 | * Device flags |
| 141 | */ |
| 142 | #define LM90_FLAG_ADT7461_EXT 0x01 /* ADT7461 extended mode */ |
| 143 | |
| 144 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | * Functions declaration |
| 146 | */ |
| 147 | |
Jean Delvare | 9b0e852 | 2008-07-16 19:30:15 +0200 | [diff] [blame] | 148 | static int lm90_detect(struct i2c_client *client, int kind, |
| 149 | struct i2c_board_info *info); |
| 150 | static int lm90_probe(struct i2c_client *client, |
| 151 | const struct i2c_device_id *id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | static void lm90_init_client(struct i2c_client *client); |
Jean Delvare | 9b0e852 | 2008-07-16 19:30:15 +0200 | [diff] [blame] | 153 | static int lm90_remove(struct i2c_client *client); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | static struct lm90_data *lm90_update_device(struct device *dev); |
| 155 | |
| 156 | /* |
| 157 | * Driver data (common to all clients) |
| 158 | */ |
| 159 | |
Jean Delvare | 9b0e852 | 2008-07-16 19:30:15 +0200 | [diff] [blame] | 160 | static const struct i2c_device_id lm90_id[] = { |
| 161 | { "adm1032", adm1032 }, |
| 162 | { "adt7461", adt7461 }, |
| 163 | { "lm90", lm90 }, |
| 164 | { "lm86", lm86 }, |
| 165 | { "lm89", lm99 }, |
| 166 | { "lm99", lm99 }, /* Missing temperature offset */ |
| 167 | { "max6657", max6657 }, |
| 168 | { "max6658", max6657 }, |
| 169 | { "max6659", max6657 }, |
| 170 | { "max6680", max6680 }, |
| 171 | { "max6681", max6680 }, |
| 172 | { } |
| 173 | }; |
| 174 | MODULE_DEVICE_TABLE(i2c, lm90_id); |
| 175 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | static struct i2c_driver lm90_driver = { |
Jean Delvare | 9b0e852 | 2008-07-16 19:30:15 +0200 | [diff] [blame] | 177 | .class = I2C_CLASS_HWMON, |
Laurent Riffard | cdaf793 | 2005-11-26 20:37:41 +0100 | [diff] [blame] | 178 | .driver = { |
Laurent Riffard | cdaf793 | 2005-11-26 20:37:41 +0100 | [diff] [blame] | 179 | .name = "lm90", |
| 180 | }, |
Jean Delvare | 9b0e852 | 2008-07-16 19:30:15 +0200 | [diff] [blame] | 181 | .probe = lm90_probe, |
| 182 | .remove = lm90_remove, |
| 183 | .id_table = lm90_id, |
| 184 | .detect = lm90_detect, |
| 185 | .address_data = &addr_data, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | }; |
| 187 | |
| 188 | /* |
| 189 | * Client data (each client gets its own) |
| 190 | */ |
| 191 | |
| 192 | struct lm90_data { |
Tony Jones | 1beeffe | 2007-08-20 13:46:20 -0700 | [diff] [blame] | 193 | struct device *hwmon_dev; |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 194 | struct mutex update_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | char valid; /* zero until following fields are valid */ |
| 196 | unsigned long last_updated; /* in jiffies */ |
| 197 | int kind; |
Nate Case | 23b2d47 | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 198 | int flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | |
| 200 | /* registers values */ |
Jean Delvare | f65e170 | 2008-10-17 17:51:09 +0200 | [diff] [blame] | 201 | s8 temp8[4]; /* 0: local low limit |
| 202 | 1: local high limit |
| 203 | 2: local critical limit |
| 204 | 3: remote critical limit */ |
| 205 | s16 temp11[5]; /* 0: remote input |
Jean Delvare | 30d7394 | 2005-06-05 21:27:28 +0200 | [diff] [blame] | 206 | 1: remote low limit |
Jean Delvare | 69f2f96 | 2007-09-05 14:15:37 +0200 | [diff] [blame] | 207 | 2: remote high limit |
Jean Delvare | f65e170 | 2008-10-17 17:51:09 +0200 | [diff] [blame] | 208 | 3: remote offset (except max6657) |
| 209 | 4: local input */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | u8 temp_hyst; |
| 211 | u8 alarms; /* bitvector */ |
| 212 | }; |
| 213 | |
| 214 | /* |
Nate Case | cea50fe | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 215 | * Conversions |
| 216 | * For local temperatures and limits, critical limits and the hysteresis |
| 217 | * value, the LM90 uses signed 8-bit values with LSB = 1 degree Celsius. |
| 218 | * For remote temperatures and limits, it uses signed 11-bit values with |
| 219 | * LSB = 0.125 degree Celsius, left-justified in 16-bit registers. |
| 220 | */ |
| 221 | |
Ben Hutchings | 9d4d383 | 2008-10-17 17:51:10 +0200 | [diff] [blame^] | 222 | static inline int temp_from_s8(s8 val) |
Nate Case | cea50fe | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 223 | { |
| 224 | return val * 1000; |
| 225 | } |
| 226 | |
Ben Hutchings | 9d4d383 | 2008-10-17 17:51:10 +0200 | [diff] [blame^] | 227 | static inline int temp_from_s16(s16 val) |
Nate Case | cea50fe | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 228 | { |
| 229 | return val / 32 * 125; |
| 230 | } |
| 231 | |
Ben Hutchings | 9d4d383 | 2008-10-17 17:51:10 +0200 | [diff] [blame^] | 232 | static s8 temp_to_s8(long val) |
Nate Case | cea50fe | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 233 | { |
| 234 | if (val <= -128000) |
| 235 | return -128; |
| 236 | if (val >= 127000) |
| 237 | return 127; |
| 238 | if (val < 0) |
| 239 | return (val - 500) / 1000; |
| 240 | return (val + 500) / 1000; |
| 241 | } |
| 242 | |
Ben Hutchings | 9d4d383 | 2008-10-17 17:51:10 +0200 | [diff] [blame^] | 243 | static s16 temp_to_s16(long val) |
Nate Case | cea50fe | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 244 | { |
| 245 | if (val <= -128000) |
| 246 | return 0x8000; |
| 247 | if (val >= 127875) |
| 248 | return 0x7FE0; |
| 249 | if (val < 0) |
| 250 | return (val - 62) / 125 * 32; |
| 251 | return (val + 62) / 125 * 32; |
| 252 | } |
| 253 | |
| 254 | static u8 hyst_to_reg(long val) |
| 255 | { |
| 256 | if (val <= 0) |
| 257 | return 0; |
| 258 | if (val >= 30500) |
| 259 | return 31; |
| 260 | return (val + 500) / 1000; |
| 261 | } |
| 262 | |
| 263 | /* |
Nate Case | 23b2d47 | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 264 | * ADT7461 in compatibility mode is almost identical to LM90 except that |
| 265 | * attempts to write values that are outside the range 0 < temp < 127 are |
| 266 | * treated as the boundary value. |
| 267 | * |
| 268 | * ADT7461 in "extended mode" operation uses unsigned integers offset by |
| 269 | * 64 (e.g., 0 -> -64 degC). The range is restricted to -64..191 degC. |
Nate Case | cea50fe | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 270 | */ |
Ben Hutchings | 9d4d383 | 2008-10-17 17:51:10 +0200 | [diff] [blame^] | 271 | static inline int temp_from_u8_adt7461(struct lm90_data *data, u8 val) |
Nate Case | cea50fe | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 272 | { |
Nate Case | 23b2d47 | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 273 | if (data->flags & LM90_FLAG_ADT7461_EXT) |
| 274 | return (val - 64) * 1000; |
| 275 | else |
Ben Hutchings | 9d4d383 | 2008-10-17 17:51:10 +0200 | [diff] [blame^] | 276 | return temp_from_s8(val); |
Nate Case | cea50fe | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 277 | } |
| 278 | |
Ben Hutchings | 9d4d383 | 2008-10-17 17:51:10 +0200 | [diff] [blame^] | 279 | static inline int temp_from_u16_adt7461(struct lm90_data *data, u16 val) |
Nate Case | cea50fe | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 280 | { |
Nate Case | 23b2d47 | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 281 | if (data->flags & LM90_FLAG_ADT7461_EXT) |
| 282 | return (val - 0x4000) / 64 * 250; |
| 283 | else |
Ben Hutchings | 9d4d383 | 2008-10-17 17:51:10 +0200 | [diff] [blame^] | 284 | return temp_from_s16(val); |
Nate Case | 23b2d47 | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 285 | } |
| 286 | |
Ben Hutchings | 9d4d383 | 2008-10-17 17:51:10 +0200 | [diff] [blame^] | 287 | static u8 temp_to_u8_adt7461(struct lm90_data *data, long val) |
Nate Case | 23b2d47 | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 288 | { |
| 289 | if (data->flags & LM90_FLAG_ADT7461_EXT) { |
| 290 | if (val <= -64000) |
| 291 | return 0; |
| 292 | if (val >= 191000) |
| 293 | return 0xFF; |
| 294 | return (val + 500 + 64000) / 1000; |
| 295 | } else { |
| 296 | if (val <= 0) |
| 297 | return 0; |
| 298 | if (val >= 127000) |
| 299 | return 127; |
| 300 | return (val + 500) / 1000; |
| 301 | } |
| 302 | } |
| 303 | |
Ben Hutchings | 9d4d383 | 2008-10-17 17:51:10 +0200 | [diff] [blame^] | 304 | static u16 temp_to_u16_adt7461(struct lm90_data *data, long val) |
Nate Case | 23b2d47 | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 305 | { |
| 306 | if (data->flags & LM90_FLAG_ADT7461_EXT) { |
| 307 | if (val <= -64000) |
| 308 | return 0; |
| 309 | if (val >= 191750) |
| 310 | return 0xFFC0; |
| 311 | return (val + 64000 + 125) / 250 * 64; |
| 312 | } else { |
| 313 | if (val <= 0) |
| 314 | return 0; |
| 315 | if (val >= 127750) |
| 316 | return 0x7FC0; |
| 317 | return (val + 125) / 250 * 64; |
| 318 | } |
Nate Case | cea50fe | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | * Sysfs stuff |
| 323 | */ |
| 324 | |
Jean Delvare | 30d7394 | 2005-06-05 21:27:28 +0200 | [diff] [blame] | 325 | static ssize_t show_temp8(struct device *dev, struct device_attribute *devattr, |
| 326 | char *buf) |
| 327 | { |
| 328 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
| 329 | struct lm90_data *data = lm90_update_device(dev); |
Nate Case | 23b2d47 | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 330 | int temp; |
| 331 | |
| 332 | if (data->kind == adt7461) |
Ben Hutchings | 9d4d383 | 2008-10-17 17:51:10 +0200 | [diff] [blame^] | 333 | temp = temp_from_u8_adt7461(data, data->temp8[attr->index]); |
Nate Case | 23b2d47 | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 334 | else |
Ben Hutchings | 9d4d383 | 2008-10-17 17:51:10 +0200 | [diff] [blame^] | 335 | temp = temp_from_s8(data->temp8[attr->index]); |
Nate Case | 23b2d47 | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 336 | |
| 337 | return sprintf(buf, "%d\n", temp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | |
Jean Delvare | 30d7394 | 2005-06-05 21:27:28 +0200 | [diff] [blame] | 340 | static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr, |
| 341 | const char *buf, size_t count) |
| 342 | { |
| 343 | static const u8 reg[4] = { |
| 344 | LM90_REG_W_LOCAL_LOW, |
| 345 | LM90_REG_W_LOCAL_HIGH, |
| 346 | LM90_REG_W_LOCAL_CRIT, |
| 347 | LM90_REG_W_REMOTE_CRIT, |
| 348 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | |
Jean Delvare | 30d7394 | 2005-06-05 21:27:28 +0200 | [diff] [blame] | 350 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
| 351 | struct i2c_client *client = to_i2c_client(dev); |
| 352 | struct lm90_data *data = i2c_get_clientdata(client); |
| 353 | long val = simple_strtol(buf, NULL, 10); |
| 354 | int nr = attr->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 356 | mutex_lock(&data->update_lock); |
Jean Delvare | 30d7394 | 2005-06-05 21:27:28 +0200 | [diff] [blame] | 357 | if (data->kind == adt7461) |
Ben Hutchings | 9d4d383 | 2008-10-17 17:51:10 +0200 | [diff] [blame^] | 358 | data->temp8[nr] = temp_to_u8_adt7461(data, val); |
Jean Delvare | 30d7394 | 2005-06-05 21:27:28 +0200 | [diff] [blame] | 359 | else |
Ben Hutchings | 9d4d383 | 2008-10-17 17:51:10 +0200 | [diff] [blame^] | 360 | data->temp8[nr] = temp_to_s8(val); |
Jean Delvare | f65e170 | 2008-10-17 17:51:09 +0200 | [diff] [blame] | 361 | i2c_smbus_write_byte_data(client, reg[nr], data->temp8[nr]); |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 362 | mutex_unlock(&data->update_lock); |
Jean Delvare | 30d7394 | 2005-06-05 21:27:28 +0200 | [diff] [blame] | 363 | return count; |
| 364 | } |
| 365 | |
| 366 | static ssize_t show_temp11(struct device *dev, struct device_attribute *devattr, |
| 367 | char *buf) |
| 368 | { |
| 369 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
| 370 | struct lm90_data *data = lm90_update_device(dev); |
Nate Case | 23b2d47 | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 371 | int temp; |
| 372 | |
| 373 | if (data->kind == adt7461) |
Ben Hutchings | 9d4d383 | 2008-10-17 17:51:10 +0200 | [diff] [blame^] | 374 | temp = temp_from_u16_adt7461(data, data->temp11[attr->index]); |
Nate Case | 23b2d47 | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 375 | else |
Ben Hutchings | 9d4d383 | 2008-10-17 17:51:10 +0200 | [diff] [blame^] | 376 | temp = temp_from_s16(data->temp11[attr->index]); |
Nate Case | 23b2d47 | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 377 | |
| 378 | return sprintf(buf, "%d\n", temp); |
Jean Delvare | 30d7394 | 2005-06-05 21:27:28 +0200 | [diff] [blame] | 379 | } |
| 380 | |
| 381 | static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr, |
| 382 | const char *buf, size_t count) |
| 383 | { |
Jean Delvare | 69f2f96 | 2007-09-05 14:15:37 +0200 | [diff] [blame] | 384 | static const u8 reg[6] = { |
Jean Delvare | 30d7394 | 2005-06-05 21:27:28 +0200 | [diff] [blame] | 385 | LM90_REG_W_REMOTE_LOWH, |
| 386 | LM90_REG_W_REMOTE_LOWL, |
| 387 | LM90_REG_W_REMOTE_HIGHH, |
| 388 | LM90_REG_W_REMOTE_HIGHL, |
Jean Delvare | 69f2f96 | 2007-09-05 14:15:37 +0200 | [diff] [blame] | 389 | LM90_REG_W_REMOTE_OFFSH, |
| 390 | LM90_REG_W_REMOTE_OFFSL, |
Jean Delvare | 30d7394 | 2005-06-05 21:27:28 +0200 | [diff] [blame] | 391 | }; |
| 392 | |
| 393 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
| 394 | struct i2c_client *client = to_i2c_client(dev); |
| 395 | struct lm90_data *data = i2c_get_clientdata(client); |
| 396 | long val = simple_strtol(buf, NULL, 10); |
| 397 | int nr = attr->index; |
| 398 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 399 | mutex_lock(&data->update_lock); |
Jean Delvare | 30d7394 | 2005-06-05 21:27:28 +0200 | [diff] [blame] | 400 | if (data->kind == adt7461) |
Ben Hutchings | 9d4d383 | 2008-10-17 17:51:10 +0200 | [diff] [blame^] | 401 | data->temp11[nr] = temp_to_u16_adt7461(data, val); |
Jean Delvare | 5f502a8 | 2008-10-17 17:51:09 +0200 | [diff] [blame] | 402 | else if (data->kind == max6657 || data->kind == max6680) |
Ben Hutchings | 9d4d383 | 2008-10-17 17:51:10 +0200 | [diff] [blame^] | 403 | data->temp11[nr] = temp_to_s8(val) << 8; |
Jean Delvare | 30d7394 | 2005-06-05 21:27:28 +0200 | [diff] [blame] | 404 | else |
Ben Hutchings | 9d4d383 | 2008-10-17 17:51:10 +0200 | [diff] [blame^] | 405 | data->temp11[nr] = temp_to_s16(val); |
Jean Delvare | 5f502a8 | 2008-10-17 17:51:09 +0200 | [diff] [blame] | 406 | |
Jean Delvare | 30d7394 | 2005-06-05 21:27:28 +0200 | [diff] [blame] | 407 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2], |
| 408 | data->temp11[nr] >> 8); |
Jean Delvare | 5f502a8 | 2008-10-17 17:51:09 +0200 | [diff] [blame] | 409 | if (data->kind != max6657 && data->kind != max6680) |
| 410 | i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1], |
| 411 | data->temp11[nr] & 0xff); |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 412 | mutex_unlock(&data->update_lock); |
Jean Delvare | 30d7394 | 2005-06-05 21:27:28 +0200 | [diff] [blame] | 413 | return count; |
| 414 | } |
| 415 | |
| 416 | static ssize_t show_temphyst(struct device *dev, struct device_attribute *devattr, |
| 417 | char *buf) |
| 418 | { |
| 419 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
| 420 | struct lm90_data *data = lm90_update_device(dev); |
Nate Case | 23b2d47 | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 421 | int temp; |
| 422 | |
| 423 | if (data->kind == adt7461) |
Ben Hutchings | 9d4d383 | 2008-10-17 17:51:10 +0200 | [diff] [blame^] | 424 | temp = temp_from_u8_adt7461(data, data->temp8[attr->index]); |
Nate Case | 23b2d47 | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 425 | else |
Ben Hutchings | 9d4d383 | 2008-10-17 17:51:10 +0200 | [diff] [blame^] | 426 | temp = temp_from_s8(data->temp8[attr->index]); |
Nate Case | 23b2d47 | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 427 | |
Ben Hutchings | 9d4d383 | 2008-10-17 17:51:10 +0200 | [diff] [blame^] | 428 | return sprintf(buf, "%d\n", temp - temp_from_s8(data->temp_hyst)); |
Jean Delvare | 30d7394 | 2005-06-05 21:27:28 +0200 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | static ssize_t set_temphyst(struct device *dev, struct device_attribute *dummy, |
| 432 | const char *buf, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | { |
| 434 | struct i2c_client *client = to_i2c_client(dev); |
| 435 | struct lm90_data *data = i2c_get_clientdata(client); |
| 436 | long val = simple_strtol(buf, NULL, 10); |
| 437 | long hyst; |
| 438 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 439 | mutex_lock(&data->update_lock); |
Ben Hutchings | 9d4d383 | 2008-10-17 17:51:10 +0200 | [diff] [blame^] | 440 | hyst = temp_from_s8(data->temp8[2]) - val; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST, |
Nate Case | cea50fe | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 442 | hyst_to_reg(hyst)); |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 443 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 444 | return count; |
| 445 | } |
| 446 | |
Jean Delvare | 30d7394 | 2005-06-05 21:27:28 +0200 | [diff] [blame] | 447 | static ssize_t show_alarms(struct device *dev, struct device_attribute *dummy, |
| 448 | char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | { |
| 450 | struct lm90_data *data = lm90_update_device(dev); |
| 451 | return sprintf(buf, "%d\n", data->alarms); |
| 452 | } |
| 453 | |
Jean Delvare | 2d45771 | 2006-09-24 20:52:15 +0200 | [diff] [blame] | 454 | static ssize_t show_alarm(struct device *dev, struct device_attribute |
| 455 | *devattr, char *buf) |
| 456 | { |
| 457 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
| 458 | struct lm90_data *data = lm90_update_device(dev); |
| 459 | int bitnr = attr->index; |
| 460 | |
| 461 | return sprintf(buf, "%d\n", (data->alarms >> bitnr) & 1); |
| 462 | } |
| 463 | |
Jean Delvare | f65e170 | 2008-10-17 17:51:09 +0200 | [diff] [blame] | 464 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp11, NULL, 4); |
Jean Delvare | 30d7394 | 2005-06-05 21:27:28 +0200 | [diff] [blame] | 465 | static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp11, NULL, 0); |
| 466 | static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp8, |
Jean Delvare | f65e170 | 2008-10-17 17:51:09 +0200 | [diff] [blame] | 467 | set_temp8, 0); |
Jean Delvare | 30d7394 | 2005-06-05 21:27:28 +0200 | [diff] [blame] | 468 | static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp11, |
| 469 | set_temp11, 1); |
| 470 | static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp8, |
Jean Delvare | f65e170 | 2008-10-17 17:51:09 +0200 | [diff] [blame] | 471 | set_temp8, 1); |
Jean Delvare | 30d7394 | 2005-06-05 21:27:28 +0200 | [diff] [blame] | 472 | static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp11, |
| 473 | set_temp11, 2); |
| 474 | static SENSOR_DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp8, |
Jean Delvare | f65e170 | 2008-10-17 17:51:09 +0200 | [diff] [blame] | 475 | set_temp8, 2); |
Jean Delvare | 30d7394 | 2005-06-05 21:27:28 +0200 | [diff] [blame] | 476 | static SENSOR_DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_temp8, |
Jean Delvare | f65e170 | 2008-10-17 17:51:09 +0200 | [diff] [blame] | 477 | set_temp8, 3); |
Jean Delvare | 30d7394 | 2005-06-05 21:27:28 +0200 | [diff] [blame] | 478 | static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temphyst, |
Jean Delvare | f65e170 | 2008-10-17 17:51:09 +0200 | [diff] [blame] | 479 | set_temphyst, 2); |
| 480 | static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temphyst, NULL, 3); |
Jean Delvare | 69f2f96 | 2007-09-05 14:15:37 +0200 | [diff] [blame] | 481 | static SENSOR_DEVICE_ATTR(temp2_offset, S_IWUSR | S_IRUGO, show_temp11, |
| 482 | set_temp11, 3); |
Jean Delvare | 2d45771 | 2006-09-24 20:52:15 +0200 | [diff] [blame] | 483 | |
| 484 | /* Individual alarm files */ |
| 485 | static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 0); |
| 486 | static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL, 1); |
Jean Delvare | 7817a39 | 2007-06-09 10:11:16 -0400 | [diff] [blame] | 487 | static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 2); |
Jean Delvare | 2d45771 | 2006-09-24 20:52:15 +0200 | [diff] [blame] | 488 | static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, show_alarm, NULL, 3); |
| 489 | static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 4); |
| 490 | static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, 5); |
| 491 | static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6); |
| 492 | /* Raw alarm file for compatibility */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
| 494 | |
Jean Delvare | 0e39e01 | 2006-09-24 21:16:40 +0200 | [diff] [blame] | 495 | static struct attribute *lm90_attributes[] = { |
| 496 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
| 497 | &sensor_dev_attr_temp2_input.dev_attr.attr, |
| 498 | &sensor_dev_attr_temp1_min.dev_attr.attr, |
| 499 | &sensor_dev_attr_temp2_min.dev_attr.attr, |
| 500 | &sensor_dev_attr_temp1_max.dev_attr.attr, |
| 501 | &sensor_dev_attr_temp2_max.dev_attr.attr, |
| 502 | &sensor_dev_attr_temp1_crit.dev_attr.attr, |
| 503 | &sensor_dev_attr_temp2_crit.dev_attr.attr, |
| 504 | &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr, |
| 505 | &sensor_dev_attr_temp2_crit_hyst.dev_attr.attr, |
| 506 | |
| 507 | &sensor_dev_attr_temp1_crit_alarm.dev_attr.attr, |
| 508 | &sensor_dev_attr_temp2_crit_alarm.dev_attr.attr, |
Jean Delvare | 7817a39 | 2007-06-09 10:11:16 -0400 | [diff] [blame] | 509 | &sensor_dev_attr_temp2_fault.dev_attr.attr, |
Jean Delvare | 0e39e01 | 2006-09-24 21:16:40 +0200 | [diff] [blame] | 510 | &sensor_dev_attr_temp2_min_alarm.dev_attr.attr, |
| 511 | &sensor_dev_attr_temp2_max_alarm.dev_attr.attr, |
| 512 | &sensor_dev_attr_temp1_min_alarm.dev_attr.attr, |
| 513 | &sensor_dev_attr_temp1_max_alarm.dev_attr.attr, |
| 514 | &dev_attr_alarms.attr, |
| 515 | NULL |
| 516 | }; |
| 517 | |
| 518 | static const struct attribute_group lm90_group = { |
| 519 | .attrs = lm90_attributes, |
| 520 | }; |
| 521 | |
Jean Delvare | c3df580 | 2005-10-26 21:39:40 +0200 | [diff] [blame] | 522 | /* pec used for ADM1032 only */ |
| 523 | static ssize_t show_pec(struct device *dev, struct device_attribute *dummy, |
| 524 | char *buf) |
| 525 | { |
| 526 | struct i2c_client *client = to_i2c_client(dev); |
| 527 | return sprintf(buf, "%d\n", !!(client->flags & I2C_CLIENT_PEC)); |
| 528 | } |
| 529 | |
| 530 | static ssize_t set_pec(struct device *dev, struct device_attribute *dummy, |
| 531 | const char *buf, size_t count) |
| 532 | { |
| 533 | struct i2c_client *client = to_i2c_client(dev); |
| 534 | long val = simple_strtol(buf, NULL, 10); |
| 535 | |
| 536 | switch (val) { |
| 537 | case 0: |
| 538 | client->flags &= ~I2C_CLIENT_PEC; |
| 539 | break; |
| 540 | case 1: |
| 541 | client->flags |= I2C_CLIENT_PEC; |
| 542 | break; |
| 543 | default: |
| 544 | return -EINVAL; |
| 545 | } |
| 546 | |
| 547 | return count; |
| 548 | } |
| 549 | |
| 550 | static DEVICE_ATTR(pec, S_IWUSR | S_IRUGO, show_pec, set_pec); |
| 551 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | /* |
| 553 | * Real code |
| 554 | */ |
| 555 | |
Jean Delvare | c3df580 | 2005-10-26 21:39:40 +0200 | [diff] [blame] | 556 | /* The ADM1032 supports PEC but not on write byte transactions, so we need |
Jean Delvare | 0966415 | 2007-06-09 10:11:15 -0400 | [diff] [blame] | 557 | to explicitly ask for a transaction without PEC. */ |
Jean Delvare | c3df580 | 2005-10-26 21:39:40 +0200 | [diff] [blame] | 558 | static inline s32 adm1032_write_byte(struct i2c_client *client, u8 value) |
| 559 | { |
| 560 | return i2c_smbus_xfer(client->adapter, client->addr, |
| 561 | client->flags & ~I2C_CLIENT_PEC, |
| 562 | I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL); |
| 563 | } |
| 564 | |
| 565 | /* It is assumed that client->update_lock is held (unless we are in |
| 566 | detection or initialization steps). This matters when PEC is enabled, |
| 567 | because we don't want the address pointer to change between the write |
| 568 | byte and the read byte transactions. */ |
Jean Delvare | 8256fe0 | 2005-10-26 21:37:52 +0200 | [diff] [blame] | 569 | static int lm90_read_reg(struct i2c_client* client, u8 reg, u8 *value) |
| 570 | { |
| 571 | int err; |
| 572 | |
Jean Delvare | c3df580 | 2005-10-26 21:39:40 +0200 | [diff] [blame] | 573 | if (client->flags & I2C_CLIENT_PEC) { |
| 574 | err = adm1032_write_byte(client, reg); |
| 575 | if (err >= 0) |
| 576 | err = i2c_smbus_read_byte(client); |
| 577 | } else |
| 578 | err = i2c_smbus_read_byte_data(client, reg); |
Jean Delvare | 8256fe0 | 2005-10-26 21:37:52 +0200 | [diff] [blame] | 579 | |
| 580 | if (err < 0) { |
| 581 | dev_warn(&client->dev, "Register %#02x read failed (%d)\n", |
| 582 | reg, err); |
| 583 | return err; |
| 584 | } |
| 585 | *value = err; |
| 586 | |
| 587 | return 0; |
| 588 | } |
| 589 | |
Jean Delvare | 9b0e852 | 2008-07-16 19:30:15 +0200 | [diff] [blame] | 590 | /* Return 0 if detection is successful, -ENODEV otherwise */ |
| 591 | static int lm90_detect(struct i2c_client *new_client, int kind, |
| 592 | struct i2c_board_info *info) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | { |
Jean Delvare | 9b0e852 | 2008-07-16 19:30:15 +0200 | [diff] [blame] | 594 | struct i2c_adapter *adapter = new_client->adapter; |
| 595 | int address = new_client->addr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | const char *name = ""; |
| 597 | |
| 598 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
Jean Delvare | 9b0e852 | 2008-07-16 19:30:15 +0200 | [diff] [blame] | 599 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | |
| 601 | /* |
| 602 | * Now we do the remaining detection. A negative kind means that |
| 603 | * the driver was loaded with no force parameter (default), so we |
| 604 | * must both detect and identify the chip. A zero kind means that |
| 605 | * the driver was loaded with the force parameter, the detection |
| 606 | * step shall be skipped. A positive kind means that the driver |
| 607 | * was loaded with the force parameter and a given kind of chip is |
| 608 | * requested, so both the detection and the identification steps |
| 609 | * are skipped. |
| 610 | */ |
| 611 | |
| 612 | /* Default to an LM90 if forced */ |
| 613 | if (kind == 0) |
| 614 | kind = lm90; |
| 615 | |
| 616 | if (kind < 0) { /* detection and identification */ |
Jean Delvare | e0ae87a | 2007-11-25 21:58:21 +0100 | [diff] [blame] | 617 | int man_id, chip_id, reg_config1, reg_convrate; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | |
Jean Delvare | e0ae87a | 2007-11-25 21:58:21 +0100 | [diff] [blame] | 619 | if ((man_id = i2c_smbus_read_byte_data(new_client, |
| 620 | LM90_REG_R_MAN_ID)) < 0 |
| 621 | || (chip_id = i2c_smbus_read_byte_data(new_client, |
| 622 | LM90_REG_R_CHIP_ID)) < 0 |
| 623 | || (reg_config1 = i2c_smbus_read_byte_data(new_client, |
| 624 | LM90_REG_R_CONFIG1)) < 0 |
| 625 | || (reg_convrate = i2c_smbus_read_byte_data(new_client, |
| 626 | LM90_REG_R_CONVRATE)) < 0) |
Jean Delvare | 9b0e852 | 2008-07-16 19:30:15 +0200 | [diff] [blame] | 627 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | |
Rainer Birkenmaier | 32c82a9 | 2007-06-09 10:11:16 -0400 | [diff] [blame] | 629 | if ((address == 0x4C || address == 0x4D) |
| 630 | && man_id == 0x01) { /* National Semiconductor */ |
Jean Delvare | e0ae87a | 2007-11-25 21:58:21 +0100 | [diff] [blame] | 631 | int reg_config2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | |
Jean Delvare | e0ae87a | 2007-11-25 21:58:21 +0100 | [diff] [blame] | 633 | if ((reg_config2 = i2c_smbus_read_byte_data(new_client, |
| 634 | LM90_REG_R_CONFIG2)) < 0) |
Jean Delvare | 9b0e852 | 2008-07-16 19:30:15 +0200 | [diff] [blame] | 635 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 | |
| 637 | if ((reg_config1 & 0x2A) == 0x00 |
| 638 | && (reg_config2 & 0xF8) == 0x00 |
| 639 | && reg_convrate <= 0x09) { |
| 640 | if (address == 0x4C |
| 641 | && (chip_id & 0xF0) == 0x20) { /* LM90 */ |
| 642 | kind = lm90; |
| 643 | } else |
| 644 | if ((chip_id & 0xF0) == 0x30) { /* LM89/LM99 */ |
| 645 | kind = lm99; |
| 646 | } else |
| 647 | if (address == 0x4C |
| 648 | && (chip_id & 0xF0) == 0x10) { /* LM86 */ |
| 649 | kind = lm86; |
| 650 | } |
| 651 | } |
| 652 | } else |
Rainer Birkenmaier | 32c82a9 | 2007-06-09 10:11:16 -0400 | [diff] [blame] | 653 | if ((address == 0x4C || address == 0x4D) |
| 654 | && man_id == 0x41) { /* Analog Devices */ |
Jean Delvare | 90209b4 | 2005-10-26 22:20:21 +0200 | [diff] [blame] | 655 | if ((chip_id & 0xF0) == 0x40 /* ADM1032 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 656 | && (reg_config1 & 0x3F) == 0x00 |
| 657 | && reg_convrate <= 0x0A) { |
| 658 | kind = adm1032; |
| 659 | } else |
Jean Delvare | 90209b4 | 2005-10-26 22:20:21 +0200 | [diff] [blame] | 660 | if (chip_id == 0x51 /* ADT7461 */ |
Nate Case | 23b2d47 | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 661 | && (reg_config1 & 0x1B) == 0x00 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | && reg_convrate <= 0x0A) { |
| 663 | kind = adt7461; |
| 664 | } |
| 665 | } else |
| 666 | if (man_id == 0x4D) { /* Maxim */ |
| 667 | /* |
Rainer Birkenmaier | 32c82a9 | 2007-06-09 10:11:16 -0400 | [diff] [blame] | 668 | * The MAX6657, MAX6658 and MAX6659 do NOT have a |
| 669 | * chip_id register. Reading from that address will |
| 670 | * return the last read value, which in our case is |
| 671 | * those of the man_id register. Likewise, the config1 |
| 672 | * register seems to lack a low nibble, so the value |
| 673 | * will be those of the previous read, so in our case |
| 674 | * those of the man_id register. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | */ |
| 676 | if (chip_id == man_id |
Guillaume Chazarain | f5744e3 | 2007-07-27 01:04:22 +0200 | [diff] [blame] | 677 | && (address == 0x4C || address == 0x4D) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | && (reg_config1 & 0x1F) == (man_id & 0x0F) |
| 679 | && reg_convrate <= 0x09) { |
| 680 | kind = max6657; |
Rainer Birkenmaier | 32c82a9 | 2007-06-09 10:11:16 -0400 | [diff] [blame] | 681 | } else |
| 682 | /* The chip_id register of the MAX6680 and MAX6681 |
| 683 | * holds the revision of the chip. |
| 684 | * the lowest bit of the config1 register is unused |
| 685 | * and should return zero when read, so should the |
| 686 | * second to last bit of config1 (software reset) |
| 687 | */ |
| 688 | if (chip_id == 0x01 |
| 689 | && (reg_config1 & 0x03) == 0x00 |
| 690 | && reg_convrate <= 0x07) { |
| 691 | kind = max6680; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 692 | } |
| 693 | } |
| 694 | |
| 695 | if (kind <= 0) { /* identification failed */ |
| 696 | dev_info(&adapter->dev, |
| 697 | "Unsupported chip (man_id=0x%02X, " |
| 698 | "chip_id=0x%02X).\n", man_id, chip_id); |
Jean Delvare | 9b0e852 | 2008-07-16 19:30:15 +0200 | [diff] [blame] | 699 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | } |
| 701 | } |
| 702 | |
Jean Delvare | 9b0e852 | 2008-07-16 19:30:15 +0200 | [diff] [blame] | 703 | /* Fill the i2c board info */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 704 | if (kind == lm90) { |
| 705 | name = "lm90"; |
| 706 | } else if (kind == adm1032) { |
| 707 | name = "adm1032"; |
Jean Delvare | c3df580 | 2005-10-26 21:39:40 +0200 | [diff] [blame] | 708 | /* The ADM1032 supports PEC, but only if combined |
| 709 | transactions are not used. */ |
| 710 | if (i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE)) |
Jean Delvare | 9b0e852 | 2008-07-16 19:30:15 +0200 | [diff] [blame] | 711 | info->flags |= I2C_CLIENT_PEC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 712 | } else if (kind == lm99) { |
| 713 | name = "lm99"; |
| 714 | } else if (kind == lm86) { |
| 715 | name = "lm86"; |
| 716 | } else if (kind == max6657) { |
| 717 | name = "max6657"; |
Rainer Birkenmaier | 32c82a9 | 2007-06-09 10:11:16 -0400 | [diff] [blame] | 718 | } else if (kind == max6680) { |
| 719 | name = "max6680"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 720 | } else if (kind == adt7461) { |
| 721 | name = "adt7461"; |
| 722 | } |
Jean Delvare | 9b0e852 | 2008-07-16 19:30:15 +0200 | [diff] [blame] | 723 | strlcpy(info->type, name, I2C_NAME_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 724 | |
Jean Delvare | 9b0e852 | 2008-07-16 19:30:15 +0200 | [diff] [blame] | 725 | return 0; |
| 726 | } |
| 727 | |
| 728 | static int lm90_probe(struct i2c_client *new_client, |
| 729 | const struct i2c_device_id *id) |
| 730 | { |
| 731 | struct i2c_adapter *adapter = to_i2c_adapter(new_client->dev.parent); |
| 732 | struct lm90_data *data; |
| 733 | int err; |
| 734 | |
| 735 | data = kzalloc(sizeof(struct lm90_data), GFP_KERNEL); |
| 736 | if (!data) { |
| 737 | err = -ENOMEM; |
| 738 | goto exit; |
| 739 | } |
| 740 | i2c_set_clientdata(new_client, data); |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 741 | mutex_init(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 742 | |
Jean Delvare | 9b0e852 | 2008-07-16 19:30:15 +0200 | [diff] [blame] | 743 | /* Set the device type */ |
| 744 | data->kind = id->driver_data; |
| 745 | if (data->kind == adm1032) { |
| 746 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE)) |
| 747 | new_client->flags &= ~I2C_CLIENT_PEC; |
| 748 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 749 | |
| 750 | /* Initialize the LM90 chip */ |
| 751 | lm90_init_client(new_client); |
| 752 | |
| 753 | /* Register sysfs hooks */ |
Jean Delvare | 0e39e01 | 2006-09-24 21:16:40 +0200 | [diff] [blame] | 754 | if ((err = sysfs_create_group(&new_client->dev.kobj, &lm90_group))) |
Jean Delvare | 9b0e852 | 2008-07-16 19:30:15 +0200 | [diff] [blame] | 755 | goto exit_free; |
Jean Delvare | 0e39e01 | 2006-09-24 21:16:40 +0200 | [diff] [blame] | 756 | if (new_client->flags & I2C_CLIENT_PEC) { |
| 757 | if ((err = device_create_file(&new_client->dev, |
| 758 | &dev_attr_pec))) |
| 759 | goto exit_remove_files; |
| 760 | } |
Jean Delvare | 69f2f96 | 2007-09-05 14:15:37 +0200 | [diff] [blame] | 761 | if (data->kind != max6657) { |
| 762 | if ((err = device_create_file(&new_client->dev, |
| 763 | &sensor_dev_attr_temp2_offset.dev_attr))) |
| 764 | goto exit_remove_files; |
| 765 | } |
Jean Delvare | 0e39e01 | 2006-09-24 21:16:40 +0200 | [diff] [blame] | 766 | |
Tony Jones | 1beeffe | 2007-08-20 13:46:20 -0700 | [diff] [blame] | 767 | data->hwmon_dev = hwmon_device_register(&new_client->dev); |
| 768 | if (IS_ERR(data->hwmon_dev)) { |
| 769 | err = PTR_ERR(data->hwmon_dev); |
Jean Delvare | 0e39e01 | 2006-09-24 21:16:40 +0200 | [diff] [blame] | 770 | goto exit_remove_files; |
Mark M. Hoffman | 943b083 | 2005-07-15 21:39:18 -0400 | [diff] [blame] | 771 | } |
| 772 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 773 | return 0; |
| 774 | |
Jean Delvare | 0e39e01 | 2006-09-24 21:16:40 +0200 | [diff] [blame] | 775 | exit_remove_files: |
| 776 | sysfs_remove_group(&new_client->dev.kobj, &lm90_group); |
| 777 | device_remove_file(&new_client->dev, &dev_attr_pec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 778 | exit_free: |
| 779 | kfree(data); |
| 780 | exit: |
| 781 | return err; |
| 782 | } |
| 783 | |
| 784 | static void lm90_init_client(struct i2c_client *client) |
| 785 | { |
Rainer Birkenmaier | 32c82a9 | 2007-06-09 10:11:16 -0400 | [diff] [blame] | 786 | u8 config, config_orig; |
| 787 | struct lm90_data *data = i2c_get_clientdata(client); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 788 | |
| 789 | /* |
| 790 | * Start the conversions. |
| 791 | */ |
| 792 | i2c_smbus_write_byte_data(client, LM90_REG_W_CONVRATE, |
| 793 | 5); /* 2 Hz */ |
Jean Delvare | 8256fe0 | 2005-10-26 21:37:52 +0200 | [diff] [blame] | 794 | if (lm90_read_reg(client, LM90_REG_R_CONFIG1, &config) < 0) { |
| 795 | dev_warn(&client->dev, "Initialization failed!\n"); |
| 796 | return; |
| 797 | } |
Rainer Birkenmaier | 32c82a9 | 2007-06-09 10:11:16 -0400 | [diff] [blame] | 798 | config_orig = config; |
| 799 | |
Nate Case | 23b2d47 | 2008-10-17 17:51:10 +0200 | [diff] [blame] | 800 | /* Check Temperature Range Select */ |
| 801 | if (data->kind == adt7461) { |
| 802 | if (config & 0x04) |
| 803 | data->flags |= LM90_FLAG_ADT7461_EXT; |
| 804 | } |
| 805 | |
Rainer Birkenmaier | 32c82a9 | 2007-06-09 10:11:16 -0400 | [diff] [blame] | 806 | /* |
| 807 | * Put MAX6680/MAX8881 into extended resolution (bit 0x10, |
| 808 | * 0.125 degree resolution) and range (0x08, extend range |
| 809 | * to -64 degree) mode for the remote temperature sensor. |
| 810 | */ |
| 811 | if (data->kind == max6680) { |
| 812 | config |= 0x18; |
| 813 | } |
| 814 | |
| 815 | config &= 0xBF; /* run */ |
| 816 | if (config != config_orig) /* Only write if changed */ |
| 817 | i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, config); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 818 | } |
| 819 | |
Jean Delvare | 9b0e852 | 2008-07-16 19:30:15 +0200 | [diff] [blame] | 820 | static int lm90_remove(struct i2c_client *client) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 821 | { |
Mark M. Hoffman | 943b083 | 2005-07-15 21:39:18 -0400 | [diff] [blame] | 822 | struct lm90_data *data = i2c_get_clientdata(client); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 823 | |
Tony Jones | 1beeffe | 2007-08-20 13:46:20 -0700 | [diff] [blame] | 824 | hwmon_device_unregister(data->hwmon_dev); |
Jean Delvare | 0e39e01 | 2006-09-24 21:16:40 +0200 | [diff] [blame] | 825 | sysfs_remove_group(&client->dev.kobj, &lm90_group); |
| 826 | device_remove_file(&client->dev, &dev_attr_pec); |
Jean Delvare | 69f2f96 | 2007-09-05 14:15:37 +0200 | [diff] [blame] | 827 | if (data->kind != max6657) |
| 828 | device_remove_file(&client->dev, |
| 829 | &sensor_dev_attr_temp2_offset.dev_attr); |
Mark M. Hoffman | 943b083 | 2005-07-15 21:39:18 -0400 | [diff] [blame] | 830 | |
Mark M. Hoffman | 943b083 | 2005-07-15 21:39:18 -0400 | [diff] [blame] | 831 | kfree(data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 832 | return 0; |
| 833 | } |
| 834 | |
Jean Delvare | 6388a38 | 2008-10-17 17:51:09 +0200 | [diff] [blame] | 835 | static int lm90_read16(struct i2c_client *client, u8 regh, u8 regl, u16 *value) |
| 836 | { |
| 837 | int err; |
| 838 | u8 oldh, newh, l; |
| 839 | |
| 840 | /* |
| 841 | * There is a trick here. We have to read two registers to have the |
| 842 | * sensor temperature, but we have to beware a conversion could occur |
| 843 | * inbetween the readings. The datasheet says we should either use |
| 844 | * the one-shot conversion register, which we don't want to do |
| 845 | * (disables hardware monitoring) or monitor the busy bit, which is |
| 846 | * impossible (we can't read the values and monitor that bit at the |
| 847 | * exact same time). So the solution used here is to read the high |
| 848 | * byte once, then the low byte, then the high byte again. If the new |
| 849 | * high byte matches the old one, then we have a valid reading. Else |
| 850 | * we have to read the low byte again, and now we believe we have a |
| 851 | * correct reading. |
| 852 | */ |
| 853 | if ((err = lm90_read_reg(client, regh, &oldh)) |
| 854 | || (err = lm90_read_reg(client, regl, &l)) |
| 855 | || (err = lm90_read_reg(client, regh, &newh))) |
| 856 | return err; |
| 857 | if (oldh != newh) { |
| 858 | err = lm90_read_reg(client, regl, &l); |
| 859 | if (err) |
| 860 | return err; |
| 861 | } |
| 862 | *value = (newh << 8) | l; |
| 863 | |
| 864 | return 0; |
| 865 | } |
| 866 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 867 | static struct lm90_data *lm90_update_device(struct device *dev) |
| 868 | { |
| 869 | struct i2c_client *client = to_i2c_client(dev); |
| 870 | struct lm90_data *data = i2c_get_clientdata(client); |
| 871 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 872 | mutex_lock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 873 | |
| 874 | if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { |
Jean Delvare | 6388a38 | 2008-10-17 17:51:09 +0200 | [diff] [blame] | 875 | u8 h, l; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 876 | |
| 877 | dev_dbg(&client->dev, "Updating lm90 data.\n"); |
Jean Delvare | f65e170 | 2008-10-17 17:51:09 +0200 | [diff] [blame] | 878 | lm90_read_reg(client, LM90_REG_R_LOCAL_LOW, &data->temp8[0]); |
| 879 | lm90_read_reg(client, LM90_REG_R_LOCAL_HIGH, &data->temp8[1]); |
| 880 | lm90_read_reg(client, LM90_REG_R_LOCAL_CRIT, &data->temp8[2]); |
| 881 | lm90_read_reg(client, LM90_REG_R_REMOTE_CRIT, &data->temp8[3]); |
Jean Delvare | 8256fe0 | 2005-10-26 21:37:52 +0200 | [diff] [blame] | 882 | lm90_read_reg(client, LM90_REG_R_TCRIT_HYST, &data->temp_hyst); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 883 | |
Jean Delvare | f65e170 | 2008-10-17 17:51:09 +0200 | [diff] [blame] | 884 | if (data->kind == max6657) { |
| 885 | lm90_read16(client, LM90_REG_R_LOCAL_TEMP, |
| 886 | MAX6657_REG_R_LOCAL_TEMPL, |
| 887 | &data->temp11[4]); |
| 888 | } else { |
| 889 | if (lm90_read_reg(client, LM90_REG_R_LOCAL_TEMP, |
| 890 | &h) == 0) |
| 891 | data->temp11[4] = h << 8; |
| 892 | } |
Jean Delvare | 6388a38 | 2008-10-17 17:51:09 +0200 | [diff] [blame] | 893 | lm90_read16(client, LM90_REG_R_REMOTE_TEMPH, |
| 894 | LM90_REG_R_REMOTE_TEMPL, &data->temp11[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 895 | |
Jean Delvare | 5f502a8 | 2008-10-17 17:51:09 +0200 | [diff] [blame] | 896 | if (lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH, &h) == 0) { |
| 897 | data->temp11[1] = h << 8; |
| 898 | if (data->kind != max6657 && data->kind != max6680 |
| 899 | && lm90_read_reg(client, LM90_REG_R_REMOTE_LOWL, |
| 900 | &l) == 0) |
| 901 | data->temp11[1] |= l; |
| 902 | } |
| 903 | if (lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHH, &h) == 0) { |
| 904 | data->temp11[2] = h << 8; |
| 905 | if (data->kind != max6657 && data->kind != max6680 |
| 906 | && lm90_read_reg(client, LM90_REG_R_REMOTE_HIGHL, |
| 907 | &l) == 0) |
| 908 | data->temp11[2] |= l; |
| 909 | } |
| 910 | |
Jean Delvare | 69f2f96 | 2007-09-05 14:15:37 +0200 | [diff] [blame] | 911 | if (data->kind != max6657) { |
| 912 | if (lm90_read_reg(client, LM90_REG_R_REMOTE_OFFSH, |
Jean Delvare | 6388a38 | 2008-10-17 17:51:09 +0200 | [diff] [blame] | 913 | &h) == 0 |
Jean Delvare | 69f2f96 | 2007-09-05 14:15:37 +0200 | [diff] [blame] | 914 | && lm90_read_reg(client, LM90_REG_R_REMOTE_OFFSL, |
| 915 | &l) == 0) |
Jean Delvare | 6388a38 | 2008-10-17 17:51:09 +0200 | [diff] [blame] | 916 | data->temp11[3] = (h << 8) | l; |
Jean Delvare | 69f2f96 | 2007-09-05 14:15:37 +0200 | [diff] [blame] | 917 | } |
Jean Delvare | 8256fe0 | 2005-10-26 21:37:52 +0200 | [diff] [blame] | 918 | lm90_read_reg(client, LM90_REG_R_STATUS, &data->alarms); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 919 | |
| 920 | data->last_updated = jiffies; |
| 921 | data->valid = 1; |
| 922 | } |
| 923 | |
Ingo Molnar | 9a61bf6 | 2006-01-18 23:19:26 +0100 | [diff] [blame] | 924 | mutex_unlock(&data->update_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 925 | |
| 926 | return data; |
| 927 | } |
| 928 | |
| 929 | static int __init sensors_lm90_init(void) |
| 930 | { |
| 931 | return i2c_add_driver(&lm90_driver); |
| 932 | } |
| 933 | |
| 934 | static void __exit sensors_lm90_exit(void) |
| 935 | { |
| 936 | i2c_del_driver(&lm90_driver); |
| 937 | } |
| 938 | |
| 939 | MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>"); |
| 940 | MODULE_DESCRIPTION("LM90/ADM1032 driver"); |
| 941 | MODULE_LICENSE("GPL"); |
| 942 | |
| 943 | module_init(sensors_lm90_init); |
| 944 | module_exit(sensors_lm90_exit); |