All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/10] iio: st_sensors: print error when failing to get IRQ
@ 2015-04-30 13:15 Linus Walleij
  2015-04-30 13:15 ` [PATCH 02/10] iio: st_sensors: make interrupt optional Linus Walleij
                   ` (8 more replies)
  0 siblings, 9 replies; 19+ messages in thread
From: Linus Walleij @ 2015-04-30 13:15 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald, linux-iio, Denis CIOCCA
  Cc: Lee Jones, Linus Walleij

Print a proper error message if we're missing the trigger
IRQ.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/iio/common/st_sensors/st_sensors_trigger.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/common/st_sensors/st_sensors_trigger.c b/drivers/iio/common/st_sensors/st_sensors_trigger.c
index 8d8ca6f1e16a..3e907040c2c7 100644
--- a/drivers/iio/common/st_sensors/st_sensors_trigger.c
+++ b/drivers/iio/common/st_sensors/st_sensors_trigger.c
@@ -37,8 +37,10 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev,
 			IRQF_TRIGGER_RISING,
 			sdata->trig->name,
 			sdata->trig);
-	if (err)
+	if (err) {
+		dev_err(&indio_dev->dev, "failed to request trigger IRQ.\n");
 		goto request_irq_error;
+	}
 
 	iio_trigger_set_drvdata(sdata->trig, indio_dev);
 	sdata->trig->ops = trigger_ops;
-- 
1.9.3

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

* [PATCH 02/10] iio: st_sensors: make interrupt optional
  2015-04-30 13:15 [PATCH 01/10] iio: st_sensors: print error when failing to get IRQ Linus Walleij
@ 2015-04-30 13:15 ` Linus Walleij
  2015-05-04 16:20   ` Jonathan Cameron
  2015-04-30 13:15 ` [PATCH 04/10] iio: st_sensors: make detection more helpful Linus Walleij
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Linus Walleij @ 2015-04-30 13:15 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald, linux-iio, Denis CIOCCA
  Cc: Lee Jones, Linus Walleij

Some sensors such as magnetometers and pressure sensors doesn't
have interrupts at all, and thus no DRDY setting applies. Make
the assignment of an interrupt optional, and do not call
st_sensors_set_drdy_int_pin() if there is no drdy (data ready)
pin specified.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/iio/common/st_sensors/st_sensors_core.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
index edd13d2b4121..5a01093b29a2 100644
--- a/drivers/iio/common/st_sensors/st_sensors_core.c
+++ b/drivers/iio/common/st_sensors/st_sensors_core.c
@@ -245,6 +245,16 @@ static int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev,
 {
 	struct st_sensor_data *sdata = iio_priv(indio_dev);
 
+	/* Sensor does not support interrupts */
+	if (sdata->sensor_settings->drdy_irq.addr == 0) {
+		if (pdata->drdy_int_pin)
+			dev_info(&indio_dev->dev,
+				 "DRDY on pin INT%d specified, but sensor "
+				 "does not support interrupts\n",
+				 pdata->drdy_int_pin);
+		return 0;
+	}
+
 	switch (pdata->drdy_int_pin) {
 	case 1:
 		if (sdata->sensor_settings->drdy_irq.mask_int1 == 0) {
@@ -285,7 +295,7 @@ static struct st_sensors_platform_data *st_sensors_of_probe(struct device *dev,
 	if (!of_property_read_u32(np, "st,drdy-int-pin", &val) && (val <= 2))
 		pdata->drdy_int_pin = (u8) val;
 	else
-		pdata->drdy_int_pin = defdata ? defdata->drdy_int_pin : 1;
+		pdata->drdy_int_pin = defdata ? defdata->drdy_int_pin : 0;
 
 	return pdata;
 }
-- 
1.9.3


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

* [PATCH 04/10] iio: st_sensors: make detection more helpful
  2015-04-30 13:15 [PATCH 01/10] iio: st_sensors: print error when failing to get IRQ Linus Walleij
  2015-04-30 13:15 ` [PATCH 02/10] iio: st_sensors: make interrupt optional Linus Walleij
@ 2015-04-30 13:15 ` Linus Walleij
  2015-05-04 16:24   ` Jonathan Cameron
  2015-04-30 13:15 ` [PATCH 05/10] iio: magnetometer: support for lsm303dlh Linus Walleij
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Linus Walleij @ 2015-04-30 13:15 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald, linux-iio, Denis CIOCCA
  Cc: Lee Jones, Linus Walleij

The ST sensors are detected by reading a WhoAmI register and
matching the number found to a sensor name string. To make it
easier to figure out what happens when things go wrong, print
the WhoAmI value and the device name we're trying to match.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/iio/common/st_sensors/st_sensors_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
index cbeb5e01bc3a..1255b157c71c 100644
--- a/drivers/iio/common/st_sensors/st_sensors_core.c
+++ b/drivers/iio/common/st_sensors/st_sensors_core.c
@@ -503,7 +503,8 @@ int st_sensors_check_device_support(struct iio_dev *indio_dev,
 			break;
 	}
 	if (n == ARRAY_SIZE(sensor_settings[i].sensors_supported)) {
-		dev_err(&indio_dev->dev, "device name and WhoAmI mismatch.\n");
+		dev_err(&indio_dev->dev, "device name \"%s\" and WhoAmI (0x%02x) mismatch",
+			indio_dev->name, wai);
 		goto sensor_name_mismatch;
 	}
 
-- 
1.9.3


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

* [PATCH 05/10] iio: magnetometer: support for lsm303dlh
  2015-04-30 13:15 [PATCH 01/10] iio: st_sensors: print error when failing to get IRQ Linus Walleij
  2015-04-30 13:15 ` [PATCH 02/10] iio: st_sensors: make interrupt optional Linus Walleij
  2015-04-30 13:15 ` [PATCH 04/10] iio: st_sensors: make detection more helpful Linus Walleij
@ 2015-04-30 13:15 ` Linus Walleij
  2015-05-04 16:26   ` Jonathan Cameron
  2015-04-30 13:15 ` [PATCH 06/10] iio: st_accel: support 8bit channel data Linus Walleij
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Linus Walleij @ 2015-04-30 13:15 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald, linux-iio, Denis CIOCCA
  Cc: Lee Jones, Linus Walleij

The LSM303DLH accelerometer/magnetometer has a different
device identification method than using register 0x0f, instead
three registers contain a magic value. We rely on WhoAmI
to be zero for this variant.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 .../devicetree/bindings/iio/st-sensors.txt         |   1 +
 drivers/iio/magnetometer/st_magn.h                 |   1 +
 drivers/iio/magnetometer/st_magn_core.c            | 116 +++++++++++++++++++++
 drivers/iio/magnetometer/st_magn_i2c.c             |   5 +
 4 files changed, 123 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt
index d2aaca974531..fb5e0c2d18b5 100644
--- a/Documentation/devicetree/bindings/iio/st-sensors.txt
+++ b/Documentation/devicetree/bindings/iio/st-sensors.txt
@@ -45,6 +45,7 @@ Gyroscopes:
 - st,lsm330-gyro
 
 Magnetometers:
+- st,lsm303dlh-magn
 - st,lsm303dlhc-magn
 - st,lsm303dlm-magn
 - st,lis3mdl-magn
diff --git a/drivers/iio/magnetometer/st_magn.h b/drivers/iio/magnetometer/st_magn.h
index 7e81d00ef0c3..287691ca56c1 100644
--- a/drivers/iio/magnetometer/st_magn.h
+++ b/drivers/iio/magnetometer/st_magn.h
@@ -14,6 +14,7 @@
 #include <linux/types.h>
 #include <linux/iio/common/st_sensors.h>
 
+#define LSM303DLH_MAGN_DEV_NAME		"lsm303dlh_magn"
 #define LSM303DLHC_MAGN_DEV_NAME	"lsm303dlhc_magn"
 #define LSM303DLM_MAGN_DEV_NAME		"lsm303dlm_magn"
 #define LIS3MDL_MAGN_DEV_NAME		"lis3mdl"
diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c
index 8ade473f99fe..73574d912e7c 100644
--- a/drivers/iio/magnetometer/st_magn_core.c
+++ b/drivers/iio/magnetometer/st_magn_core.c
@@ -45,6 +45,46 @@
 #define ST_MAGN_FS_AVL_12000MG			12000
 #define ST_MAGN_FS_AVL_16000MG			16000
 
