Skip to contentSkip to conversation

iio: STMicroelectronics iio drivers bugfix

PATCH In review Denis CIOCCA 3 participants 8 messages Jan 9, 2013 – Jan 12, 2013 IIO

lore
Share & tools
lore
#0 lore raw

Hi guys,

sorry but yesterday I sended to you the wrong patch! I attach the last (correct) patchs for the linux-next kernel and I have modified the config names in according with Alessandro suggestion. Thanks

Denis

#1 lore raw

PATCH 1/4 iio:common: Add STMicroelectronics common library

This patch add generic library for STMicroelectronics 3-axis sensors.

---
 drivers/iio/common/Kconfig                         |    1 +
 drivers/iio/common/Makefile                        |    1 +
 drivers/iio/common/st_sensors/Kconfig              |   30 ++
 drivers/iio/common/st_sensors/Makefile             |    9 +
 drivers/iio/common/st_sensors/st_sensors_buffer.c  |  115 +++++++
 drivers/iio/common/st_sensors/st_sensors_core.c    |  329 ++++++++++++++++++++
 drivers/iio/common/st_sensors/st_sensors_i2c.c     |   81 +++++
 drivers/iio/common/st_sensors/st_sensors_spi.c     |  128 ++++++++
 drivers/iio/common/st_sensors/st_sensors_trigger.c |   83 +++++
 include/linux/iio/common/st_sensors.h              |  278 +++++++++++++++++
 10 files changed, 1055 insertions(+), 0 deletions(-)
 create mode 100644 drivers/iio/common/st_sensors/Kconfig
 create mode 100644 drivers/iio/common/st_sensors/Makefile
 create mode 100644 drivers/iio/common/st_sensors/st_sensors_buffer.c
 create mode 100644 drivers/iio/common/st_sensors/st_sensors_core.c
 create mode 100644 drivers/iio/common/st_sensors/st_sensors_i2c.c
 create mode 100644 drivers/iio/common/st_sensors/st_sensors_spi.c
 create mode 100644 drivers/iio/common/st_sensors/st_sensors_trigger.c
 create mode 100644 include/linux/iio/common/st_sensors.h
drivers/iio/common/Kconfig +1 -0
index ed45ee5..0b6e97d 100644
@@ -3,3 +3,4 @@
 #
 
 source "drivers/iio/common/hid-sensors/Kconfig"
+source "drivers/iio/common/st_sensors/Kconfig"
drivers/iio/common/Makefile +1 -0
index 8158400..c2352be 100644
@@ -7,3 +7,4 @@
 #
 
 obj-y += hid-sensors/
+obj-y += st_sensors/
drivers/iio/common/st_sensors/Kconfig new file +30 -0
new file mode 100644
index 0000000..1cf41fd
@@ -0,0 +1,30 @@
+#
+# Hid Sensor common modules
+#
+menu "STMicroelectronics sensors library"
+
+config IIO_ST_SENSORS_CORE
+	tristate "Common modules for all ST sensors IIO drivers"
+	help
+	  Say yes here to build support for ST sensors to use
+	  common core functions.
+
+config IIO_ST_SENSORS_I2C
+	tristate "I2C common library for ST Sensor IIO drivers"
+	help
+	  Say yes here to build support for ST sensors to use
+	  common i2c functions.
+
+config IIO_ST_SENSORS_SPI
+	tristate "SPI common library for ST Sensor IIO drivers"
+	help
+	  Say yes here to build support for ST sensors to use
+	  common spi functions.
+
+config IIO_ST_SENSORS_TRIGGERED_BUFFER
+	tristate "trigger and buffer common library for ST Sensor IIO drivers"
+	help
+	  Say yes here to build support for ST sensors to use
+	  common trigger and buffer functions.
+
+endmenu
drivers/iio/common/st_sensors/Makefile new file +9 -0
new file mode 100644
index 0000000..8418b6b
@@ -0,0 +1,9 @@
+#
+# Makefile for the STMicroelectronics sensor common modules.
+#
+
+obj-$(CONFIG_IIO_ST_SENSORS_CORE) += st_sensors_core.o
+obj-$(CONFIG_IIO_ST_SENSORS_I2C) += st_sensors_i2c.o
+obj-$(CONFIG_IIO_ST_SENSORS_SPI) += st_sensors_spi.o
+obj-$(CONFIG_IIO_ST_SENSORS_TRIGGERED_BUFFER) += st_sensors_triggered_buffer.o
+st_sensors_triggered_buffer-y := st_sensors_trigger.o st_sensors_buffer.o
drivers/iio/common/st_sensors/st_sensors_buffer.c new file +115 -0

