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