]> git.itanic.dy.fi Git - linux-stable/commitdiff
hwmon: (lm70) Add ti,tmp125 support
authorChristian Lamparter <chunkeey@gmail.com>
Fri, 18 Feb 2022 09:06:43 +0000 (10:06 +0100)
committerGuenter Roeck <linux@roeck-us.net>
Mon, 28 Feb 2022 01:03:19 +0000 (17:03 -0800)
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>
Documentation/hwmon/lm70.rst
drivers/hwmon/Kconfig
drivers/hwmon/lm70.c

index 6ddc5b67ccb540d94d1992eb7c2f4522a7e78fa1..11303a7e16a806b2678ca0b4bd8c8057e7ebeab6 100644 (file)
@@ -15,6 +15,10 @@ Supported chips:
 
     Information: https://www.ti.com/product/tmp122
 
+  * Texas Instruments TMP125
+
+    Information: https://www.ti.com/product/tmp125
+
   * National Semiconductor LM71
 
     Datasheet: https://www.ti.com/product/LM71
@@ -53,6 +57,9 @@ The LM74 and TMP121/TMP122/TMP123/TMP124 are very similar; main difference is
 
 The TMP122/TMP124 also feature configurable temperature thresholds.
 
+The TMP125 is less accurate and provides 10-bit temperature data
+with 0.25 degrees Celsius resolution.
+
 The LM71 is also very similar; main difference is 14-bit temperature
 data (0.03125 degrees celsius resolution).
 
index b3597ba66ddb99793b821f9b9848652ca8ea6db1..463d5b110a85f90e540eacbbef368f27dd6df5ae 100644 (file)
@@ -1224,8 +1224,8 @@ config SENSORS_LM70
        depends on SPI_MASTER
        help
          If you say yes here you get support for the National Semiconductor
-         LM70, LM71, LM74 and Texas Instruments TMP121/TMP123 digital tempera-
-         ture sensor chips.
+         LM70, LM71, LM74 and Texas Instruments TMP121/TMP123, TMP122/TMP124,
+         TMP125 digital temperature sensor chips.
 
          This driver can also be built as a module. If so, the module
          will be called lm70.
index d2a60de5b8de9d66918247c2c4ae8870dcfb5d6e..c20a749fc7f21ab2cdd739747042e14299013453 100644 (file)
@@ -34,6 +34,7 @@
 #define LM70_CHIP_LM71         2       /* NS LM71 */
 #define LM70_CHIP_LM74         3       /* NS LM74 */
 #define LM70_CHIP_TMP122       4       /* TI TMP122/TMP124 */
+#define LM70_CHIP_TMP125       5       /* TI TMP125 */
 
 struct lm70 {
        struct spi_device *spi;
@@ -87,6 +88,12 @@ static ssize_t temp1_input_show(struct device *dev,
         * LM71:
         * 14 bits of 2's complement data, discard LSB 2 bits,
         * resolution 0.0312 degrees celsius.
+        *
+        * TMP125:
+        * MSB/D15 is a leading zero. D14 is the sign-bit. This is
+        * followed by 9 temperature bits (D13..D5) in 2's complement
+        * data format with a resolution of 0.25 degrees celsius per unit.
+        * LSB 5 bits (D4..D0) share the same value as D5 and get discarded.
         */
        switch (p_lm70->chip) {
        case LM70_CHIP_LM70:
@@ -102,6 +109,10 @@ static ssize_t temp1_input_show(struct device *dev,
        case LM70_CHIP_LM71:
                val = ((int)raw / 4) * 3125 / 100;
                break;
+
+       case LM70_CHIP_TMP125:
+               val = (sign_extend32(raw, 14) / 32) * 250;
+               break;
        }
 
        status = sprintf(buf, "%d\n", val); /* millidegrees Celsius */
@@ -135,6 +146,10 @@ static const struct of_device_id lm70_of_ids[] = {
                .compatible = "ti,tmp122",
                .data = (void *) LM70_CHIP_TMP122,
        },
+       {
+               .compatible = "ti,tmp125",
+               .data = (void *) LM70_CHIP_TMP125,
+       },
        {
                .compatible = "ti,lm71",
                .data = (void *) LM70_CHIP_LM71,
@@ -184,6 +199,7 @@ static const struct spi_device_id lm70_ids[] = {
        { "lm70",   LM70_CHIP_LM70 },
        { "tmp121", LM70_CHIP_TMP121 },
        { "tmp122", LM70_CHIP_TMP122 },
+       { "tmp125", LM70_CHIP_TMP125 },
        { "lm71",   LM70_CHIP_LM71 },
        { "lm74",   LM70_CHIP_LM74 },
        { },