34 #include <linux/module.h>
36 #include <linux/slab.h>
38 #include <linux/i2c.h>
51 static const unsigned short normal_i2c[] = {
52 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e,
I2C_CLIENT_END };
61 #define LM83_REG_R_MAN_ID 0xFE
62 #define LM83_REG_R_CHIP_ID 0xFF
63 #define LM83_REG_R_CONFIG 0x03
64 #define LM83_REG_W_CONFIG 0x09
65 #define LM83_REG_R_STATUS1 0x02
66 #define LM83_REG_R_STATUS2 0x35
67 #define LM83_REG_R_LOCAL_TEMP 0x00
68 #define LM83_REG_R_LOCAL_HIGH 0x05
69 #define LM83_REG_W_LOCAL_HIGH 0x0B
70 #define LM83_REG_R_REMOTE1_TEMP 0x30
71 #define LM83_REG_R_REMOTE1_HIGH 0x38
72 #define LM83_REG_W_REMOTE1_HIGH 0x50
73 #define LM83_REG_R_REMOTE2_TEMP 0x01
74 #define LM83_REG_R_REMOTE2_HIGH 0x07
75 #define LM83_REG_W_REMOTE2_HIGH 0x0D
76 #define LM83_REG_R_REMOTE3_TEMP 0x31
77 #define LM83_REG_R_REMOTE3_HIGH 0x3A
78 #define LM83_REG_W_REMOTE3_HIGH 0x52
79 #define LM83_REG_R_TCRIT 0x42
80 #define LM83_REG_W_TCRIT 0x5A
87 #define TEMP_FROM_REG(val) ((val) * 1000)
88 #define TEMP_TO_REG(val) ((val) <= -128000 ? -128 : \
89 (val) >= 127000 ? 127 : \
90 (val) < 0 ? ((val) - 500) / 1000 : \
93 static const u8 LM83_REG_R_TEMP[] = {
105 static const u8 LM83_REG_W_HIGH[] = {
117 static int lm83_detect(
struct i2c_client *new_client,
141 .remove = lm83_remove,
143 .detect = lm83_detect,
144 .address_list = normal_i2c,
186 err = kstrtol(buf, 10, &val);
201 struct lm83_data *data = lm83_update_device(dev);
209 struct lm83_data *data = lm83_update_device(dev);
210 int bitnr = attr->
index;
248 static struct attribute *lm83_attributes[] = {
249 &sensor_dev_attr_temp1_input.dev_attr.attr,
250 &sensor_dev_attr_temp3_input.dev_attr.attr,
251 &sensor_dev_attr_temp1_max.dev_attr.attr,
252 &sensor_dev_attr_temp3_max.dev_attr.attr,
253 &sensor_dev_attr_temp1_crit.dev_attr.attr,
254 &sensor_dev_attr_temp3_crit.dev_attr.attr,
256 &sensor_dev_attr_temp1_crit_alarm.dev_attr.attr,
257 &sensor_dev_attr_temp3_crit_alarm.dev_attr.attr,
258 &sensor_dev_attr_temp3_fault.dev_attr.attr,
259 &sensor_dev_attr_temp3_max_alarm.dev_attr.attr,
260 &sensor_dev_attr_temp1_max_alarm.dev_attr.attr,
261 &dev_attr_alarms.attr,
266 .attrs = lm83_attributes,
269 static struct attribute *lm83_attributes_opt[] = {
270 &sensor_dev_attr_temp2_input.dev_attr.attr,
271 &sensor_dev_attr_temp4_input.dev_attr.attr,
272 &sensor_dev_attr_temp2_max.dev_attr.attr,
273 &sensor_dev_attr_temp4_max.dev_attr.attr,
274 &sensor_dev_attr_temp2_crit.dev_attr.attr,
275 &sensor_dev_attr_temp4_crit.dev_attr.attr,
277 &sensor_dev_attr_temp2_crit_alarm.dev_attr.attr,
278 &sensor_dev_attr_temp4_crit_alarm.dev_attr.attr,
279 &sensor_dev_attr_temp4_fault.dev_attr.attr,
280 &sensor_dev_attr_temp4_max_alarm.dev_attr.attr,
281 &sensor_dev_attr_temp2_fault.dev_attr.attr,
282 &sensor_dev_attr_temp2_max_alarm.dev_attr.attr,
287 .attrs = lm83_attributes_opt,
295 static int lm83_detect(
struct i2c_client *new_client,
309 dev_dbg(&adapter->
dev,
"LM83 detection failed at 0x%02x\n",
330 "Unsupported chip (man_id=0x%02X, chip_id=0x%02X)\n",
340 static int lm83_probe(
struct i2c_client *new_client,
351 i2c_set_clientdata(new_client, data);
366 if (id->driver_data ==
lm83) {
370 goto exit_remove_files;
376 goto exit_remove_files;
387 static int lm83_remove(
struct i2c_client *client)
389 struct lm83_data *data = i2c_get_clientdata(client);
401 struct lm83_data *data = i2c_get_clientdata(client);
408 dev_dbg(&client->
dev,
"Updating lm83 data.\n");
409 for (nr = 0; nr < 9; nr++) {
412 LM83_REG_R_TEMP[nr]);