23 #include <linux/module.h>
25 #include <linux/slab.h>
27 #include <linux/i2c.h>
43 #define DS620_REG_CONFIG_DONE 0x8000
44 #define DS620_REG_CONFIG_NVB 0x4000
45 #define DS620_REG_CONFIG_THF 0x2000
46 #define DS620_REG_CONFIG_TLF 0x1000
47 #define DS620_REG_CONFIG_R1 0x0800
48 #define DS620_REG_CONFIG_R0 0x0400
49 #define DS620_REG_CONFIG_AUTOC 0x0200
50 #define DS620_REG_CONFIG_1SHOT 0x0100
51 #define DS620_REG_CONFIG_PO2 0x0080
52 #define DS620_REG_CONFIG_PO1 0x0040
53 #define DS620_REG_CONFIG_A2 0x0020
54 #define DS620_REG_CONFIG_A1 0x0010
55 #define DS620_REG_CONFIG_A0 0x0008
58 static const u8 DS620_REG_TEMP[3] = {
64 #define DS620_REG_CONF 0xAC
65 #define DS620_COM_START 0x51
66 #define DS620_COM_STOP 0x22
91 if (ds620_info && ds620_info->
pomode == 1)
93 else if (ds620_info && ds620_info->
pomode == 2)
100 if (conf != new_conf)
120 dev_dbg(&client->
dev,
"Starting ds620 update\n");
123 res = i2c_smbus_read_word_swapped(client,
146 struct ds620_data *data = ds620_update_client(dev);
149 return PTR_ERR(data);
155 const char *buf,
size_t count)
162 struct ds620_data *data = i2c_get_clientdata(client);
164 res = kstrtol(buf, 10, &val);
169 val = (val * 10 / 625) * 8;
173 i2c_smbus_write_word_swapped(client, DS620_REG_TEMP[attr->
index],
183 struct ds620_data *data = ds620_update_client(dev);
189 return PTR_ERR(data);
196 new_conf = conf =
res;
197 new_conf &= ~attr->
index;
198 if (conf != new_conf) {
216 static struct attribute *ds620_attributes[] = {
217 &sensor_dev_attr_temp1_input.dev_attr.attr,
218 &sensor_dev_attr_temp1_min.dev_attr.attr,
219 &sensor_dev_attr_temp1_max.dev_attr.attr,
220 &sensor_dev_attr_temp1_min_alarm.dev_attr.attr,
221 &sensor_dev_attr_temp1_max_alarm.dev_attr.attr,
226 .attrs = ds620_attributes,
229 static int ds620_probe(
struct i2c_client *client,
240 i2c_set_clientdata(client, data);
244 ds620_init_client(client);
254 goto exit_remove_files;
257 dev_info(&client->
dev,
"temperature sensor found\n");
266 static int ds620_remove(
struct i2c_client *client)
268 struct ds620_data *data = i2c_get_clientdata(client);
289 .probe = ds620_probe,
290 .remove = ds620_remove,
291 .id_table = ds620_id,