generic: move pending 870 ca8210 fix crash patch to backport
[openwrt/openwrt.git] / target / linux / generic / backport-5.10 / 870-hwmon-next-hwmon-lm70-Add-ti-tmp125-support.patch
1 From 31d8f414e1596ba54a4315418e4c0086fda9e428 Mon Sep 17 00:00:00 2001
2 From: Christian Lamparter <chunkeey@gmail.com>
3 Date: Fri, 18 Feb 2022 10:06:43 +0100
4 Subject: hwmon: (lm70) Add ti,tmp125 support
5
6 The TMP125 is a 2 degree Celsius accurate Digital
7 Temperature Sensor with a SPI interface.
8
9 The temperature register is a 16-bit, read-only register.
10 The MSB (Bit 15) is a leading zero and never set. Bits 14
11 to 5 are the 1+9 temperature data bits in a two's
12 complement format. Bits 4 to 0 are useless copies of
13 Bit 5 value and therefore ignored.
14
15 Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
16 Link: https://lore.kernel.org/r/43b19cbd4e7f51e9509e561b02b5d8d0e7079fac.1645175187.git.chunkeey@gmail.com
17 Signed-off-by: Guenter Roeck <linux@roeck-us.net>
18 ---
19 --- a/drivers/hwmon/lm70.c
20 +++ b/drivers/hwmon/lm70.c
21 @@ -34,6 +34,7 @@
22 #define LM70_CHIP_LM71 2 /* NS LM71 */
23 #define LM70_CHIP_LM74 3 /* NS LM74 */
24 #define LM70_CHIP_TMP122 4 /* TI TMP122/TMP124 */
25 +#define LM70_CHIP_TMP125 5 /* TI TMP125 */
26
27 struct lm70 {
28 struct spi_device *spi;
29 @@ -87,6 +88,12 @@ static ssize_t temp1_input_show(struct d
30 * LM71:
31 * 14 bits of 2's complement data, discard LSB 2 bits,
32 * resolution 0.0312 degrees celsius.
33 + *
34 + * TMP125:
35 + * MSB/D15 is a leading zero. D14 is the sign-bit. This is
36 + * followed by 9 temperature bits (D13..D5) in 2's complement
37 + * data format with a resolution of 0.25 degrees celsius per unit.
38 + * LSB 5 bits (D4..D0) share the same value as D5 and get discarded.
39 */
40 switch (p_lm70->chip) {
41 case LM70_CHIP_LM70:
42 @@ -102,6 +109,10 @@ static ssize_t temp1_input_show(struct d
43 case LM70_CHIP_LM71:
44 val = ((int)raw / 4) * 3125 / 100;
45 break;
46 +
47 + case LM70_CHIP_TMP125:
48 + val = (sign_extend32(raw, 14) / 32) * 250;
49 + break;
50 }
51
52 status = sprintf(buf, "%d\n", val); /* millidegrees Celsius */
53 @@ -136,6 +147,10 @@ static const struct of_device_id lm70_of
54 .data = (void *) LM70_CHIP_TMP122,
55 },
56 {
57 + .compatible = "ti,tmp125",
58 + .data = (void *) LM70_CHIP_TMP125,
59 + },
60 + {
61 .compatible = "ti,lm71",
62 .data = (void *) LM70_CHIP_LM71,
63 },
64 @@ -184,6 +199,7 @@ static const struct spi_device_id lm70_i
65 { "lm70", LM70_CHIP_LM70 },
66 { "tmp121", LM70_CHIP_TMP121 },
67 { "tmp122", LM70_CHIP_TMP122 },
68 + { "tmp125", LM70_CHIP_TMP125 },
69 { "lm71", LM70_CHIP_LM71 },
70 { "lm74", LM70_CHIP_LM74 },
71 { },