+/* CUSTOM VALUES FOR SENSOR 0 */
+#define ST_MAGN_0_ODR_ADDR			0x00
+#define ST_MAGN_0_ODR_MASK			0x1c
+#define ST_MAGN_0_ODR_AVL_1HZ_VAL		0x00
+#define ST_MAGN_0_ODR_AVL_2HZ_VAL		0x01
+#define ST_MAGN_0_ODR_AVL_3HZ_VAL		0x02
+#define ST_MAGN_0_ODR_AVL_8HZ_VAL		0x03
+#define ST_MAGN_0_ODR_AVL_15HZ_VAL		0x04
+#define ST_MAGN_0_ODR_AVL_30HZ_VAL		0x05
+#define ST_MAGN_0_ODR_AVL_75HZ_VAL		0x06
+#define ST_MAGN_0_ODR_AVL_220HZ_VAL		0x07
+#define ST_MAGN_0_PW_ADDR			0x02
+#define ST_MAGN_0_PW_MASK			0x03
+#define ST_MAGN_0_PW_ON				0x00
+#define ST_MAGN_0_PW_OFF			0x03
+#define ST_MAGN_0_FS_ADDR			0x01
+#define ST_MAGN_0_FS_MASK			0xe0
+#define ST_MAGN_0_FS_AVL_1300_VAL		0x01
+#define ST_MAGN_0_FS_AVL_1900_VAL		0x02
+#define ST_MAGN_0_FS_AVL_2500_VAL		0x03
+#define ST_MAGN_0_FS_AVL_4000_VAL		0x04
+#define ST_MAGN_0_FS_AVL_4700_VAL		0x05
+#define ST_MAGN_0_FS_AVL_5600_VAL		0x06
+#define ST_MAGN_0_FS_AVL_8100_VAL		0x07
+#define ST_MAGN_0_FS_AVL_1300_GAIN_XY		1100
+#define ST_MAGN_0_FS_AVL_1900_GAIN_XY		855
+#define ST_MAGN_0_FS_AVL_2500_GAIN_XY		670
+#define ST_MAGN_0_FS_AVL_4000_GAIN_XY		450
+#define ST_MAGN_0_FS_AVL_4700_GAIN_XY		400
+#define ST_MAGN_0_FS_AVL_5600_GAIN_XY		330
+#define ST_MAGN_0_FS_AVL_8100_GAIN_XY		230
+#define ST_MAGN_0_FS_AVL_1300_GAIN_Z		980
+#define ST_MAGN_0_FS_AVL_1900_GAIN_Z		760
+#define ST_MAGN_0_FS_AVL_2500_GAIN_Z		600
+#define ST_MAGN_0_FS_AVL_4000_GAIN_Z		400
+#define ST_MAGN_0_FS_AVL_4700_GAIN_Z		355
+#define ST_MAGN_0_FS_AVL_5600_GAIN_Z		295
+#define ST_MAGN_0_FS_AVL_8100_GAIN_Z		205
+#define ST_MAGN_0_MULTIREAD_BIT			false
+
 /* CUSTOM VALUES FOR SENSOR 1 */
 #define ST_MAGN_1_WAI_EXP			0x3c
 #define ST_MAGN_1_ODR_ADDR			0x00
