All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND] iio: st-sensors: add support for lis3lv02d accelerometer
@ 2015-03-18  9:52 ` Linus Walleij
  0 siblings, 0 replies; 10+ messages in thread
From: Linus Walleij @ 2015-03-18  9:52 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio-u79uwXL29TY76Z2rM5mHXA, Denis CIOCCA
  Cc: Lee Jones, Linus Walleij, devicetree-u79uwXL29TY76Z2rM5mHXA

This adds support for the LIS3LV02 accelerometer found in the
ST Microelectronics Nomadik board series.

Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Denis CIOCCA <denis.ciocca-qxv4g6HH51o@public.gmane.org>
Cc: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Signed-off-by: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
I'm not giving up on this. I think the st-sensors driver should
support this variant as its framework is way better than the misc
driver. The other driver is anyway not even in the right subsystem.
---
 .../devicetree/bindings/iio/st-sensors.txt         |  1 +
 drivers/iio/accel/st_accel.h                       |  1 +
 drivers/iio/accel/st_accel_core.c                  | 81 ++++++++++++++++++++++
 drivers/iio/accel/st_accel_i2c.c                   |  4 ++
 4 files changed, 87 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt
index a7a0a15913ad..d2aaca974531 100644
--- a/Documentation/devicetree/bindings/iio/st-sensors.txt
+++ b/Documentation/devicetree/bindings/iio/st-sensors.txt
@@ -23,6 +23,7 @@ standard bindings from pinctrl/pinctrl-bindings.txt.
 Valid compatible strings:
 
 Accelerometers:
+- st,lis3lv02dl-accel
 - st,lsm303dlh-accel
 - st,lsm303dlhc-accel
 - st,lis3dh-accel
diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h
index fa9646034305..7ee9724b1428 100644
--- a/drivers/iio/accel/st_accel.h
+++ b/drivers/iio/accel/st_accel.h
@@ -14,6 +14,7 @@
 #include <linux/types.h>
 #include <linux/iio/common/st_sensors.h>
 
+#define LIS3LV02DL_ACCEL_DEV_NAME	"lis3lv02dl_accel"
 #define LSM303DLHC_ACCEL_DEV_NAME	"lsm303dlhc_accel"
 #define LIS3DH_ACCEL_DEV_NAME		"lis3dh"
 #define LSM330D_ACCEL_DEV_NAME		"lsm330d_accel"
diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
index 53f32629283a..58d1d13d552a 100644
--- a/drivers/iio/accel/st_accel_core.c
+++ b/drivers/iio/accel/st_accel_core.c
@@ -129,6 +129,30 @@
 #define ST_ACCEL_3_IG1_EN_MASK			0x08
 #define ST_ACCEL_3_MULTIREAD_BIT		false
 
+/* CUSTOM VALUES FOR SENSOR 4 */
+#define ST_ACCEL_4_WAI_EXP			0x3a
+#define ST_ACCEL_4_ODR_ADDR			0x20
+#define ST_ACCEL_4_ODR_MASK			0x30 /* DF1 and DF0 */
+#define ST_ACCEL_4_ODR_AVL_40HZ_VAL		0x00
+#define ST_ACCEL_4_ODR_AVL_160HZ_VAL		0x01
+#define ST_ACCEL_4_ODR_AVL_640HZ_VAL		0x02
+#define ST_ACCEL_4_ODR_AVL_2560HZ_VAL		0x03
+#define ST_ACCEL_4_PW_ADDR			0x20
+#define ST_ACCEL_4_PW_MASK			0xc0
+#define ST_ACCEL_4_FS_ADDR			0x21
+#define ST_ACCEL_4_FS_MASK			0x80
+#define ST_ACCEL_4_FS_AVL_2_VAL			0X00
+#define ST_ACCEL_4_FS_AVL_6_VAL			0X01
+#define ST_ACCEL_4_FS_AVL_2_GAIN		IIO_G_TO_M_S_2(1024)
+#define ST_ACCEL_4_FS_AVL_6_GAIN		IIO_G_TO_M_S_2(340)
+#define ST_ACCEL_4_BDU_ADDR			0x21
+#define ST_ACCEL_4_BDU_MASK			0x40
+#define ST_ACCEL_4_DRDY_IRQ_ADDR		0x21
+#define ST_ACCEL_4_DRDY_IRQ_INT1_MASK		0x04
+#define ST_ACCEL_4_IG1_EN_ADDR			0x21
+#define ST_ACCEL_4_IG1_EN_MASK			0x08
+#define ST_ACCEL_4_MULTIREAD_BIT		true
+
 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),
@@ -373,6 +397,63 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
 		.multi_read_bit = ST_ACCEL_3_MULTIREAD_BIT,
 		.bootime = 2,
 	},
+	{
+		.wai = ST_ACCEL_4_WAI_EXP,
+		.sensors_supported = {
+			[0] = LIS3LV02DL_ACCEL_DEV_NAME,
+		},
+		.ch = (struct iio_chan_spec *)st_accel_12bit_channels,
+		.odr = {
+			.addr = ST_ACCEL_4_ODR_ADDR,
+			.mask = ST_ACCEL_4_ODR_MASK,
+			.odr_avl = {
+				{ 40, ST_ACCEL_4_ODR_AVL_40HZ_VAL },
+				{ 160, ST_ACCEL_4_ODR_AVL_160HZ_VAL, },
+				{ 640, ST_ACCEL_4_ODR_AVL_640HZ_VAL, },
+				{ 2560, ST_ACCEL_4_ODR_AVL_2560HZ_VAL, },
+			},
+		},
+		.pw = {
+			.addr = ST_ACCEL_4_PW_ADDR,
+			.mask = ST_ACCEL_4_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_4_FS_ADDR,
+			.mask = ST_ACCEL_4_FS_MASK,
+			.fs_avl = {
+				[0] = {
+					.num = ST_ACCEL_FS_AVL_2G,
+					.value = ST_ACCEL_4_FS_AVL_2_VAL,
+					.gain = ST_ACCEL_4_FS_AVL_2_GAIN,
+				},
+				[1] = {
+					.num = ST_ACCEL_FS_AVL_6G,
+					.value = ST_ACCEL_4_FS_AVL_6_VAL,
+					.gain = ST_ACCEL_4_FS_AVL_6_GAIN,
+				},
+			},
+		},
+		.bdu = {
+			.addr = ST_ACCEL_4_BDU_ADDR,
+			.mask = ST_ACCEL_4_BDU_MASK,
+		},
+		.drdy_irq = {
+			.addr = ST_ACCEL_4_DRDY_IRQ_ADDR,
+			.mask_int1 = ST_ACCEL_4_DRDY_IRQ_INT1_MASK,
+			.ig1 = {
+				.en_addr = ST_ACCEL_4_IG1_EN_ADDR,
+				.en_mask = ST_ACCEL_4_IG1_EN_MASK,
+			},
+		},
+		.multi_read_bit = ST_ACCEL_4_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 c7246bdd30b9..6b720c190b2d 100644
--- a/drivers/iio/accel/st_accel_i2c.c
+++ b/drivers/iio/accel/st_accel_i2c.c
@@ -21,6 +21,10 @@
 #ifdef CONFIG_OF
 static const struct of_device_id st_accel_of_match[] = {
 	{
+		.compatible = "st,lis3lv02dl-accel",
+		.data = LIS3LV02DL_ACCEL_DEV_NAME,
+	},
+	{
 		.compatible = "st,lsm303dlh-accel",
 		.data = LSM303DLH_ACCEL_DEV_NAME,
 	},
-- 
1.9.3

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

* [PATCH RESEND] iio: st-sensors: add support for lis3lv02d accelerometer
@ 2015-03-18  9:52 ` Linus Walleij
  0 siblings, 0 replies; 10+ messages in thread
