Linux IIO development
 help / color / mirror / Atom feed
* [PATCH 1/2] dt-bindings: iio: st,st-sensors add LPS22DF.
@ 2022-09-09 16:16 Martyn Welch
  2022-09-09 16:16 ` [PATCH 2/2] iio: pressure: st_pressure: Add support for LPS22DF Martyn Welch
  2022-09-09 16:22 ` [PATCH 1/2] dt-bindings: iio: st,st-sensors add LPS22DF Krzysztof Kozlowski
  0 siblings, 2 replies; 4+ messages in thread
From: Martyn Welch @ 2022-09-09 16:16 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Denis Ciocca, Linus Walleij
  Cc: kernel, Martyn Welch, linux-iio, devicetree, linux-kernel

Add support for the ST LPS22DF, an I2C/SPI pressure sensor.

Signed-off-by: Martyn Welch <martyn.welch@collabora.co.uk>
---
 Documentation/devicetree/bindings/iio/st,st-sensors.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/st,st-sensors.yaml b/Documentation/devicetree/bindings/iio/st,st-sensors.yaml
index fcb2902683c7..250439b13152 100644
--- a/Documentation/devicetree/bindings/iio/st,st-sensors.yaml
+++ b/Documentation/devicetree/bindings/iio/st,st-sensors.yaml
@@ -73,6 +73,7 @@ properties:
       - description: STMicroelectronics Pressure Sensors
         enum:
           - st,lps001wp-press
+          - st,lps22df
           - st,lps22hb-press
           - st,lps22hh
           - st,lps25h-press
@@ -141,6 +142,7 @@ allOf:
             - st,lis2mdl
             - st,lis3l02dq
             - st,lis3lv02dl-accel
+            - st,lps22df
             - st,lps22hb-press
             - st,lps22hh
             - st,lps25h-press
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] iio: pressure: st_pressure: Add support for LPS22DF
  2022-09-09 16:16 [PATCH 1/2] dt-bindings: iio: st,st-sensors add LPS22DF Martyn Welch
@ 2022-09-09 16:16 ` Martyn Welch
  2022-09-09 16:22 ` [PATCH 1/2] dt-bindings: iio: st,st-sensors add LPS22DF Krzysztof Kozlowski
  1 sibling, 0 replies; 4+ messages in thread
From: Martyn Welch @ 2022-09-09 16:16 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen
  Cc: kernel, Martyn Welch, linux-iio, linux-kernel

Add support for ST LPS22DF pressure sensor.

Datasheet: https://www.st.com/resource/en/datasheet/lps22df.pdf
Signed-off-by: Martyn Welch <martyn.welch@collabora.co.uk>
---
 drivers/iio/pressure/st_pressure.h      |  2 +
 drivers/iio/pressure/st_pressure_core.c | 70 +++++++++++++++++++++++++
 drivers/iio/pressure/st_pressure_i2c.c  |  5 ++
 drivers/iio/pressure/st_pressure_spi.c  |  5 ++
 4 files changed, 82 insertions(+)

diff --git a/drivers/iio/pressure/st_pressure.h b/drivers/iio/pressure/st_pressure.h
index 156e6a72dc5c..6e11bea784fa 100644
--- a/drivers/iio/pressure/st_pressure.h
+++ b/drivers/iio/pressure/st_pressure.h
@@ -22,6 +22,7 @@ enum st_press_type {
 	LPS33HW,
 	LPS35HW,
 	LPS22HH,
+	LPS22DF,
 	ST_PRESS_MAX,
 };
 
