diff options
author | Guenter Roeck <linux@roeck-us.net> | 2013-03-28 04:36:44 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2013-04-21 11:56:48 -0400 |
commit | 29dd3b64b9edba3dd3dc8bb4d589869a4597a710 (patch) | |
tree | fdc8d81542108ea8ee93e9c4ae722232f5eedac8 /drivers/hwmon | |
parent | 0846e30dd403ca613c203ccb6e4a89c09235480c (diff) |
hwmon: (tmp401) Add support for TMP432
TMP432 is similar to TMP431 with a second external temperature sensor.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/Kconfig | 2 | ||||
-rw-r--r-- | drivers/hwmon/tmp401.c | 192 |
2 files changed, 156 insertions, 38 deletions
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 26ebff0b45ca..4f29117651b6 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig | |||
@@ -1249,7 +1249,7 @@ config SENSORS_TMP401 | |||
1249 | depends on I2C | 1249 | depends on I2C |
1250 | help | 1250 | help |
1251 | If you say yes here you get support for Texas Instruments TMP401, | 1251 | If you say yes here you get support for Texas Instruments TMP401, |
1252 | TMP411, and TMP431 temperature sensor chips. | 1252 | TMP411, TMP431, and TMP432 temperature sensor chips. |
1253 | 1253 | ||
1254 | This driver can also be built as a module. If so, the module | 1254 | This driver can also be built as a module. If so, the module |
1255 | will be called tmp401. | 1255 | will be called tmp401. |
diff --git a/drivers/hwmon/tmp401.c b/drivers/hwmon/tmp401.c index fa6af51b300d..a478454f690f 100644 --- a/drivers/hwmon/tmp401.c +++ b/drivers/hwmon/tmp401.c | |||
@@ -5,6 +5,9 @@ | |||
5 | * Gabriel Konat, Sander Leget, Wouter Willems | 5 | * Gabriel Konat, Sander Leget, Wouter Willems |
6 | * Copyright (C) 2009 Andre Prendel <andre.prendel@gmx.de> | 6 | * Copyright (C) 2009 Andre Prendel <andre.prendel@gmx.de> |
7 | * | 7 | * |
8 | * Cleanup and support for TMP431 and TMP432 by Guenter Roeck | ||
9 | * Copyright (c) 2013 Guenter Roeck <linux@roeck-us.net> | ||
10 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | 11 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by | 12 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation; either version 2 of the License, or | 13 | * the Free Software Foundation; either version 2 of the License, or |
@@ -43,7 +46,7 @@ | |||
43 | /* Addresses to scan */ | 46 | /* Addresses to scan */ |
44 | static const unsigned short normal_i2c[] = { 0x4c, 0x4d, 0x4e, I2C_CLIENT_END }; | 47 | static const unsigned short normal_i2c[] = { 0x4c, 0x4d, 0x4e, I2C_CLIENT_END }; |
45 | 48 | ||
46 | enum chips { tmp401, tmp411, tmp431 }; | 49 | enum chips { tmp401, tmp411, tmp431, tmp432 }; |
47 | 50 | ||
48 | /* | 51 | /* |
49 | * The TMP401 registers, note some registers have different addresses for | 52 | * The TMP401 registers, note some registers have different addresses for |
@@ -85,6 +88,30 @@ static const u8 TMP401_TEMP_LSB[6][2] = { | |||
85 | { 0x33, 0x37 }, /* highest */ | 88 | { 0x33, 0x37 }, /* highest */ |
86 | }; | 89 | }; |
87 | 90 | ||
91 | static const u8 TMP432_TEMP_MSB_READ[4][3] = { | ||
92 | { 0x00, 0x01, 0x23 }, /* temp */ | ||
93 | { 0x06, 0x08, 0x16 }, /* low limit */ | ||
94 | { 0x05, 0x07, 0x15 }, /* high limit */ | ||
95 | { 0x20, 0x19, 0x1A }, /* therm (crit) limit */ | ||
96 | }; | ||
97 | |||
98 | static const u8 TMP432_TEMP_MSB_WRITE[4][3] = { | ||
99 | { 0, 0, 0 }, /* temp - unused */ | ||
100 | { 0x0C, 0x0E, 0x16 }, /* low limit */ | ||
101 | { 0x0B, 0x0D, 0x15 }, /* high limit */ | ||
102 | { 0x20, 0x19, 0x1A }, /* therm (crit) limit */ | ||
103 | }; | ||
104 | |||
105 | static const u8 TMP432_TEMP_LSB[3][3] = { | ||
106 | { 0x29, 0x10, 0x24 }, /* temp */ | ||
107 | { 0x3E, 0x14, 0x18 }, /* low limit */ | ||
108 | { 0x3D, 0x13, 0x17 }, /* high limit */ | ||
109 | }; | ||
110 | |||
111 | /* [0] = fault, [1] = low, [2] = high, [3] = therm/crit */ | ||
112 | static const u8 TMP432_STATUS_REG[] = { | ||
113 | 0x1b, 0x36, 0x35, 0x37 }; | ||
114 | |||
88 | /* Flags */ | 115 | /* Flags */ |
89 | #define TMP401_CONFIG_RANGE BIT(2) | 116 | #define TMP401_CONFIG_RANGE BIT(2) |
90 | #define TMP401_CONFIG_SHUTDOWN BIT(6) | 117 | #define TMP401_CONFIG_SHUTDOWN BIT(6) |
@@ -96,6 +123,11 @@ static const u8 TMP401_TEMP_LSB[6][2] = { | |||
96 | #define TMP401_STATUS_LOCAL_LOW BIT(5) | 123 | #define TMP401_STATUS_LOCAL_LOW BIT(5) |
97 | #define TMP401_STATUS_LOCAL_HIGH BIT(6) | 124 | #define TMP401_STATUS_LOCAL_HIGH BIT(6) |
98 | 125 | ||
126 | /* On TMP432, each status has its own register */ | ||
127 | #define TMP432_STATUS_LOCAL BIT(0) | ||
128 | #define TMP432_STATUS_REMOTE1 BIT(1) | ||
129 | #define TMP432_STATUS_REMOTE2 BIT(2) | ||
130 | |||
99 | /* Manufacturer / Device ID's */ | 131 | /* Manufacturer / Device ID's */ |
100 | #define TMP401_MANUFACTURER_ID 0x55 | 132 | #define TMP401_MANUFACTURER_ID 0x55 |
101 | #define TMP401_DEVICE_ID 0x11 | 133 | #define TMP401_DEVICE_ID 0x11 |
@@ -103,6 +135,7 @@ static const u8 TMP401_TEMP_LSB[6][2] = { | |||
103 | #define TMP411B_DEVICE_ID 0x13 | 135 | #define TMP411B_DEVICE_ID 0x13 |
104 | #define TMP411C_DEVICE_ID 0x10 | 136 | #define TMP411C_DEVICE_ID 0x10 |
105 | #define TMP431_DEVICE_ID 0x31 | 137 | #define TMP431_DEVICE_ID 0x31 |
138 | #define TMP432_DEVICE_ID 0x32 | ||
106 | 139 | ||
107 | /* | 140 | /* |
108 | * Driver data (common to all clients) | 141 | * Driver data (common to all clients) |
@@ -112,6 +145,7 @@ static const struct i2c_device_id tmp401_id[] = { | |||
112 | { "tmp401", tmp401 }, | 145 | { "tmp401", tmp401 }, |
113 | { "tmp411", tmp411 }, | 146 | { "tmp411", tmp411 }, |
114 | { "tmp431", tmp431 }, | 147 | { "tmp431", tmp431 }, |
148 | { "tmp432", tmp432 }, | ||
115 | { } | 149 | { } |
116 | }; | 150 | }; |
117 | MODULE_DEVICE_TABLE(i2c, tmp401_id); | 151 | MODULE_DEVICE_TABLE(i2c, tmp401_id); |
@@ -130,9 +164,9 @@ struct tmp401_data { | |||
130 | unsigned int update_interval; /* in milliseconds */ | 164 | unsigned int update_interval; /* in milliseconds */ |
131 | 165 | ||
132 | /* register values */ | 166 | /* register values */ |
133 | u8 status; | 167 | u8 status[4]; |
134 | u8 config; | 168 | u8 config; |
135 | u16 temp[6][2]; | 169 | u16 temp[6][3]; |
136 | u8 temp_crit_hyst; | 170 | u8 temp_crit_hyst; |
137 | }; | 171 | }; |
138 | 172 | ||
@@ -166,22 +200,27 @@ static int tmp401_update_device_reg16(struct i2c_client *client, | |||
166 | { | 200 | { |
167 | int i, j, val; | 201 | int i, j, val; |
168 | int num_regs = data->kind == tmp411 ? 6 : 4; | 202 | int num_regs = data->kind == tmp411 ? 6 : 4; |
203 | int num_sensors = data->kind == tmp432 ? 3 : 2; | ||
169 | 204 | ||
170 | for (i = 0; i < 2; i++) { /* local / rem1 */ | 205 | for (i = 0; i < num_sensors; i++) { /* local / r1 / r2 */ |
171 | for (j = 0; j < num_regs; j++) { /* temp / low / ... */ | 206 | for (j = 0; j < num_regs; j++) { /* temp / low / ... */ |
207 | u8 regaddr; | ||
172 | /* | 208 | /* |
173 | * High byte must be read first immediately followed | 209 | * High byte must be read first immediately followed |
174 | * by the low byte | 210 | * by the low byte |
175 | */ | 211 | */ |
176 | val = i2c_smbus_read_byte_data(client, | 212 | regaddr = data->kind == tmp432 ? |
177 | TMP401_TEMP_MSB_READ[j][i]); | 213 | TMP432_TEMP_MSB_READ[j][i] : |
214 | TMP401_TEMP_MSB_READ[j][i]; | ||
215 | val = i2c_smbus_read_byte_data(client, regaddr); | ||
178 | if (val < 0) | 216 | if (val < 0) |
179 | return val; | 217 | return val; |
180 | data->temp[j][i] = val << 8; | 218 | data->temp[j][i] = val << 8; |
181 | if (j == 3) /* crit is msb only */ | 219 | if (j == 3) /* crit is msb only */ |
182 | continue; | 220 | continue; |
183 | val = i2c_smbus_read_byte_data(client, | 221 | regaddr = data->kind == tmp432 ? TMP432_TEMP_LSB[j][i] |
184 | TMP401_TEMP_LSB[j][i]); | 222 | : TMP401_TEMP_LSB[j][i]; |
223 | val = i2c_smbus_read_byte_data(client, regaddr); | ||
185 | if (val < 0) | 224 | if (val < 0) |
186 | return val; | 225 | return val; |
187 | data->temp[j][i] |= val; | 226 | data->temp[j][i] |= val; |
@@ -195,7 +234,7 @@ static struct tmp401_data *tmp401_update_device(struct device *dev) | |||
195 | struct i2c_client *client = to_i2c_client(dev); | 234 | struct i2c_client *client = to_i2c_client(dev); |
196 | struct tmp401_data *data = i2c_get_clientdata(client); | 235 | struct tmp401_data *data = i2c_get_clientdata(client); |
197 | struct tmp401_data *ret = data; | 236 | struct tmp401_data *ret = data; |
198 | int val; | 237 | int i, val; |
199 | unsigned long next_update; | 238 | unsigned long next_update; |
200 | 239 | ||
201 | mutex_lock(&data->update_lock); | 240 | mutex_lock(&data->update_lock); |
@@ -203,12 +242,38 @@ static struct tmp401_data *tmp401_update_device(struct device *dev) | |||
203 | next_update = data->last_updated + | 242 | next_update = data->last_updated + |
204 | msecs_to_jiffies(data->update_interval) + 1; | 243 | msecs_to_jiffies(data->update_interval) + 1; |
205 | if (time_after(jiffies, next_update) || !data->valid) { | 244 | if (time_after(jiffies, next_update) || !data->valid) { |
206 | val = i2c_smbus_read_byte_data(client, TMP401_STATUS); | 245 | if (data->kind != tmp432) { |
207 | if (val < 0) { | 246 | /* |
208 | ret = ERR_PTR(val); | 247 | * The driver uses the TMP432 status format internally. |
209 | goto abort; | 248 | * Convert status to TMP432 format for other chips. |
249 | */ | ||
250 | val = i2c_smbus_read_byte_data(client, TMP401_STATUS); | ||
251 | if (val < 0) { | ||
252 | ret = ERR_PTR(val); | ||
253 | goto abort; | ||
254 | } | ||
255 | data->status[0] = | ||
256 | (val & TMP401_STATUS_REMOTE_OPEN) >> 1; | ||
257 | data->status[1] = | ||
258 | ((val & TMP401_STATUS_REMOTE_LOW) >> 2) | | ||
259 | ((val & TMP401_STATUS_LOCAL_LOW) >> 5); | ||
260 | data->status[2] = | ||
261 | ((val & TMP401_STATUS_REMOTE_HIGH) >> 3) | | ||
262 | ((val & TMP401_STATUS_LOCAL_HIGH) >> 6); | ||
263 | data->status[3] = val & (TMP401_STATUS_LOCAL_CRIT | ||
264 | | TMP401_STATUS_REMOTE_CRIT); | ||
265 | } else { | ||
266 | for (i = 0; i < ARRAY_SIZE(data->status); i++) { | ||
267 | val = i2c_smbus_read_byte_data(client, | ||
268 | TMP432_STATUS_REG[i]); | ||
269 | if (val < 0) { | ||
270 | ret = ERR_PTR(val); | ||
271 | goto abort; | ||
272 | } | ||
273 | data->status[i] = val; | ||
274 | } | ||
210 | } | 275 | } |
211 | data->status = val; | 276 | |
212 | val = i2c_smbus_read_byte_data(client, TMP401_CONFIG_READ); | 277 | val = i2c_smbus_read_byte_data(client, TMP401_CONFIG_READ); |
213 | if (val < 0) { | 278 | if (val < 0) { |
214 | ret = ERR_PTR(val); | 279 | ret = ERR_PTR(val); |
@@ -270,13 +335,14 @@ static ssize_t show_temp_crit_hyst(struct device *dev, | |||
270 | static ssize_t show_status(struct device *dev, | 335 | static ssize_t show_status(struct device *dev, |
271 | struct device_attribute *devattr, char *buf) | 336 | struct device_attribute *devattr, char *buf) |
272 | { | 337 | { |
273 | int mask = to_sensor_dev_attr(devattr)->index; | 338 | int nr = to_sensor_dev_attr_2(devattr)->nr; |
339 | int mask = to_sensor_dev_attr_2(devattr)->index; | ||
274 | struct tmp401_data *data = tmp401_update_device(dev); | 340 | struct tmp401_data *data = tmp401_update_device(dev); |
275 | 341 | ||
276 | if (IS_ERR(data)) | 342 | if (IS_ERR(data)) |
277 | return PTR_ERR(data); | 343 | return PTR_ERR(data); |
278 | 344 | ||
279 | return sprintf(buf, "%d\n", !!(data->status & mask)); | 345 | return sprintf(buf, "%d\n", !!(data->status[nr] & mask)); |
280 | } | 346 | } |
281 | 347 | ||
282 | static ssize_t store_temp(struct device *dev, struct device_attribute *devattr, | 348 | static ssize_t store_temp(struct device *dev, struct device_attribute *devattr, |
@@ -288,6 +354,7 @@ static ssize_t store_temp(struct device *dev, struct device_attribute *devattr, | |||
288 | struct tmp401_data *data = tmp401_update_device(dev); | 354 | struct tmp401_data *data = tmp401_update_device(dev); |
289 | long val; | 355 | long val; |
290 | u16 reg; | 356 | u16 reg; |
357 | u8 regaddr; | ||
291 | 358 | ||
292 | if (IS_ERR(data)) | 359 | if (IS_ERR(data)) |
293 | return PTR_ERR(data); | 360 | return PTR_ERR(data); |
@@ -299,13 +366,13 @@ static ssize_t store_temp(struct device *dev, struct device_attribute *devattr, | |||
299 | 366 | ||
300 | mutex_lock(&data->update_lock); | 367 | mutex_lock(&data->update_lock); |
301 | 368 | ||
302 | i2c_smbus_write_byte_data(client, | 369 | regaddr = data->kind == tmp432 ? TMP432_TEMP_MSB_WRITE[nr][index] |
303 | TMP401_TEMP_MSB_WRITE[nr][index], | 370 | : TMP401_TEMP_MSB_WRITE[nr][index]; |
304 | reg >> 8); | 371 | i2c_smbus_write_byte_data(client, regaddr, reg >> 8); |
305 | if (nr != 3) { | 372 | if (nr != 3) { |
306 | i2c_smbus_write_byte_data(client, | 373 | regaddr = data->kind == tmp432 ? TMP432_TEMP_LSB[nr][index] |
307 | TMP401_TEMP_LSB[nr][index], | 374 | : TMP401_TEMP_LSB[nr][index]; |
308 | reg & 0xFF); | 375 | i2c_smbus_write_byte_data(client, regaddr, reg & 0xFF); |
309 | } | 376 | } |
310 | data->temp[nr][index] = reg; | 377 | data->temp[nr][index] = reg; |
311 | 378 | ||
@@ -426,12 +493,12 @@ static SENSOR_DEVICE_ATTR_2(temp1_crit, S_IWUSR | S_IRUGO, show_temp, | |||
426 | store_temp, 3, 0); | 493 | store_temp, 3, 0); |
427 | static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, | 494 | static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, |
428 | show_temp_crit_hyst, store_temp_crit_hyst, 0); | 495 | show_temp_crit_hyst, store_temp_crit_hyst, 0); |
429 | static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_status, NULL, | 496 | static SENSOR_DEVICE_ATTR_2(temp1_min_alarm, S_IRUGO, show_status, NULL, |
430 | TMP401_STATUS_LOCAL_LOW); | 497 | 1, TMP432_STATUS_LOCAL); |
431 | static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_status, NULL, | 498 | static SENSOR_DEVICE_ATTR_2(temp1_max_alarm, S_IRUGO, show_status, NULL, |
432 | TMP401_STATUS_LOCAL_HIGH); | 499 | 2, TMP432_STATUS_LOCAL); |
433 | static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_status, NULL, | 500 | static SENSOR_DEVICE_ATTR_2(temp1_crit_alarm, S_IRUGO, show_status, NULL, |
434 | TMP401_STATUS_LOCAL_CRIT); | 501 | 3, TMP432_STATUS_LOCAL); |
435 | static SENSOR_DEVICE_ATTR_2(temp2_input, S_IRUGO, show_temp, NULL, 0, 1); | 502 | static SENSOR_DEVICE_ATTR_2(temp2_input, S_IRUGO, show_temp, NULL, 0, 1); |
436 | static SENSOR_DEVICE_ATTR_2(temp2_min, S_IWUSR | S_IRUGO, show_temp, | 503 | static SENSOR_DEVICE_ATTR_2(temp2_min, S_IWUSR | S_IRUGO, show_temp, |
437 | store_temp, 1, 1); | 504 | store_temp, 1, 1); |
@@ -441,14 +508,14 @@ static SENSOR_DEVICE_ATTR_2(temp2_crit, S_IWUSR | S_IRUGO, show_temp, | |||
441 | store_temp, 3, 1); | 508 | store_temp, 3, 1); |
442 | static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temp_crit_hyst, | 509 | static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_temp_crit_hyst, |
443 | NULL, 1); | 510 | NULL, 1); |
444 | static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_status, NULL, | 511 | static SENSOR_DEVICE_ATTR_2(temp2_fault, S_IRUGO, show_status, NULL, |
445 | TMP401_STATUS_REMOTE_OPEN); | 512 | 0, TMP432_STATUS_REMOTE1); |
446 | static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, show_status, NULL, | 513 | static SENSOR_DEVICE_ATTR_2(temp2_min_alarm, S_IRUGO, show_status, NULL, |
447 | TMP401_STATUS_REMOTE_LOW); | 514 | 1, TMP432_STATUS_REMOTE1); |
448 | static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_status, NULL, | 515 | static SENSOR_DEVICE_ATTR_2(temp2_max_alarm, S_IRUGO, show_status, NULL, |
449 | TMP401_STATUS_REMOTE_HIGH); | 516 | 2, TMP432_STATUS_REMOTE1); |
450 | static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_status, NULL, | 517 | static SENSOR_DEVICE_ATTR_2(temp2_crit_alarm, S_IRUGO, show_status, NULL, |
451 | TMP401_STATUS_REMOTE_CRIT); | 518 | 3, TMP432_STATUS_REMOTE1); |
452 | 519 | ||
453 | static DEVICE_ATTR(update_interval, S_IRUGO | S_IWUSR, show_update_interval, | 520 | static DEVICE_ATTR(update_interval, S_IRUGO | S_IWUSR, show_update_interval, |
454 | set_update_interval); | 521 | set_update_interval); |
@@ -509,6 +576,42 @@ static const struct attribute_group tmp411_group = { | |||
509 | .attrs = tmp411_attributes, | 576 | .attrs = tmp411_attributes, |
510 | }; | 577 | }; |
511 | 578 | ||
579 | static SENSOR_DEVICE_ATTR_2(temp3_input, S_IRUGO, show_temp, NULL, 0, 2); | ||
580 | static SENSOR_DEVICE_ATTR_2(temp3_min, S_IWUSR | S_IRUGO, show_temp, | ||
581 | store_temp, 1, 2); | ||
582 | static SENSOR_DEVICE_ATTR_2(temp3_max, S_IWUSR | S_IRUGO, show_temp, | ||
583 | store_temp, 2, 2); | ||
584 | static SENSOR_DEVICE_ATTR_2(temp3_crit, S_IWUSR | S_IRUGO, show_temp, | ||
585 | store_temp, 3, 2); | ||
586 | static SENSOR_DEVICE_ATTR(temp3_crit_hyst, S_IRUGO, show_temp_crit_hyst, | ||
587 | NULL, 2); | ||
588 | static SENSOR_DEVICE_ATTR_2(temp3_fault, S_IRUGO, show_status, NULL, | ||
589 | 0, TMP432_STATUS_REMOTE2); | ||
590 | static SENSOR_DEVICE_ATTR_2(temp3_min_alarm, S_IRUGO, show_status, NULL, | ||
591 | 1, TMP432_STATUS_REMOTE2); | ||
592 | static SENSOR_DEVICE_ATTR_2(temp3_max_alarm, S_IRUGO, show_status, NULL, | ||
593 | 2, TMP432_STATUS_REMOTE2); | ||
594 | static SENSOR_DEVICE_ATTR_2(temp3_crit_alarm, S_IRUGO, show_status, NULL, | ||
595 | 3, TMP432_STATUS_REMOTE2); | ||
596 | |||
597 | static struct attribute *tmp432_attributes[] = { | ||
598 | &sensor_dev_attr_temp3_input.dev_attr.attr, | ||
599 | &sensor_dev_attr_temp3_min.dev_attr.attr, | ||
600 | &sensor_dev_attr_temp3_max.dev_attr.attr, | ||
601 | &sensor_dev_attr_temp3_crit.dev_attr.attr, | ||
602 | &sensor_dev_attr_temp3_crit_hyst.dev_attr.attr, | ||
603 | &sensor_dev_attr_temp3_fault.dev_attr.attr, | ||
604 | &sensor_dev_attr_temp3_max_alarm.dev_attr.attr, | ||
605 | &sensor_dev_attr_temp3_min_alarm.dev_attr.attr, | ||
606 | &sensor_dev_attr_temp3_crit_alarm.dev_attr.attr, | ||
607 | |||
608 | NULL | ||
609 | }; | ||
610 | |||
611 | static const struct attribute_group tmp432_group = { | ||
612 | .attrs = tmp432_attributes, | ||
613 | }; | ||
614 | |||
512 | /* | 615 | /* |
513 | * Begin non sysfs callback code (aka Real code) | 616 | * Begin non sysfs callback code (aka Real code) |
514 | */ | 617 | */ |
@@ -579,6 +682,11 @@ static int tmp401_detect(struct i2c_client *client, | |||
579 | return -ENODEV; | 682 | return -ENODEV; |
580 | kind = tmp431; | 683 | kind = tmp431; |
581 | break; | 684 | break; |
685 | case TMP432_DEVICE_ID: | ||
686 | if (client->addr == 0x4e) | ||
687 | return -ENODEV; | ||
688 | kind = tmp432; | ||
689 | break; | ||
582 | default: | 690 | default: |
583 | return -ENODEV; | 691 | return -ENODEV; |
584 | } | 692 | } |
@@ -610,6 +718,9 @@ static int tmp401_remove(struct i2c_client *client) | |||
610 | if (data->kind == tmp411) | 718 | if (data->kind == tmp411) |
611 | sysfs_remove_group(&dev->kobj, &tmp411_group); | 719 | sysfs_remove_group(&dev->kobj, &tmp411_group); |
612 | 720 | ||
721 | if (data->kind == tmp432) | ||
722 | sysfs_remove_group(&dev->kobj, &tmp432_group); | ||
723 | |||
613 | return 0; | 724 | return 0; |
614 | } | 725 | } |
615 | 726 | ||
@@ -619,7 +730,7 @@ static int tmp401_probe(struct i2c_client *client, | |||
619 | struct device *dev = &client->dev; | 730 | struct device *dev = &client->dev; |
620 | int err; | 731 | int err; |
621 | struct tmp401_data *data; | 732 | struct tmp401_data *data; |
622 | const char *names[] = { "TMP401", "TMP411", "TMP431" }; | 733 | const char *names[] = { "TMP401", "TMP411", "TMP431", "TMP432" }; |
623 | 734 | ||
624 | data = devm_kzalloc(dev, sizeof(struct tmp401_data), GFP_KERNEL); | 735 | data = devm_kzalloc(dev, sizeof(struct tmp401_data), GFP_KERNEL); |
625 | if (!data) | 736 | if (!data) |
@@ -644,6 +755,13 @@ static int tmp401_probe(struct i2c_client *client, | |||
644 | goto exit_remove; | 755 | goto exit_remove; |
645 | } | 756 | } |
646 | 757 | ||
758 | /* Register additional tmp432 sysfs hooks */ | ||
759 | if (data->kind == tmp432) { | ||
760 | err = sysfs_create_group(&dev->kobj, &tmp432_group); | ||
761 | if (err) | ||
762 | goto exit_remove; | ||
763 | } | ||
764 | |||
647 | data->hwmon_dev = hwmon_device_register(dev); | 765 | data->hwmon_dev = hwmon_device_register(dev); |
648 | if (IS_ERR(data->hwmon_dev)) { | 766 | if (IS_ERR(data->hwmon_dev)) { |
649 | err = PTR_ERR(data->hwmon_dev); | 767 | err = PTR_ERR(data->hwmon_dev); |