From: Linus Walleij @ 2015-03-18  9:52 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio, Denis CIOCCA
  Cc: Lee Jones, Linus Walleij, devicetree

This adds support for the LIS3LV02 accelerometer found in the
ST Microelectronics Nomadik board series.

Cc: devicetree@vger.kernel.org
Cc: Denis CIOCCA <denis.ciocca@st.com>
Cc: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
I'm not giving up on this. I think the st-sensors driver should
support this variant as its framework is way better than the misc
driver. The other driver is anyway not even in the right subsystem.
---
 .../devicetree/bindings/iio/st-sensors.txt         |  1 +
 drivers/iio/accel/st_accel.h                       |  1 +
 drivers/iio/accel/st_accel_core.c                  | 81 ++++++++++++++++++++++
 drivers/iio/accel/st_accel_i2c.c                   |  4 ++
 4 files changed, 87 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt
index a7a0a15913ad..d2aaca974531 100644
--- a/Documentation/devicetree/bindings/iio/st-sensors.txt
+++ b/Documentation/devicetree/bindings/iio/st-sensors.txt
@@ -23,6 +23,7 @@ standard bindings from pinctrl/pinctrl-bindings.txt.
 Valid compatible strings:
 
 Accelerometers:
+- st,lis3lv02dl-accel
 - st,lsm303dlh-accel
 - st,lsm303dlhc-accel
 - st,lis3dh-accel
diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h
index fa9646034305..7ee9724b1428 100644
--- a/drivers/iio/accel/st_accel.h
+++ b/drivers/iio/accel/st_accel.h
@@ -14,6 +14,7 @@
 #include <linux/types.h>
 #include <linux/iio/common/st_sensors.h>
 
+#define LIS3LV02DL_ACCEL_DEV_NAME	"lis3lv02dl_accel"
 #define LSM303DLHC_ACCEL_DEV_NAME	"lsm303dlhc_accel"
 #define LIS3DH_ACCEL_DEV_NAME		"lis3dh"
 #define LSM330D_ACCEL_DEV_NAME		"lsm330d_accel"
diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
index 53f32629283a..58d1d13d552a 100644
--- a/drivers/iio/accel/st_accel_core.c
+++ b/drivers/iio/accel/st_accel_core.c
@@ -129,6 +129,30 @@
 #define ST_ACCEL_3_IG1_EN_MASK			0x08
 #define ST_ACCEL_3_MULTIREAD_BIT		false
 
+/* CUSTOM VALUES FOR SENSOR 4 */
+#define ST_ACCEL_4_WAI_EXP			0x3a
+#define ST_ACCEL_4_ODR_ADDR			0x20
+#define ST_ACCEL_4_ODR_MASK			0x30 /* DF1 and DF0 */
+#define ST_ACCEL_4_ODR_AVL_40HZ_VAL		0x00
+#define ST_ACCEL_4_ODR_AVL_160HZ_VAL		0x01
+#define ST_ACCEL_4_ODR_AVL_640HZ_VAL		0x02
+#define ST_ACCEL_4_ODR_AVL_2560HZ_VAL		0x03
+#define ST_ACCEL_4_PW_ADDR			0x20
+#define ST_ACCEL_4_PW_MASK			0xc0
+#define ST_ACCEL_4_FS_ADDR			0x21
+#define ST_ACCEL_4_FS_MASK			0x80
+#define ST_ACCEL_4_FS_AVL_2_VAL			0X00
+#define ST_ACCEL_4_FS_AVL_6_VAL			0X01
+#define ST_ACCEL_4_FS_AVL_2_GAIN		IIO_G_TO_M_S_2(1024)
+#define ST_ACCEL_4_FS_AVL_6_GAIN		IIO_G_TO_M_S_2(340)
+#define ST_ACCEL_4_BDU_ADDR			0x21
+#define ST_ACCEL_4_BDU_MASK			0x40
+#define ST_ACCEL_4_DRDY_IRQ_ADDR		0x21
+#define ST_ACCEL_4_DRDY_IRQ_INT1_MASK		0x04
+#define ST_ACCEL_4_IG1_EN_ADDR			0x21
+#define ST_ACCEL_4_IG1_EN_MASK			0x08
+#define ST_ACCEL_4_MULTIREAD_BIT		true
+
 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),
@@ -373,6 +397,63 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
 		.multi_read_bit = ST_ACCEL_3_MULTIREAD_BIT,
 		.bootime = 2,
 	},
