2019-05-24 18:04:09 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2012-08-13 00:15:49 +08:00
|
|
|
/*
|
2013-03-12 18:38:46 +08:00
|
|
|
* ADT7410/ADT7420 digital temperature sensor driver
|
2012-08-13 00:15:49 +08:00
|
|
|
*
|
2013-03-12 18:38:46 +08:00
|
|
|
* Copyright 2012-2013 Analog Devices Inc.
|
|
|
|
* Author: Lars-Peter Clausen <lars@metafoo.de>
|
2012-08-13 00:15:49 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/i2c.h>
|
|
|
|
|
2013-03-12 18:38:46 +08:00
|
|
|
#include "adt7x10.h"
|
2012-08-13 00:15:49 +08:00
|
|
|
|
2013-03-12 18:38:46 +08:00
|
|
|
static int adt7410_i2c_read_word(struct device *dev, u8 reg)
|
2012-08-13 00:15:49 +08:00
|
|
|
{
|
2013-03-12 18:38:46 +08:00
|
|
|
return i2c_smbus_read_word_swapped(to_i2c_client(dev), reg);
|
2012-08-13 00:15:49 +08:00
|
|
|
}
|
|
|
|
|
2013-03-12 18:38:46 +08:00
|
|
|
static int adt7410_i2c_write_word(struct device *dev, u8 reg, u16 data)
|
2012-08-13 00:15:49 +08:00
|
|
|
{
|
2013-03-12 18:38:46 +08:00
|
|
|
return i2c_smbus_write_word_swapped(to_i2c_client(dev), reg, data);
|
2012-08-13 00:15:49 +08:00
|
|
|
}
|
|
|
|
|
2013-03-12 18:38:46 +08:00
|
|
|
static int adt7410_i2c_read_byte(struct device *dev, u8 reg)
|
2012-08-13 00:15:49 +08:00
|
|
|
{
|
2013-03-12 18:38:46 +08:00
|
|
|
return i2c_smbus_read_byte_data(to_i2c_client(dev), reg);
|
2012-08-13 00:15:49 +08:00
|
|
|
}
|
|
|
|
|
2013-03-12 18:38:46 +08:00
|
|
|
static int adt7410_i2c_write_byte(struct device *dev, u8 reg, u8 data)
|
2012-08-13 00:15:49 +08:00
|
|
|
{
|
2013-03-12 18:38:46 +08:00
|
|
|
return i2c_smbus_write_byte_data(to_i2c_client(dev), reg, data);
|
2012-08-13 00:15:49 +08:00
|
|
|
}
|
|
|
|
|
2013-03-12 18:38:46 +08:00
|
|
|
static const struct adt7x10_ops adt7410_i2c_ops = {
|
|
|
|
.read_word = adt7410_i2c_read_word,
|
|
|
|
.write_word = adt7410_i2c_write_word,
|
|
|
|
.read_byte = adt7410_i2c_read_byte,
|
|
|
|
.write_byte = adt7410_i2c_write_byte,
|
2012-08-13 00:15:49 +08:00
|
|
|
};
|
|
|
|
|
2020-08-14 00:02:22 +08:00
|
|
|
static int adt7410_i2c_probe(struct i2c_client *client)
|
2012-08-13 00:15:49 +08:00
|
|
|
{
|
|
|
|
if (!i2c_check_functionality(client->adapter,
|
|
|
|
I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA))
|
|
|
|
return -ENODEV;
|
|
|
|
|
2013-03-12 18:38:47 +08:00
|
|
|
return adt7x10_probe(&client->dev, NULL, client->irq, &adt7410_i2c_ops);
|
2012-08-13 00:15:49 +08:00
|
|
|
}
|
|
|
|
|
2013-03-12 18:38:46 +08:00
|
|
|
static int adt7410_i2c_remove(struct i2c_client *client)
|
2012-08-13 00:15:49 +08:00
|
|
|
{
|
2013-03-12 18:38:47 +08:00
|
|
|
return adt7x10_remove(&client->dev, client->irq);
|
2012-08-13 00:15:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct i2c_device_id adt7410_ids[] = {
|
2013-03-12 18:38:46 +08:00
|
|
|
{ "adt7410", 0 },
|
|
|
|
{ "adt7420", 0 },
|
|
|
|
{}
|
2012-08-13 00:15:49 +08:00
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(i2c, adt7410_ids);
|
|
|
|
|
|
|
|
static struct i2c_driver adt7410_driver = {
|
|
|
|
.class = I2C_CLASS_HWMON,
|
|
|
|
.driver = {
|
|
|
|
.name = "adt7410",
|
2013-03-12 18:38:46 +08:00
|
|
|
.pm = ADT7X10_DEV_PM_OPS,
|
2012-08-13 00:15:49 +08:00
|
|
|
},
|
2020-08-14 00:02:22 +08:00
|
|
|
.probe_new = adt7410_i2c_probe,
|
2013-03-12 18:38:46 +08:00
|
|
|
.remove = adt7410_i2c_remove,
|
2012-08-13 00:15:49 +08:00
|
|
|
.id_table = adt7410_ids,
|
2013-02-16 00:57:13 +08:00
|
|
|
.address_list = I2C_ADDRS(0x48, 0x49, 0x4a, 0x4b),
|
2012-08-13 00:15:49 +08:00
|
|
|
};
|
|
|
|
module_i2c_driver(adt7410_driver);
|
|
|
|
|
2013-03-12 18:38:46 +08:00
|
|
|
MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
|
|
|
|
MODULE_DESCRIPTION("ADT7410/AD7420 driver");
|
2012-08-13 00:15:49 +08:00
|
|
|
MODULE_LICENSE("GPL");
|