diff mbox series

[v2,3/3] iio: accel: add support for LIS302DL variant

Message ID 20220301225432.60844-4-absicsz@gmail.com (mailing list archive)
State Changes Requested
Headers show
Series Support LIS302DL in st_accel | expand

Commit Message

Sicelo March 1, 2022, 10:54 p.m. UTC
Add support for STMicroelectronics LIS302DL accelerometer to the st_accel
framework.

https://www.st.com/resource/en/datasheet/lis302dl.pdf

Signed-off-by: Sicelo A. Mhlongo <absicsz@gmail.com>
---
 drivers/iio/accel/st_accel.h      | 1 +
 drivers/iio/accel/st_accel_core.c | 1 +
 drivers/iio/accel/st_accel_i2c.c  | 5 +++++
 3 files changed, 7 insertions(+)

Comments

Linus Walleij March 1, 2022, 11:50 p.m. UTC | #1
On Tue, Mar 1, 2022 at 11:56 PM Sicelo A. Mhlongo <absicsz@gmail.com> wrote:

> Add support for STMicroelectronics LIS302DL accelerometer to the st_accel
> framework.
>
> https://www.st.com/resource/en/datasheet/lis302dl.pdf
>
> Signed-off-by: Sicelo A. Mhlongo <absicsz@gmail.com>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

As discussed on chat this sensor has the nice freefall-detection
feature which we should implement as an event in IIO one of these
days :)

Yours,
Linus Walleij
Andy Shevchenko March 2, 2022, 1:59 p.m. UTC | #2
On Wed, Mar 02, 2022 at 12:54:32AM +0200, Sicelo A. Mhlongo wrote:
> Add support for STMicroelectronics LIS302DL accelerometer to the st_accel
> framework.

> https://www.st.com/resource/en/datasheet/lis302dl.pdf

Can this be converted to Datasheet: tag, please?

> Signed-off-by: Sicelo A. Mhlongo <absicsz@gmail.com>

...

>  drivers/iio/accel/st_accel_i2c.c  | 5 +++++

Doesn't SPI also need to be updated? I believe those sensors are capable
of both interfaces, but correct me, if I'm wrong.
diff mbox series

Patch

diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h
index 969cc7faca07..0e79dc100ce5 100644
--- a/drivers/iio/accel/st_accel.h
+++ b/drivers/iio/accel/st_accel.h
@@ -36,6 +36,7 @@ 
 #define LIS3DE_ACCEL_DEV_NAME		"lis3de"
 #define LIS2DE12_ACCEL_DEV_NAME		"lis2de12"
 #define LIS2HH12_ACCEL_DEV_NAME		"lis2hh12"
+#define LIS302DL_ACCEL_DEV_NAME		"lis302dl"
 
 #ifdef CONFIG_IIO_BUFFER
 int st_accel_allocate_ring(struct iio_dev *indio_dev);
diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
index 31ea19d0ba71..2a353c51c84a 100644
--- a/drivers/iio/accel/st_accel_core.c
+++ b/drivers/iio/accel/st_accel_core.c
@@ -444,6 +444,7 @@  static const struct st_sensor_settings st_accel_sensors_settings[] = {
 		.wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
 		.sensors_supported = {
 			[0] = LIS331DL_ACCEL_DEV_NAME,
+			[1] = LIS302DL_ACCEL_DEV_NAME,
 		},
 		.ch = (struct iio_chan_spec *)st_accel_8bit_channels,
 		.odr = {
diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c
index c0ce78eebad9..086e8af89e18 100644
--- a/drivers/iio/accel/st_accel_i2c.c
+++ b/drivers/iio/accel/st_accel_i2c.c
@@ -107,6 +107,10 @@  static const struct of_device_id st_accel_of_match[] = {
 		.compatible = "st,lis2hh12",
 		.data = LIS2HH12_ACCEL_DEV_NAME,
 	},
+	{
+		.compatible = "st,lis302dl",
+		.data = LIS302DL_ACCEL_DEV_NAME,
+	},
 	{},
 };
 MODULE_DEVICE_TABLE(of, st_accel_of_match);
@@ -142,6 +146,7 @@  static const struct i2c_device_id st_accel_id_table[] = {
 	{ LIS3DE_ACCEL_DEV_NAME },
 	{ LIS2DE12_ACCEL_DEV_NAME },
 	{ LIS2HH12_ACCEL_DEV_NAME },
+	{ LIS302DL_ACCEL_DEV_NAME },
 	{},
 };
 MODULE_DEVICE_TABLE(i2c, st_accel_id_table);