115 lines not on this page · raw message

drivers/iio/common/st_sensors/st_sensors_core.c new file +329 -0

329 lines not on this page · raw message

drivers/iio/common/st_sensors/st_sensors_i2c.c new file +81 -0

81 lines not on this page · raw message

drivers/iio/common/st_sensors/st_sensors_spi.c new file +128 -0

128 lines not on this page · raw message

drivers/iio/common/st_sensors/st_sensors_trigger.c new file +83 -0

83 lines not on this page · raw message

include/linux/iio/common/st_sensors.h new file +278 -0

278 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#3 lore raw

PATCH 2/4 iio:accel: Add STMicroelectronics accelerometers driver

In reply to Denis CIOCCA

This patch adds generic accelerometer driver for STMicroelectronics accelerometers, currently it supports:
LSM303DLH, LSM303DLHC, LIS3DH, LSM330D, LSM330DL, LSM330DLC, LIS331DLH, LSM303DL, LSM303DLM, LSM330.

---
 drivers/iio/accel/Kconfig           |   41 +++
 drivers/iio/accel/Makefile          |    6 +
 drivers/iio/accel/st_accel_buffer.c |  119 +++++++
 drivers/iio/accel/st_accel_core.c   |  652 +++++++++++++++++++++++++++++++++++
 drivers/iio/accel/st_accel_i2c.c    |   87 +++++
 drivers/iio/accel/st_accel_spi.c    |   86 +++++
 include/linux/iio/accel/st_accel.h  |   48 +++
 7 files changed, 1039 insertions(+), 0 deletions(-)
 create mode 100644 drivers/iio/accel/st_accel_buffer.c
 create mode 100644 drivers/iio/accel/st_accel_core.c
 create mode 100644 drivers/iio/accel/st_accel_i2c.c
 create mode 100644 drivers/iio/accel/st_accel_spi.c
 create mode 100644 include/linux/iio/accel/st_accel.h
drivers/iio/accel/Kconfig +41 -0
index 05e996f..ab67379 100644
@@ -14,4 +14,45 @@ config HID_SENSOR_ACCEL_3D
 	  Say yes here to build support for the HID SENSOR
 	  accelerometers 3D.
 
+config IIO_ST_ACCEL_3AXIS
+	tristate "STMicroelectronics accelerometers 3-Axis Driver"
+	depends on (I2C || SPI_MASTER) && SYSFS
+	select IIO_ST_SENSORS_CORE
+	help
+	  Say yes here to build support for STMicroelectronics accelerometers:
+	  LSM303DLH, LSM303DLHC, LIS3DH, LSM330D, LSM330DL, LSM330DLC,
+	  LIS331DLH, LSM303DL, LSM303DLM, LSM330.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called st_accel.
+
+config IIO_ST_ACCEL_3AXIS_I2C
+	tristate "support I2C bus connection"
+	depends on IIO_ST_ACCEL_3AXIS && I2C
+	select IIO_ST_SENSORS_I2C
+	help
+	  Say yes here to build I2C support for STMicroelectronics accelerometers.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called st_accel_i2c.
+
+config IIO_ST_ACCEL_3AXIS_SPI
+	tristate "support SPI bus connection"
+	depends on IIO_ST_ACCEL_3AXIS && SPI_MASTER
+	select IIO_ST_SENSORS_SPI
+	help
+	  Say yes here to build SPI support for STMicroelectronics accelerometers.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called st_accel_spi.
+
+config IIO_ST_ACCEL_3AXIS_TRIGGERED_BUFFER
+	tristate "support triggered buffer"
+	depends on IIO_ST_ACCEL_3AXIS
+	select IIO_TRIGGERED_BUFFER
+	select IIO_BUFFER
+	select IIO_ST_SENSORS_TRIGGERED_BUFFER
+	help
+	  Default trigger and buffer for STMicroelectronics accelerometers driver.
+
 endmenu
drivers/iio/accel/Makefile +6 -0
index 5bc6855..bb1fa7e 100644
@@ -3,3 +3,9 @@
 #
 
 obj-$(CONFIG_HID_SENSOR_ACCEL_3D) += hid-sensor-accel-3d.o
