All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Add support to LIS3DHH accel sensor
@ 2017-09-17 16:17 ` Lorenzo Bianconi
  0 siblings, 0 replies; 20+ messages in thread
From: Lorenzo Bianconi @ 2017-09-17 16:17 UTC (permalink / raw)
  To: jic23-DgEjT+Ai2ygdnm+yROfE0A
  Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA, lorenzo.bianconi-qxv4g6HH51o,
	devicetree-u79uwXL29TY76Z2rM5mHXA

Separate data-ready open-drain configuration parameters for
INT1 and INT2

This patchset depends on 'Add support to LIS2DW12 accel sensor' patchset
not yet applied on testing branch

Lorenzo Bianconi (4):
  iio: st_sensors: split open-drain parameters for irq1 and irq2
  iio: common: st_sensors: check odr address value in
    st_sensors_set_odr()
  iio: accel: add support to LIS3DHH
  dt-bindings: iio: accel: add LIS3DHH device bindings

 .../devicetree/bindings/iio/st-sensors.txt         |  1 +
 drivers/iio/accel/st_accel.h                       |  2 +
 drivers/iio/accel/st_accel_core.c                  | 70 ++++++++++++++++++++--
 drivers/iio/accel/st_accel_spi.c                   |  5 ++
 drivers/iio/common/st_sensors/st_sensors_core.c    | 24 ++++++--
 drivers/iio/pressure/st_pressure_core.c            | 14 +++--
 include/linux/iio/common/st_sensors.h              | 28 +++++----
 7 files changed, 115 insertions(+), 29 deletions(-)

-- 
2.14.1

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

* [PATCH 0/4] Add support to LIS3DHH accel sensor
@ 2017-09-17 16:17 ` Lorenzo Bianconi
  0 siblings, 0 replies; 20+ messages in thread
From: Lorenzo Bianconi @ 2017-09-17 16:17 UTC (permalink / raw)
  To: jic23; +Cc: linux-iio, lorenzo.bianconi, devicetree

Separate data-ready open-drain configuration parameters for
INT1 and INT2

This patchset depends on 'Add support to LIS2DW12 accel sensor' patchset
not yet applied on testing branch

Lorenzo Bianconi (4):
  iio: st_sensors: split open-drain parameters for irq1 and irq2
  iio: common: st_sensors: check odr address value in
    st_sensors_set_odr()
  iio: accel: add support to LIS3DHH
  dt-bindings: iio: accel: add LIS3DHH device bindings

 .../devicetree/bindings/iio/st-sensors.txt         |  1 +
 drivers/iio/accel/st_accel.h                       |  2 +
 drivers/iio/accel/st_accel_core.c                  | 70 ++++++++++++++++++++--
 drivers/iio/accel/st_accel_spi.c                   |  5 ++
 drivers/iio/common/st_sensors/st_sensors_core.c    | 24 ++++++--
 drivers/iio/pressure/st_pressure_core.c            | 14 +++--
 include/linux/iio/common/st_sensors.h              | 28 +++++----
 7 files changed, 115 insertions(+), 29 deletions(-)

-- 
2.14.1


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

* [PATCH 1/4] iio: st_sensors: split open-drain parameters for irq1 and irq2
  2017-09-17 16:17 ` Lorenzo Bianconi
@ 2017-09-17 16:17     ` Lorenzo Bianconi
  -1 siblings, 0 replies; 20+ messages in thread
From: Lorenzo Bianconi @ 2017-09-17 16:17 UTC (permalink / raw)
  To: jic23-DgEjT+Ai2ygdnm+yROfE0A
  Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA, lorenzo.bianconi-qxv4g6HH51o,
	devicetree-u79uwXL29TY76Z2rM5mHXA

Define st_sensor_int_drdy structure in st_sensor_data_ready_irq in order
to contain irq line parameters of the device.
Moreover separate data-ready open-drain configuration parameters for INT1
and INT2 pins in st_sensor_data_ready_irq data structure.
That change will be used to properly support LIS3DHH accel sensor.

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
---
 drivers/iio/accel/st_accel_core.c               | 18 ++++++++++------
 drivers/iio/common/st_sensors/st_sensors_core.c | 21 ++++++++++++++-----
 drivers/iio/pressure/st_pressure_core.c         | 14 +++++++------
 include/linux/iio/common/st_sensors.h           | 28 ++++++++++++++-----------
 4 files changed, 52 insertions(+), 29 deletions(-)

diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
index 731ec3a4c82b..c88db25a1aff 100644
--- a/drivers/iio/accel/st_accel_core.c
+++ b/drivers/iio/accel/st_accel_core.c
@@ -236,15 +236,17 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
 			.int1 = {
 				.addr = 0x22,
 				.mask = 0x02,
+				.addr_od = 0x22,
+				.mask_od = 0x40,
 			},
 			.int2 = {
 				.addr = 0x22,
 				.mask = 0x10,
+				.addr_od = 0x22,
+				.mask_od = 0x40,
 			},
 			.addr_ihl = 0x22,
 			.mask_ihl = 0x80,
