aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm90.c
diff options
context:
space:
mode:
authorWei Ni <wni@nvidia.com>2013-11-15 04:40:39 -0500
committerJean Delvare <khali@endymion.delvare>2013-11-15 04:40:39 -0500
commit1daaceb26d5e6cc08eedf03f64ab220f62243c22 (patch)
tree4e5288b6f071177591efb375e4e27380a32d3cd2 /drivers/hwmon/lm90.c
parent40465d9424453aa499ea91114d94b52ef8f75d61 (diff)
hwmon: (lm90) Add support for TI TMP451
TI TMP451 is mostly compatible with ADT7461, except for local temperature low byte and max conversion rate. Add support to the LM90 driver. Signed-off-by: Wei Ni <wni@nvidia.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon/lm90.c')
-rw-r--r--drivers/hwmon/lm90.c45
1 files changed, 37 insertions, 8 deletions
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index 6b0a39264bb0..03735c490891 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -60,6 +60,11 @@
60 * This driver also supports the G781 from GMT. This device is compatible 60 * This driver also supports the G781 from GMT. This device is compatible
61 * with the ADM1032. 61 * with the ADM1032.
62 * 62 *
63 * This driver also supports TMP451 from Texas Instruments. This device is
64 * supported in both compatibility and extended mode. It's mostly compatible
65 * with ADT7461 except for local temperature low byte register and max
66 * conversion rate.
67 *
63 * Since the LM90 was the first chipset supported by this driver, most 68 * Since the LM90 was the first chipset supported by this driver, most
64 * comments will refer to this chipset, but are actually general and 69 * comments will refer to this chipset, but are actually general and
65 * concern all supported chipsets, unless mentioned otherwise. 70 * concern all supported chipsets, unless mentioned otherwise.
@@ -111,7 +116,7 @@ static const unsigned short normal_i2c[] = {
111 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; 116 0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
112 117
113enum chips { lm90, adm1032, lm99, lm86, max6657, max6659, adt7461, max6680, 118enum chips { lm90, adm1032, lm99, lm86, max6657, max6659, adt7461, max6680,
114 max6646, w83l771, max6696, sa56004, g781 }; 119 max6646, w83l771, max6696, sa56004, g781, tmp451 };
115 120
116/* 121/*
117 * The LM90 registers 122 * The LM90 registers
@@ -168,6 +173,9 @@ enum chips { lm90, adm1032, lm99, lm86, max6657, max6659, adt7461, max6680,
168#define LM90_DEF_CONVRATE_RVAL 6 /* Def conversion rate register value */ 173#define LM90_DEF_CONVRATE_RVAL 6 /* Def conversion rate register value */
169#define LM90_MAX_CONVRATE_MS 16000 /* Maximum conversion rate in ms */ 174#define LM90_MAX_CONVRATE_MS 16000 /* Maximum conversion rate in ms */
170 175
176/* TMP451 registers */
177#define TMP451_REG_R_LOCAL_TEMPL 0x15
178
171/* 179/*
172 * Device flags 180 * Device flags
173 */ 181 */
@@ -223,6 +231,7 @@ static const struct i2c_device_id lm90_id[] = {
223 { "nct1008", adt7461 }, 231 { "nct1008", adt7461 },
224 { "w83l771", w83l771 }, 232 { "w83l771", w83l771 },
225 { "sa56004", sa56004 }, 233 { "sa56004", sa56004 },
234 { "tmp451", tmp451 },
226 { } 235 { }
227}; 236};
228MODULE_DEVICE_TABLE(i2c, lm90_id); 237MODULE_DEVICE_TABLE(i2c, lm90_id);
@@ -311,6 +320,13 @@ static const struct lm90_params lm90_params[] = {
311 .max_convrate = 9, 320 .max_convrate = 9,
312 .reg_local_ext = SA56004_REG_R_LOCAL_TEMPL, 321 .reg_local_ext = SA56004_REG_R_LOCAL_TEMPL,
313 }, 322 },
323 [tmp451] = {
324 .flags = LM90_HAVE_OFFSET | LM90_HAVE_REM_LIMIT_EXT
325 | LM90_HAVE_BROKEN_ALERT,
326 .alert_alarms = 0x7c,
327 .max_convrate = 9,
328 .reg_local_ext = TMP451_REG_R_LOCAL_TEMPL,
329 }
314}; 330};
315 331
316/* 332/*
@@ -746,7 +762,7 @@ static ssize_t show_temp8(struct device *dev, struct device_attribute *devattr,
746 struct lm90_data *data = lm90_update_device(dev); 762 struct lm90_data *data = lm90_update_device(dev);
747 int temp; 763 int temp;
748 764
749 if (data->kind == adt7461) 765 if (data->kind == adt7461 || data->kind == tmp451)
750 temp = temp_from_u8_adt7461(data, data->temp8[attr->index]); 766 temp = temp_from_u8_adt7461(data, data->temp8[attr->index]);
751 else if (data->kind == max6646) 767 else if (data->kind == max6646)
752 temp = temp_from_u8(data->temp8[attr->index]); 768 temp = temp_from_u8(data->temp8[attr->index]);
@@ -790,7 +806,7 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr,
790 val -= 16000; 806 val -= 16000;
791 807
792 mutex_lock(&data->update_lock); 808 mutex_lock(&data->update_lock);
793 if (data->kind == adt7461) 809 if (data->kind == adt7461 || data->kind == tmp451)
794 data->temp8[nr] = temp_to_u8_adt7461(data, val); 810 data->temp8[nr] = temp_to_u8_adt7461(data, val);
795 else if (data->kind == max6646) 811 else if (data->kind == max6646)
796 data->temp8[nr] = temp_to_u8(val); 812 data->temp8[nr] = temp_to_u8(val);
@@ -812,7 +828,7 @@ static ssize_t show_temp11(struct device *dev, struct device_attribute *devattr,
812 struct lm90_data *data = lm90_update_device(dev); 828 struct lm90_data *data = lm90_update_device(dev);
813 int temp; 829 int temp;
814 830
815 if (data->kind == adt7461) 831 if (data->kind == adt7461 || data->kind == tmp451)
816 temp = temp_from_u16_adt7461(data, data->temp11[attr->index]); 832 temp = temp_from_u16_adt7461(data, data->temp11[attr->index]);
817 else if (data->kind == max6646) 833 else if (data->kind == max6646)
818 temp = temp_from_u16(data->temp11[attr->index]); 834 temp = temp_from_u16(data->temp11[attr->index]);
@@ -858,7 +874,7 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
858 val -= 16000; 874 val -= 16000;
859 875
860 mutex_lock(&data->update_lock); 876 mutex_lock(&data->update_lock);
861 if (data->kind == adt7461) 877 if (data->kind == adt7461 || data->kind == tmp451)
862 data->temp11[index] = temp_to_u16_adt7461(data, val); 878 data->temp11[index] = temp_to_u16_adt7461(data, val);
863 else if (data->kind == max6646) 879 else if (data->kind == max6646)
864 data->temp11[index] = temp_to_u8(val) << 8; 880 data->temp11[index] = temp_to_u8(val) << 8;
@@ -887,7 +903,7 @@ static ssize_t show_temphyst(struct device *dev,
887 struct lm90_data *data = lm90_update_device(dev); 903 struct lm90_data *data = lm90_update_device(dev);
888 int temp; 904 int temp;
889 905
890 if (data->kind == adt7461) 906 if (data->kind == adt7461 || data->kind == tmp451)
891 temp = temp_from_u8_adt7461(data, data->temp8[attr->index]); 907 temp = temp_from_u8_adt7461(data, data->temp8[attr->index]);
892 else if (data->kind == max6646) 908 else if (data->kind == max6646)
893 temp = temp_from_u8(data->temp8[attr->index]); 909 temp = temp_from_u8(data->temp8[attr->index]);
@@ -915,7 +931,7 @@ static ssize_t set_temphyst(struct device *dev, struct device_attribute *dummy,
915 return err; 931 return err;
916 932
917 mutex_lock(&data->update_lock); 933 mutex_lock(&data->update_lock);
918 if (data->kind == adt7461) 934 if (data->kind == adt7461 || data->kind == tmp451)
919 temp = temp_from_u8_adt7461(data, data->temp8[LOCAL_CRIT]); 935 temp = temp_from_u8_adt7461(data, data->temp8[LOCAL_CRIT]);
920 else if (data->kind == max6646) 936 else if (data->kind == max6646)
921 temp = temp_from_u8(data->temp8[LOCAL_CRIT]); 937 temp = temp_from_u8(data->temp8[LOCAL_CRIT]);
@@ -1348,6 +1364,19 @@ static int lm90_detect(struct i2c_client *client,
1348 && (config1 & 0x3F) == 0x00 1364 && (config1 & 0x3F) == 0x00
1349 && convrate <= 0x08) 1365 && convrate <= 0x08)
1350 name = "g781"; 1366 name = "g781";
1367 } else
1368 if (address == 0x4C
1369 && man_id == 0x55) { /* Texas Instruments */
1370 int local_ext;
1371
1372 local_ext = i2c_smbus_read_byte_data(client,
1373 TMP451_REG_R_LOCAL_TEMPL);
1374
1375 if (chip_id == 0x00 /* TMP451 */
1376 && (config1 & 0x1B) == 0x00
1377 && convrate <= 0x09
1378 && (local_ext & 0x0F) == 0x00)
1379 name = "tmp451";
1351 } 1380 }
1352 1381
1353 if (!name) { /* identification failed */ 1382 if (!name) { /* identification failed */
@@ -1409,7 +1438,7 @@ static void lm90_init_client(struct i2c_client *client)
1409 data->config_orig = config; 1438 data->config_orig = config;
1410 1439
1411 /* Check Temperature Range Select */ 1440 /* Check Temperature Range Select */
1412 if (data->kind == adt7461) { 1441 if (data->kind == adt7461 || data->kind == tmp451) {
1413 if (config & 0x04) 1442 if (config & 0x04)
1414 data->flags |= LM90_FLAG_ADT7461_EXT; 1443 data->flags |= LM90_FLAG_ADT7461_EXT;
1415 } 1444 }