+
+st_accel-y := st_accel_core.o
+obj-$(CONFIG_IIO_ST_ACCEL_3AXIS_I2C) += st_accel_i2c.o
+obj-$(CONFIG_IIO_ST_ACCEL_3AXIS_SPI) += st_accel_spi.o
+obj-$(CONFIG_IIO_ST_ACCEL_3AXIS_TRIGGERED_BUFFER) += st_accel_buffer.o
+obj-$(CONFIG_IIO_ST_ACCEL_3AXIS) += st_accel.o
drivers/iio/accel/st_accel_buffer.c new file +119 -0

119 lines not on this page · raw message

drivers/iio/accel/st_accel_core.c new file +652 -0

652 lines not on this page · raw message

drivers/iio/accel/st_accel_i2c.c new file +87 -0

87 lines not on this page · raw message

drivers/iio/accel/st_accel_spi.c new file +86 -0

86 lines not on this page · raw message

include/linux/iio/accel/st_accel.h new file +48 -0

48 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#4 lore raw

PATCH 3/4 iio:gyro: Add STMicroelectronics gyroscopes driver

In reply to Denis CIOCCA

This patch adds generic gyroscope driver for STMicroelectronics gyroscopes, currently it supports:
L3G4200D, LSM330DL, L3GD20, L3GD20H, LSM330DLC, L3G4IS, LSM330.

---
 drivers/iio/gyro/Kconfig          |   40 +++
 drivers/iio/gyro/Makefile         |    6 +
 drivers/iio/gyro/st_gyro_buffer.c |  119 +++++++++
 drivers/iio/gyro/st_gyro_core.c   |  513 +++++++++++++++++++++++++++++++++++++
 drivers/iio/gyro/st_gyro_i2c.c    |   84 ++++++
 drivers/iio/gyro/st_gyro_spi.c    |   83 ++++++
 include/linux/iio/gyro/st_gyro.h  |   45 ++++
 7 files changed, 890 insertions(+), 0 deletions(-)
 create mode 100644 drivers/iio/gyro/st_gyro_buffer.c
 create mode 100644 drivers/iio/gyro/st_gyro_core.c
 create mode 100644 drivers/iio/gyro/st_gyro_i2c.c
 create mode 100644 drivers/iio/gyro/st_gyro_spi.c
 create mode 100644 include/linux/iio/gyro/st_gyro.h
drivers/iio/gyro/Kconfig +40 -0
index 96b68f6..7a7eef5 100644
@@ -23,4 +23,44 @@ config HID_SENSOR_GYRO_3D
 	  Say yes here to build support for the HID SENSOR
 	  Gyroscope 3D.
 
+config IIO_ST_GYRO_3AXIS
+	tristate "STMicroelectronics gyroscopes 3-Axis Driver"
+	depends on (I2C || SPI_MASTER) && SYSFS
+	select IIO_ST_SENSORS_CORE
+	help
+	  Say yes here to build support for STMicroelectronics gyroscopes:
+	  L3G4200D, LSM330DL, L3GD20, L3GD20H, LSM330DLC, L3G4IS, LSM330.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called st_gyro.
+
+config IIO_ST_GYRO_3AXIS_I2C
+	tristate "support I2C bus connection"
+	depends on IIO_ST_GYRO_3AXIS && I2C
+	select IIO_ST_SENSORS_I2C
+	help
+	  Say yes here to build I2C support for STMicroelectronics gyroscopes.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called st_gyro_i2c.
+
+config IIO_ST_GYRO_3AXIS_SPI
+	tristate "support SPI bus connection"
+	depends on IIO_ST_GYRO_3AXIS && SPI_MASTER
+	select IIO_ST_SENSORS_SPI
+	help
+	  Say yes here to build SPI support for STMicroelectronics gyroscopes.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called st_gyro_spi.
+
+config IIO_ST_GYRO_3AXIS_TRIGGERED_BUFFER
+	tristate "support triggered buffer"
+	depends on IIO_ST_GYRO_3AXIS
+	select IIO_TRIGGERED_BUFFER
+	select IIO_BUFFER
+	select IIO_ST_SENSORS_TRIGGERED_BUFFER
+	help
+	  Default trigger and buffer for STMicroelectronics gyroscopes driver.
+
 endmenu
drivers/iio/gyro/Makefile +6 -0
index 702a058..61d43ba 100644
@@ -4,3 +4,9 @@
 
 obj-$(CONFIG_ADIS16136) += adis16136.o
 obj-$(CONFIG_HID_SENSOR_GYRO_3D) += hid-sensor-gyro-3d.o
