22 #include <linux/module.h>
24 #include <linux/i2c.h>
30 #include <linux/slab.h>
34 #define AD7414_REG_TEMP 0x00
35 #define AD7414_REG_CONF 0x01
36 #define AD7414_REG_T_HIGH 0x02
37 #define AD7414_REG_T_LOW 0x03
51 static inline int ad7414_temp_from_reg(
s16 reg)
57 return ((
int)reg / 64) * 250;
63 return i2c_smbus_read_word_swapped(client, reg);
83 dev_dbg(&client->
dev,
"starting ad7414 update\n");
87 dev_dbg(&client->
dev,
"AD7414_REG_TEMP err %d\n",
92 for (i = 0; i <
ARRAY_SIZE(AD7414_REG_LIMIT); ++
i) {
93 value = ad7414_read(client, AD7414_REG_LIMIT[i]);
95 dev_dbg(&client->
dev,
"AD7414 reg %d err %d\n",
96 AD7414_REG_LIMIT[i], value);
113 struct ad7414_data *data = ad7414_update_device(dev);
122 struct ad7414_data *data = ad7414_update_device(dev);
128 const char *buf,
size_t count)
131 struct ad7414_data *data = i2c_get_clientdata(client);
133 u8 reg = AD7414_REG_LIMIT[
index];
135 int ret = kstrtol(buf, 10, &temp);
140 temp = SENSORS_LIMIT(temp, -40000, 85000);
141 temp = (temp + (temp < 0 ? -500 : 500)) / 1000;
145 ad7414_write(client, reg, temp);
151 show_max_min, set_max_min, 0);
153 show_max_min, set_max_min, 1);
159 struct ad7414_data *data = ad7414_update_device(dev);
161 return sprintf(buf,
"%d\n", value);
167 static struct attribute *ad7414_attributes[] = {
168 &sensor_dev_attr_temp1_input.dev_attr.attr,
169 &sensor_dev_attr_temp1_max.dev_attr.attr,
170 &sensor_dev_attr_temp1_min.dev_attr.attr,
171 &sensor_dev_attr_temp1_max_alarm.dev_attr.attr,
172 &sensor_dev_attr_temp1_min_alarm.dev_attr.attr,
177 .attrs = ad7414_attributes,
180 static int ad7414_probe(
struct i2c_client *client,
196 i2c_set_clientdata(client, data);
205 "ad7414_probe unable to read config register.\n");
231 struct ad7414_data *data = i2c_get_clientdata(client);
248 .probe = ad7414_probe,
250 .id_table = ad7414_id,
256 "Frank Edelhaeuser <frank.edelhaeuser at spansion.com>");