+	{
+		.wai = ST_ACCEL_4_WAI_EXP,
+		.sensors_supported = {
+			[0] = LIS3LV02DL_ACCEL_DEV_NAME,
+		},
+		.ch = (struct iio_chan_spec *)st_accel_12bit_channels,
+		.odr = {
+			.addr = ST_ACCEL_4_ODR_ADDR,
+			.mask = ST_ACCEL_4_ODR_MASK,
+			.odr_avl = {
+				{ 40, ST_ACCEL_4_ODR_AVL_40HZ_VAL },
+				{ 160, ST_ACCEL_4_ODR_AVL_160HZ_VAL, },
+				{ 640, ST_ACCEL_4_ODR_AVL_640HZ_VAL, },
+				{ 2560, ST_ACCEL_4_ODR_AVL_2560HZ_VAL, },
+			},
+		},
+		.pw = {
+			.addr = ST_ACCEL_4_PW_ADDR,
+			.mask = ST_ACCEL_4_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_4_FS_ADDR,
+			.mask = ST_ACCEL_4_FS_MASK,
+			.fs_avl = {
+				[0] = {
+					.num = ST_ACCEL_FS_AVL_2G,
+					.value = ST_ACCEL_4_FS_AVL_2_VAL,
+					.gain = ST_ACCEL_4_FS_AVL_2_GAIN,
+				},
+				[1] = {
+					.num = ST_ACCEL_FS_AVL_6G,
+					.value = ST_ACCEL_4_FS_AVL_6_VAL,
+					.gain = ST_ACCEL_4_FS_AVL_6_GAIN,
+				},
+			},
+		},
+		.bdu = {
+			.addr = ST_ACCEL_4_BDU_ADDR,
+			.mask = ST_ACCEL_4_BDU_MASK,
+		},
+		.drdy_irq = {
+			.addr = ST_ACCEL_4_DRDY_IRQ_ADDR,
+			.mask_int1 = ST_ACCEL_4_DRDY_IRQ_INT1_MASK,
+			.ig1 = {
+				.en_addr = ST_ACCEL_4_IG1_EN_ADDR,
+				.en_mask = ST_ACCEL_4_IG1_EN_MASK,
+			},
+		},
+		.multi_read_bit = ST_ACCEL_4_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 c7246bdd30b9..6b720c190b2d 100644
--- a/drivers/iio/accel/st_accel_i2c.c
+++ b/drivers/iio/accel/st_accel_i2c.c
@@ -21,6 +21,10 @@
 #ifdef CONFIG_OF
 static const struct of_device_id st_accel_of_match[] = {
 	{
+		.compatible = "st,lis3lv02dl-accel",
+		.data = LIS3LV02DL_ACCEL_DEV_NAME,
+	},
+	{
 		.compatible = "st,lsm303dlh-accel",
 		.data = LSM303DLH_ACCEL_DEV_NAME,
 	},
-- 
1.9.3


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

* Re: [PATCH RESEND] iio: st-sensors: add support for lis3lv02d accelerometer
  2015-03-18  9:52 ` Linus Walleij
@ 2015-03-18 15:39     ` Lee Jones
  -1 siblings, 0 replies; 10+ messages in thread
From: Lee Jones @ 2015-03-18 15:39 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Jonathan Cameron, linux-iio-u79uwXL29TY76Z2rM5mHXA, Denis CIOCCA,
	devicetree-u79uwXL29TY76Z2rM5mHXA

On Wed, 18 Mar 2015, Linus Walleij wrote:

> This adds support for the LIS3LV02 accelerometer found in the
> ST Microelectronics Nomadik board series.
> 
> Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Cc: Denis CIOCCA <denis.ciocca-qxv4g6HH51o@public.gmane.org>
> Cc: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> Signed-off-by: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> ---
> I'm not giving up on this. I think the st-sensors driver should
> support this variant as its framework is way better than the misc
> driver. The other driver is anyway not even in the right subsystem.

I'm not sure what the historical issues are, but the code looks fine
to me.

Acked-by: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

> ---
>  .../devicetree/bindings/iio/st-sensors.txt         |  1 +
>  drivers/iio/accel/st_accel.h                       |  1 +
>  drivers/iio/accel/st_accel_core.c                  | 81 ++++++++++++++++++++++
>  drivers/iio/accel/st_accel_i2c.c                   |  4 ++
>  4 files changed, 87 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt
> index a7a0a15913ad..d2aaca974531 100644
> --- a/Documentation/devicetree/bindings/iio/st-sensors.txt
> +++ b/Documentation/devicetree/bindings/iio/st-sensors.txt
> @@ -23,6 +23,7 @@ standard bindings from pinctrl/pinctrl-bindings.txt.
>  Valid compatible strings:
>  
>  Accelerometers:
> +- st,lis3lv02dl-accel
>  - st,lsm303dlh-accel
>  - st,lsm303dlhc-accel
>  - st,lis3dh-accel
> diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h
> index fa9646034305..7ee9724b1428 100644
> --- a/drivers/iio/accel/st_accel.h
> +++ b/drivers/iio/accel/st_accel.h
> @@ -14,6 +14,7 @@
>  #include <linux/types.h>
>  #include <linux/iio/common/st_sensors.h>
>  
> +#define LIS3LV02DL_ACCEL_DEV_NAME	"lis3lv02dl_accel"
>  #define LSM303DLHC_ACCEL_DEV_NAME	"lsm303dlhc_accel"
>  #define LIS3DH_ACCEL_DEV_NAME		"lis3dh"
>  #define LSM330D_ACCEL_DEV_NAME		"lsm330d_accel"
> diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
> index 53f32629283a..58d1d13d552a 100644
> --- a/drivers/iio/accel/st_accel_core.c
> +++ b/drivers/iio/accel/st_accel_core.c
> @@ -129,6 +129,30 @@
>  #define ST_ACCEL_3_IG1_EN_MASK			0x08
>  #define ST_ACCEL_3_MULTIREAD_BIT		false
>  
> +/* CUSTOM VALUES FOR SENSOR 4 */
> +#define ST_ACCEL_4_WAI_EXP			0x3a
> +#define ST_ACCEL_4_ODR_ADDR			0x20
> +#define ST_ACCEL_4_ODR_MASK			0x30 /* DF1 and DF0 */
> +#define ST_ACCEL_4_ODR_AVL_40HZ_VAL		0x00
> +#define ST_ACCEL_4_ODR_AVL_160HZ_VAL		0x01
> +#define ST_ACCEL_4_ODR_AVL_640HZ_VAL		0x02
> +#define ST_ACCEL_4_ODR_AVL_2560HZ_VAL		0x03
> +#define ST_ACCEL_4_PW_ADDR			0x20
> +#define ST_ACCEL_4_PW_MASK			0xc0
> +#define ST_ACCEL_4_FS_ADDR			0x21
> +#define ST_ACCEL_4_FS_MASK			0x80
> +#define ST_ACCEL_4_FS_AVL_2_VAL			0X00
> +#define ST_ACCEL_4_FS_AVL_6_VAL			0X01
> +#define ST_ACCEL_4_FS_AVL_2_GAIN		IIO_G_TO_M_S_2(1024)
> +#define ST_ACCEL_4_FS_AVL_6_GAIN		IIO_G_TO_M_S_2(340)
> +#define ST_ACCEL_4_BDU_ADDR			0x21
> +#define ST_ACCEL_4_BDU_MASK			0x40
> +#define ST_ACCEL_4_DRDY_IRQ_ADDR		0x21
> +#define ST_ACCEL_4_DRDY_IRQ_INT1_MASK		0x04
> +#define ST_ACCEL_4_IG1_EN_ADDR			0x21
> +#define ST_ACCEL_4_IG1_EN_MASK			0x08
> +#define ST_ACCEL_4_MULTIREAD_BIT		true
> +
>  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),
> @@ -373,6 +397,63 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
>  		.multi_read_bit = ST_ACCEL_3_MULTIREAD_BIT,
>  		.bootime = 2,
>  	},
> +	{
> +		.wai = ST_ACCEL_4_WAI_EXP,
> +		.sensors_supported = {
> +			[0] = LIS3LV02DL_ACCEL_DEV_NAME,
> +		},
> +		.ch = (struct iio_chan_spec *)st_accel_12bit_channels,
> +		.odr = {
> +			.addr = ST_ACCEL_4_ODR_ADDR,
> +			.mask = ST_ACCEL_4_ODR_MASK,
> +			.odr_avl = {
> +				{ 40, ST_ACCEL_4_ODR_AVL_40HZ_VAL },
> +				{ 160, ST_ACCEL_4_ODR_AVL_160HZ_VAL, },
> +				{ 640, ST_ACCEL_4_ODR_AVL_640HZ_VAL, },
> +				{ 2560, ST_ACCEL_4_ODR_AVL_2560HZ_VAL, },
> +			},
> +		},
> +		.pw = {
> +			.addr = ST_ACCEL_4_PW_ADDR,
> +			.mask = ST_ACCEL_4_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_4_FS_ADDR,
> +			.mask = ST_ACCEL_4_FS_MASK,
> +			.fs_avl = {
> +				[0] = {
> +					.num = ST_ACCEL_FS_AVL_2G,
> +					.value = ST_ACCEL_4_FS_AVL_2_VAL,
> +					.gain = ST_ACCEL_4_FS_AVL_2_GAIN,
> +				},
> +				[1] = {
> +					.num = ST_ACCEL_FS_AVL_6G,
> +					.value = ST_ACCEL_4_FS_AVL_6_VAL,
> +					.gain = ST_ACCEL_4_FS_AVL_6_GAIN,
> +				},
> +			},
> +		},
> +		.bdu = {
> +			.addr = ST_ACCEL_4_BDU_ADDR,
> +			.mask = ST_ACCEL_4_BDU_MASK,
> +		},
> +		.drdy_irq = {
> +			.addr = ST_ACCEL_4_DRDY_IRQ_ADDR,
> +			.mask_int1 = ST_ACCEL_4_DRDY_IRQ_INT1_MASK,
> +			.ig1 = {
> +				.en_addr = ST_ACCEL_4_IG1_EN_ADDR,
> +				.en_mask = ST_ACCEL_4_IG1_EN_MASK,
> +			},
> +		},
> +		.multi_read_bit = ST_ACCEL_4_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 c7246bdd30b9..6b720c190b2d 100644
> --- a/drivers/iio/accel/st_accel_i2c.c
> +++ b/drivers/iio/accel/st_accel_i2c.c
> @@ -21,6 +21,10 @@
>  #ifdef CONFIG_OF
>  static const struct of_device_id st_accel_of_match[] = {
>  	{
> +		.compatible = "st,lis3lv02dl-accel",
> +		.data = LIS3LV02DL_ACCEL_DEV_NAME,
> +	},
> +	{
>  		.compatible = "st,lsm303dlh-accel",
>  		.data = LSM303DLH_ACCEL_DEV_NAME,
>  	},

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH RESEND] iio: st-sensors: add support for lis3lv02d accelerometer
@ 2015-03-18 15:39     ` Lee Jones
  0 siblings, 0 replies; 10+ messages in thread
From: Lee Jones @ 2015-03-18 15:39 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Jonathan Cameron, linux-iio, Denis CIOCCA, devicetree

On Wed, 18 Mar 2015, Linus Walleij wrote:

> This adds support for the LIS3LV02 accelerometer found in the
> ST Microelectronics Nomadik board series.
> 
> Cc: devicetree@vger.kernel.org
> Cc: Denis CIOCCA <denis.ciocca@st.com>
> Cc: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> I'm not giving up on this. I think the st-sensors driver should
> support this variant as its framework is way better than the misc
> driver. The other driver is anyway not even in the right subsystem.

I'm not sure what the historical issues are, but the code looks fine
to me.

Acked-by: Lee Jones <lee.jones@linaro.org>

> ---
>  .../devicetree/bindings/iio/st-sensors.txt         |  1 +
>  drivers/iio/accel/st_accel.h                       |  1 +
>  drivers/iio/accel/st_accel_core.c                  | 81 ++++++++++++++++++++++
>  drivers/iio/accel/st_accel_i2c.c                   |  4 ++
>  4 files changed, 87 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt
> index a7a0a15913ad..d2aaca974531 100644
> --- a/Documentation/devicetree/bindings/iio/st-sensors.txt
> +++ b/Documentation/devicetree/bindings/iio/st-sensors.txt
> @@ -23,6 +23,7 @@ standard bindings from pinctrl/pinctrl-bindings.txt.
>  Valid compatible strings:
>  
>  Accelerometers:
> +- st,lis3lv02dl-accel
>  - st,lsm303dlh-accel
>  - st,lsm303dlhc-accel
>  - st,lis3dh-accel
> diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h
> index fa9646034305..7ee9724b1428 100644
> --- a/drivers/iio/accel/st_accel.h
> +++ b/drivers/iio/accel/st_accel.h
> @@ -14,6 +14,7 @@
>  #include <linux/types.h>
>  #include <linux/iio/common/st_sensors.h>
>  
> +#define LIS3LV02DL_ACCEL_DEV_NAME	"lis3lv02dl_accel"
>  #define LSM303DLHC_ACCEL_DEV_NAME	"lsm303dlhc_accel"
>  #define LIS3DH_ACCEL_DEV_NAME		"lis3dh"
>  #define LSM330D_ACCEL_DEV_NAME		"lsm330d_accel"
> diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
> index 53f32629283a..58d1d13d552a 100644
> --- a/drivers/iio/accel/st_accel_core.c
> +++ b/drivers/iio/accel/st_accel_core.c
> @@ -129,6 +129,30 @@
>  #define ST_ACCEL_3_IG1_EN_MASK			0x08
>  #define ST_ACCEL_3_MULTIREAD_BIT		false
>  
> +/* CUSTOM VALUES FOR SENSOR 4 */
> +#define ST_ACCEL_4_WAI_EXP			0x3a
> +#define ST_ACCEL_4_ODR_ADDR			0x20
> +#define ST_ACCEL_4_ODR_MASK			0x30 /* DF1 and DF0 */
> +#define ST_ACCEL_4_ODR_AVL_40HZ_VAL		0x00
> +#define ST_ACCEL_4_ODR_AVL_160HZ_VAL		0x01
> +#define ST_ACCEL_4_ODR_AVL_640HZ_VAL		0x02
> +#define ST_ACCEL_4_ODR_AVL_2560HZ_VAL		0x03
> +#define ST_ACCEL_4_PW_ADDR			0x20
> +#define ST_ACCEL_4_PW_MASK			0xc0
> +#define ST_ACCEL_4_FS_ADDR			0x21
> +#define ST_ACCEL_4_FS_MASK			0x80
> +#define ST_ACCEL_4_FS_AVL_2_VAL			0X00
> +#define ST_ACCEL_4_FS_AVL_6_VAL			0X01
> +#define ST_ACCEL_4_FS_AVL_2_GAIN		IIO_G_TO_M_S_2(1024)
> +#define ST_ACCEL_4_FS_AVL_6_GAIN		IIO_G_TO_M_S_2(340)
> +#define ST_ACCEL_4_BDU_ADDR			0x21
> +#define ST_ACCEL_4_BDU_MASK			0x40
> +#define ST_ACCEL_4_DRDY_IRQ_ADDR		0x21
> +#define ST_ACCEL_4_DRDY_IRQ_INT1_MASK		0x04
> +#define ST_ACCEL_4_IG1_EN_ADDR			0x21
> +#define ST_ACCEL_4_IG1_EN_MASK			0x08
> +#define ST_ACCEL_4_MULTIREAD_BIT		true
> +
>  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),
> @@ -373,6 +397,63 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
>  		.multi_read_bit = ST_ACCEL_3_MULTIREAD_BIT,
>  		.bootime = 2,
>  	},
> +	{
> +		.wai = ST_ACCEL_4_WAI_EXP,
> +		.sensors_supported = {
> +			[0] = LIS3LV02DL_ACCEL_DEV_NAME,
> +		},
> +		.ch = (struct iio_chan_spec *)st_accel_12bit_channels,
> +		.odr = {
> +			.addr = ST_ACCEL_4_ODR_ADDR,
> +			.mask = ST_ACCEL_4_ODR_MASK,
> +			.odr_avl = {
> +				{ 40, ST_ACCEL_4_ODR_AVL_40HZ_VAL },
> +				{ 160, ST_ACCEL_4_ODR_AVL_160HZ_VAL, },
> +				{ 640, ST_ACCEL_4_ODR_AVL_640HZ_VAL, },
> +				{ 2560, ST_ACCEL_4_ODR_AVL_2560HZ_VAL, },
> +			},
> +		},
> +		.pw = {
> +			.addr = ST_ACCEL_4_PW_ADDR,
> +			.mask = ST_ACCEL_4_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_4_FS_ADDR,
> +			.mask = ST_ACCEL_4_FS_MASK,
> +			.fs_avl = {
> +				[0] = {
> +					.num = ST_ACCEL_FS_AVL_2G,
> +					.value = ST_ACCEL_4_FS_AVL_2_VAL,
> +					.gain = ST_ACCEL_4_FS_AVL_2_GAIN,
> +				},
> +				[1] = {
> +					.num = ST_ACCEL_FS_AVL_6G,
> +					.value = ST_ACCEL_4_FS_AVL_6_VAL,
> +					.gain = ST_ACCEL_4_FS_AVL_6_GAIN,
> +				},
> +			},
> +		},
> +		.bdu = {
> +			.addr = ST_ACCEL_4_BDU_ADDR,
> +			.mask = ST_ACCEL_4_BDU_MASK,
> +		},
> +		.drdy_irq = {
> +			.addr = ST_ACCEL_4_DRDY_IRQ_ADDR,
> +			.mask_int1 = ST_ACCEL_4_DRDY_IRQ_INT1_MASK,
> +			.ig1 = {
> +				.en_addr = ST_ACCEL_4_IG1_EN_ADDR,
> +				.en_mask = ST_ACCEL_4_IG1_EN_MASK,
> +			},
> +		},
> +		.multi_read_bit = ST_ACCEL_4_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 c7246bdd30b9..6b720c190b2d 100644
> --- a/drivers/iio/accel/st_accel_i2c.c
> +++ b/drivers/iio/accel/st_accel_i2c.c
> @@ -21,6 +21,10 @@
>  #ifdef CONFIG_OF
>  static const struct of_device_id st_accel_of_match[] = {
>  	{
> +		.compatible = "st,lis3lv02dl-accel",
> +		.data = LIS3LV02DL_ACCEL_DEV_NAME,
> +	},
> +	{
>  		.compatible = "st,lsm303dlh-accel",
>  		.data = LSM303DLH_ACCEL_DEV_NAME,
>  	},

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH RESEND] iio: st-sensors: add support for lis3lv02d accelerometer
  2015-03-18 15:39     ` Lee Jones
@ 2015-03-21 11:52       ` Jonathan Cameron
  -1 siblings, 0 replies; 10+ messages in thread
From: Jonathan Cameron @ 2015-03-21 11:52 UTC (permalink / raw)
  To: Lee Jones, Linus Walleij
  Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA, Denis CIOCCA,
	devicetree-u79uwXL29TY76Z2rM5mHXA

On 18/03/15 15:39, Lee Jones wrote:
> On Wed, 18 Mar 2015, Linus Walleij wrote:
> 
>> This adds support for the LIS3LV02 accelerometer found in the
>> ST Microelectronics Nomadik board series.
>>
>> Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>> Cc: Denis CIOCCA <denis.ciocca-qxv4g6HH51o@public.gmane.org>
>> Cc: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>> Signed-off-by: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>> ---
>> I'm not giving up on this. I think the st-sensors driver should
>> support this variant as its framework is way better than the misc
>> driver. The other driver is anyway not even in the right subsystem.
> 
> I'm not sure what the historical issues are, but the code looks fine
> to me.
> 
> Acked-by: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
We aren't going to move forward without doing something.
Hence applied to the togreg branch of iio.git.  Lets see
whether anyone cares enough to add the stuff the other driver supports
and this one doesn't.

I originally meant to leave this for a few weeks to see if we
had any negative responses, but then completely forgot about it.
(sorry about that!)

Jonathan
> 
>> ---
>>  .../devicetree/bindings/iio/st-sensors.txt         |  1 +
>>  drivers/iio/accel/st_accel.h                       |  1 +
>>  drivers/iio/accel/st_accel_core.c                  | 81 ++++++++++++++++++++++
>>  drivers/iio/accel/st_accel_i2c.c                   |  4 ++
>>  4 files changed, 87 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt
>> index a7a0a15913ad..d2aaca974531 100644
>> --- a/Documentation/devicetree/bindings/iio/st-sensors.txt
>> +++ b/Documentation/devicetree/bindings/iio/st-sensors.txt
>> @@ -23,6 +23,7 @@ standard bindings from pinctrl/pinctrl-bindings.txt.
>>  Valid compatible strings:
>>  
>>  Accelerometers:
>> +- st,lis3lv02dl-accel
>>  - st,lsm303dlh-accel
>>  - st,lsm303dlhc-accel
>>  - st,lis3dh-accel
>> diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h
>> index fa9646034305..7ee9724b1428 100644
>> --- a/drivers/iio/accel/st_accel.h
>> +++ b/drivers/iio/accel/st_accel.h
>> @@ -14,6 +14,7 @@
>>  #include <linux/types.h>
>>  #include <linux/iio/common/st_sensors.h>
>>  
>> +#define LIS3LV02DL_ACCEL_DEV_NAME	"lis3lv02dl_accel"
>>  #define LSM303DLHC_ACCEL_DEV_NAME	"lsm303dlhc_accel"
>>  #define LIS3DH_ACCEL_DEV_NAME		"lis3dh"
>>  #define LSM330D_ACCEL_DEV_NAME		"lsm330d_accel"
>> diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
>> index 53f32629283a..58d1d13d552a 100644
>> --- a/drivers/iio/accel/st_accel_core.c
>> +++ b/drivers/iio/accel/st_accel_core.c
>> @@ -129,6 +129,30 @@
>>  #define ST_ACCEL_3_IG1_EN_MASK			0x08
>>  #define ST_ACCEL_3_MULTIREAD_BIT		false
>>  
>> +/* CUSTOM VALUES FOR SENSOR 4 */
>> +#define ST_ACCEL_4_WAI_EXP			0x3a
>> +#define ST_ACCEL_4_ODR_ADDR			0x20
>> +#define ST_ACCEL_4_ODR_MASK			0x30 /* DF1 and DF0 */
>> +#define ST_ACCEL_4_ODR_AVL_40HZ_VAL		0x00
>> +#define ST_ACCEL_4_ODR_AVL_160HZ_VAL		0x01
>> +#define ST_ACCEL_4_ODR_AVL_640HZ_VAL		0x02
>> +#define ST_ACCEL_4_ODR_AVL_2560HZ_VAL		0x03
>> +#define ST_ACCEL_4_PW_ADDR			0x20
>> +#define ST_ACCEL_4_PW_MASK			0xc0
>> +#define ST_ACCEL_4_FS_ADDR			0x21
>> +#define ST_ACCEL_4_FS_MASK			0x80
>> +#define ST_ACCEL_4_FS_AVL_2_VAL			0X00
>> +#define ST_ACCEL_4_FS_AVL_6_VAL			0X01
>> +#define ST_ACCEL_4_FS_AVL_2_GAIN		IIO_G_TO_M_S_2(1024)
>> +#define ST_ACCEL_4_FS_AVL_6_GAIN		IIO_G_TO_M_S_2(340)
>> +#define ST_ACCEL_4_BDU_ADDR			0x21
>> +#define ST_ACCEL_4_BDU_MASK			0x40
>> +#define ST_ACCEL_4_DRDY_IRQ_ADDR		0x21
>> +#define ST_ACCEL_4_DRDY_IRQ_INT1_MASK		0x04
>> +#define ST_ACCEL_4_IG1_EN_ADDR			0x21
>> +#define ST_ACCEL_4_IG1_EN_MASK			0x08
>> +#define ST_ACCEL_4_MULTIREAD_BIT		true
>> +
>>  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),
>> @@ -373,6 +397,63 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
>>  		.multi_read_bit = ST_ACCEL_3_MULTIREAD_BIT,
>>  		.bootime = 2,
>>  	},
>> +	{
>> +		.wai = ST_ACCEL_4_WAI_EXP,
>> +		.sensors_supported = {
>> +			[0] = LIS3LV02DL_ACCEL_DEV_NAME,
>> +		},
>> +		.ch = (struct iio_chan_spec *)st_accel_12bit_channels,
>> +		.odr = {
>> +			.addr = ST_ACCEL_4_ODR_ADDR,
>> +			.mask = ST_ACCEL_4_ODR_MASK,
>> +			.odr_avl = {
>> +				{ 40, ST_ACCEL_4_ODR_AVL_40HZ_VAL },
>> +				{ 160, ST_ACCEL_4_ODR_AVL_160HZ_VAL, },
>> +				{ 640, ST_ACCEL_4_ODR_AVL_640HZ_VAL, },
>> +				{ 2560, ST_ACCEL_4_ODR_AVL_2560HZ_VAL, },
>> +			},
>> +		},
>> +		.pw = {
>> +			.addr = ST_ACCEL_4_PW_ADDR,
>> +			.mask = ST_ACCEL_4_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_4_FS_ADDR,
>> +			.mask = ST_ACCEL_4_FS_MASK,
>> +			.fs_avl = {
>> +				[0] = {
>> +					.num = ST_ACCEL_FS_AVL_2G,
>> +					.value = ST_ACCEL_4_FS_AVL_2_VAL,
>> +					.gain = ST_ACCEL_4_FS_AVL_2_GAIN,
>> +				},
>> +				[1] = {
>> +					.num = ST_ACCEL_FS_AVL_6G,
>> +					.value = ST_ACCEL_4_FS_AVL_6_VAL,
>> +					.gain = ST_ACCEL_4_FS_AVL_6_GAIN,
>> +				},
>> +			},
>> +		},
>> +		.bdu = {
>> +			.addr = ST_ACCEL_4_BDU_ADDR,
>> +			.mask = ST_ACCEL_4_BDU_MASK,
>> +		},
>> +		.drdy_irq = {
>> +			.addr = ST_ACCEL_4_DRDY_IRQ_ADDR,
>> +			.mask_int1 = ST_ACCEL_4_DRDY_IRQ_INT1_MASK,
>> +			.ig1 = {
>> +				.en_addr = ST_ACCEL_4_IG1_EN_ADDR,
>> +				.en_mask = ST_ACCEL_4_IG1_EN_MASK,
>> +			},
>> +		},
>> +		.multi_read_bit = ST_ACCEL_4_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 c7246bdd30b9..6b720c190b2d 100644
>> --- a/drivers/iio/accel/st_accel_i2c.c
>> +++ b/drivers/iio/accel/st_accel_i2c.c
>> @@ -21,6 +21,10 @@
>>  #ifdef CONFIG_OF
>>  static const struct of_device_id st_accel_of_match[] = {
>>  	{
>> +		.compatible = "st,lis3lv02dl-accel",
>> +		.data = LIS3LV02DL_ACCEL_DEV_NAME,
>> +	},
>> +	{
>>  		.compatible = "st,lsm303dlh-accel",
>>  		.data = LSM303DLH_ACCEL_DEV_NAME,
>>  	},
> 

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

* Re: [PATCH RESEND] iio: st-sensors: add support for lis3lv02d accelerometer
@ 2015-03-21 11:52       ` Jonathan Cameron
  0 siblings, 0 replies; 10+ messages in thread
From: Jonathan Cameron @ 2015-03-21 11:52 UTC (permalink / raw)
  To: Lee Jones, Linus Walleij; +Cc: linux-iio, Denis CIOCCA, devicetree

On 18/03/15 15:39, Lee Jones wrote:
> On Wed, 18 Mar 2015, Linus Walleij wrote:
> 
>> This adds support for the LIS3LV02 accelerometer found in the
>> ST Microelectronics Nomadik board series.
>>
>> Cc: devicetree@vger.kernel.org
>> Cc: Denis CIOCCA <denis.ciocca@st.com>
>> Cc: Lee Jones <lee.jones@linaro.org>
>> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
>> ---
>> I'm not giving up on this. I think the st-sensors driver should
>> support this variant as its framework is way better than the misc
>> driver. The other driver is anyway not even in the right subsystem.
> 
> I'm not sure what the historical issues are, but the code looks fine
> to me.
> 
> Acked-by: Lee Jones <lee.jones@linaro.org>
We aren't going to move forward without doing something.
Hence applied to the togreg branch of iio.git.  Lets see
whether anyone cares enough to add the stuff the other driver supports
and this one doesn't.

I originally meant to leave this for a few weeks to see if we
had any negative responses, but then completely forgot about it.
(sorry about that!)

Jonathan
> 
>> ---
>>  .../devicetree/bindings/iio/st-sensors.txt         |  1 +
>>  drivers/iio/accel/st_accel.h                       |  1 +
>>  drivers/iio/accel/st_accel_core.c                  | 81 ++++++++++++++++++++++
>>  drivers/iio/accel/st_accel_i2c.c                   |  4 ++
>>  4 files changed, 87 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt
>> index a7a0a15913ad..d2aaca974531 100644
>> --- a/Documentation/devicetree/bindings/iio/st-sensors.txt
>> +++ b/Documentation/devicetree/bindings/iio/st-sensors.txt
>> @@ -23,6 +23,7 @@ standard bindings from pinctrl/pinctrl-bindings.txt.
>>  Valid compatible strings:
>>  
>>  Accelerometers:
>> +- st,lis3lv02dl-accel
>>  - st,lsm303dlh-accel
>>  - st,lsm303dlhc-accel
>>  - st,lis3dh-accel
>> diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h
>> index fa9646034305..7ee9724b1428 100644
>> --- a/drivers/iio/accel/st_accel.h
>> +++ b/drivers/iio/accel/st_accel.h
>> @@ -14,6 +14,7 @@
>>  #include <linux/types.h>
>>  #include <linux/iio/common/st_sensors.h>
>>  
>> +#define LIS3LV02DL_ACCEL_DEV_NAME	"lis3lv02dl_accel"
>>  #define LSM303DLHC_ACCEL_DEV_NAME	"lsm303dlhc_accel"
>>  #define LIS3DH_ACCEL_DEV_NAME		"lis3dh"
>>  #define LSM330D_ACCEL_DEV_NAME		"lsm330d_accel"
>> diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
>> index 53f32629283a..58d1d13d552a 100644
>> --- a/drivers/iio/accel/st_accel_core.c
>> +++ b/drivers/iio/accel/st_accel_core.c
>> @@ -129,6 +129,30 @@
>>  #define ST_ACCEL_3_IG1_EN_MASK			0x08
>>  #define ST_ACCEL_3_MULTIREAD_BIT		false
>>  
>> +/* CUSTOM VALUES FOR SENSOR 4 */
>> +#define ST_ACCEL_4_WAI_EXP			0x3a
>> +#define ST_ACCEL_4_ODR_ADDR			0x20
>> +#define ST_ACCEL_4_ODR_MASK			0x30 /* DF1 and DF0 */
>> +#define ST_ACCEL_4_ODR_AVL_40HZ_VAL		0x00
>> +#define ST_ACCEL_4_ODR_AVL_160HZ_VAL		0x01
>> +#define ST_ACCEL_4_ODR_AVL_640HZ_VAL		0x02
>> +#define ST_ACCEL_4_ODR_AVL_2560HZ_VAL		0x03
>> +#define ST_ACCEL_4_PW_ADDR			0x20
>> +#define ST_ACCEL_4_PW_MASK			0xc0
>> +#define ST_ACCEL_4_FS_ADDR			0x21
>> +#define ST_ACCEL_4_FS_MASK			0x80
>> +#define ST_ACCEL_4_FS_AVL_2_VAL			0X00
>> +#define ST_ACCEL_4_FS_AVL_6_VAL			0X01
>> +#define ST_ACCEL_4_FS_AVL_2_GAIN		IIO_G_TO_M_S_2(1024)
>> +#define ST_ACCEL_4_FS_AVL_6_GAIN		IIO_G_TO_M_S_2(340)
>> +#define ST_ACCEL_4_BDU_ADDR			0x21
>> +#define ST_ACCEL_4_BDU_MASK			0x40
>> +#define ST_ACCEL_4_DRDY_IRQ_ADDR		0x21
>> +#define ST_ACCEL_4_DRDY_IRQ_INT1_MASK		0x04
>> +#define ST_ACCEL_4_IG1_EN_ADDR			0x21
>> +#define ST_ACCEL_4_IG1_EN_MASK			0x08
>> +#define ST_ACCEL_4_MULTIREAD_BIT		true
>> +
>>  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),
>> @@ -373,6 +397,63 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
>>  		.multi_read_bit = ST_ACCEL_3_MULTIREAD_BIT,
>>  		.bootime = 2,
>>  	},
>> +	{
>> +		.wai = ST_ACCEL_4_WAI_EXP,
>> +		.sensors_supported = {
>> +			[0] = LIS3LV02DL_ACCEL_DEV_NAME,
>> +		},
>> +		.ch = (struct iio_chan_spec *)st_accel_12bit_channels,
>> +		.odr = {
>> +			.addr = ST_ACCEL_4_ODR_ADDR,
>> +			.mask = ST_ACCEL_4_ODR_MASK,
>> +			.odr_avl = {
>> +				{ 40, ST_ACCEL_4_ODR_AVL_40HZ_VAL },
>> +				{ 160, ST_ACCEL_4_ODR_AVL_160HZ_VAL, },
>> +				{ 640, ST_ACCEL_4_ODR_AVL_640HZ_VAL, },
>> +				{ 2560, ST_ACCEL_4_ODR_AVL_2560HZ_VAL, },
>> +			},
>> +		},
>> +		.pw = {
>> +			.addr = ST_ACCEL_4_PW_ADDR,
>> +			.mask = ST_ACCEL_4_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_4_FS_ADDR,
>> +			.mask = ST_ACCEL_4_FS_MASK,
>> +			.fs_avl = {
>> +				[0] = {
>> +					.num = ST_ACCEL_FS_AVL_2G,
>> +					.value = ST_ACCEL_4_FS_AVL_2_VAL,
>> +					.gain = ST_ACCEL_4_FS_AVL_2_GAIN,
>> +				},
>> +				[1] = {
>> +					.num = ST_ACCEL_FS_AVL_6G,
>> +					.value = ST_ACCEL_4_FS_AVL_6_VAL,
>> +					.gain = ST_ACCEL_4_FS_AVL_6_GAIN,
>> +				},
>> +			},
>> +		},
>> +		.bdu = {
>> +			.addr = ST_ACCEL_4_BDU_ADDR,
>> +			.mask = ST_ACCEL_4_BDU_MASK,
>> +		},
>> +		.drdy_irq = {
>> +			.addr = ST_ACCEL_4_DRDY_IRQ_ADDR,
>> +			.mask_int1 = ST_ACCEL_4_DRDY_IRQ_INT1_MASK,
>> +			.ig1 = {
>> +				.en_addr = ST_ACCEL_4_IG1_EN_ADDR,
>> +				.en_mask = ST_ACCEL_4_IG1_EN_MASK,
>> +			},
>> +		},
>> +		.multi_read_bit = ST_ACCEL_4_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 c7246bdd30b9..6b720c190b2d 100644
>> --- a/drivers/iio/accel/st_accel_i2c.c
>> +++ b/drivers/iio/accel/st_accel_i2c.c
>> @@ -21,6 +21,10 @@
>>  #ifdef CONFIG_OF
>>  static const struct of_device_id st_accel_of_match[] = {
>>  	{
>> +		.compatible = "st,lis3lv02dl-accel",
>> +		.data = LIS3LV02DL_ACCEL_DEV_NAME,
>> +	},
>> +	{
>>  		.compatible = "st,lsm303dlh-accel",
>>  		.data = LSM303DLH_ACCEL_DEV_NAME,
>>  	},
> 


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

* Re: [PATCH RESEND] iio: st-sensors: add support for lis3lv02d accelerometer
  2015-03-21 11:52       ` Jonathan Cameron
@ 2015-03-23  9:21           ` Linus Walleij
  -1 siblings, 0 replies; 10+ messages in thread
From: Linus Walleij @ 2015-03-23  9:21 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Lee Jones, linux-iio-u79uwXL29TY76Z2rM5mHXA, Denis CIOCCA,
	devicetree-u79uwXL29TY76Z2rM5mHXA

On Sat, Mar 21, 2015 at 12:52 PM, Jonathan Cameron <jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote:

> We aren't going to move forward without doing something.
> Hence applied to the togreg branch of iio.git.

Thanks!

>  Lets see
> whether anyone cares enough to add the stuff the other driver supports
> and this one doesn't.

The one really interesting feature I saw was the free-fall detection.
I think it'd be nice if we had the ability to register for listening
to such events from the IIO accelerometer subsystem, but I'm
scared to even try to test it, god knows how many boards I'd
break before I had this properly supported...

Yours,
Linus Walleij

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

* Re: [PATCH RESEND] iio: st-sensors: add support for lis3lv02d accelerometer
@ 2015-03-23  9:21           ` Linus Walleij
  0 siblings, 0 replies; 10+ messages in thread
From: Linus Walleij @ 2015-03-23  9:21 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: Lee Jones, linux-iio, Denis CIOCCA, devicetree

On Sat, Mar 21, 2015 at 12:52 PM, Jonathan Cameron <jic23@kernel.org> wrote:

> We aren't going to move forward without doing something.
> Hence applied to the togreg branch of iio.git.

Thanks!

>  Lets see
> whether anyone cares enough to add the stuff the other driver supports
> and this one doesn't.

The one really interesting feature I saw was the free-fall detection.
I think it'd be nice if we had the ability to register for listening
to such events from the IIO accelerometer subsystem, but I'm
scared to even try to test it, god knows how many boards I'd
break before I had this properly supported...

Yours,
Linus Walleij

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

* Re: [PATCH RESEND] iio: st-sensors: add support for lis3lv02d accelerometer
  2015-03-23  9:21           ` Linus Walleij
@ 2015-03-28 12:18               ` Jonathan Cameron
  -1 siblings, 0 replies; 10+ messages in thread
From: Jonathan Cameron @ 2015-03-28 12:18 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Lee Jones, linux-iio-u79uwXL29TY76Z2rM5mHXA, Denis CIOCCA,
	devicetree-u79uwXL29TY76Z2rM5mHXA

On 23/03/15 09:21, Linus Walleij wrote:
> On Sat, Mar 21, 2015 at 12:52 PM, Jonathan Cameron <jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> wrote:
> 
>> We aren't going to move forward without doing something.
>> Hence applied to the togreg branch of iio.git.
> 
> Thanks!
> 
>>  Lets see
>> whether anyone cares enough to add the stuff the other driver supports
>> and this one doesn't.
> 
> The one really interesting feature I saw was the free-fall detection.
> I think it'd be nice if we had the ability to register for listening
> to such events from the IIO accelerometer subsystem, but I'm
> scared to even try to test it, god knows how many boards I'd
> break before I had this properly supported...
I used to have a couple of accelerometers on the end of really long cables
for this sort of thing ;)

Mind you we regularly put whole boards through accelerations well past
the limits of most of these devices.  Never broke one yet - though did
break a lot of battery cables..

You raise a good point though.  We really need a generic framework for handling
freefall events.  Various sources exist not all in IIO (and not all should be)
but a slim lined interface /dev/freefall was discussed to allow a really fast
response would probably make sense - afterall the point is usual to park mechanical
parts before the device hits the ground.

On second thoughts how many of the devices we care about actually have spinning disks
anymore?  Maybe we are 10 years too late on this one ;) 
> 
> Yours,
> Linus Walleij
> 

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

* Re: [PATCH RESEND] iio: st-sensors: add support for lis3lv02d accelerometer
@ 2015-03-28 12:18               ` Jonathan Cameron
  0 siblings, 0 replies; 10+ messages in thread
From: Jonathan Cameron @ 2015-03-28 12:18 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Lee Jones, linux-iio, Denis CIOCCA, devicetree

On 23/03/15 09:21, Linus Walleij wrote:
> On Sat, Mar 21, 2015 at 12:52 PM, Jonathan Cameron <jic23@kernel.org> wrote:
> 
>> We aren't going to move forward without doing something.
>> Hence applied to the togreg branch of iio.git.
> 
> Thanks!
> 
>>  Lets see
>> whether anyone cares enough to add the stuff the other driver supports
>> and this one doesn't.
> 
> The one really interesting feature I saw was the free-fall detection.
> I think it'd be nice if we had the ability to register for listening
> to such events from the IIO accelerometer subsystem, but I'm
> scared to even try to test it, god knows how many boards I'd
> break before I had this properly supported...
I used to have a couple of accelerometers on the end of really long cables
for this sort of thing ;)

Mind you we regularly put whole boards through accelerations well past
the limits of most of these devices.  Never broke one yet - though did
break a lot of battery cables..

You raise a good point though.  We really need a generic framework for handling
freefall events.  Various sources exist not all in IIO (and not all should be)
but a slim lined interface /dev/freefall was discussed to allow a really fast
response would probably make sense - afterall the point is usual to park mechanical
parts before the device hits the ground.

On second thoughts how many of the devices we care about actually have spinning disks
anymore?  Maybe we are 10 years too late on this one ;) 
> 
> Yours,
> Linus Walleij
> 


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

end of thread, other threads:[~2015-03-28 12:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-18  9:52 [PATCH RESEND] iio: st-sensors: add support for lis3lv02d accelerometer Linus Walleij
2015-03-18  9:52 ` Linus Walleij
     [not found] ` <1426672326-6292-1-git-send-email-linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-03-18 15:39   ` Lee Jones
2015-03-18 15:39     ` Lee Jones
2015-03-21 11:52     ` Jonathan Cameron
2015-03-21 11:52       ` Jonathan Cameron
     [not found]       ` <550D5B65.10906-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-03-23  9:21         ` Linus Walleij
2015-03-23  9:21           ` Linus Walleij
     [not found]           ` <CACRpkdYuWL_rs9nzg8ivRehG6-yFOheo+ZugZ-1iqmAyhwVaLQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-03-28 12:18             ` Jonathan Cameron
2015-03-28 12:18               ` 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.