+
+st_gyro-y := st_gyro_core.o
+obj-$(CONFIG_IIO_ST_GYRO_3AXIS_I2C) += st_gyro_i2c.o
+obj-$(CONFIG_IIO_ST_GYRO_3AXIS_SPI) += st_gyro_spi.o
+obj-$(CONFIG_IIO_ST_GYRO_3AXIS_TRIGGERED_BUFFER) += st_gyro_buffer.o
+obj-$(CONFIG_IIO_ST_GYRO_3AXIS) += st_gyro.o
drivers/iio/gyro/st_gyro_buffer.c new file +119 -0

119 lines not on this page · raw message

drivers/iio/gyro/st_gyro_core.c new file +513 -0

513 lines not on this page · raw message

drivers/iio/gyro/st_gyro_i2c.c new file +84 -0

84 lines not on this page · raw message

drivers/iio/gyro/st_gyro_spi.c new file +83 -0

83 lines not on this page · raw message

include/linux/iio/gyro/st_gyro.h new file +45 -0

45 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#5 lore raw

PATCH 4/4 iio:magnetometer: Add STMicroelectronics magnetometers driver

In reply to Denis CIOCCA

This patch adds generic magnetometer driver for STMicroelectronics magnetometers, currently it supports:
LSM303DLHC, LSM303DLM, LIS3MDL.

---
 drivers/iio/magnetometer/Kconfig          |   40 +++
 drivers/iio/magnetometer/Makefile         |    6 +
 drivers/iio/magnetometer/st_magn_buffer.c |  102 ++++++
 drivers/iio/magnetometer/st_magn_core.c   |  526 +++++++++++++++++++++++++++++
 drivers/iio/magnetometer/st_magn_i2c.c    |   81 +++++
 drivers/iio/magnetometer/st_magn_spi.c    |   80 +++++
 include/linux/iio/magnetometer/st_magn.h  |   49 +++
 7 files changed, 884 insertions(+), 0 deletions(-)
 create mode 100644 drivers/iio/magnetometer/st_magn_buffer.c
 create mode 100644 drivers/iio/magnetometer/st_magn_core.c
 create mode 100644 drivers/iio/magnetometer/st_magn_i2c.c
 create mode 100644 drivers/iio/magnetometer/st_magn_spi.c
 create mode 100644 include/linux/iio/magnetometer/st_magn.h
drivers/iio/magnetometer/Kconfig +40 -0
index ff11d68..02e1273 100644
@@ -14,4 +14,44 @@ config HID_SENSOR_MAGNETOMETER_3D
 	  Say yes here to build support for the HID SENSOR
 	  Magnetometer 3D.
 
+config IIO_ST_MAGN_3AXIS
+	tristate "STMicroelectronics magnetometers 3-Axis Driver"
+	depends on (I2C || SPI_MASTER) && SYSFS
+	select IIO_ST_SENSORS_CORE
+	help
+	  Say yes here to build support for STMicroelectronics magnetometers:
+	  LSM303DLHC, LSM303DLM, LIS3MDL.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called st_magn.
+
+config IIO_ST_MAGN_3AXIS_I2C
+	tristate "support I2C bus connection"
+	depends on IIO_ST_MAGN_3AXIS && I2C
+	select IIO_ST_SENSORS_I2C
+	help
+	  Say yes here to build I2C support for STMicroelectronics magnetometers.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called st_magn_i2c.
+
+config IIO_ST_MAGN_3AXIS_SPI
+	tristate "support SPI bus connection"
+	depends on IIO_ST_MAGN_3AXIS && SPI_MASTER
+	select IIO_ST_SENSORS_SPI
+	help
+	  Say yes here to build SPI support for STMicroelectronics magnetometers.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called st_magn_spi.
+
+config IIO_ST_MAGN_3AXIS_TRIGGERED_BUFFER
+	tristate "support triggered buffer"
+	depends on IIO_ST_MAGN_3AXIS
+	select IIO_TRIGGERED_BUFFER
+	select IIO_BUFFER
+	select IIO_ST_SENSORS_TRIGGERED_BUFFER
+	help
+	  Default trigger and buffer for STMicroelectronics magnetometers driver.
+
 endmenu
drivers/iio/magnetometer/Makefile +6 -0
index 60dc4f2..33d42e5 100644
@@ -3,3 +3,9 @@
 #
 
 obj-$(CONFIG_HID_SENSOR_MAGNETOMETER_3D) += hid-sensor-magn-3d.o