@@ -32,6 +33,7 @@ enum st_press_type {
 #define LPS33HW_PRESS_DEV_NAME		"lps33hw"
 #define LPS35HW_PRESS_DEV_NAME		"lps35hw"
 #define LPS22HH_PRESS_DEV_NAME		"lps22hh"
+#define LPS22DF_PRESS_DEV_NAME		"lps22df"
 
 /**
  * struct st_sensors_platform_data - default press platform data
diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c
index 76913a2028d2..80176e3083af 100644
--- a/drivers/iio/pressure/st_pressure_core.c
+++ b/drivers/iio/pressure/st_pressure_core.c
@@ -552,6 +552,76 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
 		.multi_read_bit = false,
 		.bootime = 2,
 	},
+	{
+		/*
+		 * CUSTOM VALUES FOR LPS22DF SENSOR
+		 * See LPS22DF datasheet:
+		 * http://www.st.com/resource/en/datasheet/lps22df.pdf
+		 */
+		.wai = 0xb4,
+		.wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
+		.sensors_supported = {
+			[0] = LPS22DF_PRESS_DEV_NAME,
+		},
+		.ch = (struct iio_chan_spec *)st_press_lps22hb_channels,
+		.num_ch = ARRAY_SIZE(st_press_lps22hb_channels),
+		.odr = {
+			.addr = 0x10,
+			.mask = 0x78,
+			.odr_avl = {
+				{ .hz = 1, .value = 0x01 },
+				{ .hz = 4, .value = 0x02 },
+				{ .hz = 10, .value = 0x03 },
+				{ .hz = 25, .value = 0x04 },
+				{ .hz = 50, .value = 0x05 },
+				{ .hz = 75, .value = 0x06 },
+				{ .hz = 100, .value = 0x07 },
+				{ .hz = 200, .value = 0x08 },
+			},
+		},
+		.pw = {
+			.addr = 0x10,
+			.mask = 0x78,
+			.value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE,
+		},
+		.fs = {
+			.fs_avl = {
+				/*
+				 * Pressure and temperature sensitivity values
+				 * as defined in table 2 of LPS22DF datasheet.
+				 */
+				[0] = {
+					.num = ST_PRESS_FS_AVL_1260MB,
+					.gain = ST_PRESS_KPASCAL_NANO_SCALE,
+					.gain2 = ST_PRESS_LPS22HB_LSB_PER_CELSIUS,
+				},
+			},
+		},
+		.bdu = {
+			.addr = 0x11,
+			.mask = BIT(3),
+		},
+		.drdy_irq = {
+			.int1 = {
+				.addr = 0x13,
+				.mask = BIT(5),
+				.addr_od = 0x12,
+				.mask_od = BIT(1),
+			},
+			.addr_ihl = 0x12,
+			.mask_ihl = BIT(3),
+			.stat_drdy = {
+				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
+				.mask = 0x03,
+			},
+		},
+		.sim = {
+			.addr = 0x0E,
+			.value = BIT(5),
+		},
+		.multi_read_bit = false,
+		.bootime = 2,
+	},
 };
 
 static int st_press_write_raw(struct iio_dev *indio_dev,
diff --git a/drivers/iio/pressure/st_pressure_i2c.c b/drivers/iio/pressure/st_pressure_i2c.c
index 7035777fd988..58fede861891 100644
--- a/drivers/iio/pressure/st_pressure_i2c.c
+++ b/drivers/iio/pressure/st_pressure_i2c.c
@@ -47,6 +47,10 @@ static const struct of_device_id st_press_of_match[] = {
 		.compatible = "st,lps22hh",
 		.data = LPS22HH_PRESS_DEV_NAME,
 	},
+	{
+		.compatible = "st,lps22df",
+		.data = LPS22DF_PRESS_DEV_NAME,
+	},
 	{},
 };
 MODULE_DEVICE_TABLE(of, st_press_of_match);
@@ -67,6 +71,7 @@ static const struct i2c_device_id st_press_id_table[] = {
 	{ LPS33HW_PRESS_DEV_NAME, LPS33HW },
 	{ LPS35HW_PRESS_DEV_NAME, LPS35HW },
 	{ LPS22HH_PRESS_DEV_NAME, LPS22HH },
+	{ LPS22DF_PRESS_DEV_NAME, LPS22DF },
 	{},
 };
 MODULE_DEVICE_TABLE(i2c, st_press_id_table);
