Message ID | 524e85e640a4fccdf68b0a1c18b516378a581d35.1645116431.git.chunkeey@gmail.com |
---|---|
State | Superseded, archived |
Headers | show |
Series | [v1,1/2] dt-bindings: add TI TMP125 temperature sensor binding | expand |
Context | Check | Description |
---|---|---|
robh/patch-applied | success | |
robh/checkpatch | success | |
robh/dtbs-check | warning | build log |
robh/dt-meta-schema | success |
On 2/17/22 08:47, Christian Lamparter wrote: > 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 signed two's > complement format. Bits 4 to 0 are mirrors of Bit 5 and > therefore ignored. > > This was tested on a Aerohive HiveAP-350. > > Bonus: lm70 supports TMP122/TMP124 as well. So, I > added them to the Kconfig module description as well. > > Signed-off-by: Christian Lamparter <chunkeey@gmail.com> > --- > > Datasheet: (Link) > <https://www.ti.com/lit/ds/symlink/tmp125.pdf> > > I'm not sure if it's "Ok" to add the TMP125 to this lm70. > It seems like it, especially since the TMP124 and friends > are supported by this driver. Better than a separate driver just for a few lines of code. > --- > drivers/hwmon/Kconfig | 4 ++-- > drivers/hwmon/lm70.c | 15 +++++++++++++++ Please also add the chip to Documentation/hwmon/lm70.rst. > 2 files changed, 17 insertions(+), 2 deletions(-) > > diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig > index 8df25f1079ba..5cdf38004fae 100644 > --- a/drivers/hwmon/Kconfig > +++ b/drivers/hwmon/Kconfig > @@ -1208,8 +1208,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 > + and TMP125 digital temperature sensor chips. > > This driver can also be built as a module. If so, the module > will be called lm70. > diff --git a/drivers/hwmon/lm70.c b/drivers/hwmon/lm70.c > index d2a60de5b8de..4202e4e03584 100644 > --- a/drivers/hwmon/lm70.c > +++ b/drivers/hwmon/lm70.c > @@ -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,11 @@ 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 followed by > + * 9 temperature bits (D13..D5) of 2's complement data, > + * discard LSB 5 bits (same as D5), resolution 0.25 degress celsius. degrees > */ > switch (p_lm70->chip) { > case LM70_CHIP_LM70: > @@ -102,6 +108,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 +145,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 +198,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 }, > { },
diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml index 091792ba993e..09b98bf97c8d 100644 --- a/Documentation/devicetree/bindings/trivial-devices.yaml +++ b/Documentation/devicetree/bindings/trivial-devices.yaml @@ -337,6 +337,7 @@ properties: # Thermometer with SPI interface - ti,tmp121 - ti,tmp122 + - ti,tmp125 # Digital Temperature Sensor - ti,tmp275 # TI DC-DC converter on PMBus
From the Datasheet: "The TMP125 is an SPI-compatible temperature sensor available in the tiny SOT23-6 package. Requiring no external components, the TMP125 is capable of measuring temperatures within 2 degree C of accuracy over a temperature range of −25 °C to +85 °C and 2.5 °C of accuracy over −40°C to +125°C." This chip can be supported by the current hwmon's lm70 module. (lm70 already has support for the TMP124 and friends) Signed-off-by: Christian Lamparter <chunkeey@gmail.com> --- Documentation/devicetree/bindings/trivial-devices.yaml | 1 + 1 file changed, 1 insertion(+)