22 #include <linux/module.h>
24 #include <linux/slab.h>
26 #include <linux/i2c.h>
33 static unsigned short max1668_addr_list[] = {
34 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e,
I2C_CLIENT_END };
38 #define MAX1668_REG_TEMP(nr) (nr)
39 #define MAX1668_REG_STAT1 0x05
40 #define MAX1668_REG_STAT2 0x06
41 #define MAX1668_REG_MAN_ID 0xfe
42 #define MAX1668_REG_DEV_ID 0xff
47 #define MAX1668_REG_LIMH_WR(nr) (0x13 + 2 * (nr))
49 #define MAX1668_REG_LIML_WR(nr) (0x14 + 2 * (nr))
51 #define MAX1668_REG_LIMH_RD(nr) (0x08 + 2 * (nr))
53 #define MAX1668_REG_LIML_RD(nr) (0x09 + 2 * (nr))
56 #define MAN_ID_MAXIM 0x4d
57 #define DEV_ID_MAX1668 0x3
58 #define DEV_ID_MAX1805 0x5
59 #define DEV_ID_MAX1989 0xb
97 for (i = 0; i < 5; i++) {
149 return PTR_ERR(data);
151 return sprintf(buf,
"%d\n", data->
temp[index] * 1000);
161 return PTR_ERR(data);
173 return PTR_ERR(data);
185 return PTR_ERR(data);
197 return PTR_ERR(data);
200 (data->
alarms & (1 << 12)) && data->
temp[index] == 127);
205 const char *buf,
size_t count)
213 ret = kstrtol(buf, 10, &temp);
230 const char *buf,
size_t count)
238 ret = kstrtol(buf, 10, &temp);
296 static struct attribute *max1668_attribute_common[] = {
297 &sensor_dev_attr_temp1_max.dev_attr.attr,
298 &sensor_dev_attr_temp1_min.dev_attr.attr,
299 &sensor_dev_attr_temp1_input.dev_attr.attr,
300 &sensor_dev_attr_temp2_max.dev_attr.attr,
301 &sensor_dev_attr_temp2_min.dev_attr.attr,
302 &sensor_dev_attr_temp2_input.dev_attr.attr,
303 &sensor_dev_attr_temp3_max.dev_attr.attr,
304 &sensor_dev_attr_temp3_min.dev_attr.attr,
305 &sensor_dev_attr_temp3_input.dev_attr.attr,
307 &sensor_dev_attr_temp1_max_alarm.dev_attr.attr,
308 &sensor_dev_attr_temp1_min_alarm.dev_attr.attr,
309 &sensor_dev_attr_temp2_max_alarm.dev_attr.attr,
310 &sensor_dev_attr_temp2_min_alarm.dev_attr.attr,
311 &sensor_dev_attr_temp3_max_alarm.dev_attr.attr,
312 &sensor_dev_attr_temp3_min_alarm.dev_attr.attr,
314 &sensor_dev_attr_temp2_fault.dev_attr.attr,
315 &sensor_dev_attr_temp3_fault.dev_attr.attr,
320 static struct attribute *max1668_attribute_unique[] = {
321 &sensor_dev_attr_temp4_max.dev_attr.attr,
322 &sensor_dev_attr_temp4_min.dev_attr.attr,
323 &sensor_dev_attr_temp4_input.dev_attr.attr,
324 &sensor_dev_attr_temp5_max.dev_attr.attr,
325 &sensor_dev_attr_temp5_min.dev_attr.attr,
326 &sensor_dev_attr_temp5_input.dev_attr.attr,
328 &sensor_dev_attr_temp4_max_alarm.dev_attr.attr,
329 &sensor_dev_attr_temp4_min_alarm.dev_attr.attr,
330 &sensor_dev_attr_temp5_max_alarm.dev_attr.attr,
331 &sensor_dev_attr_temp5_min_alarm.dev_attr.attr,
333 &sensor_dev_attr_temp4_fault.dev_attr.attr,
334 &sensor_dev_attr_temp5_fault.dev_attr.attr,
344 if (attr == &sensor_dev_attr_temp1_max.dev_attr.attr ||
345 attr == &sensor_dev_attr_temp2_max.dev_attr.attr ||
346 attr == &sensor_dev_attr_temp3_max.dev_attr.attr ||
347 attr == &sensor_dev_attr_temp4_max.dev_attr.attr ||
348 attr == &sensor_dev_attr_temp5_max.dev_attr.attr ||
349 attr == &sensor_dev_attr_temp1_min.dev_attr.attr ||
350 attr == &sensor_dev_attr_temp2_min.dev_attr.attr ||
351 attr == &sensor_dev_attr_temp3_min.dev_attr.attr ||
352 attr == &sensor_dev_attr_temp4_min.dev_attr.attr ||
353 attr == &sensor_dev_attr_temp5_min.dev_attr.attr)
359 .attrs = max1668_attribute_common,
360 .is_visible = max1668_attribute_mode
364 .attrs = max1668_attribute_unique,
365 .is_visible = max1668_attribute_mode
369 static int max1668_detect(
struct i2c_client *client,
373 const char *type_name;
390 type_name =
"max1668";
392 type_name =
"max1805";
394 type_name =
"max1989";
404 static int max1668_probe(
struct i2c_client *client,
419 i2c_set_clientdata(client, data);
420 data->
type =
id->driver_data;
430 &max1668_group_unique);
451 static int max1668_remove(
struct i2c_client *client)
478 .probe = max1668_probe,
479 .remove = max1668_remove,
480 .id_table = max1668_id,
481 .detect = max1668_detect,
482 .address_list = max1668_addr_list,