diff --git a/drivers/iio/pressure/st_pressure_spi.c b/drivers/iio/pressure/st_pressure_spi.c
index bfab8e7fb061..25cca5ad7c55 100644
--- a/drivers/iio/pressure/st_pressure_spi.c
+++ b/drivers/iio/pressure/st_pressure_spi.c
@@ -51,6 +51,10 @@ static const struct of_device_id st_press_of_match[] = {
 		.compatible = "st,lps22hh",
 		.data = LPS22HH_PRESS_DEV_NAME,
 	},
+	{
+		.compatible = "st,lps22df",
+		.data = LPS22DF_PRESS_DEV_NAME,
+	},
 	{},
 };
 MODULE_DEVICE_TABLE(of, st_press_of_match);
@@ -97,6 +101,7 @@ static const struct spi_device_id st_press_id_table[] = {
 	{ LPS33HW_PRESS_DEV_NAME },
 	{ LPS35HW_PRESS_DEV_NAME },
 	{ LPS22HH_PRESS_DEV_NAME },
+	{ LPS22DF_PRESS_DEV_NAME },
 	{ "lps001wp-press" },
 	{ "lps25h-press", },
 	{ "lps331ap-press" },
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] dt-bindings: iio: st,st-sensors add LPS22DF.
  2022-09-09 16:16 [PATCH 1/2] dt-bindings: iio: st,st-sensors add LPS22DF Martyn Welch
  2022-09-09 16:16 ` [PATCH 2/2] iio: pressure: st_pressure: Add support for LPS22DF Martyn Welch
@ 2022-09-09 16:22 ` Krzysztof Kozlowski
  2022-09-11 10:09   ` Jonathan Cameron
  1 sibling, 1 reply; 4+ messages in thread
From: Krzysztof Kozlowski @ 2022-09-09 16:22 UTC (permalink / raw)
  To: Martyn Welch, Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Denis Ciocca, Linus Walleij
  Cc: kernel, linux-iio, devicetree, linux-kernel

On 09/09/2022 18:16, Martyn Welch wrote:
> Add support for the ST LPS22DF, an I2C/SPI pressure sensor.
> 
> Signed-off-by: Martyn Welch <martyn.welch@collabora.co.uk>
> ---
>  Documentation/devicetree/bindings/iio/st,st-sensors.yaml | 2 ++


Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>


Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] dt-bindings: iio: st,st-sensors add LPS22DF.
  2022-09-09 16:22 ` [PATCH 1/2] dt-bindings: iio: st,st-sensors add LPS22DF Krzysztof Kozlowski
@ 2022-09-11 10:09   ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2022-09-11 10:09 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Martyn Welch, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Denis Ciocca, Linus Walleij, kernel,
	linux-iio, devicetree, linux-kernel

On Fri, 9 Sep 2022 18:22:40 +0200
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> wrote:

> On 09/09/2022 18:16, Martyn Welch wrote:
> > Add support for the ST LPS22DF, an I2C/SPI pressure sensor.
> > 
> > Signed-off-by: Martyn Welch <martyn.welch@collabora.co.uk>
> > ---
> >  Documentation/devicetree/bindings/iio/st,st-sensors.yaml | 2 ++  
> 
> 
> Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Series looks good to me.  It won't make my first pull request for this
cycle (as I've already tagged that - though not sent pull as travelling
to Dublin) so there will be time for other feedback before I push this out
as togreg.

Once I have a stable connection. Will push this out as testing for 0-day
to see if we missed anything.

Thanks,

Jonathan

> 
> 
> Best regards,
> Krzysztof


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-09-11 10:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-09 16:16 [PATCH 1/2] dt-bindings: iio: st,st-sensors add LPS22DF Martyn Welch
2022-09-09 16:16 ` [PATCH 2/2] iio: pressure: st_pressure: Add support for LPS22DF Martyn Welch
2022-09-09 16:22 ` [PATCH 1/2] dt-bindings: iio: st,st-sensors add LPS22DF Krzysztof Kozlowski
2022-09-11 10:09   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox