blob: f9fcc91d02caa09d4e533ee2c9d705420c2a2d60 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * lm83.c - Part of lm_sensors, Linux kernel modules for hardware
3 * monitoring
Jean Delvare7c81c60f2014-01-29 20:40:08 +01004 * Copyright (C) 2003-2009 Jean Delvare <jdelvare@suse.de>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 *
6 * Heavily inspired from the lm78, lm75 and adm1021 drivers. The LM83 is
7 * a sensor chip made by National Semiconductor. It reports up to four
8 * temperatures (its own plus up to three external ones) with a 1 deg
9 * resolution and a 3-4 deg accuracy. Complete datasheet can be obtained
10 * from National's website at:
11 * http://www.national.com/pf/LM/LM83.html
12 * Since the datasheet omits to give the chip stepping code, I give it
13 * here: 0x03 (at register 0xff).
14 *
Jordan Crouse43cb7eb2006-03-23 16:19:49 +010015 * Also supports the LM82 temp sensor, which is basically a stripped down
16 * model of the LM83. Datasheet is here:
17 * http://www.national.com/pf/LM/LM82.html
18 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070019 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
Linus Torvalds1da177e2005-04-16 15:20:36 -070028 */
29
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <linux/module.h>
31#include <linux/init.h>
32#include <linux/slab.h>
33#include <linux/jiffies.h>
34#include <linux/i2c.h>
Jean Delvare10c08f82005-06-06 19:34:45 +020035#include <linux/hwmon-sysfs.h>
Mark M. Hoffman943b0832005-07-15 21:39:18 -040036#include <linux/hwmon.h>
37#include <linux/err.h>
Ingo Molnar9a61bf62006-01-18 23:19:26 +010038#include <linux/mutex.h>
Jean Delvare0e39e012006-09-24 21:16:40 +020039#include <linux/sysfs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
41/*
42 * Addresses to scan
43 * Address is selected using 2 three-level pins, resulting in 9 possible
44 * addresses.
45 */
46
Mark M. Hoffman25e9c862008-02-17 22:28:03 -050047static const unsigned short normal_i2c[] = {
48 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e, I2C_CLIENT_END };
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Jean Delvaree5e9f442009-12-14 21:17:27 +010050enum chips { lm83, lm82 };
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
52/*
53 * The LM83 registers
54 * Manufacturer ID is 0x01 for National Semiconductor.
55 */
56
57#define LM83_REG_R_MAN_ID 0xFE
58#define LM83_REG_R_CHIP_ID 0xFF
59#define LM83_REG_R_CONFIG 0x03
60#define LM83_REG_W_CONFIG 0x09
61#define LM83_REG_R_STATUS1 0x02
62#define LM83_REG_R_STATUS2 0x35
63#define LM83_REG_R_LOCAL_TEMP 0x00
64#define LM83_REG_R_LOCAL_HIGH 0x05
65#define LM83_REG_W_LOCAL_HIGH 0x0B
66#define LM83_REG_R_REMOTE1_TEMP 0x30
67#define LM83_REG_R_REMOTE1_HIGH 0x38
68#define LM83_REG_W_REMOTE1_HIGH 0x50
69#define LM83_REG_R_REMOTE2_TEMP 0x01
70#define LM83_REG_R_REMOTE2_HIGH 0x07
71#define LM83_REG_W_REMOTE2_HIGH 0x0D
72#define LM83_REG_R_REMOTE3_TEMP 0x31
73#define LM83_REG_R_REMOTE3_HIGH 0x3A
74#define LM83_REG_W_REMOTE3_HIGH 0x52
75#define LM83_REG_R_TCRIT 0x42
76#define LM83_REG_W_TCRIT 0x5A
77
78/*
79 * Conversions and various macros
Steven Cole44bbe872005-05-03 18:21:25 -060080 * The LM83 uses signed 8-bit values with LSB = 1 degree Celsius.
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 */
82
83#define TEMP_FROM_REG(val) ((val) * 1000)
84#define TEMP_TO_REG(val) ((val) <= -128000 ? -128 : \
85 (val) >= 127000 ? 127 : \
86 (val) < 0 ? ((val) - 500) / 1000 : \
87 ((val) + 500) / 1000)
88
89static const u8 LM83_REG_R_TEMP[] = {
90 LM83_REG_R_LOCAL_TEMP,
91 LM83_REG_R_REMOTE1_TEMP,
92 LM83_REG_R_REMOTE2_TEMP,
Jean Delvare1a86c052005-06-05 21:16:39 +020093 LM83_REG_R_REMOTE3_TEMP,
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 LM83_REG_R_LOCAL_HIGH,
95 LM83_REG_R_REMOTE1_HIGH,
96 LM83_REG_R_REMOTE2_HIGH,
Jean Delvare1a86c052005-06-05 21:16:39 +020097 LM83_REG_R_REMOTE3_HIGH,
98 LM83_REG_R_TCRIT,
Linus Torvalds1da177e2005-04-16 15:20:36 -070099};
100
101static const u8 LM83_REG_W_HIGH[] = {
102 LM83_REG_W_LOCAL_HIGH,
103 LM83_REG_W_REMOTE1_HIGH,
104 LM83_REG_W_REMOTE2_HIGH,
Jean Delvare1a86c052005-06-05 21:16:39 +0200105 LM83_REG_W_REMOTE3_HIGH,
106 LM83_REG_W_TCRIT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107};
108
109/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 * Client data (each client gets its own)
111 */
112
113struct lm83_data {
Tony Jones1beeffe2007-08-20 13:46:20 -0700114 struct device *hwmon_dev;
Ingo Molnar9a61bf62006-01-18 23:19:26 +0100115 struct mutex update_lock;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 char valid; /* zero until following fields are valid */
117 unsigned long last_updated; /* in jiffies */
118
119 /* registers values */
Jean Delvare1a86c052005-06-05 21:16:39 +0200120 s8 temp[9]; /* 0..3: input 1-4,
121 4..7: high limit 1-4,
122 8 : critical limit */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 u16 alarms; /* bitvector, combined */
124};
125
Guenter Roeck41936372014-04-12 12:39:41 -0700126static struct lm83_data *lm83_update_device(struct device *dev)
127{
128 struct i2c_client *client = to_i2c_client(dev);
129 struct lm83_data *data = i2c_get_clientdata(client);
130
131 mutex_lock(&data->update_lock);
132
133 if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
134 int nr;
135
136 dev_dbg(&client->dev, "Updating lm83 data.\n");
137 for (nr = 0; nr < 9; nr++) {
138 data->temp[nr] =
139 i2c_smbus_read_byte_data(client,
140 LM83_REG_R_TEMP[nr]);
141 }
142 data->alarms =
143 i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS1)
144 + (i2c_smbus_read_byte_data(client, LM83_REG_R_STATUS2)
145 << 8);
146
147 data->last_updated = jiffies;
148 data->valid = 1;
149 }
150
151 mutex_unlock(&data->update_lock);
152
153 return data;
154}
155
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156/*
157 * Sysfs stuff
158 */
159
Jean Delvare1a86c052005-06-05 21:16:39 +0200160static ssize_t show_temp(struct device *dev, struct device_attribute *devattr,
161 char *buf)
162{
163 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
164 struct lm83_data *data = lm83_update_device(dev);
165 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index]));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167
Jean Delvare1a86c052005-06-05 21:16:39 +0200168static ssize_t set_temp(struct device *dev, struct device_attribute *devattr,
169 const char *buf, size_t count)
170{
171 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
172 struct i2c_client *client = to_i2c_client(dev);
173 struct lm83_data *data = i2c_get_clientdata(client);
Frans Meulenbroeksb3789a02012-01-10 23:01:40 +0100174 long val;
Jean Delvare1a86c052005-06-05 21:16:39 +0200175 int nr = attr->index;
Frans Meulenbroeksb3789a02012-01-10 23:01:40 +0100176 int err;
177
178 err = kstrtol(buf, 10, &val);
179 if (err < 0)
180 return err;
Jean Delvare1a86c052005-06-05 21:16:39 +0200181
Ingo Molnar9a61bf62006-01-18 23:19:26 +0100182 mutex_lock(&data->update_lock);
Jean Delvare1a86c052005-06-05 21:16:39 +0200183 data->temp[nr] = TEMP_TO_REG(val);
184 i2c_smbus_write_byte_data(client, LM83_REG_W_HIGH[nr - 4],
185 data->temp[nr]);
Ingo Molnar9a61bf62006-01-18 23:19:26 +0100186 mutex_unlock(&data->update_lock);
Jean Delvare1a86c052005-06-05 21:16:39 +0200187 return count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189
Jean Delvare1a86c052005-06-05 21:16:39 +0200190static ssize_t show_alarms(struct device *dev, struct device_attribute *dummy,
191 char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192{
193 struct lm83_data *data = lm83_update_device(dev);
194 return sprintf(buf, "%d\n", data->alarms);
195}
196
Jean Delvare2d457712006-09-24 20:52:15 +0200197static ssize_t show_alarm(struct device *dev, struct device_attribute
198 *devattr, char *buf)
199{
200 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
201 struct lm83_data *data = lm83_update_device(dev);
202 int bitnr = attr->index;
203
204 return sprintf(buf, "%d\n", (data->alarms >> bitnr) & 1);
205}
206
Jean Delvare1a86c052005-06-05 21:16:39 +0200207static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0);
208static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1);
209static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2);
210static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 3);
211static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp,
212 set_temp, 4);
213static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp,
214 set_temp, 5);
215static SENSOR_DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_temp,
216 set_temp, 6);
217static SENSOR_DEVICE_ATTR(temp4_max, S_IWUSR | S_IRUGO, show_temp,
218 set_temp, 7);
219static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, show_temp, NULL, 8);
220static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp, NULL, 8);
221static SENSOR_DEVICE_ATTR(temp3_crit, S_IWUSR | S_IRUGO, show_temp,
222 set_temp, 8);
223static SENSOR_DEVICE_ATTR(temp4_crit, S_IRUGO, show_temp, NULL, 8);
Jean Delvare2d457712006-09-24 20:52:15 +0200224
225/* Individual alarm files */
226static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 0);
227static SENSOR_DEVICE_ATTR(temp3_crit_alarm, S_IRUGO, show_alarm, NULL, 1);
Jean Delvare7817a392007-06-09 10:11:16 -0400228static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_alarm, NULL, 2);
Jean Delvare2d457712006-09-24 20:52:15 +0200229static SENSOR_DEVICE_ATTR(temp3_max_alarm, S_IRUGO, show_alarm, NULL, 4);
230static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6);
231static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL, 8);
232static SENSOR_DEVICE_ATTR(temp4_crit_alarm, S_IRUGO, show_alarm, NULL, 9);
Jean Delvare7817a392007-06-09 10:11:16 -0400233static SENSOR_DEVICE_ATTR(temp4_fault, S_IRUGO, show_alarm, NULL, 10);
Jean Delvare2d457712006-09-24 20:52:15 +0200234static SENSOR_DEVICE_ATTR(temp4_max_alarm, S_IRUGO, show_alarm, NULL, 12);
Jean Delvare7817a392007-06-09 10:11:16 -0400235static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 13);
Jean Delvare2d457712006-09-24 20:52:15 +0200236static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 15);
237/* Raw alarm file for compatibility */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
239
Jean Delvare0e39e012006-09-24 21:16:40 +0200240static struct attribute *lm83_attributes[] = {
241 &sensor_dev_attr_temp1_input.dev_attr.attr,
242 &sensor_dev_attr_temp3_input.dev_attr.attr,
243 &sensor_dev_attr_temp1_max.dev_attr.attr,
244 &sensor_dev_attr_temp3_max.dev_attr.attr,
245 &sensor_dev_attr_temp1_crit.dev_attr.attr,
246 &sensor_dev_attr_temp3_crit.dev_attr.attr,
247
248 &sensor_dev_attr_temp1_crit_alarm.dev_attr.attr,
249 &sensor_dev_attr_temp3_crit_alarm.dev_attr.attr,
Jean Delvare7817a392007-06-09 10:11:16 -0400250 &sensor_dev_attr_temp3_fault.dev_attr.attr,
Jean Delvare0e39e012006-09-24 21:16:40 +0200251 &sensor_dev_attr_temp3_max_alarm.dev_attr.attr,
252 &sensor_dev_attr_temp1_max_alarm.dev_attr.attr,
253 &dev_attr_alarms.attr,
254 NULL
255};
256
257static const struct attribute_group lm83_group = {
258 .attrs = lm83_attributes,
259};
260
261static struct attribute *lm83_attributes_opt[] = {
262 &sensor_dev_attr_temp2_input.dev_attr.attr,
263 &sensor_dev_attr_temp4_input.dev_attr.attr,
264 &sensor_dev_attr_temp2_max.dev_attr.attr,
265 &sensor_dev_attr_temp4_max.dev_attr.attr,
266 &sensor_dev_attr_temp2_crit.dev_attr.attr,
267 &sensor_dev_attr_temp4_crit.dev_attr.attr,
268
269 &sensor_dev_attr_temp2_crit_alarm.dev_attr.attr,
270 &sensor_dev_attr_temp4_crit_alarm.dev_attr.attr,
Jean Delvare7817a392007-06-09 10:11:16 -0400271 &sensor_dev_attr_temp4_fault.dev_attr.attr,
Jean Delvare0e39e012006-09-24 21:16:40 +0200272 &sensor_dev_attr_temp4_max_alarm.dev_attr.attr,
Jean Delvare7817a392007-06-09 10:11:16 -0400273 &sensor_dev_attr_temp2_fault.dev_attr.attr,
Jean Delvare0e39e012006-09-24 21:16:40 +0200274 &sensor_dev_attr_temp2_max_alarm.dev_attr.attr,
275 NULL
276};
277
278static const struct attribute_group lm83_group_opt = {
279 .attrs = lm83_attributes_opt,
280};
281
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282/*
283 * Real code
284 */
285
Jean Delvareb6aacdc2008-07-16 19:30:14 +0200286/* Return 0 if detection is successful, -ENODEV otherwise */
Jean Delvare310ec792009-12-14 21:17:23 +0100287static int lm83_detect(struct i2c_client *new_client,
Jean Delvareb6aacdc2008-07-16 19:30:14 +0200288 struct i2c_board_info *info)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289{
Jean Delvareb6aacdc2008-07-16 19:30:14 +0200290 struct i2c_adapter *adapter = new_client->adapter;
Jean Delvareb57dc392009-12-09 20:35:52 +0100291 const char *name;
292 u8 man_id, chip_id;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293
294 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
Jean Delvareb6aacdc2008-07-16 19:30:14 +0200295 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296
Jean Delvareb57dc392009-12-09 20:35:52 +0100297 /* Detection */
298 if ((i2c_smbus_read_byte_data(new_client, LM83_REG_R_STATUS1) & 0xA8) ||
299 (i2c_smbus_read_byte_data(new_client, LM83_REG_R_STATUS2) & 0x48) ||
300 (i2c_smbus_read_byte_data(new_client, LM83_REG_R_CONFIG) & 0x41)) {
301 dev_dbg(&adapter->dev, "LM83 detection failed at 0x%02x\n",
302 new_client->addr);
303 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304 }
305
Jean Delvareb57dc392009-12-09 20:35:52 +0100306 /* Identification */
307 man_id = i2c_smbus_read_byte_data(new_client, LM83_REG_R_MAN_ID);
308 if (man_id != 0x01) /* National Semiconductor */
309 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310
Jean Delvareb57dc392009-12-09 20:35:52 +0100311 chip_id = i2c_smbus_read_byte_data(new_client, LM83_REG_R_CHIP_ID);
312 switch (chip_id) {
313 case 0x03:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314 name = "lm83";
Jean Delvareb57dc392009-12-09 20:35:52 +0100315 break;
316 case 0x01:
Jordan Crouse43cb7eb2006-03-23 16:19:49 +0100317 name = "lm82";
Jean Delvareb57dc392009-12-09 20:35:52 +0100318 break;
319 default:
320 /* identification failed */
321 dev_info(&adapter->dev,
322 "Unsupported chip (man_id=0x%02X, chip_id=0x%02X)\n",
323 man_id, chip_id);
324 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 }
326
Jean Delvareb6aacdc2008-07-16 19:30:14 +0200327 strlcpy(info->type, name, I2C_NAME_SIZE);
328
329 return 0;
330}
331
332static int lm83_probe(struct i2c_client *new_client,
333 const struct i2c_device_id *id)
334{
335 struct lm83_data *data;
336 int err;
337
Guenter Roeckc087f732012-06-02 09:58:10 -0700338 data = devm_kzalloc(&new_client->dev, sizeof(struct lm83_data),
339 GFP_KERNEL);
340 if (!data)
341 return -ENOMEM;
Jean Delvareb6aacdc2008-07-16 19:30:14 +0200342
343 i2c_set_clientdata(new_client, data);
Ingo Molnar9a61bf62006-01-18 23:19:26 +0100344 mutex_init(&data->update_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346 /*
Jean Delvare0e39e012006-09-24 21:16:40 +0200347 * Register sysfs hooks
Jordan Crouse43cb7eb2006-03-23 16:19:49 +0100348 * The LM82 can only monitor one external diode which is
349 * at the same register as the LM83 temp3 entry - so we
350 * declare 1 and 3 common, and then 2 and 4 only for the LM83.
351 */
352
Frans Meulenbroeksb3789a02012-01-10 23:01:40 +0100353 err = sysfs_create_group(&new_client->dev.kobj, &lm83_group);
354 if (err)
Guenter Roeckc087f732012-06-02 09:58:10 -0700355 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356
Jean Delvareb6aacdc2008-07-16 19:30:14 +0200357 if (id->driver_data == lm83) {
Frans Meulenbroeksb3789a02012-01-10 23:01:40 +0100358 err = sysfs_create_group(&new_client->dev.kobj,
359 &lm83_group_opt);
360 if (err)
Jean Delvare0e39e012006-09-24 21:16:40 +0200361 goto exit_remove_files;
362 }
Jordan Crouse43cb7eb2006-03-23 16:19:49 +0100363
Tony Jones1beeffe2007-08-20 13:46:20 -0700364 data->hwmon_dev = hwmon_device_register(&new_client->dev);
365 if (IS_ERR(data->hwmon_dev)) {
366 err = PTR_ERR(data->hwmon_dev);
Jean Delvare0e39e012006-09-24 21:16:40 +0200367 goto exit_remove_files;
Jordan Crouse43cb7eb2006-03-23 16:19:49 +0100368 }
369
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370 return 0;
371
Jean Delvare0e39e012006-09-24 21:16:40 +0200372exit_remove_files:
373 sysfs_remove_group(&new_client->dev.kobj, &lm83_group);
374 sysfs_remove_group(&new_client->dev.kobj, &lm83_group_opt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 return err;
376}
377
Jean Delvareb6aacdc2008-07-16 19:30:14 +0200378static int lm83_remove(struct i2c_client *client)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379{
Mark M. Hoffman943b0832005-07-15 21:39:18 -0400380 struct lm83_data *data = i2c_get_clientdata(client);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381
Tony Jones1beeffe2007-08-20 13:46:20 -0700382 hwmon_device_unregister(data->hwmon_dev);
Jean Delvare0e39e012006-09-24 21:16:40 +0200383 sysfs_remove_group(&client->dev.kobj, &lm83_group);
384 sysfs_remove_group(&client->dev.kobj, &lm83_group_opt);
Mark M. Hoffman943b0832005-07-15 21:39:18 -0400385
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386 return 0;
387}
388
Guenter Roeck41936372014-04-12 12:39:41 -0700389/*
390 * Driver data (common to all clients)
391 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392
Guenter Roeck41936372014-04-12 12:39:41 -0700393static const struct i2c_device_id lm83_id[] = {
394 { "lm83", lm83 },
395 { "lm82", lm82 },
396 { }
397};
398MODULE_DEVICE_TABLE(i2c, lm83_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399
Guenter Roeck41936372014-04-12 12:39:41 -0700400static struct i2c_driver lm83_driver = {
401 .class = I2C_CLASS_HWMON,
402 .driver = {
403 .name = "lm83",
404 },
405 .probe = lm83_probe,
406 .remove = lm83_remove,
407 .id_table = lm83_id,
408 .detect = lm83_detect,
409 .address_list = normal_i2c,
410};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411
Axel Linf0967ee2012-01-20 15:38:18 +0800412module_i2c_driver(lm83_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413
Jean Delvare7c81c60f2014-01-29 20:40:08 +0100414MODULE_AUTHOR("Jean Delvare <jdelvare@suse.de>");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415MODULE_DESCRIPTION("LM83 driver");
416MODULE_LICENSE("GPL");