1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * ADT7410/ADT7420 digital temperature sensor driver
5 * Copyright 2012-2013 Analog Devices Inc.
6 * Author: Lars-Peter Clausen <lars@metafoo.de>
9 #include <linux/module.h>
10 #include <linux/init.h>
11 #include <linux/i2c.h>
15 static int adt7410_i2c_read_word(struct device
*dev
, u8 reg
)
17 return i2c_smbus_read_word_swapped(to_i2c_client(dev
), reg
);
20 static int adt7410_i2c_write_word(struct device
*dev
, u8 reg
, u16 data
)
22 return i2c_smbus_write_word_swapped(to_i2c_client(dev
), reg
, data
);
25 static int adt7410_i2c_read_byte(struct device
*dev
, u8 reg
)
27 return i2c_smbus_read_byte_data(to_i2c_client(dev
), reg
);
30 static int adt7410_i2c_write_byte(struct device
*dev
, u8 reg
, u8 data
)
32 return i2c_smbus_write_byte_data(to_i2c_client(dev
), reg
, data
);
35 static const struct adt7x10_ops adt7410_i2c_ops
= {
36 .read_word
= adt7410_i2c_read_word
,
37 .write_word
= adt7410_i2c_write_word
,
38 .read_byte
= adt7410_i2c_read_byte
,
39 .write_byte
= adt7410_i2c_write_byte
,
42 static int adt7410_i2c_probe(struct i2c_client
*client
)
44 if (!i2c_check_functionality(client
->adapter
,
45 I2C_FUNC_SMBUS_BYTE_DATA
| I2C_FUNC_SMBUS_WORD_DATA
))
48 return adt7x10_probe(&client
->dev
, NULL
, client
->irq
, &adt7410_i2c_ops
);
51 static int adt7410_i2c_remove(struct i2c_client
*client
)
53 return adt7x10_remove(&client
->dev
, client
->irq
);
56 static const struct i2c_device_id adt7410_ids
[] = {
61 MODULE_DEVICE_TABLE(i2c
, adt7410_ids
);
63 static struct i2c_driver adt7410_driver
= {
64 .class = I2C_CLASS_HWMON
,
67 .pm
= ADT7X10_DEV_PM_OPS
,
69 .probe_new
= adt7410_i2c_probe
,
70 .remove
= adt7410_i2c_remove
,
71 .id_table
= adt7410_ids
,
72 .address_list
= I2C_ADDRS(0x48, 0x49, 0x4a, 0x4b),
74 module_i2c_driver(adt7410_driver
);
76 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
77 MODULE_DESCRIPTION("ADT7410/AD7420 driver");
78 MODULE_LICENSE("GPL");