Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * ADT7410/ADT7420 digital temperature sensor driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Copyright 2012-2013 Analog Devices Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  *   Author: Lars-Peter Clausen <lars@metafoo.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "adt7x10.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) static int adt7410_i2c_read_word(struct device *dev, u8 reg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 	return i2c_smbus_read_word_swapped(to_i2c_client(dev), reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) static int adt7410_i2c_write_word(struct device *dev, u8 reg, u16 data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	return i2c_smbus_write_word_swapped(to_i2c_client(dev), reg, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) static int adt7410_i2c_read_byte(struct device *dev, u8 reg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	return i2c_smbus_read_byte_data(to_i2c_client(dev), reg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) static int adt7410_i2c_write_byte(struct device *dev, u8 reg, u8 data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	return i2c_smbus_write_byte_data(to_i2c_client(dev), reg, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) static const struct adt7x10_ops adt7410_i2c_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	.read_word = adt7410_i2c_read_word,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	.write_word = adt7410_i2c_write_word,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	.read_byte = adt7410_i2c_read_byte,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	.write_byte = adt7410_i2c_write_byte,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) static int adt7410_i2c_probe(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	if (!i2c_check_functionality(client->adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 			I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	return adt7x10_probe(&client->dev, NULL, client->irq, &adt7410_i2c_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) static int adt7410_i2c_remove(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	return adt7x10_remove(&client->dev, client->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) static const struct i2c_device_id adt7410_ids[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	{ "adt7410", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	{ "adt7420", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) MODULE_DEVICE_TABLE(i2c, adt7410_ids);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) static struct i2c_driver adt7410_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 	.class		= I2C_CLASS_HWMON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 		.name	= "adt7410",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 		.pm	= ADT7X10_DEV_PM_OPS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 	.probe_new	= adt7410_i2c_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 	.remove		= adt7410_i2c_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 	.id_table	= adt7410_ids,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 	.address_list	= I2C_ADDRS(0x48, 0x49, 0x4a, 0x4b),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) module_i2c_driver(adt7410_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) MODULE_DESCRIPTION("ADT7410/AD7420 driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) MODULE_LICENSE("GPL");