35 #include <linux/module.h>
37 #include <linux/slab.h>
39 #include <linux/i2c.h>
46 static const unsigned short normal_i2c[] = {
53 #define MAX6642_REG_R_MAN_ID 0xFE
54 #define MAX6642_REG_R_CONFIG 0x03
55 #define MAX6642_REG_W_CONFIG 0x09
56 #define MAX6642_REG_R_STATUS 0x02
57 #define MAX6642_REG_R_LOCAL_TEMP 0x00
58 #define MAX6642_REG_R_LOCAL_TEMPL 0x11
59 #define MAX6642_REG_R_LOCAL_HIGH 0x05
60 #define MAX6642_REG_W_LOCAL_HIGH 0x0B
61 #define MAX6642_REG_R_REMOTE_TEMP 0x01
62 #define MAX6642_REG_R_REMOTE_TEMPL 0x10
63 #define MAX6642_REG_R_REMOTE_HIGH 0x07
64 #define MAX6642_REG_W_REMOTE_HIGH 0x0D
70 static int temp_from_reg10(
int val)
75 static int temp_from_reg(
int val)
80 static int temp_to_reg(
int val)
151 if ((reg_config & 0x0f) != 0x00)
161 if ((reg_status & 0x2b) != 0x00)
178 dev_dbg(&client->
dev,
"Updating max6642 data.\n");
181 tmp = (val >> 6) & 3;
184 val = (val << 2) | tmp;
188 tmp = (val >> 6) & 3;
191 val = (val << 2) | tmp;
229 const char *buf,
size_t count)
237 err = kstrtoul(buf, 10, &val);
242 data->
temp_high[attr2->
nr] = SENSORS_LIMIT(temp_to_reg(val), 0, 255);
267 static struct attribute *max6642_attributes[] = {
268 &sensor_dev_attr_temp1_input.dev_attr.attr,
269 &sensor_dev_attr_temp2_input.dev_attr.attr,
270 &sensor_dev_attr_temp1_max.dev_attr.attr,
271 &sensor_dev_attr_temp2_max.dev_attr.attr,
273 &sensor_dev_attr_temp2_fault.dev_attr.attr,
274 &sensor_dev_attr_temp1_max_alarm.dev_attr.attr,
275 &sensor_dev_attr_temp2_max_alarm.dev_attr.attr,
280 .attrs = max6642_attributes,
283 static int max6642_probe(
struct i2c_client *new_client,
294 i2c_set_clientdata(new_client, data);
298 max6642_init_client(new_client);
308 goto exit_remove_files;
318 static int max6642_remove(
struct i2c_client *client)
343 .probe = max6642_probe,
344 .remove = max6642_remove,
345 .id_table = max6642_id,
346 .detect = max6642_detect,
347 .address_list = normal_i2c,