Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: (lm90) Add max6654 support to lm90 driver

Add support for the Maxim MAX6654 to the lm90 driver.

The MAX6654 is a temperature sensor, similar to the others,
but with some differences regarding the configuration
register, and the sampling rate at which extended resolution
becomes possible.

Signed-off-by: Josh Lehan <krellan@google.com>
Link: https://lore.kernel.org/r/20200513184248.145765-1-krellan@google.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Josh Lehan and committed by
Guenter Roeck
229d495d 036855a4

+67 -10
+21 -2
Documentation/hwmon/lm90.rst
··· 123 123 124 124 http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3497 125 125 126 + * Maxim MAX6654 127 + 128 + Prefix: 'max6654' 129 + 130 + Addresses scanned: I2C 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 131 + 132 + 0x4c, 0x4d and 0x4e 133 + 134 + Datasheet: Publicly available at the Maxim website 135 + 136 + https://www.maximintegrated.com/en/products/sensors/MAX6654.html 137 + 126 138 * Maxim MAX6657 127 139 128 140 Prefix: 'max6657' ··· 313 301 * Extended temperature range (breaks compatibility) 314 302 * Lower resolution for remote temperature 315 303 304 + MAX6654: 305 + * Better local resolution 306 + * Selectable address 307 + * Remote sensor type selection 308 + * Extended temperature range 309 + * Extended resolution only available when conversion rate <= 1 Hz 310 + 316 311 MAX6657 and MAX6658: 317 312 * Better local resolution 318 313 * Remote sensor type selection ··· 355 336 356 337 All temperature values are given in degrees Celsius. Resolution 357 338 is 1.0 degree for the local temperature, 0.125 degree for the remote 358 - temperature, except for the MAX6657, MAX6658 and MAX6659 which have a 359 - resolution of 0.125 degree for both temperatures. 339 + temperature, except for the MAX6654, MAX6657, MAX6658 and MAX6659 which have 340 + a resolution of 0.125 degree for both temperatures. 360 341 361 342 Each sensor has its own high and low limits, plus a critical limit. 362 343 Additionally, there is a relative hysteresis value common to both critical
+5 -4
drivers/hwmon/Kconfig
··· 1198 1198 help 1199 1199 If you say yes here you get support for National Semiconductor LM90, 1200 1200 LM86, LM89 and LM99, Analog Devices ADM1032, ADT7461, and ADT7461A, 1201 - Maxim MAX6646, MAX6647, MAX6648, MAX6649, MAX6657, MAX6658, MAX6659, 1202 - MAX6680, MAX6681, MAX6692, MAX6695, MAX6696, ON Semiconductor NCT1008, 1203 - Winbond/Nuvoton W83L771W/G/AWG/ASG, Philips SA56004, GMT G781, and 1204 - Texas Instruments TMP451 sensor chips. 1201 + Maxim MAX6646, MAX6647, MAX6648, MAX6649, MAX6654, MAX6657, MAX6658, 1202 + MAX6659, MAX6680, MAX6681, MAX6692, MAX6695, MAX6696, 1203 + ON Semiconductor NCT1008, Winbond/Nuvoton W83L771W/G/AWG/ASG, 1204 + Philips SA56004, GMT G781, and Texas Instruments TMP451 1205 + sensor chips. 1205 1206 1206 1207 This driver can also be built as a module. If so, the module 1207 1208 will be called lm90.
+41 -4
drivers/hwmon/lm90.c
··· 35 35 * explicitly as max6659, or if its address is not 0x4c. 36 36 * These chips lack the remote temperature offset feature. 37 37 * 38 + * This driver also supports the MAX6654 chip made by Maxim. This chip can 39 + * be at 9 different addresses, similar to MAX6680/MAX6681. The MAX6654 is 40 + * otherwise similar to MAX6657/MAX6658/MAX6659. Extended range is available 41 + * by setting the configuration register accordingly, and is done during 42 + * initialization. Extended precision is only available at conversion rates 43 + * of 1 Hz and slower. Note that extended precision is not enabled by 44 + * default, as this driver initializes all chips to 2 Hz by design. 45 + * 38 46 * This driver also supports the MAX6646, MAX6647, MAX6648, MAX6649 and 39 47 * MAX6692 chips made by Maxim. These are again similar to the LM86, 40 48 * but they use unsigned temperature values and can report temperatures ··· 102 94 * have address 0x4d. 103 95 * MAX6647 has address 0x4e. 104 96 * MAX6659 can have address 0x4c, 0x4d or 0x4e. 105 - * MAX6680 and MAX6681 can have address 0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 106 - * 0x4c, 0x4d or 0x4e. 97 + * MAX6654, MAX6680, and MAX6681 can have address 0x18, 0x19, 0x1a, 0x29, 98 + * 0x2a, 0x2b, 0x4c, 0x4d or 0x4e. 107 99 * SA56004 can have address 0x48 through 0x4F. 108 100 */ 109 101 ··· 112 104 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; 113 105 114 106 enum chips { lm90, adm1032, lm99, lm86, max6657, max6659, adt7461, max6680, 115 - max6646, w83l771, max6696, sa56004, g781, tmp451 }; 107 + max6646, w83l771, max6696, sa56004, g781, tmp451, max6654 }; 116 108 117 109 /* 118 110 * The LM90 registers ··· 153 145 #define LM90_REG_R_TCRIT_HYST 0x21 154 146 #define LM90_REG_W_TCRIT_HYST 0x21 155 147 156 - /* MAX6646/6647/6649/6657/6658/6659/6695/6696 registers */ 148 + /* MAX6646/6647/6649/6654/6657/6658/6659/6695/6696 registers */ 157 149 158 150 #define MAX6657_REG_R_LOCAL_TEMPL 0x11 159 151 #define MAX6696_REG_R_STATUS2 0x12 ··· 217 209 { "max6646", max6646 }, 218 210 { "max6647", max6646 }, 219 211 { "max6649", max6646 }, 212 + { "max6654", max6654 }, 220 213 { "max6657", max6657 }, 221 214 { "max6658", max6657 }, 222 215 { "max6659", max6659 }, ··· 277 268 { 278 269 .compatible = "dallas,max6649", 279 270 .data = (void *)max6646 271 + }, 272 + { 273 + .compatible = "dallas,max6654", 274 + .data = (void *)max6654 280 275 }, 281 276 { 282 277 .compatible = "dallas,max6657", ··· 378 365 [max6646] = { 379 366 .alert_alarms = 0x7c, 380 367 .max_convrate = 6, 368 + .reg_local_ext = MAX6657_REG_R_LOCAL_TEMPL, 369 + }, 370 + [max6654] = { 371 + .alert_alarms = 0x7c, 372 + .max_convrate = 7, 381 373 .reg_local_ext = MAX6657_REG_R_LOCAL_TEMPL, 382 374 }, 383 375 [max6657] = { ··· 1575 1557 && (config1 & 0x3f) == 0x00 1576 1558 && convrate <= 0x07) { 1577 1559 name = "max6646"; 1560 + } else 1561 + /* 1562 + * The chip_id of the MAX6654 holds the revision of the chip. 1563 + * The lowest 3 bits of the config1 register are unused and 1564 + * should return zero when read. 1565 + */ 1566 + if (chip_id == 0x08 1567 + && (config1 & 0x07) == 0x00 1568 + && convrate <= 0x07) { 1569 + name = "max6654"; 1578 1570 } 1579 1571 } else 1580 1572 if (address == 0x4C ··· 1687 1659 */ 1688 1660 if (data->kind == max6680) 1689 1661 config |= 0x18; 1662 + 1663 + /* 1664 + * Put MAX6654 into extended range (0x20, extend minimum range from 1665 + * 0 degrees to -64 degrees). Note that extended resolution is not 1666 + * possible on the MAX6654 unless conversion rate is set to 1 Hz or 1667 + * slower, which is intentionally not done by default. 1668 + */ 1669 + if (data->kind == max6654) 1670 + config |= 0x20; 1690 1671 1691 1672 /* 1692 1673 * Select external channel 0 for max6695/96