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

hwmon: (lm70) Add ti,tmp125 support

The TMP125 is a 2 degree Celsius accurate Digital
Temperature Sensor with a SPI interface.

The temperature register is a 16-bit, read-only register.
The MSB (Bit 15) is a leading zero and never set. Bits 14
to 5 are the 1+9 temperature data bits in a two's
complement format. Bits 4 to 0 are useless copies of
Bit 5 value and therefore ignored.

This was tested on a Aerohive HiveAP-350.

Bonus: lm70 supports TMP122/TMP124 as well.
I added them to the Kconfig module description.

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Link: https://lore.kernel.org/r/43b19cbd4e7f51e9509e561b02b5d8d0e7079fac.1645175187.git.chunkeey@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Christian Lamparter and committed by
Guenter Roeck
cd929672 64b631fb

+25 -2
+7
Documentation/hwmon/lm70.rst
··· 15 15 16 16 Information: https://www.ti.com/product/tmp122 17 17 18 + * Texas Instruments TMP125 19 + 20 + Information: https://www.ti.com/product/tmp125 21 + 18 22 * National Semiconductor LM71 19 23 20 24 Datasheet: https://www.ti.com/product/LM71 ··· 56 52 13-bit temperature data (0.0625 degrees celsius resolution). 57 53 58 54 The TMP122/TMP124 also feature configurable temperature thresholds. 55 + 56 + The TMP125 is less accurate and provides 10-bit temperature data 57 + with 0.25 degrees Celsius resolution. 59 58 60 59 The LM71 is also very similar; main difference is 14-bit temperature 61 60 data (0.03125 degrees celsius resolution).
+2 -2
drivers/hwmon/Kconfig
··· 1224 1224 depends on SPI_MASTER 1225 1225 help 1226 1226 If you say yes here you get support for the National Semiconductor 1227 - LM70, LM71, LM74 and Texas Instruments TMP121/TMP123 digital tempera- 1228 - ture sensor chips. 1227 + LM70, LM71, LM74 and Texas Instruments TMP121/TMP123, TMP122/TMP124, 1228 + TMP125 digital temperature sensor chips. 1229 1229 1230 1230 This driver can also be built as a module. If so, the module 1231 1231 will be called lm70.
+16
drivers/hwmon/lm70.c
··· 34 34 #define LM70_CHIP_LM71 2 /* NS LM71 */ 35 35 #define LM70_CHIP_LM74 3 /* NS LM74 */ 36 36 #define LM70_CHIP_TMP122 4 /* TI TMP122/TMP124 */ 37 + #define LM70_CHIP_TMP125 5 /* TI TMP125 */ 37 38 38 39 struct lm70 { 39 40 struct spi_device *spi; ··· 88 87 * LM71: 89 88 * 14 bits of 2's complement data, discard LSB 2 bits, 90 89 * resolution 0.0312 degrees celsius. 90 + * 91 + * TMP125: 92 + * MSB/D15 is a leading zero. D14 is the sign-bit. This is 93 + * followed by 9 temperature bits (D13..D5) in 2's complement 94 + * data format with a resolution of 0.25 degrees celsius per unit. 95 + * LSB 5 bits (D4..D0) share the same value as D5 and get discarded. 91 96 */ 92 97 switch (p_lm70->chip) { 93 98 case LM70_CHIP_LM70: ··· 108 101 109 102 case LM70_CHIP_LM71: 110 103 val = ((int)raw / 4) * 3125 / 100; 104 + break; 105 + 106 + case LM70_CHIP_TMP125: 107 + val = (sign_extend32(raw, 14) / 32) * 250; 111 108 break; 112 109 } 113 110 ··· 145 134 { 146 135 .compatible = "ti,tmp122", 147 136 .data = (void *) LM70_CHIP_TMP122, 137 + }, 138 + { 139 + .compatible = "ti,tmp125", 140 + .data = (void *) LM70_CHIP_TMP125, 148 141 }, 149 142 { 150 143 .compatible = "ti,lm71", ··· 199 184 { "lm70", LM70_CHIP_LM70 }, 200 185 { "tmp121", LM70_CHIP_TMP121 }, 201 186 { "tmp122", LM70_CHIP_TMP122 }, 187 + { "tmp125", LM70_CHIP_TMP125 }, 202 188 { "lm71", LM70_CHIP_LM71 }, 203 189 { "lm74", LM70_CHIP_LM74 }, 204 190 { },