14 #include <linux/kernel.h>
15 #include <linux/module.h>
20 #include <linux/i2c.h>
23 #include <linux/slab.h>
25 #define ADT7411_REG_INT_TEMP_VDD_LSB 0x03
26 #define ADT7411_REG_EXT_TEMP_AIN14_LSB 0x04
27 #define ADT7411_REG_VDD_MSB 0x06
28 #define ADT7411_REG_INT_TEMP_MSB 0x07
29 #define ADT7411_REG_EXT_TEMP_AIN1_MSB 0x08
31 #define ADT7411_REG_CFG1 0x18
32 #define ADT7411_CFG1_START_MONITOR (1 << 0)
34 #define ADT7411_REG_CFG2 0x19
35 #define ADT7411_CFG2_DISABLE_AVG (1 << 5)
37 #define ADT7411_REG_CFG3 0x1a
38 #define ADT7411_CFG3_ADC_CLK_225 (1 << 0)
39 #define ADT7411_CFG3_REF_VDD (1 << 4)
41 #define ADT7411_REG_DEVICE_ID 0x4d
42 #define ADT7411_REG_MANUFACTURER_ID 0x4e
44 #define ADT7411_DEVICE_ID 0x2
45 #define ADT7411_MANUFACTURER_ID 0x41
47 static const unsigned short normal_i2c[] = { 0x48, 0x4a, 0x4b,
I2C_CLIENT_END };
64 u8 msb_reg,
u8 lsb_shift)
75 tmp = (val >> lsb_shift) & 3;
79 val = (val << 2) | tmp;
118 return ret < 0 ? ret :
sprintf(buf,
"%u\n", ret * 7000 / 1024);
131 val = val & 0x200 ? val - 0x400 :
val;
133 return sprintf(buf,
"%d\n", val * 250);
143 u8 lsb_reg, lsb_shift;
152 val = adt7411_read_10_bit(client,
167 lsb_shift = 2 * (nr & 0x03);
168 val = adt7411_read_10_bit(client, lsb_reg,
186 return ret < 0 ? ret :
sprintf(buf,
"%u\n", !!(ret & attr2->
nr));
199 ret = kstrtoul(buf, 0, &flag);
203 ret = adt7411_modify_bit(client, s_attr2->
index, s_attr2->
nr, flag);
210 return ret < 0 ? ret :
count;
213 #define ADT7411_BIT_ATTR(__name, __reg, __bit) \
214 SENSOR_DEVICE_ATTR_2(__name, S_IRUGO | S_IWUSR, adt7411_show_bit, \
215 adt7411_set_bit, __bit, __reg)
231 static struct attribute *adt7411_attrs[] = {
232 &dev_attr_temp1_input.attr,
233 &dev_attr_in0_input.attr,
234 &sensor_dev_attr_in1_input.dev_attr.attr,
235 &sensor_dev_attr_in2_input.dev_attr.attr,
236 &sensor_dev_attr_in3_input.dev_attr.attr,
237 &sensor_dev_attr_in4_input.dev_attr.attr,
238 &sensor_dev_attr_in5_input.dev_attr.attr,
239 &sensor_dev_attr_in6_input.dev_attr.attr,
240 &sensor_dev_attr_in7_input.dev_attr.attr,
241 &sensor_dev_attr_in8_input.dev_attr.attr,
242 &sensor_dev_attr_no_average.dev_attr.attr,
243 &sensor_dev_attr_fast_sampling.dev_attr.attr,
244 &sensor_dev_attr_adc_ref_vdd.dev_attr.attr,
249 .attrs = adt7411_attrs,
252 static int adt7411_detect(
struct i2c_client *client,
262 dev_dbg(&client->
dev,
"Wrong manufacturer ID. Got %d, "
269 dev_dbg(&client->
dev,
"Wrong device ID. Got %d, "
289 i2c_set_clientdata(client, data);
311 dev_info(&client->
dev,
"successfully registered\n");
339 .probe = adt7411_probe,
341 .id_table = adt7411_id,
342 .detect = adt7411_detect,
343 .address_list = normal_i2c,