+
+st_magn-y := st_magn_core.o
+obj-$(CONFIG_IIO_ST_MAGN_3AXIS_I2C) += st_magn_i2c.o
+obj-$(CONFIG_IIO_ST_MAGN_3AXIS_SPI) += st_magn_spi.o
+obj-$(CONFIG_IIO_ST_MAGN_3AXIS_TRIGGERED_BUFFER) += st_magn_buffer.o
+obj-$(CONFIG_IIO_ST_MAGN_3AXIS) += st_magn.o
drivers/iio/magnetometer/st_magn_buffer.c new file +102 -0

102 lines not on this page · raw message

drivers/iio/magnetometer/st_magn_core.c new file +526 -0

526 lines not on this page · raw message

drivers/iio/magnetometer/st_magn_i2c.c new file +81 -0

81 lines not on this page · raw message

drivers/iio/magnetometer/st_magn_spi.c new file +80 -0

80 lines not on this page · raw message

include/linux/iio/magnetometer/st_magn.h new file +49 -0

49 lines not on this page · raw message

Signature · 1 line
1.7.0.4
maintainer
#2 lore raw

Re: [PATCH 1/4] iio:common: Add STMicroelectronics common library

In reply to Denis CIOCCA

...

drivers/iio/common/st_sensors/st_sensors_core.c line 319

Quoted 12 lines
drivers/iio/common/st_sensors/st_sensors_core.c new file +12 -0
+int st_sensors_read_axis_data(struct iio_dev *indio_dev, u8 ch_addr, int *data)
+{
+	int err;
+	u8 outdata[ST_SENSORS_BYTE_FOR_CHANNEL];
+	struct st_sensor_data *sdata = iio_priv(indio_dev);
+
+	err = sdata->tf->read_multiple_byte(&sdata->tb, sdata->dev,
+			ch_addr, ST_SENSORS_BYTE_FOR_CHANNEL,
+						outdata, sdata->multiread_bit);
+	if (err < 0)
+		goto read_error;
+

If you want to keep the cast this way around, then make
it __le16 instead of u16. Personally I'd make outdata a __le16 array and then do the cast the other way, but it is far from important.

Quoted 6 lines
drivers/iio/common/st_sensors/st_sensors_core.c new file +6 -0
+	*data = ((s16)le16_to_cpup((u16 *)outdata));
+
+read_error:
+	return err;
+}
+EXPORT_SYMBOL(st_sensors_read_axis_data);

...

maintainer
#6 lore raw
In reply to Denis CIOCCA
Quoted 7 lines · Denis CIOCCA

Hi guys,

sorry but yesterday I sended to you the wrong patch! I attach the last (correct) patchs for the linux-next kernel and I have modified the config names in according with Alessandro suggestion. Thanks

Denis

Hi Denis,

Just a quick email to say I'm very happy with the state these patches are now in. I have one utterly trivial point on patch 1 but am happy to fix that up during the merge. (Basically you type cast a parameter to u16 instead of __le16).

However, given the size of the series I would like to leave them sitting on the mailing list for a little while (maybe until next Saturday given my usual timetable for such things) in case anyone else wants to review them. Also right now I've only looked at 1 and 2 (assuming the others are very similar for obvious reasons!) I will give them a look before merging just in case anything slipped by.

Thanks for all your work on these. When I get some time I'll see what is needed to add support for the lis3l02dq to this driver. From what I recall that chip is a little dumber than some of the newer ones and needs some uggly interrupt handling trickery. Given it's an ancient chip I doubt it is terribly high on your list to support. I just happen to have one on my test board so it's always been of inordinate interest to me ;)

Jonathan

#7 lore raw

Hi Jonathan,

thanks for your comments and your support to my works!

Quoted 2 lines

Just a quick email to say I'm very happy with the state these patches are now in.

me too...:)

Quoted 3 lines

I have one utterly trivial point on patch 1 but am happy to fix that up during the merge. (Basically you type cast a parameter to u16 instead of __le16).

no problem, in this days I can review and fix this issue.

Quoted 3 lines

Also right now I've only looked at 1 and 2 (assuming the others are very similar for obvious reasons!) I will give them a look before merging just in case anything slipped by.

Yeah, the other patchs are very very similar.

Quoted 6 lines

Thanks for all your work on these. When I get some time I'll see what is needed to add support for the lis3l02dq to this driver. From what I recall that chip is a little dumber than some of the newer ones and needs some uggly interrupt handling trickery. Given it's an ancient chip I doubt it is terribly high on your list to support. I just happen to have one on my test board so it's always been of inordinate interest to me ;)

If I have a little bit of time, I can check what is needed to add support for the lis3l02dq!

Denis