@@ -151,6 +191,82 @@ static const struct iio_chan_spec st_magn_2_16bit_channels[] = {
 
 static const struct st_sensor_settings st_magn_sensors_settings[] = {
 	{
+		.wai = 0, /* This sensor has no valid WhoAmI report 0 */
+		.sensors_supported = {
+			[0] = LSM303DLH_MAGN_DEV_NAME,
+		},
+		.ch = (struct iio_chan_spec *)st_magn_16bit_channels,
+		.odr = {
+			.addr = ST_MAGN_0_ODR_ADDR,
+			.mask = ST_MAGN_0_ODR_MASK,
+			.odr_avl = {
+				{ 1, ST_MAGN_0_ODR_AVL_1HZ_VAL, },
+				{ 2, ST_MAGN_0_ODR_AVL_2HZ_VAL, },
+				{ 3, ST_MAGN_0_ODR_AVL_3HZ_VAL, },
+				{ 8, ST_MAGN_0_ODR_AVL_8HZ_VAL, },
+				{ 15, ST_MAGN_0_ODR_AVL_15HZ_VAL, },
+				{ 30, ST_MAGN_0_ODR_AVL_30HZ_VAL, },
+				{ 75, ST_MAGN_0_ODR_AVL_75HZ_VAL, },
+			},
+		},
+		.pw = {
+			.addr = ST_MAGN_0_PW_ADDR,
+			.mask = ST_MAGN_0_PW_MASK,
+			.value_on = ST_MAGN_0_PW_ON,
+			.value_off = ST_MAGN_0_PW_OFF,
+		},
+		.fs = {
+			.addr = ST_MAGN_0_FS_ADDR,
+			.mask = ST_MAGN_0_FS_MASK,
+			.fs_avl = {
+				[0] = {
+					.num = ST_MAGN_FS_AVL_1300MG,
+					.value = ST_MAGN_0_FS_AVL_1300_VAL,
+					.gain = ST_MAGN_0_FS_AVL_1300_GAIN_XY,
+					.gain2 = ST_MAGN_0_FS_AVL_1300_GAIN_Z,
+				},
+				[1] = {
+					.num = ST_MAGN_FS_AVL_1900MG,
+					.value = ST_MAGN_0_FS_AVL_1900_VAL,
+					.gain = ST_MAGN_0_FS_AVL_1900_GAIN_XY,
+					.gain2 = ST_MAGN_0_FS_AVL_1900_GAIN_Z,
+				},
+				[2] = {
+					.num = ST_MAGN_FS_AVL_2500MG,
+					.value = ST_MAGN_0_FS_AVL_2500_VAL,
+					.gain = ST_MAGN_0_FS_AVL_2500_GAIN_XY,
+					.gain2 = ST_MAGN_0_FS_AVL_2500_GAIN_Z,
+				},
+				[3] = {
+					.num = ST_MAGN_FS_AVL_4000MG,
+					.value = ST_MAGN_0_FS_AVL_4000_VAL,
+					.gain = ST_MAGN_0_FS_AVL_4000_GAIN_XY,
+					.gain2 = ST_MAGN_0_FS_AVL_4000_GAIN_Z,
+				},
+				[4] = {
+					.num = ST_MAGN_FS_AVL_4700MG,
+					.value = ST_MAGN_0_FS_AVL_4700_VAL,
+					.gain = ST_MAGN_0_FS_AVL_4700_GAIN_XY,
+					.gain2 = ST_MAGN_0_FS_AVL_4700_GAIN_Z,
+				},
+				[5] = {
+					.num = ST_MAGN_FS_AVL_5600MG,
+					.value = ST_MAGN_0_FS_AVL_5600_VAL,
+					.gain = ST_MAGN_0_FS_AVL_5600_GAIN_XY,
+					.gain2 = ST_MAGN_0_FS_AVL_5600_GAIN_Z,
+				},
+				[6] = {
+					.num = ST_MAGN_FS_AVL_8100MG,
+					.value = ST_MAGN_0_FS_AVL_8100_VAL,
+					.gain = ST_MAGN_0_FS_AVL_8100_GAIN_XY,
+					.gain2 = ST_MAGN_0_FS_AVL_8100_GAIN_Z,
+				},
+			},
+		},
+		.multi_read_bit = ST_MAGN_0_MULTIREAD_BIT,
+		.bootime = 2,
+	},
+	{
 		.wai = ST_MAGN_1_WAI_EXP,
 		.sensors_supported = {
 			[0] = LSM303DLHC_MAGN_DEV_NAME,
diff --git a/drivers/iio/magnetometer/st_magn_i2c.c b/drivers/iio/magnetometer/st_magn_i2c.c
index 92e5c15452a3..5311d8aea8cc 100644
--- a/drivers/iio/magnetometer/st_magn_i2c.c
+++ b/drivers/iio/magnetometer/st_magn_i2c.c
@@ -21,6 +21,10 @@
 #ifdef CONFIG_OF
 static const struct of_device_id st_magn_of_match[] = {
 	{
+		.compatible = "st,lsm303dlh-magn",
+		.data = LSM303DLH_MAGN_DEV_NAME,
+	},
+	{
 		.compatible = "st,lsm303dlhc-magn",
 		.data = LSM303DLHC_MAGN_DEV_NAME,
 	},
@@ -71,6 +75,7 @@ static int st_magn_i2c_remove(struct i2c_client *client)
 }
 
 static const struct i2c_device_id st_magn_id_table[] = {
+	{ LSM303DLH_MAGN_DEV_NAME },
 	{ LSM303DLHC_MAGN_DEV_NAME },
 	{ LSM303DLM_MAGN_DEV_NAME },
 	{ LIS3MDL_MAGN_DEV_NAME },
-- 
1.9.3


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

* [PATCH 06/10] iio: st_accel: support 8bit channel data
  2015-04-30 13:15 [PATCH 01/10] iio: st_sensors: print error when failing to get IRQ Linus Walleij
                   ` (2 preceding siblings ...)
  2015-04-30 13:15 ` [PATCH 05/10] iio: magnetometer: support for lsm303dlh Linus Walleij
@ 2015-04-30 13:15 ` Linus Walleij
  2015-04-30 14:56   ` Peter Meerwald
  2015-04-30 13:15 ` [PATCH 07/10] iio: st_accel: support the LIS331DL sensor Linus Walleij
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Linus Walleij @ 2015-04-30 13:15 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald, linux-iio, Denis CIOCCA
  Cc: Lee Jones, Linus Walleij

Some sensors like the LIS331DL only support 8bit data by a single
register per axis. These utilize the MSB byte. Make it possible
to register these apropriately.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/iio/accel/st_accel_core.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
index 58d1d13d552a..689a9f360e7c 100644
--- a/drivers/iio/accel/st_accel_core.c
+++ b/drivers/iio/accel/st_accel_core.c
@@ -153,6 +153,22 @@
 #define ST_ACCEL_4_IG1_EN_MASK			0x08
 #define ST_ACCEL_4_MULTIREAD_BIT		true
 
+static const struct iio_chan_spec st_accel_8bit_channels[] = {
+	ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
+			BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
+			ST_SENSORS_SCAN_X, 1, IIO_MOD_X, 's', IIO_LE, 8, 16,
+			ST_ACCEL_DEFAULT_OUT_X_L_ADDR+1),
+	ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
+			BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
+			ST_SENSORS_SCAN_Y, 1, IIO_MOD_Y, 's', IIO_LE, 8, 16,
+			ST_ACCEL_DEFAULT_OUT_Y_L_ADDR+1),
+	ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
+			BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
+			ST_SENSORS_SCAN_Z, 1, IIO_MOD_Z, 's', IIO_LE, 8, 16,
+			ST_ACCEL_DEFAULT_OUT_Z_L_ADDR+1),
+	IIO_CHAN_SOFT_TIMESTAMP(3)
+};
+
 static const struct iio_chan_spec st_accel_12bit_channels[] = {
 	ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
 			BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
-- 
1.9.3


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

* [PATCH 07/10] iio: st_accel: support the LIS331DL sensor
  2015-04-30 13:15 [PATCH 01/10] iio: st_sensors: print error when failing to get IRQ Linus Walleij
                   ` (3 preceding siblings ...)
  2015-04-30 13:15 ` [PATCH 06/10] iio: st_accel: support 8bit channel data Linus Walleij
@ 2015-04-30 13:15 ` Linus Walleij
  2015-04-30 13:15 ` [PATCH 08/10] ARM: ux500: fix lsm303dlh magnetometer compat string Linus Walleij
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 19+ messages in thread
From: Linus Walleij @ 2015-04-30 13:15 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald, linux-iio, Denis CIOCCA
  Cc: Lee Jones, Linus Walleij

This adds support for the LIS331DL sensor version. This is
a simple 8bit-only accelerometer.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
Help me figuring out how the gain values are calculated for
these sensors. I have no clue, it's not in the datasheet.
---
 .../devicetree/bindings/iio/st-sensors.txt         |  1 +
 drivers/iio/accel/st_accel.h                       |  1 +
 drivers/iio/accel/st_accel_core.c                  | 70 ++++++++++++++++++++++
 drivers/iio/accel/st_accel_i2c.c                   |  4 ++
 4 files changed, 76 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt
index fb5e0c2d18b5..8a6be3bdf267 100644
--- a/Documentation/devicetree/bindings/iio/st-sensors.txt
+++ b/Documentation/devicetree/bindings/iio/st-sensors.txt
@@ -30,6 +30,7 @@ Accelerometers:
 - st,lsm330d-accel
 - st,lsm330dl-accel
 - st,lsm330dlc-accel
+- st,lis331dl-accel
 - st,lis331dlh-accel
 - st,lsm303dl-accel
 - st,lsm303dlm-accel
diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h
index 7ee9724b1428..aa1001931d0c 100644
--- a/drivers/iio/accel/st_accel.h
+++ b/drivers/iio/accel/st_accel.h
@@ -20,6 +20,7 @@
 #define LSM330D_ACCEL_DEV_NAME		"lsm330d_accel"
 #define LSM330DL_ACCEL_DEV_NAME		"lsm330dl_accel"
 #define LSM330DLC_ACCEL_DEV_NAME	"lsm330dlc_accel"
+#define LIS331DL_ACCEL_DEV_NAME		"lis331dl_accel"
 #define LIS331DLH_ACCEL_DEV_NAME	"lis331dlh"
 #define LSM303DL_ACCEL_DEV_NAME		"lsm303dl_accel"
 #define LSM303DLH_ACCEL_DEV_NAME	"lsm303dlh_accel"
diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
index 689a9f360e7c..314db16b7a3d 100644
--- a/drivers/iio/accel/st_accel_core.c
+++ b/drivers/iio/accel/st_accel_core.c
@@ -153,6 +153,28 @@
 #define ST_ACCEL_4_IG1_EN_MASK			0x08
 #define ST_ACCEL_4_MULTIREAD_BIT		true
 
+/* CUSTOM VALUES FOR SENSOR 5 */
+#define ST_ACCEL_5_WAI_EXP			0x3b
+#define ST_ACCEL_5_ODR_ADDR			0x20
+#define ST_ACCEL_5_ODR_MASK			0x80
+#define ST_ACCEL_5_ODR_AVL_100HZ_VAL		0x00
+#define ST_ACCEL_5_ODR_AVL_400HZ_VAL		0x01
+#define ST_ACCEL_5_PW_ADDR			0x20
+#define ST_ACCEL_5_PW_MASK			0x40
+#define ST_ACCEL_5_FS_ADDR			0x20
+#define ST_ACCEL_5_FS_MASK			0x20
+#define ST_ACCEL_5_FS_AVL_2_VAL			0X00
+#define ST_ACCEL_5_FS_AVL_8_VAL			0X01
+/* TODO: check these resulting gain settings, these are not in the datsheet */
+#define ST_ACCEL_5_FS_AVL_2_GAIN		IIO_G_TO_M_S_2(1000)
+#define ST_ACCEL_5_FS_AVL_8_GAIN		IIO_G_TO_M_S_2(3900)
+#define ST_ACCEL_5_DRDY_IRQ_ADDR		0x22
+#define ST_ACCEL_5_DRDY_IRQ_INT1_MASK		0x04
+#define ST_ACCEL_5_DRDY_IRQ_INT2_MASK		0x20
+#define ST_ACCEL_5_IG1_EN_ADDR			0x21
+#define ST_ACCEL_5_IG1_EN_MASK			0x08
+#define ST_ACCEL_5_MULTIREAD_BIT		false
+
 static const struct iio_chan_spec st_accel_8bit_channels[] = {
 	ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
 			BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
@@ -470,6 +492,54 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
 		.multi_read_bit = ST_ACCEL_4_MULTIREAD_BIT,
 		.bootime = 2, /* guess */
 	},
+	{
+		.wai = ST_ACCEL_5_WAI_EXP,
+		.sensors_supported = {
+			[0] = LIS331DL_ACCEL_DEV_NAME,
+		},
+		.ch = (struct iio_chan_spec *)st_accel_8bit_channels,
+		.odr = {
+			.addr = ST_ACCEL_5_ODR_ADDR,
+			.mask = ST_ACCEL_5_ODR_MASK,
+			.odr_avl = {
+				{ 100, ST_ACCEL_5_ODR_AVL_100HZ_VAL },
+				{ 400, ST_ACCEL_5_ODR_AVL_400HZ_VAL, },
+			},
+		},
+		.pw = {
+			.addr = ST_ACCEL_5_PW_ADDR,
+			.mask = ST_ACCEL_5_PW_MASK,
+			.value_on = ST_SENSORS_DEFAULT_POWER_ON_VALUE,
+			.value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE,
+		},
+		.enable_axis = {
+			.addr = ST_SENSORS_DEFAULT_AXIS_ADDR,
+			.mask = ST_SENSORS_DEFAULT_AXIS_MASK,
+		},
+		.fs = {
+			.addr = ST_ACCEL_5_FS_ADDR,
+			.mask = ST_ACCEL_5_FS_MASK,
+			.fs_avl = {
+				[0] = {
+					.num = ST_ACCEL_FS_AVL_2G,
+					.value = ST_ACCEL_5_FS_AVL_2_VAL,
+					.gain = ST_ACCEL_5_FS_AVL_2_GAIN,
+				},
+				[1] = {
+					.num = ST_ACCEL_FS_AVL_8G,
+					.value = ST_ACCEL_5_FS_AVL_8_VAL,
+					.gain = ST_ACCEL_5_FS_AVL_8_GAIN,
+				},
+			},
+		},
+		.drdy_irq = {
+			.addr = ST_ACCEL_5_DRDY_IRQ_ADDR,
+			.mask_int1 = ST_ACCEL_5_DRDY_IRQ_INT1_MASK,
+			.mask_int2 = ST_ACCEL_5_DRDY_IRQ_INT2_MASK,
+		},
+		.multi_read_bit = ST_ACCEL_5_MULTIREAD_BIT,
+		.bootime = 2, /* guess */
+	},
 };
 
 static int st_accel_read_raw(struct iio_dev *indio_dev,
diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c
index 6b720c190b2d..d4ad72ca4a3d 100644
--- a/drivers/iio/accel/st_accel_i2c.c
+++ b/drivers/iio/accel/st_accel_i2c.c
@@ -49,6 +49,10 @@ static const struct of_device_id st_accel_of_match[] = {
 		.data = LSM330DLC_ACCEL_DEV_NAME,
 	},
 	{
+		.compatible = "st,lis331dl-accel",
+		.data = LIS331DL_ACCEL_DEV_NAME,
+	},
+	{
 		.compatible = "st,lis331dlh-accel",
 		.data = LIS331DLH_ACCEL_DEV_NAME,
 	},
-- 
1.9.3


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

* [PATCH 08/10] ARM: ux500: fix lsm303dlh magnetometer compat string
  2015-04-30 13:15 [PATCH 01/10] iio: st_sensors: print error when failing to get IRQ Linus Walleij
                   ` (4 preceding siblings ...)
  2015-04-30 13:15 ` [PATCH 07/10] iio: st_accel: support the LIS331DL sensor Linus Walleij
@ 2015-04-30 13:15 ` Linus Walleij
  2015-05-04 16:33   ` Jonathan Cameron
  2015-04-30 13:15 ` [PATCH 09/10] ARM: ux500: assign the sensor trigger IRQs Linus Walleij
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Linus Walleij @ 2015-04-30 13:15 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald, linux-iio, Denis CIOCCA
  Cc: Lee Jones, Linus Walleij

The magnetometer found on the Ux500 TVK and Snowball boards
is a LSM303DLH not a LSM303DLM, small differences but still
different. Put in the right compatible strings and things start
working smoothly.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
Jonathan: This will be merged through the ARM SoC tree if
found OK. Do not merge to the IIO tree.
---
 arch/arm/boot/dts/ste-href-tvk1281618.dtsi | 4 ++--
 arch/arm/boot/dts/ste-snowball.dts         | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/dts/ste-href-tvk1281618.dtsi b/arch/arm/boot/dts/ste-href-tvk1281618.dtsi
index 062c6aae3afa..0eeb4d4b5202 100644
--- a/arch/arm/boot/dts/ste-href-tvk1281618.dtsi
+++ b/arch/arm/boot/dts/ste-href-tvk1281618.dtsi
@@ -100,9 +100,9 @@
 				pinctrl-names = "default";
 				pinctrl-0 = <&accel_tvk_mode>;
 			};
-			lsm303dlm@1e {
+			lsm303dlh@1e {
 				/* Magnetometer */
-				compatible = "st,lsm303dlm-magn";
+				compatible = "st,lsm303dlh-magn";
 				reg = <0x1e>;
 				vdd-supply = <&ab8500_ldo_aux1_reg>;
 				vddio-supply = <&db8500_vsmps2_reg>;
diff --git a/arch/arm/boot/dts/ste-snowball.dts b/arch/arm/boot/dts/ste-snowball.dts
index 1bc84ebdccaa..e2a7417777f9 100644
--- a/arch/arm/boot/dts/ste-snowball.dts
+++ b/arch/arm/boot/dts/ste-snowball.dts
@@ -263,9 +263,9 @@
 				pinctrl-names = "default";
 				pinctrl-0 = <&accel_snowball_mode>;
 			};
-			lsm303dlm@1e {
+			lsm303dlh@1e {
 				/* Magnetometer */
-				compatible = "st,lsm303dlm-magn";
+				compatible = "st,lsm303dlh-magn";
 				reg = <0x1e>;
 				vdd-supply = <&ab8500_ldo_aux1_reg>;
 				vddio-supply = <&db8500_vsmps2_reg>;
-- 
1.9.3


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

* [PATCH 09/10] ARM: ux500: assign the sensor trigger IRQs
  2015-04-30 13:15 [PATCH 01/10] iio: st_sensors: print error when failing to get IRQ Linus Walleij
                   ` (5 preceding siblings ...)
  2015-04-30 13:15 ` [PATCH 08/10] ARM: ux500: fix lsm303dlh magnetometer compat string Linus Walleij
@ 2015-04-30 13:15 ` Linus Walleij
  2015-04-30 13:15 ` [PATCH 10/10] ARM: ux500: add the sensors to the STUIB board Linus Walleij
  2015-05-04 16:17 ` [PATCH 01/10] iio: st_sensors: print error when failing to get IRQ Jonathan Cameron
  8 siblings, 0 replies; 19+ messages in thread
From: Linus Walleij @ 2015-04-30 13:15 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald, linux-iio, Denis CIOCCA
  Cc: Lee Jones, Linus Walleij

The ST sensors on the Ux500 boards were not utilizing the IRQs
for data ready sample triggers. Enable this by assigning the
right GPIO lines and interrupt lines (when the GPIO lines are
used for IRQs) to the accelerometer, gyro and magnetometer
sensors.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
Jonathan: This will be merged through the ARM SoC tree if
found OK. Do not merge to the IIO tree.
---
 arch/arm/boot/dts/ste-href-tvk1281618.dtsi |  3 +++
 arch/arm/boot/dts/ste-snowball.dts         | 19 +++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/arch/arm/boot/dts/ste-href-tvk1281618.dtsi b/arch/arm/boot/dts/ste-href-tvk1281618.dtsi
index 0eeb4d4b5202..0e1c96943d47 100644
--- a/arch/arm/boot/dts/ste-href-tvk1281618.dtsi
+++ b/arch/arm/boot/dts/ste-href-tvk1281618.dtsi
@@ -99,6 +99,9 @@
 				vddio-supply = <&db8500_vsmps2_reg>;
 				pinctrl-names = "default";
 				pinctrl-0 = <&accel_tvk_mode>;
+				interrupt-parent = <&gpio2>;
+				interrupts = <18 IRQ_TYPE_EDGE_RISING>,
+					     <19 IRQ_TYPE_EDGE_RISING>;
 			};
 			lsm303dlh@1e {
 				/* Magnetometer */
diff --git a/arch/arm/boot/dts/ste-snowball.dts b/arch/arm/boot/dts/ste-snowball.dts
index e2a7417777f9..9edadc37719f 100644
--- a/arch/arm/boot/dts/ste-snowball.dts
+++ b/arch/arm/boot/dts/ste-snowball.dts
@@ -262,6 +262,9 @@
 				vddio-supply = <&db8500_vsmps2_reg>;
 				pinctrl-names = "default";
 				pinctrl-0 = <&accel_snowball_mode>;
+				interrupt-parent = <&gpio5>;
+				interrupts = <3 IRQ_TYPE_EDGE_RISING>, /* INT1 */
+					     <4 IRQ_TYPE_EDGE_RISING>; /* INT2 */
 			};
 			lsm303dlh@1e {
 				/* Magnetometer */
@@ -271,6 +274,7 @@
 				vddio-supply = <&db8500_vsmps2_reg>;
 				pinctrl-names = "default";
 				pinctrl-0 = <&magneto_snowball_mode>;
+				gpios = <&gpio5 5 0x4>; /* DRDY line */
 			};
 			l3g4200d@68 {
 				/* Gyroscope */
@@ -279,6 +283,11 @@
 				reg = <0x68>;
 				vdd-supply = <&ab8500_ldo_aux1_reg>;
 				vddio-supply = <&db8500_vsmps2_reg>;
+				pinctrl-names = "default";
+				pinctrl-0 = <&gyro_snowball_mode>;
+				gpios = <&gpio5 6 0x4>; /* DRDY line */
+				interrupt-parent = <&gpio5>;
+				interrupts = <9 IRQ_TYPE_EDGE_RISING>; /* INT1 */
 			};
 			lsp001wm@5c {
 				/* Barometer/pressure sensor */
@@ -489,6 +498,16 @@
 					};
 				};
 			};
+			gyro {
+				gyro_snowball_mode: gyro_snowball {
+					snowball_cfg1 {
+						pins =
+						"GPIO166_A22", /* DRDY */
+						"GPIO169_D22"; /* INT */
+						ste,config = <&gpio_in_pu>;
+					};
+				};
+			};
 			magnetometer {
 				magneto_snowball_mode: magneto_snowball {
 					snowball_cfg1 {
-- 
1.9.3


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

* [PATCH 10/10] ARM: ux500: add the sensors to the STUIB board
  2015-04-30 13:15 [PATCH 01/10] iio: st_sensors: print error when failing to get IRQ Linus Walleij
                   ` (6 preceding siblings ...)
  2015-04-30 13:15 ` [PATCH 09/10] ARM: ux500: assign the sensor trigger IRQs Linus Walleij
@ 2015-04-30 13:15 ` Linus Walleij
  2015-05-04 16:17 ` [PATCH 01/10] iio: st_sensors: print error when failing to get IRQ Jonathan Cameron
  8 siblings, 0 replies; 19+ messages in thread
From: Linus Walleij @ 2015-04-30 13:15 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald, linux-iio, Denis CIOCCA
  Cc: Lee Jones, Linus Walleij

This adds the device tree data for the LIS331DL and the
AK8974 magnetometer to the STUIB board device tree include
file.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
Jonathan: This will be merged through the ARM SoC tree if
found OK. Do not merge to the IIO tree.
---
 arch/arm/boot/dts/ste-href-stuib.dtsi | 50 +++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/arch/arm/boot/dts/ste-href-stuib.dtsi b/arch/arm/boot/dts/ste-href-stuib.dtsi
index 7d4f8184c522..78b75256c638 100644
--- a/arch/arm/boot/dts/ste-href-stuib.dtsi
+++ b/arch/arm/boot/dts/ste-href-stuib.dtsi
@@ -77,6 +77,34 @@
 			};
 		};
 
+		/* Sensors mounted on this board variant */
+		i2c@80128000 {
+			lis331dl@1c {
+				/* Accelerometer */
+				compatible = "st,lis331dl-accel";
+				st,drdy-int-pin = <1>;
+				reg = <0x1c>;
+				vdd-supply = <&ab8500_ldo_aux1_reg>;
+				vddio-supply = <&db8500_vsmps2_reg>;
+				pinctrl-names = "default";
+				pinctrl-0 = <&accel_stuib_mode>;
+				interrupt-parent = <&gpio2>;
+				interrupts = <18 IRQ_TYPE_EDGE_RISING>,
+					     <19 IRQ_TYPE_EDGE_RISING>;
+			};
+			ak8974@0f {
+				/* Magnetometer */
+				compatible = "asahi-kasei,ak8974";
+				reg = <0x0f>;
+				vdd-supply = <&ab8500_ldo_aux1_reg>;
+				vddio-supply = <&db8500_vsmps2_reg>;
+				pinctrl-names = "default";
+				pinctrl-0 = <&magneto_stuib_mode>;
+				interrupt-parent = <&gpio1>;
+				interrupts = <0 IRQ_TYPE_EDGE_RISING>;
+			};
+		};
+
 		i2c@80110000 {
 			bu21013_tp@5c {
 				compatible = "rohm,bu21013_tp";
@@ -116,6 +144,28 @@
 					};
 				};
 			};
+			accelerometer {
+				accel_stuib_mode: accel_stuib {
+					/* Accelerometer interrupt lines 1 & 2 */
+					stuib_cfg {
+						pins = "GPIO82_C1", "GPIO83_D3";
+						ste,config = <&gpio_in_pu>;
+					};
+				};
+			};
+			magnetometer {
+				magneto_stuib_mode: magneto_stuib {
+					/* Magnetometer uses GPIO 31 and 32, pull these up/down respectively */
+					stuib_cfg1 {
+						pins = "GPIO31_V3";
+						ste,config = <&gpio_in_pu>;
+					};
+					stuib_cfg2 {
+						pins = "GPIO32_V2";
+						ste,config = <&gpio_in_pd>;
+					};
+				};
+			};
 		};
 	};
 };
-- 
1.9.3


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

* Re: [PATCH 06/10] iio: st_accel: support 8bit channel data
  2015-04-30 13:15 ` [PATCH 06/10] iio: st_accel: support 8bit channel data Linus Walleij
@ 2015-04-30 14:56   ` Peter Meerwald
  2015-05-04 12:11     ` Linus Walleij
  0 siblings, 1 reply; 19+ messages in thread
From: Peter Meerwald @ 2015-04-30 14:56 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen, linux-iio,
	Denis CIOCCA, Lee Jones

Hello,

> Some sensors like the LIS331DL only support 8bit data by a single
> register per axis. These utilize the MSB byte. Make it possible
> to register these apropriately.

this doesn't seem right;

st_accel_8bit_channels is just added, but not used; this probably results 
in a warning

the start address, ST_ACCEL_DEFAULT_OUT_X_L_ADDR, is +1 to read just the 
MSB byte; but the storage size is still 16bit

the actual read is done in st_sensors_get_buffer_element(); with special 
case handling for the reads depending on the number of channels

I think either the _ADDR should not be +1 or the storage_bits should be 8, 
but not both

p.

> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  drivers/iio/accel/st_accel_core.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
> index 58d1d13d552a..689a9f360e7c 100644
> --- a/drivers/iio/accel/st_accel_core.c
> +++ b/drivers/iio/accel/st_accel_core.c
> @@ -153,6 +153,22 @@
>  #define ST_ACCEL_4_IG1_EN_MASK			0x08
>  #define ST_ACCEL_4_MULTIREAD_BIT		true
>  
> +static const struct iio_chan_spec st_accel_8bit_channels[] = {
> +	ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
> +			BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> +			ST_SENSORS_SCAN_X, 1, IIO_MOD_X, 's', IIO_LE, 8, 16,
> +			ST_ACCEL_DEFAULT_OUT_X_L_ADDR+1),
> +	ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
> +			BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> +			ST_SENSORS_SCAN_Y, 1, IIO_MOD_Y, 's', IIO_LE, 8, 16,
> +			ST_ACCEL_DEFAULT_OUT_Y_L_ADDR+1),
> +	ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
> +			BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> +			ST_SENSORS_SCAN_Z, 1, IIO_MOD_Z, 's', IIO_LE, 8, 16,
> +			ST_ACCEL_DEFAULT_OUT_Z_L_ADDR+1),
> +	IIO_CHAN_SOFT_TIMESTAMP(3)
> +};
> +
>  static const struct iio_chan_spec st_accel_12bit_channels[] = {
>  	ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
>  			BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> 

-- 

Peter Meerwald
+43-664-2444418 (mobile)

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

* Re: [PATCH 06/10] iio: st_accel: support 8bit channel data
  2015-04-30 14:56   ` Peter Meerwald
@ 2015-05-04 12:11     ` Linus Walleij
  2015-05-04 16:39       ` Jonathan Cameron
  0 siblings, 1 reply; 19+ messages in thread
From: Linus Walleij @ 2015-05-04 12:11 UTC (permalink / raw)
  To: Peter Meerwald
  Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen, linux-iio,
	Denis CIOCCA, Lee Jones

On Thu, Apr 30, 2015 at 4:56 PM, Peter Meerwald <pmeerw@pmeerw.net> wrote:
>
>> Some sensors like the LIS331DL only support 8bit data by a single
>> register per axis. These utilize the MSB byte. Make it possible
>> to register these apropriately.
>
> this doesn't seem right;
>
> st_accel_8bit_channels is just added, but not used; this probably results
> in a warning

Yes the actual LIS331DL patch adding support for this sensor is
7/11, the next patch in the series.

> the start address, ST_ACCEL_DEFAULT_OUT_X_L_ADDR, is +1 to read just the
> MSB byte; but the storage size is still 16bit

So in the LIS331DL datasheet page 29 & 30.
http://www.st.com/st-web-ui/static/active/en/resource/technical/document/datasheet/CD00172345.pdf

It is clear that registers 0x29, 0x2b and 0x2d contain
8-bit values of X,Y,Z respectively and 0x28, 0x2a and 0x2c
are unused.

Since ST_ACCEL_DEFAULT_OUT_X_L_ADDR is 0x28, it
is clear that ST choose to put the 8bit data into the MSB
for this sensor. So when reading 8bit sensors we need to
read MSB, and discard LSB.

+       ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
+                       BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
+                       ST_SENSORS_SCAN_X, 1, IIO_MOD_X, 's', IIO_LE, 8, 16,
+                       ST_ACCEL_DEFAULT_OUT_X_L_ADDR+1),

> the actual read is done in st_sensors_get_buffer_element(); with special
> case handling for the reads depending on the number of channels

Not getting this, I traced around the code. When I cat in_accel_x_raw
in sysfs the read happens in
st_sensors_read_axis_data() called from st_sensors_read_info_raw().
It reads correctly from 0x29, 0x2b and 0x2d as desired.

Same if I turn on buffered I/O.

Do I have to use buffered I/O *and* triggers to go down
the execution path you point out? How do I do that from
sysfs (no clue really)? Do I need a special testprogram?

> I think either the _ADDR should not be +1 or the storage_bits should be 8,
> but not both

But this works :/

The raw values I get seem correct.

I'm suspicious on the scale values though, they don't even
trigger a read from the register.

Yours,
Linus Walleij

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

* Re: [PATCH 01/10] iio: st_sensors: print error when failing to get IRQ
  2015-04-30 13:15 [PATCH 01/10] iio: st_sensors: print error when failing to get IRQ Linus Walleij
                   ` (7 preceding siblings ...)
  2015-04-30 13:15 ` [PATCH 10/10] ARM: ux500: add the sensors to the STUIB board Linus Walleij
@ 2015-05-04 16:17 ` Jonathan Cameron
  8 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2015-05-04 16:17 UTC (permalink / raw)
  To: Linus Walleij, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald, linux-iio, Denis CIOCCA
  Cc: Lee Jones

On 30/04/15 14:15, Linus Walleij wrote:
> Print a proper error message if we're missing the trigger
> IRQ.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Applied to the togreg branch of iio.git which will get pushed out
as testing sometime in the next few days...
> ---
>  drivers/iio/common/st_sensors/st_sensors_trigger.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/common/st_sensors/st_sensors_trigger.c b/drivers/iio/common/st_sensors/st_sensors_trigger.c
> index 8d8ca6f1e16a..3e907040c2c7 100644
> --- a/drivers/iio/common/st_sensors/st_sensors_trigger.c
> +++ b/drivers/iio/common/st_sensors/st_sensors_trigger.c
> @@ -37,8 +37,10 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev,
>  			IRQF_TRIGGER_RISING,
>  			sdata->trig->name,
>  			sdata->trig);
> -	if (err)
> +	if (err) {
> +		dev_err(&indio_dev->dev, "failed to request trigger IRQ.\n");
>  		goto request_irq_error;
> +	}
>  
>  	iio_trigger_set_drvdata(sdata->trig, indio_dev);
>  	sdata->trig->ops = trigger_ops;
> 


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

* Re: [PATCH 02/10] iio: st_sensors: make interrupt optional
  2015-04-30 13:15 ` [PATCH 02/10] iio: st_sensors: make interrupt optional Linus Walleij
@ 2015-05-04 16:20   ` Jonathan Cameron
  0 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2015-05-04 16:20 UTC (permalink / raw)
  To: Linus Walleij, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald, linux-iio, Denis CIOCCA
  Cc: Lee Jones

On 30/04/15 14:15, Linus Walleij wrote:
> Some sensors such as magnetometers and pressure sensors doesn't
> have interrupts at all, and thus no DRDY setting applies. Make
> the assignment of an interrupt optional, and do not call
> st_sensors_set_drdy_int_pin() if there is no drdy (data ready)
> pin specified.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Applied to the togreg branch of iio.git.

thanks,

Jonathan
> ---
>  drivers/iio/common/st_sensors/st_sensors_core.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
> index edd13d2b4121..5a01093b29a2 100644
> --- a/drivers/iio/common/st_sensors/st_sensors_core.c
> +++ b/drivers/iio/common/st_sensors/st_sensors_core.c
> @@ -245,6 +245,16 @@ static int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev,
>  {
>  	struct st_sensor_data *sdata = iio_priv(indio_dev);
>  
> +	/* Sensor does not support interrupts */
> +	if (sdata->sensor_settings->drdy_irq.addr == 0) {
> +		if (pdata->drdy_int_pin)
> +			dev_info(&indio_dev->dev,
> +				 "DRDY on pin INT%d specified, but sensor "
> +				 "does not support interrupts\n",
> +				 pdata->drdy_int_pin);
> +		return 0;
> +	}
> +
>  	switch (pdata->drdy_int_pin) {
>  	case 1:
>  		if (sdata->sensor_settings->drdy_irq.mask_int1 == 0) {
> @@ -285,7 +295,7 @@ static struct st_sensors_platform_data *st_sensors_of_probe(struct device *dev,
>  	if (!of_property_read_u32(np, "st,drdy-int-pin", &val) && (val <= 2))
>  		pdata->drdy_int_pin = (u8) val;
>  	else
> -		pdata->drdy_int_pin = defdata ? defdata->drdy_int_pin : 1;
> +		pdata->drdy_int_pin = defdata ? defdata->drdy_int_pin : 0;
>  
>  	return pdata;
>  }
> 


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

* Re: [PATCH 04/10] iio: st_sensors: make detection more helpful
  2015-04-30 13:15 ` [PATCH 04/10] iio: st_sensors: make detection more helpful Linus Walleij
@ 2015-05-04 16:24   ` Jonathan Cameron
  0 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2015-05-04 16:24 UTC (permalink / raw)
  To: Linus Walleij, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald, linux-iio, Denis CIOCCA
  Cc: Lee Jones

On 30/04/15 14:15, Linus Walleij wrote:
> The ST sensors are detected by reading a WhoAmI register and
> matching the number found to a sensor name string. To make it
> easier to figure out what happens when things go wrong, print
> the WhoAmI value and the device name we're trying to match.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Applied.
> ---
>  drivers/iio/common/st_sensors/st_sensors_core.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
> index cbeb5e01bc3a..1255b157c71c 100644
> --- a/drivers/iio/common/st_sensors/st_sensors_core.c
> +++ b/drivers/iio/common/st_sensors/st_sensors_core.c
> @@ -503,7 +503,8 @@ int st_sensors_check_device_support(struct iio_dev *indio_dev,
>  			break;
>  	}
>  	if (n == ARRAY_SIZE(sensor_settings[i].sensors_supported)) {
> -		dev_err(&indio_dev->dev, "device name and WhoAmI mismatch.\n");
> +		dev_err(&indio_dev->dev, "device name \"%s\" and WhoAmI (0x%02x) mismatch",
> +			indio_dev->name, wai);
>  		goto sensor_name_mismatch;
>  	}
>  
> 


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

* Re: [PATCH 05/10] iio: magnetometer: support for lsm303dlh
  2015-04-30 13:15 ` [PATCH 05/10] iio: magnetometer: support for lsm303dlh Linus Walleij
@ 2015-05-04 16:26   ` Jonathan Cameron
  0 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2015-05-04 16:26 UTC (permalink / raw)
  To: Linus Walleij, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald, linux-iio, Denis CIOCCA
  Cc: Lee Jones

On 30/04/15 14:15, Linus Walleij wrote:
> The LSM303DLH accelerometer/magnetometer has a different
> device identification method than using register 0x0f, instead
> three registers contain a magic value. We rely on WhoAmI
> to be zero for this variant.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Applied to the togreg branch of iio.git which will initially get
pushed out as testing sometime in the next few days.

Jonathan
> ---
>  .../devicetree/bindings/iio/st-sensors.txt         |   1 +
>  drivers/iio/magnetometer/st_magn.h                 |   1 +
>  drivers/iio/magnetometer/st_magn_core.c            | 116 +++++++++++++++++++++
>  drivers/iio/magnetometer/st_magn_i2c.c             |   5 +
>  4 files changed, 123 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt
> index d2aaca974531..fb5e0c2d18b5 100644
> --- a/Documentation/devicetree/bindings/iio/st-sensors.txt
> +++ b/Documentation/devicetree/bindings/iio/st-sensors.txt
> @@ -45,6 +45,7 @@ Gyroscopes:
>  - st,lsm330-gyro
>  
>  Magnetometers:
> +- st,lsm303dlh-magn
>  - st,lsm303dlhc-magn
>  - st,lsm303dlm-magn
>  - st,lis3mdl-magn
> diff --git a/drivers/iio/magnetometer/st_magn.h b/drivers/iio/magnetometer/st_magn.h
> index 7e81d00ef0c3..287691ca56c1 100644
> --- a/drivers/iio/magnetometer/st_magn.h
> +++ b/drivers/iio/magnetometer/st_magn.h
> @@ -14,6 +14,7 @@
>  #include <linux/types.h>
>  #include <linux/iio/common/st_sensors.h>
>  
> +#define LSM303DLH_MAGN_DEV_NAME		"lsm303dlh_magn"
>  #define LSM303DLHC_MAGN_DEV_NAME	"lsm303dlhc_magn"
>  #define LSM303DLM_MAGN_DEV_NAME		"lsm303dlm_magn"
>  #define LIS3MDL_MAGN_DEV_NAME		"lis3mdl"
> diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c
> index 8ade473f99fe..73574d912e7c 100644
> --- a/drivers/iio/magnetometer/st_magn_core.c
> +++ b/drivers/iio/magnetometer/st_magn_core.c
> @@ -45,6 +45,46 @@
>  #define ST_MAGN_FS_AVL_12000MG			12000
>  #define ST_MAGN_FS_AVL_16000MG			16000
>  
> +/* CUSTOM VALUES FOR SENSOR 0 */
> +#define ST_MAGN_0_ODR_ADDR			0x00
> +#define ST_MAGN_0_ODR_MASK			0x1c
> +#define ST_MAGN_0_ODR_AVL_1HZ_VAL		0x00
> +#define ST_MAGN_0_ODR_AVL_2HZ_VAL		0x01
> +#define ST_MAGN_0_ODR_AVL_3HZ_VAL		0x02
> +#define ST_MAGN_0_ODR_AVL_8HZ_VAL		0x03
> +#define ST_MAGN_0_ODR_AVL_15HZ_VAL		0x04
> +#define ST_MAGN_0_ODR_AVL_30HZ_VAL		0x05
> +#define ST_MAGN_0_ODR_AVL_75HZ_VAL		0x06
> +#define ST_MAGN_0_ODR_AVL_220HZ_VAL		0x07
> +#define ST_MAGN_0_PW_ADDR			0x02
> +#define ST_MAGN_0_PW_MASK			0x03
> +#define ST_MAGN_0_PW_ON				0x00
> +#define ST_MAGN_0_PW_OFF			0x03
> +#define ST_MAGN_0_FS_ADDR			0x01
> +#define ST_MAGN_0_FS_MASK			0xe0
> +#define ST_MAGN_0_FS_AVL_1300_VAL		0x01
> +#define ST_MAGN_0_FS_AVL_1900_VAL		0x02
> +#define ST_MAGN_0_FS_AVL_2500_VAL		0x03
> +#define ST_MAGN_0_FS_AVL_4000_VAL		0x04
> +#define ST_MAGN_0_FS_AVL_4700_VAL		0x05
> +#define ST_MAGN_0_FS_AVL_5600_VAL		0x06
> +#define ST_MAGN_0_FS_AVL_8100_VAL		0x07
> +#define ST_MAGN_0_FS_AVL_1300_GAIN_XY		1100
> +#define ST_MAGN_0_FS_AVL_1900_GAIN_XY		855
> +#define ST_MAGN_0_FS_AVL_2500_GAIN_XY		670
> +#define ST_MAGN_0_FS_AVL_4000_GAIN_XY		450
> +#define ST_MAGN_0_FS_AVL_4700_GAIN_XY		400
> +#define ST_MAGN_0_FS_AVL_5600_GAIN_XY		330
> +#define ST_MAGN_0_FS_AVL_8100_GAIN_XY		230
> +#define ST_MAGN_0_FS_AVL_1300_GAIN_Z		980
> +#define ST_MAGN_0_FS_AVL_1900_GAIN_Z		760
> +#define ST_MAGN_0_FS_AVL_2500_GAIN_Z		600
> +#define ST_MAGN_0_FS_AVL_4000_GAIN_Z		400
> +#define ST_MAGN_0_FS_AVL_4700_GAIN_Z		355
> +#define ST_MAGN_0_FS_AVL_5600_GAIN_Z		295
> +#define ST_MAGN_0_FS_AVL_8100_GAIN_Z		205
> +#define ST_MAGN_0_MULTIREAD_BIT			false
> +
>  /* CUSTOM VALUES FOR SENSOR 1 */
>  #define ST_MAGN_1_WAI_EXP			0x3c
>  #define ST_MAGN_1_ODR_ADDR			0x00
> @@ -151,6 +191,82 @@ static const struct iio_chan_spec st_magn_2_16bit_channels[] = {
>  
>  static const struct st_sensor_settings st_magn_sensors_settings[] = {
>  	{
> +		.wai = 0, /* This sensor has no valid WhoAmI report 0 */
> +		.sensors_supported = {
> +			[0] = LSM303DLH_MAGN_DEV_NAME,
> +		},
> +		.ch = (struct iio_chan_spec *)st_magn_16bit_channels,
> +		.odr = {
> +			.addr = ST_MAGN_0_ODR_ADDR,
> +			.mask = ST_MAGN_0_ODR_MASK,
> +			.odr_avl = {
> +				{ 1, ST_MAGN_0_ODR_AVL_1HZ_VAL, },
> +				{ 2, ST_MAGN_0_ODR_AVL_2HZ_VAL, },
> +				{ 3, ST_MAGN_0_ODR_AVL_3HZ_VAL, },
> +				{ 8, ST_MAGN_0_ODR_AVL_8HZ_VAL, },
> +				{ 15, ST_MAGN_0_ODR_AVL_15HZ_VAL, },
> +				{ 30, ST_MAGN_0_ODR_AVL_30HZ_VAL, },
> +				{ 75, ST_MAGN_0_ODR_AVL_75HZ_VAL, },
> +			},
> +		},
> +		.pw = {
> +			.addr = ST_MAGN_0_PW_ADDR,
> +			.mask = ST_MAGN_0_PW_MASK,
> +			.value_on = ST_MAGN_0_PW_ON,
> +			.value_off = ST_MAGN_0_PW_OFF,
> +		},
> +		.fs = {
> +			.addr = ST_MAGN_0_FS_ADDR,
> +			.mask = ST_MAGN_0_FS_MASK,
> +			.fs_avl = {
> +				[0] = {
> +					.num = ST_MAGN_FS_AVL_1300MG,
> +					.value = ST_MAGN_0_FS_AVL_1300_VAL,
> +					.gain = ST_MAGN_0_FS_AVL_1300_GAIN_XY,
> +					.gain2 = ST_MAGN_0_FS_AVL_1300_GAIN_Z,
> +				},
> +				[1] = {
> +					.num = ST_MAGN_FS_AVL_1900MG,
> +					.value = ST_MAGN_0_FS_AVL_1900_VAL,
> +					.gain = ST_MAGN_0_FS_AVL_1900_GAIN_XY,
> +					.gain2 = ST_MAGN_0_FS_AVL_1900_GAIN_Z,
> +				},
> +				[2] = {
> +					.num = ST_MAGN_FS_AVL_2500MG,
> +					.value = ST_MAGN_0_FS_AVL_2500_VAL,
> +					.gain = ST_MAGN_0_FS_AVL_2500_GAIN_XY,
> +					.gain2 = ST_MAGN_0_FS_AVL_2500_GAIN_Z,
> +				},
> +				[3] = {
> +					.num = ST_MAGN_FS_AVL_4000MG,
> +					.value = ST_MAGN_0_FS_AVL_4000_VAL,
> +					.gain = ST_MAGN_0_FS_AVL_4000_GAIN_XY,
> +					.gain2 = ST_MAGN_0_FS_AVL_4000_GAIN_Z,
> +				},
> +				[4] = {
> +					.num = ST_MAGN_FS_AVL_4700MG,
> +					.value = ST_MAGN_0_FS_AVL_4700_VAL,
> +					.gain = ST_MAGN_0_FS_AVL_4700_GAIN_XY,
> +					.gain2 = ST_MAGN_0_FS_AVL_4700_GAIN_Z,
> +				},
> +				[5] = {
> +					.num = ST_MAGN_FS_AVL_5600MG,
> +					.value = ST_MAGN_0_FS_AVL_5600_VAL,
> +					.gain = ST_MAGN_0_FS_AVL_5600_GAIN_XY,
> +					.gain2 = ST_MAGN_0_FS_AVL_5600_GAIN_Z,
> +				},
> +				[6] = {
> +					.num = ST_MAGN_FS_AVL_8100MG,
> +					.value = ST_MAGN_0_FS_AVL_8100_VAL,
> +					.gain = ST_MAGN_0_FS_AVL_8100_GAIN_XY,
> +					.gain2 = ST_MAGN_0_FS_AVL_8100_GAIN_Z,
> +				},
> +			},
> +		},
> +		.multi_read_bit = ST_MAGN_0_MULTIREAD_BIT,
> +		.bootime = 2,
> +	},
> +	{
>  		.wai = ST_MAGN_1_WAI_EXP,
>  		.sensors_supported = {
>  			[0] = LSM303DLHC_MAGN_DEV_NAME,
> diff --git a/drivers/iio/magnetometer/st_magn_i2c.c b/drivers/iio/magnetometer/st_magn_i2c.c
> index 92e5c15452a3..5311d8aea8cc 100644
> --- a/drivers/iio/magnetometer/st_magn_i2c.c
> +++ b/drivers/iio/magnetometer/st_magn_i2c.c
> @@ -21,6 +21,10 @@
>  #ifdef CONFIG_OF
>  static const struct of_device_id st_magn_of_match[] = {
>  	{
> +		.compatible = "st,lsm303dlh-magn",
> +		.data = LSM303DLH_MAGN_DEV_NAME,
> +	},
> +	{
>  		.compatible = "st,lsm303dlhc-magn",
>  		.data = LSM303DLHC_MAGN_DEV_NAME,
>  	},
> @@ -71,6 +75,7 @@ static int st_magn_i2c_remove(struct i2c_client *client)
>  }
>  
>  static const struct i2c_device_id st_magn_id_table[] = {
> +	{ LSM303DLH_MAGN_DEV_NAME },
>  	{ LSM303DLHC_MAGN_DEV_NAME },
>  	{ LSM303DLM_MAGN_DEV_NAME },
>  	{ LIS3MDL_MAGN_DEV_NAME },
> 


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

* Re: [PATCH 08/10] ARM: ux500: fix lsm303dlh magnetometer compat string
  2015-04-30 13:15 ` [PATCH 08/10] ARM: ux500: fix lsm303dlh magnetometer compat string Linus Walleij
@ 2015-05-04 16:33   ` Jonathan Cameron
  0 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2015-05-04 16:33 UTC (permalink / raw)
  To: Linus Walleij, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald, linux-iio, Denis CIOCCA
  Cc: Lee Jones

On 30/04/15 14:15, Linus Walleij wrote:
> The magnetometer found on the Ux500 TVK and Snowball boards
> is a LSM303DLH not a LSM303DLM, small differences but still
> different. Put in the right compatible strings and things start
> working smoothly.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> Jonathan: This will be merged through the ARM SoC tree if
> found OK. Do not merge to the IIO tree.
Sure.  I'm going to ignore it completely ;)
> ---
>  arch/arm/boot/dts/ste-href-tvk1281618.dtsi | 4 ++--
>  arch/arm/boot/dts/ste-snowball.dts         | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/ste-href-tvk1281618.dtsi b/arch/arm/boot/dts/ste-href-tvk1281618.dtsi
> index 062c6aae3afa..0eeb4d4b5202 100644
> --- a/arch/arm/boot/dts/ste-href-tvk1281618.dtsi
> +++ b/arch/arm/boot/dts/ste-href-tvk1281618.dtsi
> @@ -100,9 +100,9 @@
>  				pinctrl-names = "default";
>  				pinctrl-0 = <&accel_tvk_mode>;
>  			};
> -			lsm303dlm@1e {
> +			lsm303dlh@1e {
>  				/* Magnetometer */
> -				compatible = "st,lsm303dlm-magn";
> +				compatible = "st,lsm303dlh-magn";
>  				reg = <0x1e>;
>  				vdd-supply = <&ab8500_ldo_aux1_reg>;
>  				vddio-supply = <&db8500_vsmps2_reg>;
> diff --git a/arch/arm/boot/dts/ste-snowball.dts b/arch/arm/boot/dts/ste-snowball.dts
> index 1bc84ebdccaa..e2a7417777f9 100644
> --- a/arch/arm/boot/dts/ste-snowball.dts
> +++ b/arch/arm/boot/dts/ste-snowball.dts
> @@ -263,9 +263,9 @@
>  				pinctrl-names = "default";
>  				pinctrl-0 = <&accel_snowball_mode>;
>  			};
> -			lsm303dlm@1e {
> +			lsm303dlh@1e {
>  				/* Magnetometer */
> -				compatible = "st,lsm303dlm-magn";
> +				compatible = "st,lsm303dlh-magn";
>  				reg = <0x1e>;
>  				vdd-supply = <&ab8500_ldo_aux1_reg>;
>  				vddio-supply = <&db8500_vsmps2_reg>;
> 


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

* Re: [PATCH 06/10] iio: st_accel: support 8bit channel data
  2015-05-04 12:11     ` Linus Walleij
@ 2015-05-04 16:39       ` Jonathan Cameron
  2015-05-05 12:22         ` Linus Walleij
  0 siblings, 1 reply; 19+ messages in thread
From: Jonathan Cameron @ 2015-05-04 16:39 UTC (permalink / raw)
  To: Linus Walleij, Peter Meerwald
  Cc: Hartmut Knaack, Lars-Peter Clausen, linux-iio, Denis CIOCCA, Lee Jones

On 04/05/15 13:11, Linus Walleij wrote:
> On Thu, Apr 30, 2015 at 4:56 PM, Peter Meerwald <pmeerw@pmeerw.net> wrote:
>>
>>> Some sensors like the LIS331DL only support 8bit data by a single
>>> register per axis. These utilize the MSB byte. Make it possible
>>> to register these apropriately.
>>
>> this doesn't seem right;
>>
>> st_accel_8bit_channels is just added, but not used; this probably results
>> in a warning
> 
> Yes the actual LIS331DL patch adding support for this sensor is
> 7/11, the next patch in the series.
> 
>> the start address, ST_ACCEL_DEFAULT_OUT_X_L_ADDR, is +1 to read just the
>> MSB byte; but the storage size is still 16bit
> 
> So in the LIS331DL datasheet page 29 & 30.
> http://www.st.com/st-web-ui/static/active/en/resource/technical/document/datasheet/CD00172345.pdf
> 
> It is clear that registers 0x29, 0x2b and 0x2d contain
> 8-bit values of X,Y,Z respectively and 0x28, 0x2a and 0x2c
> are unused.
> 
> Since ST_ACCEL_DEFAULT_OUT_X_L_ADDR is 0x28, it
> is clear that ST choose to put the 8bit data into the MSB
> for this sensor. So when reading 8bit sensors we need to
> read MSB, and discard LSB.
> 
> +       ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
> +                       BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> +                       ST_SENSORS_SCAN_X, 1, IIO_MOD_X, 's', IIO_LE, 8, 16,
> +                       ST_ACCEL_DEFAULT_OUT_X_L_ADDR+1),
> 
>> the actual read is done in st_sensors_get_buffer_element(); with special
>> case handling for the reads depending on the number of channels
> 
> Not getting this, I traced around the code. When I cat in_accel_x_raw
> in sysfs the read happens in
> st_sensors_read_axis_data() called from st_sensors_read_info_raw().
> It reads correctly from 0x29, 0x2b and 0x2d as desired.
> 
> Same if I turn on buffered I/O.
> 
> Do I have to use buffered I/O *and* triggers to go down
> the execution path you point out? How do I do that from
> sysfs (no clue really)? Do I need a special testprogram?
Yup. It's in the trigger handler.  The generic_buffer.c
test app (now under tools/iio) should do the job for testing
this. The purpose of that one is to act as an example
of the chardev (buffered) interface and as documentation
as the docs always got out of date when we kept them seperately.
(yeah I'm lazy).

>From a quick look, I'd say storage_bits should be 8.  Then
it will just read one byte rather than the correct one and the next
address up (which might be 0, but in theory might not be for some sensor).

> 
>> I think either the _ADDR should not be +1 or the storage_bits should be 8,
>> but not both
> 
> But this works :/
> 
> The raw values I get seem correct.
> 
> I'm suspicious on the scale values though, they don't even
> trigger a read from the register.
> 
> Yours,
> Linus Walleij
> --
> 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] 19+ messages in thread

* Re: [PATCH 06/10] iio: st_accel: support 8bit channel data
  2015-05-04 16:39       ` Jonathan Cameron
@ 2015-05-05 12:22         ` Linus Walleij
  2015-05-05 12:41           ` Linus Walleij
  0 siblings, 1 reply; 19+ messages in thread
From: Linus Walleij @ 2015-05-05 12:22 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Peter Meerwald, Hartmut Knaack, Lars-Peter Clausen, linux-iio,
	Denis CIOCCA, Lee Jones

On Mon, May 4, 2015 at 6:39 PM, Jonathan Cameron <jic23@kernel.org> wrote:

> The generic_buffer.c
> test app (now under tools/iio) should do the job for testing
> this. The purpose of that one is to act as an example
> of the chardev (buffered) interface and as documentation
> as the docs always got out of date when we kept them seperately.
> (yeah I'm lazy).

Aha and that test app like iio_event_monitor needs proper
device creation in /dev/iio:device0 etc ...

And then I notice that busybox' mdev doesn't really auto-create
devices for anything else than what appears below
/sys/class/*, /sys/bus/* is not scanned for device, yippie-ay.

I guess you have udev for creating your devices on test
systems and a full distro-type userspace?

I wonder how people solve this for IIO on stripped-down
systems, static devices?

Is mdev even doing the right thing by just looking under
/sys/class?

I'm so confused by this, sorry Jonathan just airing some
frustration :/

Yours,
Linus Walleij

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

* Re: [PATCH 06/10] iio: st_accel: support 8bit channel data
  2015-05-05 12:22         ` Linus Walleij
@ 2015-05-05 12:41           ` Linus Walleij
  0 siblings, 0 replies; 19+ messages in thread
From: Linus Walleij @ 2015-05-05 12:41 UTC (permalink / raw)
  To: Jonathan Cameron, busybox, Denys Vlasenko
  Cc: Peter Meerwald, Hartmut Knaack, Lars-Peter Clausen, linux-iio,
	Denis CIOCCA, Lee Jones

Looping in busybox people.

On Tue, May 5, 2015 at 2:22 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Mon, May 4, 2015 at 6:39 PM, Jonathan Cameron <jic23@kernel.org> wrote:
>
>> The generic_buffer.c
>> test app (now under tools/iio) should do the job for testing
>> this. The purpose of that one is to act as an example
>> of the chardev (buffered) interface and as documentation
>> as the docs always got out of date when we kept them seperately.
>> (yeah I'm lazy).
>
> Aha and that test app like iio_event_monitor needs proper
> device creation in /dev/iio:device0 etc ...
>
> And then I notice that busybox' mdev doesn't really auto-create
> devices for anything else than what appears below
> /sys/class/*, /sys/bus/* is not scanned for device, yippie-ay.
>
> I wonder how people solve this for IIO on stripped-down
> systems, static devices?
>
> Is mdev even doing the right thing by just looking under
> /sys/class?

Typically the following patch to mdev.c makes the devices
appear:

                recursive_action("/sys/class",
                        ACTION_RECURSE | ACTION_FOLLOWLINKS,
                        fileAction, dirAction, temp, 0);
+               recursive_action("/sys/bus/iio",
+                       ACTION_RECURSE | ACTION_FOLLOWLINKS,
+                       fileAction, dirAction, temp, 0);

That is not just a little bit annoying. Who is doing the wrong thing?

* Busybox does the wrong thing by just inspecting
  /sys/class for coldplug mdev -s

* IIO does the wrong thing by not registering a class
  device (I think Greg said he doesn't like these...)

Yours,
Linus Walleij

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

end of thread, other threads:[~2015-05-05 12:41 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-30 13:15 [PATCH 01/10] iio: st_sensors: print error when failing to get IRQ Linus Walleij
2015-04-30 13:15 ` [PATCH 02/10] iio: st_sensors: make interrupt optional Linus Walleij
2015-05-04 16:20   ` Jonathan Cameron
2015-04-30 13:15 ` [PATCH 04/10] iio: st_sensors: make detection more helpful Linus Walleij
2015-05-04 16:24   ` Jonathan Cameron
2015-04-30 13:15 ` [PATCH 05/10] iio: magnetometer: support for lsm303dlh Linus Walleij
2015-05-04 16:26   ` Jonathan Cameron
2015-04-30 13:15 ` [PATCH 06/10] iio: st_accel: support 8bit channel data Linus Walleij
2015-04-30 14:56   ` Peter Meerwald
2015-05-04 12:11     ` Linus Walleij
2015-05-04 16:39       ` Jonathan Cameron
2015-05-05 12:22         ` Linus Walleij
2015-05-05 12:41           ` Linus Walleij
2015-04-30 13:15 ` [PATCH 07/10] iio: st_accel: support the LIS331DL sensor Linus Walleij
2015-04-30 13:15 ` [PATCH 08/10] ARM: ux500: fix lsm303dlh magnetometer compat string Linus Walleij
2015-05-04 16:33   ` Jonathan Cameron
2015-04-30 13:15 ` [PATCH 09/10] ARM: ux500: assign the sensor trigger IRQs Linus Walleij
2015-04-30 13:15 ` [PATCH 10/10] ARM: ux500: add the sensors to the STUIB board Linus Walleij
2015-05-04 16:17 ` [PATCH 01/10] iio: st_sensors: print error when failing to get IRQ 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.