diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt
index d3ccdb1..b25fe92 100644
@@ -57,3 +57,4 @@ Pressure sensors:
diff --git a/drivers/iio/pressure/Kconfig b/drivers/iio/pressure/Kconfig
index 6f2e7c9..a5fc260 100644
@@ -101,7 +101,7 @@ config IIO_ST_PRESS
select IIO_TRIGGERED_BUFFER if (IIO_BUFFER)
Say yes here to build support for STMicroelectronics pressure
- sensors: LPS001WP, LPS25H, LPS331AP.
+ sensors: LPS001WP, LPS25H, LPS331AP, LPS22HB.
This driver can also be built as a module. If so, these modules
will be created:
diff --git a/drivers/iio/pressure/st_pressure.h b/drivers/iio/pressure/st_pressure.h
index f5f4149..903a21e 100644
@@ -17,6 +17,7 @@
#define LPS001WP_PRESS_DEV_NAME "lps001wp"
#define LPS25H_PRESS_DEV_NAME "lps25h"
#define LPS331AP_PRESS_DEV_NAME "lps331ap"
+#define LPS22HB_PRESS_DEV_NAME "lps22hb"
+ * About determining pressure scaling factors
+ * ------------------------------------------
+ * Datasheets specify typical pressure sensitivity so that pressure is computed
+ * according to the following equation :
+ * pressure[mBar] = raw / sensitivity
+ * where :
+ * raw the 24 bits long raw sampled pressure
+ * sensitivity a scaling factor specified by the datasheet in LSB/mBar
+ * IIO ABI expects pressure to be expressed as kPascal, hence pressure should be
+ * computed according to :
+ * pressure[kPascal] = pressure[mBar] / 10
+ * = raw / (sensitivity * 10) (1)
+ * Finally, st_press_read_raw() returns pressure scaling factor as an
+ * IIO_VAL_INT_PLUS_NANO with a zero integral part and "gain" as decimal part.
+ * Therefore, from (1), "gain" becomes :
+ * gain = 10^9 / (sensitivity * 10)
+ * = 10^8 / sensitivity
+ * About determining temperature scaling factors and offsets
+ * ---------------------------------------------------------
+ * Datasheets specify typical temperature sensitivity and offset so that
+ * temperature is computed according to the following equation :
+ * temp[Celsius] = offset[Celsius] + (raw / sensitivity)
+ * where :
+ * raw the 16 bits long raw sampled temperature
+ * offset a constant specified by the datasheet in degree Celsius
+ * (sometimes zero)
+ * sensitivity a scaling factor specified by the datasheet in LSB/Celsius
+ * IIO ABI expects temperature to be expressed as milli degree Celsius such as
+ * user space should compute temperature according to :
+ * temp[mCelsius] = temp[Celsius] * 10^3
+ * = (offset[Celsius] + (raw / sensitivity)) * 10^3
+ * = ((offset[Celsius] * sensitivity) + raw) *
+ * (10^3 / sensitivity) (2)
+ * IIO ABI expects user space to apply offset and scaling factors to raw samples
+ * according to :
+ * temp[mCelsius] = (OFFSET + raw) * SCALE
+ * where :
+ * OFFSET an arbitrary constant exposed by device
+ * SCALE an arbitrary scaling factor exposed by device
+ * Matching OFFSET and SCALE with members of (2) gives :
+ * OFFSET = offset[Celsius] * sensitivity (3)
+ * SCALE = 10^3 / sensitivity (4)
+ * st_press_read_raw() returns temperature scaling factor as an
+ * IIO_VAL_FRACTIONAL with a 10^3 numerator and "gain2" as denominator.
+ * Therefore, from (3), "gain2" becomes :
+ * gain2 = sensitivity
+ * When declared within channel, i.e. for a non zero specified offset,
+ * st_press_read_raw() will return the latter as an IIO_VAL_FRACTIONAL such as :
+ * numerator = OFFSET * 10^3
+ * denominator = 10^3
+ * giving from (4):
+ * numerator = offset[Celsius] * 10^3 * sensitivity
+ * = offset[mCelsius] * gain2
#define MCELSIUS_PER_CELSIUS 1000
Most of the rest appears to add code in a way that limits it to a specific hw.
Except here ^ where I am not sure whether this could not have impact on existing
hw using this driver. Was there any testing to check for potential regressions?
> BugLink: https://launchpad.net/bugs/1642258 >
> This work is based on ver. Ubuntu-4.4.0-49.70 in Xenial kernel. The patches
> are backported and add support for lps22hb pressure sensor. This sensor is
> present on Dell IoT gateways.
> Gregor Boirie (4):
> iio:st_pressure:initial lps22hb sensor support
> iio:st_pressure: align storagebits on power of 2
> iio:st_pressure: document sampling gains
> iio:st_pressure:lps22hb: temperature support
> .../devicetree/bindings/iio/st-sensors.txt | 1 +
> drivers/iio/pressure/Kconfig | 2 +-
> drivers/iio/pressure/st_pressure.h | 1 +
> drivers/iio/pressure/st_pressure_core.c | 203 ++++++++++++++++++++-
> drivers/iio/pressure/st_pressure_i2c.c | 4 +
> drivers/iio/pressure/st_pressure_spi.c | 1 +
> 6 files changed, 203 insertions(+), 9 deletions(-)
So based on feedback the risk could be tolerable. Again set might need a bit of
adaption (cherry-pick / SAUCE) when applying.
Applied to xenial master-next branch, and also the fix for bug #1644726
("AD5593R configurable multi-channel converter support"). However, I've
added an additional patch to enable the new modules (see below).
Author: Luis Henriques <[hidden email]>
Date: Tue Nov 29 16:11:06 2016 +0000