1 From 694f9bfb8efaef8a33e8992015ff9d0866faf4a2 Mon Sep 17 00:00:00 2001
2 From: Christian Lamparter <chunkeey@gmail.com>
3 Date: Sun, 17 Dec 2017 17:27:15 +0100
4 Subject: [PATCH 1/2] hwmon: tc654 add detection routine
6 This patch adds a detection routine for the TC654/TC655
7 chips. Both IDs are listed in the Datasheet.
9 Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
11 drivers/hwmon/tc654.c | 29 +++++++++++++++++++++++++++++
12 1 file changed, 29 insertions(+)
14 --- a/drivers/hwmon/tc654.c
15 +++ b/drivers/hwmon/tc654.c
16 @@ -64,6 +64,11 @@ enum tc654_regs {
17 /* Register data is read (and cached) at most once per second. */
18 #define TC654_UPDATE_INTERVAL HZ
20 +/* Manufacturer and Version Identification Register Values */
21 +#define TC654_MFR_ID_MICROCHIP 0x84
22 +#define TC654_VER_ID 0x00
23 +#define TC655_VER_ID 0x01
26 struct i2c_client *client;
28 @@ -497,6 +502,29 @@ static const struct i2c_device_id tc654_
33 +tc654_detect(struct i2c_client *new_client, struct i2c_board_info *info)
35 + struct i2c_adapter *adapter = new_client->adapter;
36 + int manufacturer, product;
38 + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
41 + manufacturer = i2c_smbus_read_byte_data(new_client, TC654_REG_MFR_ID);
42 + if (manufacturer != TC654_MFR_ID_MICROCHIP)
45 + product = i2c_smbus_read_byte_data(new_client, TC654_REG_VER_ID);
46 + if (!((product == TC654_VER_ID) || (product == TC655_VER_ID)))
49 + strlcpy(info->type, product == TC654_VER_ID ? "tc654" : "tc655",
55 MODULE_DEVICE_TABLE(i2c, tc654_id);
57 static struct i2c_driver tc654_driver = {
58 @@ -505,6 +533,7 @@ static struct i2c_driver tc654_driver =
62 + .detect = tc654_detect,
65 module_i2c_driver(tc654_driver);