-			.addr_od = 0x22,
-			.mask_od = 0x40,
 			.stat_drdy = {
 				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
 				.mask = 0x07,
@@ -468,15 +470,17 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
 			.int1 = {
 				.addr = 0x22,
 				.mask = 0x04,
+				.addr_od = 0x22,
+				.mask_od = 0x40,
 			},
 			.int2 = {
 				.addr = 0x22,
 				.mask = 0x20,
+				.addr_od = 0x22,
+				.mask_od = 0x40,
 			},
 			.addr_ihl = 0x22,
 			.mask_ihl = 0x80,
-			.addr_od = 0x22,
-			.mask_od = 0x40,
 			.stat_drdy = {
 				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
 				.mask = 0x07,
@@ -750,15 +754,17 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
 			.int1 = {
 				.addr = 0x23,
 				.mask = 0x01,
+				.addr_od = 0x22,
+				.mask_od = 0x20,
 			},
 			.int2 = {
 				.addr = 0x24,
 				.mask = 0x01,
+				.addr_od = 0x22,
+				.mask_od = 0x20,
 			},
 			.addr_ihl = 0x22,
 			.mask_ihl = 0x08,
-			.addr_od = 0x22,
-			.mask_od = 0x20,
 			.stat_drdy = {
 				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
 				.mask = 0x01,
diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
index 6657160b5a73..40dfdfc0906b 100644
--- a/drivers/iio/common/st_sensors/st_sensors_core.c
+++ b/drivers/iio/common/st_sensors/st_sensors_core.c
@@ -319,7 +319,8 @@ static int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev,
 	}
 
 	if (pdata->open_drain) {
-		if (!sdata->sensor_settings->drdy_irq.addr_od)
+		if (!sdata->sensor_settings->drdy_irq.int1.addr_od &&
+		    !sdata->sensor_settings->drdy_irq.int2.addr_od)
 			dev_err(&indio_dev->dev,
 				"open drain requested but unsupported.\n");
 		else
@@ -446,11 +447,21 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev,
 	}
 
 	if (sdata->int_pin_open_drain) {
+		u8 addr, mask;
+
+		if (sdata->drdy_int_pin == 1) {
+			addr = sdata->sensor_settings->drdy_irq.int1.addr_od;
+			mask = sdata->sensor_settings->drdy_irq.int1.mask_od;
+		} else {
+			addr = sdata->sensor_settings->drdy_irq.int2.addr_od;
+			mask = sdata->sensor_settings->drdy_irq.int2.mask_od;
+		}
+
 		dev_info(&indio_dev->dev,
-			 "set interrupt line to open drain mode\n");
-		err = st_sensors_write_data_with_mask(indio_dev,
-				sdata->sensor_settings->drdy_irq.addr_od,
-				sdata->sensor_settings->drdy_irq.mask_od, 1);
+			 "set interrupt line to open drain mode on pin %d\n",
+			 sdata->drdy_int_pin);
+		err = st_sensors_write_data_with_mask(indio_dev, addr,
+						      mask, 1);
 		if (err < 0)
 			return err;
 	}
diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c
index 15ad6054d9f6..349e5c713c03 100644
--- a/drivers/iio/pressure/st_pressure_core.c
+++ b/drivers/iio/pressure/st_pressure_core.c
@@ -283,15 +283,17 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
 			.int1 = {
 				.addr = 0x22,
 				.mask = 0x04,
+				.addr_od = 0x22,
+				.mask_od = 0x40,
 			},
 			.int2 = {
 				.addr = 0x22,
 				.mask = 0x20,
+				.addr_od = 0x22,
+				.mask_od = 0x40,
 			},
 			.addr_ihl = 0x22,
 			.mask_ihl = 0x80,
-			.addr_od = 0x22,
-			.mask_od = 0x40,
 			.stat_drdy = {
 				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
 				.mask = 0x03,
@@ -404,11 +406,11 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
 			.int1 = {
 				.addr = 0x23,
 				.mask = 0x01,
+				.addr_od = 0x22,
+				.mask_od = 0x40,
 			},
 			.addr_ihl = 0x22,
 			.mask_ihl = 0x80,
-			.addr_od = 0x22,
-			.mask_od = 0x40,
 			.stat_drdy = {
 				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
 				.mask = 0x03,
@@ -473,11 +475,11 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
 			.int1 = {
 				.addr = 0x12,
 				.mask = 0x04,
+				.addr_od = 0x12,
+				.mask_od = 0x40,
 			},
 			.addr_ihl = 0x12,
 			.mask_ihl = 0x80,
-			.addr_od = 0x12,
-			.mask_od = 0x40,
 			.stat_drdy = {
 				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
 				.mask = 0x03,
diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h
index e6c646d5d6d4..f9bd6e8ab138 100644
--- a/include/linux/iio/common/st_sensors.h
+++ b/include/linux/iio/common/st_sensors.h
@@ -130,32 +130,36 @@ struct st_sensor_das {
 	u8 mask;
 };
 
+/**
+ * struct st_sensor_int_drdy - ST sensor device drdy line parameters
+ * @addr: address of INT drdy register.
+ * @mask: mask to enable drdy line.
+ * @addr_od: address to enable/disable Open Drain on the INT line.
+ * @mask_od: mask to enable/disable Open Drain on the INT line.
+ */
+struct st_sensor_int_drdy {
+	u8 addr;
+	u8 mask;
+	u8 addr_od;
+	u8 mask_od;
+};
+
 /**
  * struct st_sensor_data_ready_irq - ST sensor device data-ready interrupt
  * struct int1 - data-ready configuration register for INT1 pin.
  * struct int2 - data-ready configuration register for INT2 pin.
  * @addr_ihl: address to enable/disable active low on the INT lines.
  * @mask_ihl: mask to enable/disable active low on the INT lines.
- * @addr_od: address to enable/disable Open Drain on the INT lines.
- * @mask_od: mask to enable/disable Open Drain on the INT lines.
  * struct stat_drdy - status register of DRDY (data ready) interrupt.
  * struct ig1 - represents the Interrupt Generator 1 of sensors.
  * @en_addr: address of the enable ig1 register.
  * @en_mask: mask to write the on/off value for enable.
  */
 struct st_sensor_data_ready_irq {
-	struct {
-		u8 addr;
-		u8 mask;
-	} int1;
-	struct {
-		u8 addr;
-		u8 mask;
-	} int2;
+	struct st_sensor_int_drdy int1;
+	struct st_sensor_int_drdy int2;
 	u8 addr_ihl;
 	u8 mask_ihl;
-	u8 addr_od;
-	u8 mask_od;
 	struct {
 		u8 addr;
 		u8 mask;
-- 
2.14.1

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

* [PATCH 1/4] iio: st_sensors: split open-drain parameters for irq1 and irq2
@ 2017-09-17 16:17     ` Lorenzo Bianconi
  0 siblings, 0 replies; 20+ messages in thread
From: Lorenzo Bianconi @ 2017-09-17 16:17 UTC (permalink / raw)
  To: jic23; +Cc: linux-iio, lorenzo.bianconi, devicetree

Define st_sensor_int_drdy structure in st_sensor_data_ready_irq in order
to contain irq line parameters of the device.
Moreover separate data-ready open-drain configuration parameters for INT1
and INT2 pins in st_sensor_data_ready_irq data structure.
That change will be used to properly support LIS3DHH accel sensor.

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
---
 drivers/iio/accel/st_accel_core.c               | 18 ++++++++++------
 drivers/iio/common/st_sensors/st_sensors_core.c | 21 ++++++++++++++-----
 drivers/iio/pressure/st_pressure_core.c         | 14 +++++++------
 include/linux/iio/common/st_sensors.h           | 28 ++++++++++++++-----------
 4 files changed, 52 insertions(+), 29 deletions(-)

diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
index 731ec3a4c82b..c88db25a1aff 100644
--- a/drivers/iio/accel/st_accel_core.c
+++ b/drivers/iio/accel/st_accel_core.c
@@ -236,15 +236,17 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
 			.int1 = {
 				.addr = 0x22,
 				.mask = 0x02,
+				.addr_od = 0x22,
+				.mask_od = 0x40,
 			},
 			.int2 = {
 				.addr = 0x22,
 				.mask = 0x10,
+				.addr_od = 0x22,
+				.mask_od = 0x40,
 			},
 			.addr_ihl = 0x22,
 			.mask_ihl = 0x80,
-			.addr_od = 0x22,
-			.mask_od = 0x40,
 			.stat_drdy = {
 				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
 				.mask = 0x07,
@@ -468,15 +470,17 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
 			.int1 = {
 				.addr = 0x22,
 				.mask = 0x04,
+				.addr_od = 0x22,
+				.mask_od = 0x40,
 			},
 			.int2 = {
 				.addr = 0x22,
 				.mask = 0x20,
+				.addr_od = 0x22,
+				.mask_od = 0x40,
 			},
 			.addr_ihl = 0x22,
 			.mask_ihl = 0x80,
-			.addr_od = 0x22,
-			.mask_od = 0x40,
 			.stat_drdy = {
 				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
 				.mask = 0x07,
@@ -750,15 +754,17 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
 			.int1 = {
 				.addr = 0x23,
 				.mask = 0x01,
+				.addr_od = 0x22,
+				.mask_od = 0x20,
 			},
 			.int2 = {
 				.addr = 0x24,
 				.mask = 0x01,
+				.addr_od = 0x22,
+				.mask_od = 0x20,
 			},
 			.addr_ihl = 0x22,
 			.mask_ihl = 0x08,
-			.addr_od = 0x22,
-			.mask_od = 0x20,
 			.stat_drdy = {
 				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
 				.mask = 0x01,
diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
index 6657160b5a73..40dfdfc0906b 100644
--- a/drivers/iio/common/st_sensors/st_sensors_core.c
+++ b/drivers/iio/common/st_sensors/st_sensors_core.c
@@ -319,7 +319,8 @@ static int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev,
 	}
 
 	if (pdata->open_drain) {
-		if (!sdata->sensor_settings->drdy_irq.addr_od)
+		if (!sdata->sensor_settings->drdy_irq.int1.addr_od &&
+		    !sdata->sensor_settings->drdy_irq.int2.addr_od)
 			dev_err(&indio_dev->dev,
 				"open drain requested but unsupported.\n");
 		else
@@ -446,11 +447,21 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev,
 	}
 
 	if (sdata->int_pin_open_drain) {
+		u8 addr, mask;
+
+		if (sdata->drdy_int_pin == 1) {
+			addr = sdata->sensor_settings->drdy_irq.int1.addr_od;
+			mask = sdata->sensor_settings->drdy_irq.int1.mask_od;
+		} else {
+			addr = sdata->sensor_settings->drdy_irq.int2.addr_od;
+			mask = sdata->sensor_settings->drdy_irq.int2.mask_od;
+		}
+
 		dev_info(&indio_dev->dev,
-			 "set interrupt line to open drain mode\n");
-		err = st_sensors_write_data_with_mask(indio_dev,
-				sdata->sensor_settings->drdy_irq.addr_od,
-				sdata->sensor_settings->drdy_irq.mask_od, 1);
+			 "set interrupt line to open drain mode on pin %d\n",
+			 sdata->drdy_int_pin);
+		err = st_sensors_write_data_with_mask(indio_dev, addr,
+						      mask, 1);
 		if (err < 0)
 			return err;
 	}
diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c
index 15ad6054d9f6..349e5c713c03 100644
--- a/drivers/iio/pressure/st_pressure_core.c
+++ b/drivers/iio/pressure/st_pressure_core.c
@@ -283,15 +283,17 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
 			.int1 = {
 				.addr = 0x22,
 				.mask = 0x04,
+				.addr_od = 0x22,
+				.mask_od = 0x40,
 			},
 			.int2 = {
 				.addr = 0x22,
 				.mask = 0x20,
+				.addr_od = 0x22,
+				.mask_od = 0x40,
 			},
 			.addr_ihl = 0x22,
 			.mask_ihl = 0x80,
-			.addr_od = 0x22,
-			.mask_od = 0x40,
 			.stat_drdy = {
 				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
 				.mask = 0x03,
@@ -404,11 +406,11 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
 			.int1 = {
 				.addr = 0x23,
 				.mask = 0x01,
+				.addr_od = 0x22,
+				.mask_od = 0x40,
 			},
 			.addr_ihl = 0x22,
 			.mask_ihl = 0x80,
-			.addr_od = 0x22,
-			.mask_od = 0x40,
 			.stat_drdy = {
 				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
 				.mask = 0x03,
@@ -473,11 +475,11 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
 			.int1 = {
 				.addr = 0x12,
 				.mask = 0x04,
+				.addr_od = 0x12,
+				.mask_od = 0x40,
 			},
 			.addr_ihl = 0x12,
 			.mask_ihl = 0x80,
-			.addr_od = 0x12,
-			.mask_od = 0x40,
 			.stat_drdy = {
 				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
 				.mask = 0x03,
diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h
index e6c646d5d6d4..f9bd6e8ab138 100644
--- a/include/linux/iio/common/st_sensors.h
+++ b/include/linux/iio/common/st_sensors.h
@@ -130,32 +130,36 @@ struct st_sensor_das {
 	u8 mask;
 };
 
+/**
+ * struct st_sensor_int_drdy - ST sensor device drdy line parameters
+ * @addr: address of INT drdy register.
+ * @mask: mask to enable drdy line.
+ * @addr_od: address to enable/disable Open Drain on the INT line.
+ * @mask_od: mask to enable/disable Open Drain on the INT line.
+ */
+struct st_sensor_int_drdy {
+	u8 addr;
+	u8 mask;
+	u8 addr_od;
+	u8 mask_od;
+};
+
 /**
  * struct st_sensor_data_ready_irq - ST sensor device data-ready interrupt
  * struct int1 - data-ready configuration register for INT1 pin.
  * struct int2 - data-ready configuration register for INT2 pin.
  * @addr_ihl: address to enable/disable active low on the INT lines.
  * @mask_ihl: mask to enable/disable active low on the INT lines.
- * @addr_od: address to enable/disable Open Drain on the INT lines.
- * @mask_od: mask to enable/disable Open Drain on the INT lines.
  * struct stat_drdy - status register of DRDY (data ready) interrupt.
  * struct ig1 - represents the Interrupt Generator 1 of sensors.
  * @en_addr: address of the enable ig1 register.
  * @en_mask: mask to write the on/off value for enable.
  */
 struct st_sensor_data_ready_irq {
-	struct {
-		u8 addr;
-		u8 mask;
-	} int1;
-	struct {
-		u8 addr;
-		u8 mask;
-	} int2;
+	struct st_sensor_int_drdy int1;
+	struct st_sensor_int_drdy int2;
 	u8 addr_ihl;
 	u8 mask_ihl;
-	u8 addr_od;
-	u8 mask_od;
 	struct {
 		u8 addr;
 		u8 mask;
-- 
2.14.1

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

* [PATCH 2/4] iio: common: st_sensors: check odr address value in st_sensors_set_odr()
  2017-09-17 16:17 ` Lorenzo Bianconi
@ 2017-09-17 16:17     ` Lorenzo Bianconi
  -1 siblings, 0 replies; 20+ messages in thread
From: Lorenzo Bianconi @ 2017-09-17 16:17 UTC (permalink / raw)
  To: jic23-DgEjT+Ai2ygdnm+yROfE0A
  Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA, lorenzo.bianconi-qxv4g6HH51o,
	devicetree-u79uwXL29TY76Z2rM5mHXA

Do not try to configure sample frequency if the sensor do not export
odr register address in register map. That change will be used to
properly support LIS3DHH accel sensor.

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
---
 drivers/iio/common/st_sensors/st_sensors_core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
index 40dfdfc0906b..57db19182e95 100644
--- a/drivers/iio/common/st_sensors/st_sensors_core.c
+++ b/drivers/iio/common/st_sensors/st_sensors_core.c
@@ -93,6 +93,9 @@ int st_sensors_set_odr(struct iio_dev *indio_dev, unsigned int odr)
 	struct st_sensor_odr_avl odr_out = {0, 0};
 	struct st_sensor_data *sdata = iio_priv(indio_dev);
 
+	if (!sdata->sensor_settings->odr.addr)
+		return 0;
+
 	err = st_sensors_match_odr(sdata->sensor_settings, odr, &odr_out);
 	if (err < 0)
 		goto st_sensors_match_odr_error;
-- 
2.14.1

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

* [PATCH 2/4] iio: common: st_sensors: check odr address value in st_sensors_set_odr()
@ 2017-09-17 16:17     ` Lorenzo Bianconi
  0 siblings, 0 replies; 20+ messages in thread
From: Lorenzo Bianconi @ 2017-09-17 16:17 UTC (permalink / raw)
  To: jic23; +Cc: linux-iio, lorenzo.bianconi, devicetree

Do not try to configure sample frequency if the sensor do not export
odr register address in register map. That change will be used to
properly support LIS3DHH accel sensor.

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
---
 drivers/iio/common/st_sensors/st_sensors_core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
index 40dfdfc0906b..57db19182e95 100644
--- a/drivers/iio/common/st_sensors/st_sensors_core.c
+++ b/drivers/iio/common/st_sensors/st_sensors_core.c
@@ -93,6 +93,9 @@ int st_sensors_set_odr(struct iio_dev *indio_dev, unsigned int odr)
 	struct st_sensor_odr_avl odr_out = {0, 0};
 	struct st_sensor_data *sdata = iio_priv(indio_dev);
 
+	if (!sdata->sensor_settings->odr.addr)
+		return 0;
+
 	err = st_sensors_match_odr(sdata->sensor_settings, odr, &odr_out);
 	if (err < 0)
 		goto st_sensors_match_odr_error;
-- 
2.14.1

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

* [PATCH 3/4] iio: accel: add support to LIS3DHH
  2017-09-17 16:17 ` Lorenzo Bianconi
@ 2017-09-17 16:17     ` Lorenzo Bianconi
  -1 siblings, 0 replies; 20+ messages in thread
From: Lorenzo Bianconi @ 2017-09-17 16:17 UTC (permalink / raw)
  To: jic23-DgEjT+Ai2ygdnm+yROfE0A
  Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA, lorenzo.bianconi-qxv4g6HH51o,
	devicetree-u79uwXL29TY76Z2rM5mHXA

add support to STMicroelectronics LIS3DHH accel sensor

http://www.st.com/resource/en/datasheet/lis3dhh.pdf
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
---
 drivers/iio/accel/st_accel.h      |  2 ++
 drivers/iio/accel/st_accel_core.c | 52 +++++++++++++++++++++++++++++++++++++++
 drivers/iio/accel/st_accel_spi.c  |  5 ++++
 3 files changed, 59 insertions(+)

diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h
index 2ed0f60418c0..2f931e4837e5 100644
--- a/drivers/iio/accel/st_accel.h
+++ b/drivers/iio/accel/st_accel.h
@@ -33,6 +33,7 @@ enum st_accel_type {
 	LIS331DL,
 	LIS3LV02DL,
 	LIS2DW12,
+	LIS3DHH,
 	ST_ACCEL_MAX,
 };
 
@@ -54,6 +55,7 @@ enum st_accel_type {
 #define LIS3L02DQ_ACCEL_DEV_NAME	"lis3l02dq"
 #define LNG2DM_ACCEL_DEV_NAME		"lng2dm"
 #define LIS2DW12_ACCEL_DEV_NAME		"lis2dw12"
+#define LIS3DHH_ACCEL_DEV_NAME		"lis3dhh"
 
 /**
 * struct st_sensors_platform_data - default accel platform data
diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
index c88db25a1aff..460aa58e0159 100644
--- a/drivers/iio/accel/st_accel_core.c
+++ b/drivers/iio/accel/st_accel_core.c
@@ -777,6 +777,58 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
 		.multi_read_bit = false,
 		.bootime = 2,
 	},
+	{
+		.wai = 0x11,
+		.wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
+		.sensors_supported = {
+			[0] = LIS3DHH_ACCEL_DEV_NAME,
+		},
+		.ch = (struct iio_chan_spec *)st_accel_16bit_channels,
+		.odr = {
+			/* just ODR = 1100Hz available */
+			.odr_avl = {
+				{ .hz = 1100, .value = 0x00, },
+			},
+		},
+		.pw = {
+			.addr = 0x20,
+			.mask = 0x80,
+			.value_on = ST_SENSORS_DEFAULT_POWER_ON_VALUE,
+			.value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE,
+		},
+		.fs = {
+			.fs_avl = {
+				[0] = {
+					.num = ST_ACCEL_FS_AVL_2G,
+					.gain = IIO_G_TO_M_S_2(76),
+				},
+			},
+		},
+		.bdu = {
+			.addr = 0x20,
+			.mask = 0x01,
+		},
+		.drdy_irq = {
+			.int1 = {
+				.addr = 0x21,
+				.mask = 0x80,
+				.addr_od = 0x23,
+				.mask_od = 0x04,
+			},
+			.int2 = {
+				.addr = 0x22,
+				.mask = 0x80,
+				.addr_od = 0x23,
+				.mask_od = 0x08,
+			},
+			.stat_drdy = {
+				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
+				.mask = 0x07,
+			},
+		},
+		.multi_read_bit = false,
+		.bootime = 2,
+	},
 };
 
 static int st_accel_read_raw(struct iio_dev *indio_dev,
diff --git a/drivers/iio/accel/st_accel_spi.c b/drivers/iio/accel/st_accel_spi.c
index 7692da49e59f..dcc9bd243a52 100644
--- a/drivers/iio/accel/st_accel_spi.c
+++ b/drivers/iio/accel/st_accel_spi.c
@@ -86,6 +86,10 @@ static const struct of_device_id st_accel_of_match[] = {
 		.compatible = "st,lis2dw12",
 		.data = LIS2DW12_ACCEL_DEV_NAME,
 	},
+	{
+		.compatible = "st,lis3dhh",
+		.data = LIS3DHH_ACCEL_DEV_NAME,
+	},
 	{}
 };
 MODULE_DEVICE_TABLE(of, st_accel_of_match);
@@ -138,6 +142,7 @@ static const struct spi_device_id st_accel_id_table[] = {
 	{ LIS331DL_ACCEL_DEV_NAME },
 	{ LIS3LV02DL_ACCEL_DEV_NAME },
 	{ LIS2DW12_ACCEL_DEV_NAME },
+	{ LIS3DHH_ACCEL_DEV_NAME },
 	{},
 };
 MODULE_DEVICE_TABLE(spi, st_accel_id_table);
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 3/4] iio: accel: add support to LIS3DHH
@ 2017-09-17 16:17     ` Lorenzo Bianconi
  0 siblings, 0 replies; 20+ messages in thread
From: Lorenzo Bianconi @ 2017-09-17 16:17 UTC (permalink / raw)
  To: jic23; +Cc: linux-iio, lorenzo.bianconi, devicetree

add support to STMicroelectronics LIS3DHH accel sensor

http://www.st.com/resource/en/datasheet/lis3dhh.pdf
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
---
 drivers/iio/accel/st_accel.h      |  2 ++
 drivers/iio/accel/st_accel_core.c | 52 +++++++++++++++++++++++++++++++++++++++
 drivers/iio/accel/st_accel_spi.c  |  5 ++++
 3 files changed, 59 insertions(+)

diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h
index 2ed0f60418c0..2f931e4837e5 100644
--- a/drivers/iio/accel/st_accel.h
+++ b/drivers/iio/accel/st_accel.h
@@ -33,6 +33,7 @@ enum st_accel_type {
 	LIS331DL,
 	LIS3LV02DL,
 	LIS2DW12,
+	LIS3DHH,
 	ST_ACCEL_MAX,
 };
 
@@ -54,6 +55,7 @@ enum st_accel_type {
 #define LIS3L02DQ_ACCEL_DEV_NAME	"lis3l02dq"
 #define LNG2DM_ACCEL_DEV_NAME		"lng2dm"
 #define LIS2DW12_ACCEL_DEV_NAME		"lis2dw12"
+#define LIS3DHH_ACCEL_DEV_NAME		"lis3dhh"
 
 /**
 * struct st_sensors_platform_data - default accel platform data
diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
index c88db25a1aff..460aa58e0159 100644
--- a/drivers/iio/accel/st_accel_core.c
+++ b/drivers/iio/accel/st_accel_core.c
@@ -777,6 +777,58 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
 		.multi_read_bit = false,
 		.bootime = 2,
 	},
+	{
+		.wai = 0x11,
+		.wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
+		.sensors_supported = {
+			[0] = LIS3DHH_ACCEL_DEV_NAME,
+		},
+		.ch = (struct iio_chan_spec *)st_accel_16bit_channels,
+		.odr = {
+			/* just ODR = 1100Hz available */
+			.odr_avl = {
+				{ .hz = 1100, .value = 0x00, },
+			},
+		},
+		.pw = {
+			.addr = 0x20,
+			.mask = 0x80,
+			.value_on = ST_SENSORS_DEFAULT_POWER_ON_VALUE,
+			.value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE,
+		},
+		.fs = {
+			.fs_avl = {
+				[0] = {
+					.num = ST_ACCEL_FS_AVL_2G,
+					.gain = IIO_G_TO_M_S_2(76),
+				},
+			},
+		},
+		.bdu = {
+			.addr = 0x20,
+			.mask = 0x01,
+		},
+		.drdy_irq = {
+			.int1 = {
+				.addr = 0x21,
+				.mask = 0x80,
+				.addr_od = 0x23,
+				.mask_od = 0x04,
+			},
+			.int2 = {
+				.addr = 0x22,
+				.mask = 0x80,
+				.addr_od = 0x23,
+				.mask_od = 0x08,
+			},
+			.stat_drdy = {
+				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
+				.mask = 0x07,
+			},
+		},
+		.multi_read_bit = false,
+		.bootime = 2,
+	},
 };
 
 static int st_accel_read_raw(struct iio_dev *indio_dev,
diff --git a/drivers/iio/accel/st_accel_spi.c b/drivers/iio/accel/st_accel_spi.c
index 7692da49e59f..dcc9bd243a52 100644
--- a/drivers/iio/accel/st_accel_spi.c
+++ b/drivers/iio/accel/st_accel_spi.c
@@ -86,6 +86,10 @@ static const struct of_device_id st_accel_of_match[] = {
 		.compatible = "st,lis2dw12",
 		.data = LIS2DW12_ACCEL_DEV_NAME,
 	},
+	{
+		.compatible = "st,lis3dhh",
+		.data = LIS3DHH_ACCEL_DEV_NAME,
+	},
 	{}
 };
 MODULE_DEVICE_TABLE(of, st_accel_of_match);
@@ -138,6 +142,7 @@ static const struct spi_device_id st_accel_id_table[] = {
 	{ LIS331DL_ACCEL_DEV_NAME },
 	{ LIS3LV02DL_ACCEL_DEV_NAME },
 	{ LIS2DW12_ACCEL_DEV_NAME },
+	{ LIS3DHH_ACCEL_DEV_NAME },
 	{},
 };
 MODULE_DEVICE_TABLE(spi, st_accel_id_table);
-- 
2.14.1

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

* [PATCH 4/4] dt-bindings: iio: accel: add LIS3DHH device bindings
  2017-09-17 16:17 ` Lorenzo Bianconi
@ 2017-09-17 16:17     ` Lorenzo Bianconi
  -1 siblings, 0 replies; 20+ messages in thread
From: Lorenzo Bianconi @ 2017-09-17 16:17 UTC (permalink / raw)
  To: jic23-DgEjT+Ai2ygdnm+yROfE0A
  Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA, lorenzo.bianconi-qxv4g6HH51o,
	devicetree-u79uwXL29TY76Z2rM5mHXA

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
---
 Documentation/devicetree/bindings/iio/st-sensors.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt
index 9cfc82d21792..6f626f73417e 100644
--- a/Documentation/devicetree/bindings/iio/st-sensors.txt
+++ b/Documentation/devicetree/bindings/iio/st-sensors.txt
@@ -47,6 +47,7 @@ Accelerometers:
 - st,lng2dm-accel
 - st,lis3l02dq
 - st,lis2dw12
+- st,lis3dhh
 
 Gyroscopes:
 - st,l3g4200d-gyro
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 4/4] dt-bindings: iio: accel: add LIS3DHH device bindings
@ 2017-09-17 16:17     ` Lorenzo Bianconi
  0 siblings, 0 replies; 20+ messages in thread
From: Lorenzo Bianconi @ 2017-09-17 16:17 UTC (permalink / raw)
  To: jic23; +Cc: linux-iio, lorenzo.bianconi, devicetree

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
---
 Documentation/devicetree/bindings/iio/st-sensors.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt
index 9cfc82d21792..6f626f73417e 100644
--- a/Documentation/devicetree/bindings/iio/st-sensors.txt
+++ b/Documentation/devicetree/bindings/iio/st-sensors.txt
@@ -47,6 +47,7 @@ Accelerometers:
 - st,lng2dm-accel
 - st,lis3l02dq
 - st,lis2dw12
+- st,lis3dhh
 
 Gyroscopes:
 - st,l3g4200d-gyro
-- 
2.14.1

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

* Re: [PATCH 4/4] dt-bindings: iio: accel: add LIS3DHH device bindings
  2017-09-17 16:17     ` Lorenzo Bianconi
@ 2017-09-20 20:53         ` Rob Herring
  -1 siblings, 0 replies; 20+ messages in thread
From: Rob Herring @ 2017-09-20 20:53 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: jic23-DgEjT+Ai2ygdnm+yROfE0A, linux-iio-u79uwXL29TY76Z2rM5mHXA,
	lorenzo.bianconi-qxv4g6HH51o, devicetree-u79uwXL29TY76Z2rM5mHXA

On Sun, Sep 17, 2017 at 06:17:12PM +0200, Lorenzo Bianconi wrote:
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
> ---
>  Documentation/devicetree/bindings/iio/st-sensors.txt | 1 +
>  1 file changed, 1 insertion(+)

Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

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

* Re: [PATCH 4/4] dt-bindings: iio: accel: add LIS3DHH device bindings
@ 2017-09-20 20:53         ` Rob Herring
  0 siblings, 0 replies; 20+ messages in thread
From: Rob Herring @ 2017-09-20 20:53 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: jic23, linux-iio, lorenzo.bianconi, devicetree

On Sun, Sep 17, 2017 at 06:17:12PM +0200, Lorenzo Bianconi wrote:
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
> ---
>  Documentation/devicetree/bindings/iio/st-sensors.txt | 1 +
>  1 file changed, 1 insertion(+)

Acked-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH 1/4] iio: st_sensors: split open-drain parameters for irq1 and irq2
  2017-09-17 16:17     ` Lorenzo Bianconi
@ 2017-10-10 19:39         ` Jonathan Cameron
  -1 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2017-10-10 19:39 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA, lorenzo.bianconi-qxv4g6HH51o,
	devicetree-u79uwXL29TY76Z2rM5mHXA

On Sun, 17 Sep 2017 18:17:09 +0200
Lorenzo Bianconi <lorenzo.bianconi83-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> Define st_sensor_int_drdy structure in st_sensor_data_ready_irq in order
> to contain irq line parameters of the device.
> Moreover separate data-ready open-drain configuration parameters for INT1
> and INT2 pins in st_sensor_data_ready_irq data structure.
> That change will be used to properly support LIS3DHH accel sensor.
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>

Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

Thanks,

Jonathan

> ---
>  drivers/iio/accel/st_accel_core.c               | 18 ++++++++++------
>  drivers/iio/common/st_sensors/st_sensors_core.c | 21 ++++++++++++++-----
>  drivers/iio/pressure/st_pressure_core.c         | 14 +++++++------
>  include/linux/iio/common/st_sensors.h           | 28 ++++++++++++++-----------
>  4 files changed, 52 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
> index 731ec3a4c82b..c88db25a1aff 100644
> --- a/drivers/iio/accel/st_accel_core.c
> +++ b/drivers/iio/accel/st_accel_core.c
> @@ -236,15 +236,17 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
>  			.int1 = {
>  				.addr = 0x22,
>  				.mask = 0x02,
> +				.addr_od = 0x22,
> +				.mask_od = 0x40,
>  			},
>  			.int2 = {
>  				.addr = 0x22,
>  				.mask = 0x10,
> +				.addr_od = 0x22,
> +				.mask_od = 0x40,
>  			},
>  			.addr_ihl = 0x22,
>  			.mask_ihl = 0x80,
> -			.addr_od = 0x22,
> -			.mask_od = 0x40,
>  			.stat_drdy = {
>  				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
>  				.mask = 0x07,
> @@ -468,15 +470,17 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
>  			.int1 = {
>  				.addr = 0x22,
>  				.mask = 0x04,
> +				.addr_od = 0x22,
> +				.mask_od = 0x40,
>  			},
>  			.int2 = {
>  				.addr = 0x22,
>  				.mask = 0x20,
> +				.addr_od = 0x22,
> +				.mask_od = 0x40,
>  			},
>  			.addr_ihl = 0x22,
>  			.mask_ihl = 0x80,
> -			.addr_od = 0x22,
> -			.mask_od = 0x40,
>  			.stat_drdy = {
>  				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
>  				.mask = 0x07,
> @@ -750,15 +754,17 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
>  			.int1 = {
>  				.addr = 0x23,
>  				.mask = 0x01,
> +				.addr_od = 0x22,
> +				.mask_od = 0x20,
>  			},
>  			.int2 = {
>  				.addr = 0x24,
>  				.mask = 0x01,
> +				.addr_od = 0x22,
> +				.mask_od = 0x20,
>  			},
>  			.addr_ihl = 0x22,
>  			.mask_ihl = 0x08,
> -			.addr_od = 0x22,
> -			.mask_od = 0x20,
>  			.stat_drdy = {
>  				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
>  				.mask = 0x01,
> diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
> index 6657160b5a73..40dfdfc0906b 100644
> --- a/drivers/iio/common/st_sensors/st_sensors_core.c
> +++ b/drivers/iio/common/st_sensors/st_sensors_core.c
> @@ -319,7 +319,8 @@ static int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev,
>  	}
>  
>  	if (pdata->open_drain) {
> -		if (!sdata->sensor_settings->drdy_irq.addr_od)
> +		if (!sdata->sensor_settings->drdy_irq.int1.addr_od &&
> +		    !sdata->sensor_settings->drdy_irq.int2.addr_od)
>  			dev_err(&indio_dev->dev,
>  				"open drain requested but unsupported.\n");
>  		else
> @@ -446,11 +447,21 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev,
>  	}
>  
>  	if (sdata->int_pin_open_drain) {
> +		u8 addr, mask;
> +
> +		if (sdata->drdy_int_pin == 1) {
> +			addr = sdata->sensor_settings->drdy_irq.int1.addr_od;
> +			mask = sdata->sensor_settings->drdy_irq.int1.mask_od;
> +		} else {
> +			addr = sdata->sensor_settings->drdy_irq.int2.addr_od;
> +			mask = sdata->sensor_settings->drdy_irq.int2.mask_od;
> +		}
> +
>  		dev_info(&indio_dev->dev,
> -			 "set interrupt line to open drain mode\n");
> -		err = st_sensors_write_data_with_mask(indio_dev,
> -				sdata->sensor_settings->drdy_irq.addr_od,
> -				sdata->sensor_settings->drdy_irq.mask_od, 1);
> +			 "set interrupt line to open drain mode on pin %d\n",
> +			 sdata->drdy_int_pin);
> +		err = st_sensors_write_data_with_mask(indio_dev, addr,
> +						      mask, 1);
>  		if (err < 0)
>  			return err;
>  	}
> diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c
> index 15ad6054d9f6..349e5c713c03 100644
> --- a/drivers/iio/pressure/st_pressure_core.c
> +++ b/drivers/iio/pressure/st_pressure_core.c
> @@ -283,15 +283,17 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
>  			.int1 = {
>  				.addr = 0x22,
>  				.mask = 0x04,
> +				.addr_od = 0x22,
> +				.mask_od = 0x40,
>  			},
>  			.int2 = {
>  				.addr = 0x22,
>  				.mask = 0x20,
> +				.addr_od = 0x22,
> +				.mask_od = 0x40,
>  			},
>  			.addr_ihl = 0x22,
>  			.mask_ihl = 0x80,
> -			.addr_od = 0x22,
> -			.mask_od = 0x40,
>  			.stat_drdy = {
>  				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
>  				.mask = 0x03,
> @@ -404,11 +406,11 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
>  			.int1 = {
>  				.addr = 0x23,
>  				.mask = 0x01,
> +				.addr_od = 0x22,
> +				.mask_od = 0x40,
>  			},
>  			.addr_ihl = 0x22,
>  			.mask_ihl = 0x80,
> -			.addr_od = 0x22,
> -			.mask_od = 0x40,
>  			.stat_drdy = {
>  				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
>  				.mask = 0x03,
> @@ -473,11 +475,11 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
>  			.int1 = {
>  				.addr = 0x12,
>  				.mask = 0x04,
> +				.addr_od = 0x12,
> +				.mask_od = 0x40,
>  			},
>  			.addr_ihl = 0x12,
>  			.mask_ihl = 0x80,
> -			.addr_od = 0x12,
> -			.mask_od = 0x40,
>  			.stat_drdy = {
>  				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
>  				.mask = 0x03,
> diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h
> index e6c646d5d6d4..f9bd6e8ab138 100644
> --- a/include/linux/iio/common/st_sensors.h
> +++ b/include/linux/iio/common/st_sensors.h
> @@ -130,32 +130,36 @@ struct st_sensor_das {
>  	u8 mask;
>  };
>  
> +/**
> + * struct st_sensor_int_drdy - ST sensor device drdy line parameters
> + * @addr: address of INT drdy register.
> + * @mask: mask to enable drdy line.
> + * @addr_od: address to enable/disable Open Drain on the INT line.
> + * @mask_od: mask to enable/disable Open Drain on the INT line.
> + */
> +struct st_sensor_int_drdy {
> +	u8 addr;
> +	u8 mask;
> +	u8 addr_od;
> +	u8 mask_od;
> +};
> +
>  /**
>   * struct st_sensor_data_ready_irq - ST sensor device data-ready interrupt
>   * struct int1 - data-ready configuration register for INT1 pin.
>   * struct int2 - data-ready configuration register for INT2 pin.
>   * @addr_ihl: address to enable/disable active low on the INT lines.
>   * @mask_ihl: mask to enable/disable active low on the INT lines.
> - * @addr_od: address to enable/disable Open Drain on the INT lines.
> - * @mask_od: mask to enable/disable Open Drain on the INT lines.
>   * struct stat_drdy - status register of DRDY (data ready) interrupt.
>   * struct ig1 - represents the Interrupt Generator 1 of sensors.
>   * @en_addr: address of the enable ig1 register.
>   * @en_mask: mask to write the on/off value for enable.
>   */
>  struct st_sensor_data_ready_irq {
> -	struct {
> -		u8 addr;
> -		u8 mask;
> -	} int1;
> -	struct {
> -		u8 addr;
> -		u8 mask;
> -	} int2;
> +	struct st_sensor_int_drdy int1;
> +	struct st_sensor_int_drdy int2;
>  	u8 addr_ihl;
>  	u8 mask_ihl;
> -	u8 addr_od;
> -	u8 mask_od;
>  	struct {
>  		u8 addr;
>  		u8 mask;

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/4] iio: st_sensors: split open-drain parameters for irq1 and irq2
@ 2017-10-10 19:39         ` Jonathan Cameron
  0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2017-10-10 19:39 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: linux-iio, lorenzo.bianconi, devicetree

On Sun, 17 Sep 2017 18:17:09 +0200
Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> wrote:

> Define st_sensor_int_drdy structure in st_sensor_data_ready_irq in order
> to contain irq line parameters of the device.
> Moreover separate data-ready open-drain configuration parameters for INT1
> and INT2 pins in st_sensor_data_ready_irq data structure.
> That change will be used to properly support LIS3DHH accel sensor.
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>

Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

Thanks,

Jonathan

> ---
>  drivers/iio/accel/st_accel_core.c               | 18 ++++++++++------
>  drivers/iio/common/st_sensors/st_sensors_core.c | 21 ++++++++++++++-----
>  drivers/iio/pressure/st_pressure_core.c         | 14 +++++++------
>  include/linux/iio/common/st_sensors.h           | 28 ++++++++++++++-----------
>  4 files changed, 52 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
> index 731ec3a4c82b..c88db25a1aff 100644
> --- a/drivers/iio/accel/st_accel_core.c
> +++ b/drivers/iio/accel/st_accel_core.c
> @@ -236,15 +236,17 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
>  			.int1 = {
>  				.addr = 0x22,
>  				.mask = 0x02,
> +				.addr_od = 0x22,
> +				.mask_od = 0x40,
>  			},
>  			.int2 = {
>  				.addr = 0x22,
>  				.mask = 0x10,
> +				.addr_od = 0x22,
> +				.mask_od = 0x40,
>  			},
>  			.addr_ihl = 0x22,
>  			.mask_ihl = 0x80,
> -			.addr_od = 0x22,
> -			.mask_od = 0x40,
>  			.stat_drdy = {
>  				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
>  				.mask = 0x07,
> @@ -468,15 +470,17 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
>  			.int1 = {
>  				.addr = 0x22,
>  				.mask = 0x04,
> +				.addr_od = 0x22,
> +				.mask_od = 0x40,
>  			},
>  			.int2 = {
>  				.addr = 0x22,
>  				.mask = 0x20,
> +				.addr_od = 0x22,
> +				.mask_od = 0x40,
>  			},
>  			.addr_ihl = 0x22,
>  			.mask_ihl = 0x80,
> -			.addr_od = 0x22,
> -			.mask_od = 0x40,
>  			.stat_drdy = {
>  				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
>  				.mask = 0x07,
> @@ -750,15 +754,17 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
>  			.int1 = {
>  				.addr = 0x23,
>  				.mask = 0x01,
> +				.addr_od = 0x22,
> +				.mask_od = 0x20,
>  			},
>  			.int2 = {
>  				.addr = 0x24,
>  				.mask = 0x01,
> +				.addr_od = 0x22,
> +				.mask_od = 0x20,
>  			},
>  			.addr_ihl = 0x22,
>  			.mask_ihl = 0x08,
> -			.addr_od = 0x22,
> -			.mask_od = 0x20,
>  			.stat_drdy = {
>  				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
>  				.mask = 0x01,
> diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
> index 6657160b5a73..40dfdfc0906b 100644
> --- a/drivers/iio/common/st_sensors/st_sensors_core.c
> +++ b/drivers/iio/common/st_sensors/st_sensors_core.c
> @@ -319,7 +319,8 @@ static int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev,
>  	}
>  
>  	if (pdata->open_drain) {
> -		if (!sdata->sensor_settings->drdy_irq.addr_od)
> +		if (!sdata->sensor_settings->drdy_irq.int1.addr_od &&
> +		    !sdata->sensor_settings->drdy_irq.int2.addr_od)
>  			dev_err(&indio_dev->dev,
>  				"open drain requested but unsupported.\n");
>  		else
> @@ -446,11 +447,21 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev,
>  	}
>  
>  	if (sdata->int_pin_open_drain) {
> +		u8 addr, mask;
> +
> +		if (sdata->drdy_int_pin == 1) {
> +			addr = sdata->sensor_settings->drdy_irq.int1.addr_od;
> +			mask = sdata->sensor_settings->drdy_irq.int1.mask_od;
> +		} else {
> +			addr = sdata->sensor_settings->drdy_irq.int2.addr_od;
> +			mask = sdata->sensor_settings->drdy_irq.int2.mask_od;
> +		}
> +
>  		dev_info(&indio_dev->dev,
> -			 "set interrupt line to open drain mode\n");
> -		err = st_sensors_write_data_with_mask(indio_dev,
> -				sdata->sensor_settings->drdy_irq.addr_od,
> -				sdata->sensor_settings->drdy_irq.mask_od, 1);
> +			 "set interrupt line to open drain mode on pin %d\n",
> +			 sdata->drdy_int_pin);
> +		err = st_sensors_write_data_with_mask(indio_dev, addr,
> +						      mask, 1);
>  		if (err < 0)
>  			return err;
>  	}
> diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c
> index 15ad6054d9f6..349e5c713c03 100644
> --- a/drivers/iio/pressure/st_pressure_core.c
> +++ b/drivers/iio/pressure/st_pressure_core.c
> @@ -283,15 +283,17 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
>  			.int1 = {
>  				.addr = 0x22,
>  				.mask = 0x04,
> +				.addr_od = 0x22,
> +				.mask_od = 0x40,
>  			},
>  			.int2 = {
>  				.addr = 0x22,
>  				.mask = 0x20,
> +				.addr_od = 0x22,
> +				.mask_od = 0x40,
>  			},
>  			.addr_ihl = 0x22,
>  			.mask_ihl = 0x80,
> -			.addr_od = 0x22,
> -			.mask_od = 0x40,
>  			.stat_drdy = {
>  				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
>  				.mask = 0x03,
> @@ -404,11 +406,11 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
>  			.int1 = {
>  				.addr = 0x23,
>  				.mask = 0x01,
> +				.addr_od = 0x22,
> +				.mask_od = 0x40,
>  			},
>  			.addr_ihl = 0x22,
>  			.mask_ihl = 0x80,
> -			.addr_od = 0x22,
> -			.mask_od = 0x40,
>  			.stat_drdy = {
>  				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
>  				.mask = 0x03,
> @@ -473,11 +475,11 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
>  			.int1 = {
>  				.addr = 0x12,
>  				.mask = 0x04,
> +				.addr_od = 0x12,
> +				.mask_od = 0x40,
>  			},
>  			.addr_ihl = 0x12,
>  			.mask_ihl = 0x80,
> -			.addr_od = 0x12,
> -			.mask_od = 0x40,
>  			.stat_drdy = {
>  				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
>  				.mask = 0x03,
> diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h
> index e6c646d5d6d4..f9bd6e8ab138 100644
> --- a/include/linux/iio/common/st_sensors.h
> +++ b/include/linux/iio/common/st_sensors.h
> @@ -130,32 +130,36 @@ struct st_sensor_das {
>  	u8 mask;
>  };
>  
> +/**
> + * struct st_sensor_int_drdy - ST sensor device drdy line parameters
> + * @addr: address of INT drdy register.
> + * @mask: mask to enable drdy line.
> + * @addr_od: address to enable/disable Open Drain on the INT line.
> + * @mask_od: mask to enable/disable Open Drain on the INT line.
> + */
> +struct st_sensor_int_drdy {
> +	u8 addr;
> +	u8 mask;
> +	u8 addr_od;
> +	u8 mask_od;
> +};
> +
>  /**
>   * struct st_sensor_data_ready_irq - ST sensor device data-ready interrupt
>   * struct int1 - data-ready configuration register for INT1 pin.
>   * struct int2 - data-ready configuration register for INT2 pin.
>   * @addr_ihl: address to enable/disable active low on the INT lines.
>   * @mask_ihl: mask to enable/disable active low on the INT lines.
> - * @addr_od: address to enable/disable Open Drain on the INT lines.
> - * @mask_od: mask to enable/disable Open Drain on the INT lines.
>   * struct stat_drdy - status register of DRDY (data ready) interrupt.
>   * struct ig1 - represents the Interrupt Generator 1 of sensors.
>   * @en_addr: address of the enable ig1 register.
>   * @en_mask: mask to write the on/off value for enable.
>   */
>  struct st_sensor_data_ready_irq {
> -	struct {
> -		u8 addr;
> -		u8 mask;
> -	} int1;
> -	struct {
> -		u8 addr;
> -		u8 mask;
> -	} int2;
> +	struct st_sensor_int_drdy int1;
> +	struct st_sensor_int_drdy int2;
>  	u8 addr_ihl;
>  	u8 mask_ihl;
> -	u8 addr_od;
> -	u8 mask_od;
>  	struct {
>  		u8 addr;
>  		u8 mask;


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

* Re: [PATCH 2/4] iio: common: st_sensors: check odr address value in st_sensors_set_odr()
  2017-09-17 16:17     ` Lorenzo Bianconi
@ 2017-10-10 19:40         ` Jonathan Cameron
  -1 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2017-10-10 19:40 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA, lorenzo.bianconi-qxv4g6HH51o,
	devicetree-u79uwXL29TY76Z2rM5mHXA

On Sun, 17 Sep 2017 18:17:10 +0200
Lorenzo Bianconi <lorenzo.bianconi83-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> Do not try to configure sample frequency if the sensor do not export
> odr register address in register map. That change will be used to
> properly support LIS3DHH accel sensor.
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

Thanks,

Jonathan
> ---
>  drivers/iio/common/st_sensors/st_sensors_core.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
> index 40dfdfc0906b..57db19182e95 100644
> --- a/drivers/iio/common/st_sensors/st_sensors_core.c
> +++ b/drivers/iio/common/st_sensors/st_sensors_core.c
> @@ -93,6 +93,9 @@ int st_sensors_set_odr(struct iio_dev *indio_dev, unsigned int odr)
>  	struct st_sensor_odr_avl odr_out = {0, 0};
>  	struct st_sensor_data *sdata = iio_priv(indio_dev);
>  
> +	if (!sdata->sensor_settings->odr.addr)
> +		return 0;
> +
>  	err = st_sensors_match_odr(sdata->sensor_settings, odr, &odr_out);
>  	if (err < 0)
>  		goto st_sensors_match_odr_error;

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 2/4] iio: common: st_sensors: check odr address value in st_sensors_set_odr()
@ 2017-10-10 19:40         ` Jonathan Cameron
  0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2017-10-10 19:40 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: linux-iio, lorenzo.bianconi, devicetree

On Sun, 17 Sep 2017 18:17:10 +0200
Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> wrote:

> Do not try to configure sample frequency if the sensor do not export
> odr register address in register map. That change will be used to
> properly support LIS3DHH accel sensor.
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

Thanks,

Jonathan
> ---
>  drivers/iio/common/st_sensors/st_sensors_core.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
> index 40dfdfc0906b..57db19182e95 100644
> --- a/drivers/iio/common/st_sensors/st_sensors_core.c
> +++ b/drivers/iio/common/st_sensors/st_sensors_core.c
> @@ -93,6 +93,9 @@ int st_sensors_set_odr(struct iio_dev *indio_dev, unsigned int odr)
>  	struct st_sensor_odr_avl odr_out = {0, 0};
>  	struct st_sensor_data *sdata = iio_priv(indio_dev);
>  
> +	if (!sdata->sensor_settings->odr.addr)
> +		return 0;
> +
>  	err = st_sensors_match_odr(sdata->sensor_settings, odr, &odr_out);
>  	if (err < 0)
>  		goto st_sensors_match_odr_error;


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

* Re: [PATCH 3/4] iio: accel: add support to LIS3DHH
  2017-09-17 16:17     ` Lorenzo Bianconi
@ 2017-10-10 19:40         ` Jonathan Cameron
  -1 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2017-10-10 19:40 UTC (permalink / raw)
  To: Lorenzo Bianconi
  Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA, lorenzo.bianconi-qxv4g6HH51o,
	devicetree-u79uwXL29TY76Z2rM5mHXA

On Sun, 17 Sep 2017 18:17:11 +0200
Lorenzo Bianconi <lorenzo.bianconi83-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> add support to STMicroelectronics LIS3DHH accel sensor
> 
> http://www.st.com/resource/en/datasheet/lis3dhh.pdf
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

Thanks,

Jonathan
> ---
>  drivers/iio/accel/st_accel.h      |  2 ++
>  drivers/iio/accel/st_accel_core.c | 52 +++++++++++++++++++++++++++++++++++++++
>  drivers/iio/accel/st_accel_spi.c  |  5 ++++
>  3 files changed, 59 insertions(+)
> 
> diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h
> index 2ed0f60418c0..2f931e4837e5 100644
> --- a/drivers/iio/accel/st_accel.h
> +++ b/drivers/iio/accel/st_accel.h
> @@ -33,6 +33,7 @@ enum st_accel_type {
>  	LIS331DL,
>  	LIS3LV02DL,
>  	LIS2DW12,
> +	LIS3DHH,
>  	ST_ACCEL_MAX,
>  };
>  
> @@ -54,6 +55,7 @@ enum st_accel_type {
>  #define LIS3L02DQ_ACCEL_DEV_NAME	"lis3l02dq"
>  #define LNG2DM_ACCEL_DEV_NAME		"lng2dm"
>  #define LIS2DW12_ACCEL_DEV_NAME		"lis2dw12"
> +#define LIS3DHH_ACCEL_DEV_NAME		"lis3dhh"
>  
>  /**
>  * struct st_sensors_platform_data - default accel platform data
> diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
> index c88db25a1aff..460aa58e0159 100644
> --- a/drivers/iio/accel/st_accel_core.c
> +++ b/drivers/iio/accel/st_accel_core.c
> @@ -777,6 +777,58 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
>  		.multi_read_bit = false,
>  		.bootime = 2,
>  	},
> +	{
> +		.wai = 0x11,
> +		.wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
> +		.sensors_supported = {
> +			[0] = LIS3DHH_ACCEL_DEV_NAME,
> +		},
> +		.ch = (struct iio_chan_spec *)st_accel_16bit_channels,
> +		.odr = {
> +			/* just ODR = 1100Hz available */
> +			.odr_avl = {
> +				{ .hz = 1100, .value = 0x00, },
> +			},
> +		},
> +		.pw = {
> +			.addr = 0x20,
> +			.mask = 0x80,
> +			.value_on = ST_SENSORS_DEFAULT_POWER_ON_VALUE,
> +			.value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE,
> +		},
> +		.fs = {
> +			.fs_avl = {
> +				[0] = {
> +					.num = ST_ACCEL_FS_AVL_2G,
> +					.gain = IIO_G_TO_M_S_2(76),
> +				},
> +			},
> +		},
> +		.bdu = {
> +			.addr = 0x20,
> +			.mask = 0x01,
> +		},
> +		.drdy_irq = {
> +			.int1 = {
> +				.addr = 0x21,
> +				.mask = 0x80,
> +				.addr_od = 0x23,
> +				.mask_od = 0x04,
> +			},
> +			.int2 = {
> +				.addr = 0x22,
> +				.mask = 0x80,
> +				.addr_od = 0x23,
> +				.mask_od = 0x08,
> +			},
> +			.stat_drdy = {
> +				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
> +				.mask = 0x07,
> +			},
> +		},
> +		.multi_read_bit = false,
> +		.bootime = 2,
> +	},
>  };
>  
>  static int st_accel_read_raw(struct iio_dev *indio_dev,
> diff --git a/drivers/iio/accel/st_accel_spi.c b/drivers/iio/accel/st_accel_spi.c
> index 7692da49e59f..dcc9bd243a52 100644
> --- a/drivers/iio/accel/st_accel_spi.c
> +++ b/drivers/iio/accel/st_accel_spi.c
> @@ -86,6 +86,10 @@ static const struct of_device_id st_accel_of_match[] = {
>  		.compatible = "st,lis2dw12",
>  		.data = LIS2DW12_ACCEL_DEV_NAME,
>  	},
> +	{
> +		.compatible = "st,lis3dhh",
> +		.data = LIS3DHH_ACCEL_DEV_NAME,
> +	},
>  	{}
>  };
>  MODULE_DEVICE_TABLE(of, st_accel_of_match);
> @@ -138,6 +142,7 @@ static const struct spi_device_id st_accel_id_table[] = {
>  	{ LIS331DL_ACCEL_DEV_NAME },
>  	{ LIS3LV02DL_ACCEL_DEV_NAME },
>  	{ LIS2DW12_ACCEL_DEV_NAME },
> +	{ LIS3DHH_ACCEL_DEV_NAME },
>  	{},
>  };
>  MODULE_DEVICE_TABLE(spi, st_accel_id_table);

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

* Re: [PATCH 3/4] iio: accel: add support to LIS3DHH
@ 2017-10-10 19:40         ` Jonathan Cameron
  0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2017-10-10 19:40 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: linux-iio, lorenzo.bianconi, devicetree

On Sun, 17 Sep 2017 18:17:11 +0200
Lorenzo Bianconi <lorenzo.bianconi83@gmail.com> wrote:

> add support to STMicroelectronics LIS3DHH accel sensor
> 
> http://www.st.com/resource/en/datasheet/lis3dhh.pdf
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

Thanks,

Jonathan
> ---
>  drivers/iio/accel/st_accel.h      |  2 ++
>  drivers/iio/accel/st_accel_core.c | 52 +++++++++++++++++++++++++++++++++++++++
>  drivers/iio/accel/st_accel_spi.c  |  5 ++++
>  3 files changed, 59 insertions(+)
> 
> diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h
> index 2ed0f60418c0..2f931e4837e5 100644
> --- a/drivers/iio/accel/st_accel.h
> +++ b/drivers/iio/accel/st_accel.h
> @@ -33,6 +33,7 @@ enum st_accel_type {
>  	LIS331DL,
>  	LIS3LV02DL,
>  	LIS2DW12,
> +	LIS3DHH,
>  	ST_ACCEL_MAX,
>  };
>  
> @@ -54,6 +55,7 @@ enum st_accel_type {
>  #define LIS3L02DQ_ACCEL_DEV_NAME	"lis3l02dq"
>  #define LNG2DM_ACCEL_DEV_NAME		"lng2dm"
>  #define LIS2DW12_ACCEL_DEV_NAME		"lis2dw12"
> +#define LIS3DHH_ACCEL_DEV_NAME		"lis3dhh"
>  
>  /**
>  * struct st_sensors_platform_data - default accel platform data
> diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
> index c88db25a1aff..460aa58e0159 100644
> --- a/drivers/iio/accel/st_accel_core.c
> +++ b/drivers/iio/accel/st_accel_core.c
> @@ -777,6 +777,58 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
>  		.multi_read_bit = false,
>  		.bootime = 2,
>  	},
> +	{
> +		.wai = 0x11,
> +		.wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
> +		.sensors_supported = {
> +			[0] = LIS3DHH_ACCEL_DEV_NAME,
> +		},
> +		.ch = (struct iio_chan_spec *)st_accel_16bit_channels,
> +		.odr = {
> +			/* just ODR = 1100Hz available */
> +			.odr_avl = {
> +				{ .hz = 1100, .value = 0x00, },
> +			},
> +		},
> +		.pw = {
> +			.addr = 0x20,
> +			.mask = 0x80,
> +			.value_on = ST_SENSORS_DEFAULT_POWER_ON_VALUE,
> +			.value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE,
> +		},
> +		.fs = {
> +			.fs_avl = {
> +				[0] = {
> +					.num = ST_ACCEL_FS_AVL_2G,
> +					.gain = IIO_G_TO_M_S_2(76),
> +				},
> +			},
> +		},
> +		.bdu = {
> +			.addr = 0x20,
> +			.mask = 0x01,
> +		},
> +		.drdy_irq = {
> +			.int1 = {
> +				.addr = 0x21,
> +				.mask = 0x80,
> +				.addr_od = 0x23,
> +				.mask_od = 0x04,
> +			},
> +			.int2 = {
> +				.addr = 0x22,
> +				.mask = 0x80,
> +				.addr_od = 0x23,
> +				.mask_od = 0x08,
> +			},
> +			.stat_drdy = {
> +				.addr = ST_SENSORS_DEFAULT_STAT_ADDR,
> +				.mask = 0x07,
> +			},
> +		},
> +		.multi_read_bit = false,
> +		.bootime = 2,
> +	},
>  };
>  
>  static int st_accel_read_raw(struct iio_dev *indio_dev,
> diff --git a/drivers/iio/accel/st_accel_spi.c b/drivers/iio/accel/st_accel_spi.c
> index 7692da49e59f..dcc9bd243a52 100644
> --- a/drivers/iio/accel/st_accel_spi.c
> +++ b/drivers/iio/accel/st_accel_spi.c
> @@ -86,6 +86,10 @@ static const struct of_device_id st_accel_of_match[] = {
>  		.compatible = "st,lis2dw12",
>  		.data = LIS2DW12_ACCEL_DEV_NAME,
>  	},
> +	{
> +		.compatible = "st,lis3dhh",
> +		.data = LIS3DHH_ACCEL_DEV_NAME,
> +	},
>  	{}
>  };
>  MODULE_DEVICE_TABLE(of, st_accel_of_match);
> @@ -138,6 +142,7 @@ static const struct spi_device_id st_accel_id_table[] = {
>  	{ LIS331DL_ACCEL_DEV_NAME },
>  	{ LIS3LV02DL_ACCEL_DEV_NAME },
>  	{ LIS2DW12_ACCEL_DEV_NAME },
> +	{ LIS3DHH_ACCEL_DEV_NAME },
>  	{},
>  };
>  MODULE_DEVICE_TABLE(spi, st_accel_id_table);


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

* Re: [PATCH 4/4] dt-bindings: iio: accel: add LIS3DHH device bindings
  2017-09-20 20:53         ` Rob Herring
@ 2017-10-10 19:43           ` Jonathan Cameron
  -1 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2017-10-10 19:43 UTC (permalink / raw)
  To: Rob Herring
  Cc: Lorenzo Bianconi, linux-iio-u79uwXL29TY76Z2rM5mHXA,
	lorenzo.bianconi-qxv4g6HH51o, devicetree-u79uwXL29TY76Z2rM5mHXA

On Wed, 20 Sep 2017 15:53:07 -0500
Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote:

> On Sun, Sep 17, 2017 at 06:17:12PM +0200, Lorenzo Bianconi wrote:
> > Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
> > ---
> >  Documentation/devicetree/bindings/iio/st-sensors.txt | 1 +
> >  1 file changed, 1 insertion(+)  
> 
> Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Applied to the togreg branch of iio.git and pushed out as testing.

Thanks,

Jonathan

> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 4/4] dt-bindings: iio: accel: add LIS3DHH device bindings
@ 2017-10-10 19:43           ` Jonathan Cameron
  0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2017-10-10 19:43 UTC (permalink / raw)
  To: Rob Herring; +Cc: Lorenzo Bianconi, linux-iio, lorenzo.bianconi, devicetree

On Wed, 20 Sep 2017 15:53:07 -0500
Rob Herring <robh@kernel.org> wrote:

> On Sun, Sep 17, 2017 at 06:17:12PM +0200, Lorenzo Bianconi wrote:
> > Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
> > ---
> >  Documentation/devicetree/bindings/iio/st-sensors.txt | 1 +
> >  1 file changed, 1 insertion(+)  
> 
> Acked-by: Rob Herring <robh@kernel.org>
Applied to the togreg branch of iio.git and pushed out as testing.

Thanks,

Jonathan

> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

end of thread, other threads:[~2017-10-10 19:43 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-17 16:17 [PATCH 0/4] Add support to LIS3DHH accel sensor Lorenzo Bianconi
2017-09-17 16:17 ` Lorenzo Bianconi
     [not found] ` <20170917161712.14645-1-lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
2017-09-17 16:17   ` [PATCH 1/4] iio: st_sensors: split open-drain parameters for irq1 and irq2 Lorenzo Bianconi
2017-09-17 16:17     ` Lorenzo Bianconi
     [not found]     ` <20170917161712.14645-2-lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
2017-10-10 19:39       ` Jonathan Cameron
2017-10-10 19:39         ` Jonathan Cameron
2017-09-17 16:17   ` [PATCH 2/4] iio: common: st_sensors: check odr address value in st_sensors_set_odr() Lorenzo Bianconi
2017-09-17 16:17     ` Lorenzo Bianconi
     [not found]     ` <20170917161712.14645-3-lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
2017-10-10 19:40       ` Jonathan Cameron
2017-10-10 19:40         ` Jonathan Cameron
2017-09-17 16:17   ` [PATCH 3/4] iio: accel: add support to LIS3DHH Lorenzo Bianconi
2017-09-17 16:17     ` Lorenzo Bianconi
     [not found]     ` <20170917161712.14645-4-lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
2017-10-10 19:40       ` Jonathan Cameron
2017-10-10 19:40         ` Jonathan Cameron
2017-09-17 16:17   ` [PATCH 4/4] dt-bindings: iio: accel: add LIS3DHH device bindings Lorenzo Bianconi
2017-09-17 16:17     ` Lorenzo Bianconi
     [not found]     ` <20170917161712.14645-5-lorenzo.bianconi-qxv4g6HH51o@public.gmane.org>
2017-09-20 20:53       ` Rob Herring
2017-09-20 20:53         ` Rob Herring
2017-10-10 19:43         ` Jonathan Cameron
2017-10-10 19:43           ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.