diff options
Diffstat (limited to 'drivers/hwmon/lm70.c')
-rw-r--r-- | drivers/hwmon/lm70.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/drivers/hwmon/lm70.c b/drivers/hwmon/lm70.c index 4122e59f0bb4..c20a749fc7f2 100644 --- a/drivers/hwmon/lm70.c +++ b/drivers/hwmon/lm70.c @@ -22,10 +22,10 @@ #include <linux/hwmon.h> #include <linux/mutex.h> #include <linux/mod_devicetable.h> +#include <linux/of.h> +#include <linux/property.h> #include <linux/spi/spi.h> #include <linux/slab.h> -#include <linux/of_device.h> - #define DRVNAME "lm70" @@ -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 */ @@ -136,6 +147,10 @@ static const struct of_device_id lm70_of_ids[] = { .data = (void *) LM70_CHIP_TMP122, }, { + .compatible = "ti,tmp125", + .data = (void *) LM70_CHIP_TMP125, + }, + { .compatible = "ti,lm71", .data = (void *) LM70_CHIP_LM71, }, @@ -150,19 +165,18 @@ MODULE_DEVICE_TABLE(of, lm70_of_ids); static int lm70_probe(struct spi_device *spi) { - const struct of_device_id *match; struct device *hwmon_dev; struct lm70 *p_lm70; int chip; - match = of_match_device(lm70_of_ids, &spi->dev); - if (match) - chip = (int)(uintptr_t)match->data; + if (dev_fwnode(&spi->dev)) + chip = (int)(uintptr_t)device_get_match_data(&spi->dev); else chip = spi_get_device_id(spi)->driver_data; + /* signaling is SPI_MODE_0 */ - if (spi->mode & (SPI_CPOL | SPI_CPHA)) + if ((spi->mode & SPI_MODE_X_MASK) != SPI_MODE_0) return -EINVAL; /* NOTE: we assume 8-bit words, and convert to 16 bits manually */ @@ -185,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 }, { }, |