aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/ftsteutates.c
diff options
context:
space:
mode:
authorThilo Cestonaro <thilo@cestona.ro>2016-08-16 07:07:53 -0400
committerGuenter Roeck <linux@roeck-us.net>2016-09-09 00:34:16 -0400
commit2d5aee433d9c5bb6075eb42039a21c5b3728d22d (patch)
treeb534bc94f26f2a6611eb5d75c9af0f1b5d5e0f35 /drivers/hwmon/ftsteutates.c
parented42cfa881e1d8d9603b7cb872199e3c8e0d1b19 (diff)
hwmon: (ftsteutates) Add i2c detect functionality
Signed-off-by: Thilo Cestonaro <thilo@cestona.ro> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/ftsteutates.c')
-rw-r--r--drivers/hwmon/ftsteutates.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/drivers/hwmon/ftsteutates.c b/drivers/hwmon/ftsteutates.c
index 48633e541dc3..0f0277e7aae5 100644
--- a/drivers/hwmon/ftsteutates.c
+++ b/drivers/hwmon/ftsteutates.c
@@ -36,6 +36,10 @@
36#define FTS_EVENT_STATUS_REG 0x0006 36#define FTS_EVENT_STATUS_REG 0x0006
37#define FTS_GLOBAL_CONTROL_REG 0x0007 37#define FTS_GLOBAL_CONTROL_REG 0x0007
38 38
39#define FTS_DEVICE_DETECT_REG_1 0x0C
40#define FTS_DEVICE_DETECT_REG_2 0x0D
41#define FTS_DEVICE_DETECT_REG_3 0x0E
42
39#define FTS_SENSOR_EVENT_REG 0x0010 43#define FTS_SENSOR_EVENT_REG 0x0010
40 44
41#define FTS_FAN_EVENT_REG 0x0014 45#define FTS_FAN_EVENT_REG 0x0014
@@ -54,6 +58,8 @@
54#define FTS_NO_TEMP_SENSORS 0x10 58#define FTS_NO_TEMP_SENSORS 0x10
55#define FTS_NO_VOLT_SENSORS 0x04 59#define FTS_NO_VOLT_SENSORS 0x04
56 60
61static const unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END };
62
57static struct i2c_device_id fts_id[] = { 63static struct i2c_device_id fts_id[] = {
58 { "ftsteutates", 0 }, 64 { "ftsteutates", 0 },
59 { } 65 { }
@@ -734,6 +740,42 @@ static const struct attribute_group *fts_attr_groups[] = {
734/*****************************************************************************/ 740/*****************************************************************************/
735/* Module initialization / remove functions */ 741/* Module initialization / remove functions */
736/*****************************************************************************/ 742/*****************************************************************************/
743static int fts_detect(struct i2c_client *client,
744 struct i2c_board_info *info)
745{
746 int val;
747
748 /* detection works with revsion greater or equal to 0x2b */
749 val = i2c_smbus_read_byte_data(client, FTS_DEVICE_REVISION_REG);
750 if (val < 0x2b)
751 return -ENODEV;
752
753 /* Device Detect Regs must have 0x17 0x34 and 0x54 */
754 val = i2c_smbus_read_byte_data(client, FTS_DEVICE_DETECT_REG_1);
755 if (val != 0x17)
756 return -ENODEV;
757
758 val = i2c_smbus_read_byte_data(client, FTS_DEVICE_DETECT_REG_2);
759 if (val != 0x34)
760 return -ENODEV;
761
762 val = i2c_smbus_read_byte_data(client, FTS_DEVICE_DETECT_REG_3);
763 if (val != 0x54)
764 return -ENODEV;
765
766 /*
767 * 0x10 == Baseboard Management Controller, 0x01 == Teutates
768 * Device ID Reg needs to be 0x11
769 */
770 val = i2c_smbus_read_byte_data(client, FTS_DEVICE_ID_REG);
771 if (val != 0x11)
772 return -ENODEV;
773
774 strlcpy(info->type, fts_id[0].name, I2C_NAME_SIZE);
775 info->flags = 0;
776 return 0;
777}
778
737static int fts_remove(struct i2c_client *client) 779static int fts_remove(struct i2c_client *client)
738{ 780{
739 struct fts_data *data = dev_get_drvdata(&client->dev); 781 struct fts_data *data = dev_get_drvdata(&client->dev);
@@ -804,12 +846,15 @@ static int fts_probe(struct i2c_client *client, const struct i2c_device_id *id)
804/* Module Details */ 846/* Module Details */
805/*****************************************************************************/ 847/*****************************************************************************/
806static struct i2c_driver fts_driver = { 848static struct i2c_driver fts_driver = {
849 .class = I2C_CLASS_HWMON,
807 .driver = { 850 .driver = {
808 .name = "ftsteutates", 851 .name = "ftsteutates",
809 }, 852 },
810 .id_table = fts_id, 853 .id_table = fts_id,
811 .probe = fts_probe, 854 .probe = fts_probe,
812 .remove = fts_remove, 855 .remove = fts_remove,
856 .detect = fts_detect,
857 .address_list = normal_i2c,
813}; 858};
814 859
815module_i2c_driver(fts_driver); 860module_i2c_driver(fts_driver);