24 #include <linux/module.h>
26 #include <linux/slab.h>
28 #include <linux/i2c.h>
37 static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
49 #define DS1621_REG_CONFIG_NVB 0x10
50 #define DS1621_REG_CONFIG_POLARITY 0x02
51 #define DS1621_REG_CONFIG_1SHOT 0x01
52 #define DS1621_REG_CONFIG_DONE 0x80
55 static const u8 DS1621_REG_TEMP[3] = {
60 #define DS1621_REG_CONF 0xAC
61 #define DS1621_COM_START 0xEE
62 #define DS1621_COM_STOP 0x22
65 #define DS1621_ALARM_TEMP_HIGH 0x40
66 #define DS1621_ALARM_TEMP_LOW 0x20
69 #define ALARMS_FROM_REG(val) ((val) & \
70 (DS1621_ALARM_TEMP_HIGH | DS1621_ALARM_TEMP_LOW))
116 dev_dbg(&client->
dev,
"Starting ds1621 update\n");
121 data->
temp[i] = i2c_smbus_read_word_swapped(client,
125 new_conf = data->
conf;
130 if (data->
conf != new_conf)
147 struct ds1621_data *data = ds1621_update_client(dev);
149 LM75_TEMP_FROM_REG(data->
temp[attr->
index]));
153 const char *buf,
size_t count)
157 struct ds1621_data *data = i2c_get_clientdata(client);
161 err = kstrtol(buf, 10, &val);
166 data->
temp[attr->
index] = LM75_TEMP_TO_REG(val);
167 i2c_smbus_write_word_swapped(client, DS1621_REG_TEMP[attr->
index],
176 struct ds1621_data *data = ds1621_update_client(dev);
184 struct ds1621_data *data = ds1621_update_client(dev);
197 static struct attribute *ds1621_attributes[] = {
198 &sensor_dev_attr_temp1_input.dev_attr.attr,
199 &sensor_dev_attr_temp1_min.dev_attr.attr,
200 &sensor_dev_attr_temp1_max.dev_attr.attr,
201 &sensor_dev_attr_temp1_min_alarm.dev_attr.attr,
202 &sensor_dev_attr_temp1_max_alarm.dev_attr.attr,
203 &dev_attr_alarms.attr,
208 .attrs = ds1621_attributes,
213 static int ds1621_detect(
struct i2c_client *client,
235 for (i = 0; i <
ARRAY_SIZE(DS1621_REG_TEMP); i++) {
237 if (temp < 0 || (temp & 0x7f00))
246 static int ds1621_probe(
struct i2c_client *client,
257 i2c_set_clientdata(client, data);
261 ds1621_init_client(client);
271 goto exit_remove_files;
281 static int ds1621_remove(
struct i2c_client *client)
283 struct ds1621_data *data = i2c_get_clientdata(client);
304 .probe = ds1621_probe,
305 .remove = ds1621_remove,
306 .id_table = ds1621_id,
307 .detect = ds1621_detect,
308 .address_list = normal_i2c,