lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210607144718.1724413-8-liambeguin@gmail.com>
Date:   Mon,  7 Jun 2021 10:47:17 -0400
From:   Liam Beguin <liambeguin@...il.com>
To:     liambeguin@...il.com, peda@...ntia.se, jic23@...nel.org,
        lars@...afoo.de, pmeerw@...erw.net
Cc:     linux-kernel@...r.kernel.org, linux-iio@...r.kernel.org,
        devicetree@...r.kernel.org, robh+dt@...nel.org
Subject: [PATCH v2 7/8] iio: afe: rescale: add temperature sensor support

From: Liam Beguin <lvb@...hos.com>

Add support for linear temperature sensors. This is meant to work with
different kinds of analog front ends such as RTDs (resistance
thermometers), voltage IC sensors (like the LTC2997), and current IC
sensors (see AD590).

Signed-off-by: Liam Beguin <lvb@...hos.com>
---
 drivers/iio/afe/iio-rescale.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/iio/afe/iio-rescale.c b/drivers/iio/afe/iio-rescale.c
index 3d445c76dbb2..9e3c7e2b47cd 100644
--- a/drivers/iio/afe/iio-rescale.c
+++ b/drivers/iio/afe/iio-rescale.c
@@ -272,10 +272,29 @@ static int rescale_voltage_divider_props(struct device *dev,
 	return 0;
 }
 
+static int rescale_temp_sense_amplifier_props(struct device *dev,
+					      struct rescale *rescale)
+{
+	s32 gain_mult = 1;
+	s32 gain_div = 1;
+	s32 offset = 0;
+
+	device_property_read_u32(dev, "sense-gain-mult", &gain_mult);
+	device_property_read_u32(dev, "sense-gain-div", &gain_div);
+	device_property_read_u32(dev, "sense-offset-millicelsius", &offset);
+
+	rescale->numerator = gain_mult;
+	rescale->denominator = gain_div;
+	rescale->offset = offset * gain_div / gain_mult;
+
+	return 0;
+}
+
 enum rescale_variant {
 	CURRENT_SENSE_AMPLIFIER,
 	CURRENT_SENSE_SHUNT,
 	VOLTAGE_DIVIDER,
+	TEMP_SENSE_AMPLIFIER,
 };
 
 static const struct rescale_cfg rescale_cfg[] = {
@@ -291,6 +310,10 @@ static const struct rescale_cfg rescale_cfg[] = {
 		.type = IIO_VOLTAGE,
 		.props = rescale_voltage_divider_props,
 	},
+	[TEMP_SENSE_AMPLIFIER] = {
+		.type = IIO_TEMP,
+		.props = rescale_temp_sense_amplifier_props,
+	},
 };
 
 static const struct of_device_id rescale_match[] = {
@@ -300,6 +323,8 @@ static const struct of_device_id rescale_match[] = {
 	  .data = &rescale_cfg[CURRENT_SENSE_SHUNT], },
 	{ .compatible = "voltage-divider",
 	  .data = &rescale_cfg[VOLTAGE_DIVIDER], },
+	{ .compatible = "temperature-sense-amplifier",
+	  .data = &rescale_cfg[TEMP_SENSE_AMPLIFIER], },
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, rescale_match);
-- 
2.30.1.489.g328c10930387

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