STMicroelectronics driver kconfig-makefile bugfix
Hi Jonathan,
thank you very much for your support!
Now I understand why my solution doesn't work, I have used your suggestions and I applied its to the source code. Best regards,
Denis
PATCH 1/4 iio:common: Add STMicroelectronics common library
This patch add a generic library for STMicroelectronics 3-axis sensors.
--- drivers/iio/common/Kconfig | 1 + drivers/iio/common/Makefile | 1 + drivers/iio/common/st_sensors/Kconfig | 14 + drivers/iio/common/st_sensors/Makefile | 10 + drivers/iio/common/st_sensors/st_sensors_buffer.c | 115 ++++++ drivers/iio/common/st_sensors/st_sensors_core.c | 411 +++++++++++++++++++++ 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 | 77 ++++ include/linux/iio/common/st_sensors.h | 266 +++++++++++++ include/linux/iio/common/st_sensors_i2c.h | 20 + include/linux/iio/common/st_sensors_spi.h | 20 + 12 files changed, 1144 insertions(+) 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 create mode 100644 include/linux/iio/common/st_sensors_i2c.h create mode 100644 include/linux/iio/common/st_sensors_spi.h
drivers/iio/common/Kconfig +1 -0
@@ -3,3 +3,4 @@ # source "drivers/iio/common/hid-sensors/Kconfig" +source "drivers/iio/common/st_sensors/Kconfig"
drivers/iio/common/Makefile +1 -0
@@ -7,3 +7,4 @@ # obj-y += hid-sensors/ +obj-y += st_sensors/
drivers/iio/common/st_sensors/Kconfig new file +14 -0
@@ -0,0 +1,14 @@ +# +# Hid Sensor common modules +# + +config IIO_ST_SENSORS_I2C + tristate + +config IIO_ST_SENSORS_SPI + tristate + +config IIO_ST_SENSORS_CORE + tristate + select IIO_ST_SENSORS_I2C if I2C + select IIO_ST_SENSORS_SPI if SPI_MASTER
drivers/iio/common/st_sensors/Makefile new file +10 -0
@@ -0,0 +1,10 @@ +# +# Makefile for the STMicroelectronics sensor common modules. +# + +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_CORE) += st_sensors.o +st_sensors-y := st_sensors_core.o +st_sensors-$(CONFIG_IIO_BUFFER) += st_sensors_buffer.o +st_sensors-$(CONFIG_IIO_TRIGGER) += st_sensors_trigger.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 +411 -0
411 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 +77 -0
77 lines not on this page · raw message
include/linux/iio/common/st_sensors.h new file +266 -0
266 lines not on this page · raw message
include/linux/iio/common/st_sensors_i2c.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* STMicroelectronics sensors i2c library driver +* +* Copyright 2012-2013 STMicroelectronics Inc. +* +* Denis Ciocca <[email protected]> +* +* Licensed under the GPL-2. +*/ + +#ifndef ST_SENSORS_I2C_H +#define ST_SENSORS_I2C_H + +#include <linux/i2c.h> +#include <linux/iio/common/st_sensors.h> + +void st_sensors_i2c_configure (struct iio_dev *indio_dev, +struct i2c_client *client,struct st_sensor_data *sdata); + +#endif /* ST_SENSORS_I2C_H */
include/linux/iio/common/st_sensors_spi.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* STMicroelectronics sensors spi library driver +* +* Copyright 2012-2013 STMicroelectronics Inc. +* +* Denis Ciocca <[email protected]> +* +* Licensed under the GPL-2. +*/ + +#ifndef ST_SENSORS_SPI_H +#define ST_SENSORS_SPI_H + +#include <linux/spi/spi.h> +#include <linux/iio/common/st_sensors.h> + +void st_sensors_spi_configure (struct iio_dev *indio_dev, +struct spi_device *spi,struct st_sensor_data *sdata); + +#endif /* ST_SENSORS_SPI_H */
Signature · 1 line
1.8.0.3
Jonathan Cameron
maintainerRe: [PATCH 1/4] iio:common: Add STMicroelectronics common library
Quoted 4 lines · Denis CIOCCA
This patch add a generic library for STMicroelectronics 3-axis sensors.
Signed-off-by Denis Ciocca <[email protected]>---
I very nearly took this series today but in a final look found just enough slightly ugly corners to merit one more round.. To help you along I've put together a patch set to fix up the various issues..
Couple of nitpicks
There are some functions exported by the core library that are no longer used in the various drivers. These exports should go away. st_sensors_write_data_with_maskst_sensors_set_fullscale
A couple of the comments are out of date in Kconfig for the drivers. (basically there are no buffer specific modules any more..)
The gyro code at least includes a few unwanted exports as well, mostly as a result of the fact we now have 3 modules in there instead of 2.
Having said that we could go round and round with these little bits for ever so I hope you don't mind but I've just fixed up the ones I noticed and applied to togreg branch of iio.git
I'm not convinced there is anything in linux/iio/accel/st_accel.h that wants to be globally available so move it to driver/iio/accel.
Anyhow, patch set doing these to follow.
Quoted 1,245 lines
drivers/iio/common/Kconfig | 1 + drivers/iio/common/Makefile | 1 + drivers/iio/common/st_sensors/Kconfig | 14 + drivers/iio/common/st_sensors/Makefile | 10 + drivers/iio/common/st_sensors/st_sensors_buffer.c | 115 ++++++ drivers/iio/common/st_sensors/st_sensors_core.c | 411 +++++++++++++++++++++ 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 | 77 ++++ include/linux/iio/common/st_sensors.h | 266 +++++++++++++ include/linux/iio/common/st_sensors_i2c.h | 20 + include/linux/iio/common/st_sensors_spi.h | 20 + 12 files changed, 1144 insertions(+) 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 create mode 100644 include/linux/iio/common/st_sensors_i2c.h create mode 100644 include/linux/iio/common/st_sensors_spi.hdrivers/iio/common/Kconfig +1
-0@@ -3,3 +3,4 @@ # source "drivers/iio/common/hid-sensors/Kconfig" +source "drivers/iio/common/st_sensors/Kconfig"drivers/iio/common/Makefile +1
-0@@ -7,3 +7,4 @@ # obj-y += hid-sensors/ +obj-y += st_sensors/drivers/iio/common/st_sensors/Kconfig new file +14
-0@@ -0,0 +1,14 @@ +# +# Hid Sensor common modules +# + +config IIO_ST_SENSORS_I2C + tristate + +config IIO_ST_SENSORS_SPI + tristate + +config IIO_ST_SENSORS_CORE + tristate + select IIO_ST_SENSORS_I2C if I2C + select IIO_ST_SENSORS_SPI if SPI_MASTERdrivers/iio/common/st_sensors/Makefile new file +10
-0@@ -0,0 +1,10 @@ +# +# Makefile for the STMicroelectronics sensor common modules. +# + +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_CORE) += st_sensors.o +st_sensors-y := st_sensors_core.o +st_sensors-$(CONFIG_IIO_BUFFER) += st_sensors_buffer.o +st_sensors-$(CONFIG_IIO_TRIGGER) += st_sensors_trigger.odrivers/iio/common/st_sensors/st_sensors_buffer.c new file +115
-0@@ -0,0 +1,115 @@ +/* +* STMicroelectronics sensors buffer library driver +* +* Copyright 2012-2013 STMicroelectronics Inc. +* +* Denis Ciocca <[email protected]> +* +* Licensed under the GPL-2. +*/ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/slab.h> +#include <linux/iio/iio.h> +#include <linux/iio/trigger.h> +#include <linux/interrupt.h> +#include <linux/iio/buffer.h> +#include <linux/iio/trigger_consumer.h> +#include <linux/iio/triggered_buffer.h> +#include <linux/irqreturn.h> + +#include <linux/iio/common/st_sensors.h> + +int st_sensors_get_buffer_element (struct iio_dev *indio_dev,u8 *buf) +{ +int i, n =0 , len; +u8 addr[ST_SENSORS_NUMBER_DATA_CHANNELS ]; +struct st_sensor_data *sdata =iio_priv (indio_dev); + +for (i =0 ; i <ST_SENSORS_NUMBER_DATA_CHANNELS ; i++) { +if (test_bit (i, indio_dev->active_scan_mask)) { + addr[n] = indio_dev->channels[i].address; + n++; + } + } +switch (n) { +case 1 : + len = sdata->tf->read_multiple_byte (&sdata->tb, sdata->dev, + addr[0 ],ST_SENSORS_BYTE_FOR_CHANNEL , buf, + sdata->multiread_bit); +break ; +case 2 : +if ((addr[1 ] - addr[0 ]) ==ST_SENSORS_BYTE_FOR_CHANNEL ) { + len = sdata->tf->read_multiple_byte (&sdata->tb, + sdata->dev, addr[0 ], +ST_SENSORS_BYTE_FOR_CHANNEL *n, + buf, sdata->multiread_bit); + }else { +u8 rx_array[ST_SENSORS_BYTE_FOR_CHANNEL * +ST_SENSORS_NUMBER_DATA_CHANNELS ]; + len = sdata->tf->read_multiple_byte (&sdata->tb, + sdata->dev, addr[0 ], +ST_SENSORS_BYTE_FOR_CHANNEL * +ST_SENSORS_NUMBER_DATA_CHANNELS , + rx_array, sdata->multiread_bit); +if (len <0 ) + goto read_data_channels_error; + +for (i =0 ; i < n *ST_SENSORS_NUMBER_DATA_CHANNELS ; + i++) { +if (i < n) + buf[i] = rx_array[i]; +else + buf[i] = rx_array[n + i]; + } + len =ST_SENSORS_BYTE_FOR_CHANNEL *n; + } +break ; +case 3 : + len = sdata->tf->read_multiple_byte (&sdata->tb, sdata->dev, + addr[0 ],ST_SENSORS_BYTE_FOR_CHANNEL * +ST_SENSORS_NUMBER_DATA_CHANNELS , + buf, sdata->multiread_bit); +break ; +default : + len = -EINVAL ; + goto read_data_channels_error; + } +if (len !=ST_SENSORS_BYTE_FOR_CHANNEL *n) { + len = -EIO ; + goto read_data_channels_error; + } + +read_data_channels_error: +return len; +} +EXPORT_SYMBOL (st_sensors_get_buffer_element); + +irqreturn_t st_sensors_trigger_handler (int irq,void *p) +{ +int len; +struct iio_poll_func *pf = p; +struct iio_dev *indio_dev = pf->indio_dev; +struct st_sensor_data *sdata =iio_priv (indio_dev); + + len =st_sensors_get_buffer_element (indio_dev, sdata->buffer_data); +if (len <0 ) + goto st_sensors_get_buffer_element_error; + +if (indio_dev->scan_timestamp) + *(s64 *)((u8 *)sdata->buffer_data + +ALIGN (len,sizeof (s64))) = pf->timestamp; + +iio_push_to_buffers (indio_dev, sdata->buffer_data); + +st_sensors_get_buffer_element_error: +iio_trigger_notify_done (indio_dev->trig); + +return IRQ_HANDLED ; +} +EXPORT_SYMBOL (st_sensors_trigger_handler); + +MODULE_AUTHOR ("Denis Ciocca <[email protected]>" ); +MODULE_DESCRIPTION ("STMicroelectronics ST-sensors buffer" ); +MODULE_LICENSE ("GPL v2" );drivers/iio/common/st_sensors/st_sensors_core.c new file +411
-0@@ -0,0 +1,411 @@ +/* +* STMicroelectronics sensors core library driver +* +* Copyright 2012-2013 STMicroelectronics Inc. +* +* Denis Ciocca <[email protected]> +* +* Licensed under the GPL-2. +*/ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/slab.h> +#include <linux/delay.h> +#include <linux/unaligned/le_byteshift.h> +#include <linux/iio/iio.h> + +#include <linux/iio/common/st_sensors.h> + + +#define ST_SENSORS_WAI_ADDRESS 0x0f + +int st_sensors_write_data_with_mask (struct iio_dev *indio_dev, +u8 reg_addr,u8 mask,u8 data) +{ +int err; +u8 new_data; +struct st_sensor_data *sdata =iio_priv (indio_dev); + + err = sdata->tf->read_byte (&sdata->tb, sdata->dev, reg_addr, &new_data); +if (err <0 ) + goto st_sensors_write_data_with_mask_error; + + new_data = ((new_data & (~mask)) | ((data <<__ffs (mask)) & mask)); + err = sdata->tf->write_byte (&sdata->tb, sdata->dev, reg_addr, new_data); + +st_sensors_write_data_with_mask_error: +return err; +} +EXPORT_SYMBOL (st_sensors_write_data_with_mask); + +int st_sensors_get_sampling_frequency_avl (struct iio_dev *indio_dev, +const struct st_sensor_odr_avl *odr_avl,char *buf) +{ +int i, len =0 ; + +mutex_lock (&indio_dev->mlock); +for (i =0 ; i <ST_SENSORS_ODR_LIST_MAX ; i++) { +if (odr_avl[i].hz ==0 ) +break ; + + len +=scnprintf (buf + len,PAGE_SIZE - len, +"%d " , odr_avl[i].hz); + } +mutex_unlock (&indio_dev->mlock); + buf[len -1 ] ='\n' ; + +return len; +} +EXPORT_SYMBOL (st_sensors_get_sampling_frequency_avl); + +int st_sensors_get_scale_avl (struct iio_dev *indio_dev, +const struct st_sensor_fullscale_avl *fullscale_avl,char *buf) +{ +int i, len =0 ; + +mutex_lock (&indio_dev->mlock); +for (i =0 ; i <ST_SENSORS_FULLSCALE_AVL_MAX ; i++) { +if (fullscale_avl[i].num ==0 ) +break ; + + len +=scnprintf (buf + len,PAGE_SIZE - len, +"0.%06u " , fullscale_avl[i].gain); + } +mutex_unlock (&indio_dev->mlock); + buf[len -1 ] ='\n' ; + +return len; +} +EXPORT_SYMBOL (st_sensors_get_scale_avl); + +static int st_sensors_match_odr (const struct st_sensors *sensor, +unsigned int odr,struct st_sensor_odr_avl *odr_out) +{ +int i, ret = -EINVAL ; + +for (i =0 ; i <ST_SENSORS_ODR_LIST_MAX ; i++) { +if (sensor->odr.odr_avl[i].hz ==0 ) + goto st_sensors_match_odr_error; + +if (sensor->odr.odr_avl[i].hz == odr) { + odr_out->hz = sensor->odr.odr_avl[i].hz; + odr_out->value = sensor->odr.odr_avl[i].value; + ret =0 ; +break ; + } + } + +st_sensors_match_odr_error: +return ret; +} + +int st_sensors_set_odr (struct iio_dev *indio_dev, +const struct st_sensors *sensor,unsigned int odr) +{ +int err; +struct st_sensor_data *sdata =iio_priv (indio_dev); +struct st_sensor_odr_avl odr_out; + + err =st_sensors_match_odr (sensor, odr, &odr_out); +if (err <0 ) + goto st_sensors_match_odr_error; + +if ((sensor->odr.addr == sensor->pw.addr) && + (sensor->odr.mask == sensor->pw.mask)) { +if (sdata->enabled == true) { + err =st_sensors_write_data_with_mask (indio_dev, + sensor->odr.addr, sensor->odr.mask, + odr_out.value); + }else { + err =0 ; + } + }else { + err =st_sensors_write_data_with_mask (indio_dev, + sensor->odr.addr, sensor->odr.mask, odr_out.value); + } +if (err >=0 ) + sdata->odr = odr_out.hz; + +st_sensors_match_odr_error: +return err; +} +EXPORT_SYMBOL (st_sensors_set_odr); + +static int st_sensors_match_fs (const struct st_sensors *sensor, +unsigned int fs,int *index_fs_avl) +{ +int i, ret = -EINVAL ; + +for (i =0 ; i <ST_SENSORS_FULLSCALE_AVL_MAX ; i++) { +if (sensor->fs.fs_avl[i].num ==0 ) + goto st_sensors_match_odr_error; + +if (sensor->fs.fs_avl[i].num == fs) { + *index_fs_avl = i; + ret =0 ; +break ; + } + } + +st_sensors_match_odr_error: +return ret; +} + +int st_sensors_set_fullscale (struct iio_dev *indio_dev, +const struct st_sensors *sensor,unsigned int fs) +{ +int err, i; +struct st_sensor_data *sdata =iio_priv (indio_dev); + + err =st_sensors_match_fs (sensor, fs, &i); +if (err <0 ) + goto st_accel_set_fullscale_error; + + err =st_sensors_write_data_with_mask (indio_dev, + sensor->fs.addr, sensor->fs.mask, sensor->fs.fs_avl[i].value); +if (err <0 ) + goto st_accel_set_fullscale_error; + + sdata->current_fullscale = (struct st_sensor_fullscale_avl *) + &sensor->fs.fs_avl[i]; +return err; + +st_accel_set_fullscale_error: +dev_err (&indio_dev->dev,"failed to set new fullscale.\n" ); +return err; +} +EXPORT_SYMBOL (st_sensors_set_fullscale); + +int st_sensors_set_enable (struct iio_dev *indio_dev, +const struct st_sensors *sensor,bool enable) +{ +int err = -EINVAL ; +bool found; +u8 tmp_value; +struct st_sensor_odr_avl odr_out; +struct st_sensor_data *sdata =iio_priv (indio_dev); + +if (enable) { + found = false; + tmp_value = sensor->pw.value_on; +if ((sensor->odr.addr == sensor->pw.addr) && + (sensor->odr.mask == sensor->pw.mask)) { + err =st_sensors_match_odr (sensor, + sdata->odr, &odr_out); +if (err <0 ) + goto set_enable_error; + tmp_value = odr_out.value; + found = true; + } + err =st_sensors_write_data_with_mask (indio_dev, + sensor->pw.addr, sensor->pw.mask, tmp_value); +if (err <0 ) + goto set_enable_error; + sdata->enabled = true; +if (found) + sdata->odr = odr_out.hz; + }else { + err =st_sensors_write_data_with_mask (indio_dev, + sensor->pw.addr, sensor->pw.mask, + sensor->pw.value_off); +if (err <0 ) + goto set_enable_error; + sdata->enabled = false; + } + +set_enable_error: +return err; +} +EXPORT_SYMBOL (st_sensors_set_enable); + +int st_sensors_set_axis_enable (struct iio_dev *indio_dev, +const struct st_sensors *sensor,u8 axis_enable) +{ +return st_sensors_write_data_with_mask (indio_dev, + sensor->enable_axis.addr, + sensor->enable_axis.mask, axis_enable); +} +EXPORT_SYMBOL (st_sensors_set_axis_enable); + +int st_sensors_init_sensor (struct iio_dev *indio_dev, +const struct st_sensors *sensor) +{ +int err; +struct st_sensor_data *sdata =iio_priv (indio_dev); + +mutex_init (&sdata->tb.buf_lock); + + err =st_sensors_set_enable (indio_dev, sensor, false); +if (err <0 ) + goto init_error; + + err =st_sensors_set_fullscale (indio_dev, sensor, + sdata->current_fullscale->num); +if (err <0 ) + goto init_error; + + err =st_sensors_set_odr (indio_dev, sensor, sdata->odr); +if (err <0 ) + goto init_error; + +/* set BDU */ + err =st_sensors_write_data_with_mask (indio_dev, sensor->bdu.addr, + sensor->bdu.mask, true); +if (err <0 ) + goto init_error; + + err =st_sensors_set_axis_enable (indio_dev, sensor, +ST_SENSORS_ENABLE_ALL_CHANNELS ); + +init_error: +return err; +} +EXPORT_SYMBOL (st_sensors_init_sensor); + +int st_sensors_set_dataready_irq (struct iio_dev *indio_dev, +const struct st_sensors *sensor,bool enable) +{ +int err; + +/* Enable/Disable the interrupt generator 1. */ +if (sensor->drdy_irq.ig1.en_addr >0 ) { + err =st_sensors_write_data_with_mask (indio_dev, + sensor->drdy_irq.ig1.en_addr, + sensor->drdy_irq.ig1.en_mask, (int )enable); +if (err <0 ) + goto st_accel_set_dataready_irq_error; + } + +/* Enable/Disable the interrupt generator for data ready. */ + err =st_sensors_write_data_with_mask (indio_dev, + sensor->drdy_irq.addr, + sensor->drdy_irq.mask, (int )enable); + +st_accel_set_dataready_irq_error: +return err; +} +EXPORT_SYMBOL (st_sensors_set_dataready_irq); + +int st_sensors_set_fullscale_by_gain (struct iio_dev *indio_dev, +const struct st_sensors *sensor,int scale) +{ +int err = -EINVAL , i; + +for (i =0 ; i <ST_SENSORS_FULLSCALE_AVL_MAX ; i++) { +if ((sensor->fs.fs_avl[i].gain == scale) && + (sensor->fs.fs_avl[i].gain !=0 )) { + err =0 ; +break ; + } + } +if (err <0 ) + goto st_sensors_match_scale_error; + + err =st_sensors_set_fullscale (indio_dev, + sensor, sensor->fs.fs_avl[i].num); + +st_sensors_match_scale_error: +return err; +} +EXPORT_SYMBOL (st_sensors_set_fullscale_by_gain); + +static 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; + + *data = (s16 )get_unaligned_le16 (outdata); + +read_error: +return err; +} + +int st_sensors_read_info_raw (struct iio_dev *indio_dev, +struct iio_chan_spec const *ch,int *val, +const struct st_sensors *sensor) +{ +int err; +struct st_sensor_data *sdata =iio_priv (indio_dev); + +mutex_lock (&indio_dev->mlock); +if (indio_dev->currentmode ==INDIO_BUFFER_TRIGGERED ) { + err = -EBUSY ; + goto read_error; + }else { + err =st_sensors_set_enable (indio_dev, sensor, true); +if (err <0 ) + goto read_error; + +msleep ((sensor->bootime *1000 ) / sdata->odr); + err =st_sensors_read_axis_data (indio_dev, ch->address, val); +if (err <0 ) + goto read_error; + + *val = *val >> ch->scan_type.shift; + } +mutex_unlock (&indio_dev->mlock); + +return err; + +read_error: +mutex_unlock (&indio_dev->mlock); +return err; +} +EXPORT_SYMBOL (st_sensors_read_info_raw); + +int st_sensors_check_device_support (struct iio_dev *indio_dev, +int num_sensors_list,const struct st_sensors *sensors) +{ +int i, n, err; +u8 wai; +struct st_sensor_data *sdata =iio_priv (indio_dev); + + err = sdata->tf->read_byte (&sdata->tb, sdata->dev, +ST_SENSORS_DEFAULT_WAI_ADDRESS , &wai); +if (err <0 ) { +dev_err (&indio_dev->dev,"failed to read Who-Am-I register.\n" ); + goto read_wai_error; + } + +for (i =0 ; i < num_sensors_list; i++) { +if (sensors[i].wai == wai) +break ; + } +if (i == num_sensors_list) + goto device_not_supported; + +for (n =0 ; n <ARRAY_SIZE (sensors[i].sensors_supported); n++) { +if (strcmp (indio_dev->name, + &sensors[i].sensors_supported[n][0 ]) ==0 ) +break ; + } +if (n ==ARRAY_SIZE (sensors[i].sensors_supported)) { +dev_err (&indio_dev->dev,"device name and WhoAmI mismatch.\n" ); + goto sensor_name_mismatch; + } + + sdata->index = i; + +return i; + +device_not_supported: +dev_err (&indio_dev->dev,"device not supported: WhoAmI (0x%x).\n" , wai); +sensor_name_mismatch: + err = -ENODEV ; +read_wai_error: +return err; +} +EXPORT_SYMBOL (st_sensors_check_device_support); + +MODULE_AUTHOR ("Denis Ciocca <[email protected]>" ); +MODULE_DESCRIPTION ("STMicroelectronics ST-sensors core" ); +MODULE_LICENSE ("GPL v2" );drivers/iio/common/st_sensors/st_sensors_i2c.c new file +81
-0@@ -0,0 +1,81 @@ +/* +* STMicroelectronics sensors i2c library driver +* +* Copyright 2012-2013 STMicroelectronics Inc. +* +* Denis Ciocca <[email protected]> +* +* Licensed under the GPL-2. +*/ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/slab.h> +#include <linux/iio/iio.h> + +#include <linux/iio/common/st_sensors_i2c.h> + + +#define ST_SENSORS_I2C_MULTIREAD 0x80 + +static unsigned int st_sensors_i2c_get_irq (struct iio_dev *indio_dev) +{ +struct st_sensor_data *sdata =iio_priv (indio_dev); + +return to_i2c_client (sdata->dev)->irq; +} + +static int st_sensors_i2c_read_byte (struct st_sensor_transfer_buffer *tb, +struct device *dev,u8 reg_addr,u8 *res_byte) +{ +int err; + + err =i2c_smbus_read_byte_data (to_i2c_client (dev), reg_addr); +if (err <0 ) + goto st_accel_i2c_read_byte_error; + + *res_byte = err &0xff ; + +st_accel_i2c_read_byte_error: +return err <0 ? err :0 ; +} + +static int st_sensors_i2c_read_multiple_byte ( +struct st_sensor_transfer_buffer *tb,struct device *dev, +u8 reg_addr,int len,u8 *data,bool multiread_bit) +{ +if (multiread_bit == true) + reg_addr |=ST_SENSORS_I2C_MULTIREAD ; + +return i2c_smbus_read_i2c_block_data (to_i2c_client (dev), + reg_addr, len, data); +} + +static int st_sensors_i2c_write_byte (struct st_sensor_transfer_buffer *tb, +struct device *dev,u8 reg_addr,u8 data) +{ +return i2c_smbus_write_byte_data (to_i2c_client (dev), reg_addr, data); +} + +static const struct st_sensor_transfer_function st_sensors_tf_i2c = { + .read_byte = st_sensors_i2c_read_byte, + .write_byte = st_sensors_i2c_write_byte, + .read_multiple_byte = st_sensors_i2c_read_multiple_byte, +}; + +void st_sensors_i2c_configure (struct iio_dev *indio_dev, +struct i2c_client *client,struct st_sensor_data *sdata) +{ +i2c_set_clientdata (client, indio_dev); + + indio_dev->dev.parent = &client->dev; + indio_dev->name = client->name; + + sdata->tf = &st_sensors_tf_i2c; + sdata->get_irq_data_ready = st_sensors_i2c_get_irq; +} +EXPORT_SYMBOL (st_sensors_i2c_configure); + +MODULE_AUTHOR ("Denis Ciocca <[email protected]>" ); +MODULE_DESCRIPTION ("STMicroelectronics ST-sensors i2c driver" ); +MODULE_LICENSE ("GPL v2" );drivers/iio/common/st_sensors/st_sensors_spi.c new file +128
-0@@ -0,0 +1,128 @@ +/* +* STMicroelectronics sensors spi library driver +* +* Copyright 2012-2013 STMicroelectronics Inc. +* +* Denis Ciocca <[email protected]> +* +* Licensed under the GPL-2. +*/ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/slab.h> +#include <linux/iio/iio.h> + +#include <linux/iio/common/st_sensors_spi.h> + + +#define ST_SENSORS_SPI_MULTIREAD 0xc0 +#define ST_SENSORS_SPI_READ 0x80 + +static unsigned int st_sensors_spi_get_irq (struct iio_dev *indio_dev) +{ +struct st_sensor_data *sdata =iio_priv (indio_dev); + +return to_spi_device (sdata->dev)->irq; +} + +static int st_sensors_spi_read (struct st_sensor_transfer_buffer *tb, +struct device *dev,u8 reg_addr,int len,u8 *data,bool multiread_bit) +{ +struct spi_message msg; +int err; + +struct spi_transfer xfers[] = { + { + .tx_buf = tb->tx_buf, + .bits_per_word =8 , + .len =1 , + }, + { + .rx_buf = tb->rx_buf, + .bits_per_word =8 , + .len = len, + } + }; + +mutex_lock (&tb->buf_lock); +if ((multiread_bit == true) && (len >1 )) + tb->tx_buf[0 ] = reg_addr |ST_SENSORS_SPI_MULTIREAD ; +else + tb->tx_buf[0 ] = reg_addr |ST_SENSORS_SPI_READ ; + +spi_message_init (&msg); +spi_message_add_tail (&xfers[0 ], &msg); +spi_message_add_tail (&xfers[1 ], &msg); + err =spi_sync (to_spi_device (dev), &msg); +if (err) + goto acc_spi_read_error; + +memcpy (data, tb->rx_buf, len*sizeof (u8)); +mutex_unlock (&tb->buf_lock); +return len; + +acc_spi_read_error: +mutex_unlock (&tb->buf_lock); +return err; +} + +static int st_sensors_spi_read_byte (struct st_sensor_transfer_buffer *tb, +struct device *dev,u8 reg_addr,u8 *res_byte) +{ +return st_sensors_spi_read (tb, dev, reg_addr,1 , res_byte, false); +} + +static int st_sensors_spi_read_multiple_byte ( +struct st_sensor_transfer_buffer *tb,struct device *dev, +u8 reg_addr,int len,u8 *data,bool multiread_bit) +{ +return st_sensors_spi_read (tb, dev, reg_addr, len, data, multiread_bit); +} + +static int st_sensors_spi_write_byte (struct st_sensor_transfer_buffer *tb, +struct device *dev,u8 reg_addr,u8 data) +{ +struct spi_message msg; +int err; + +struct spi_transfer xfers = { + .tx_buf = tb->tx_buf, + .bits_per_word =8 , + .len =2 , + }; + +mutex_lock (&tb->buf_lock); + tb->tx_buf[0 ] = reg_addr; + tb->tx_buf[1 ] = data; + +spi_message_init (&msg); +spi_message_add_tail (&xfers, &msg); + err =spi_sync (to_spi_device (dev), &msg); +mutex_unlock (&tb->buf_lock); + +return err; +} + +static const struct st_sensor_transfer_function st_sensors_tf_spi = { + .read_byte = st_sensors_spi_read_byte, + .write_byte = st_sensors_spi_write_byte, + .read_multiple_byte = st_sensors_spi_read_multiple_byte, +}; + +void st_sensors_spi_configure (struct iio_dev *indio_dev, +struct spi_device *spi,struct st_sensor_data *sdata) +{ +spi_set_drvdata (spi, indio_dev); + + indio_dev->dev.parent = &spi->dev; + indio_dev->name = spi->modalias; + + sdata->tf = &st_sensors_tf_spi; + sdata->get_irq_data_ready = st_sensors_spi_get_irq; +} +EXPORT_SYMBOL (st_sensors_spi_configure); + +MODULE_AUTHOR ("Denis Ciocca <[email protected]>" ); +MODULE_DESCRIPTION ("STMicroelectronics ST-sensors spi driver" ); +MODULE_LICENSE ("GPL v2" );drivers/iio/common/st_sensors/st_sensors_trigger.c new file +77
-0@@ -0,0 +1,77 @@ +/* +* STMicroelectronics sensors trigger library driver +* +* Copyright 2012-2013 STMicroelectronics Inc. +* +* Denis Ciocca <[email protected]> +* +* Licensed under the GPL-2. +*/ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/slab.h> +#include <linux/iio/iio.h> +#include <linux/iio/trigger.h> +#include <linux/interrupt.h> + +#include <linux/iio/common/st_sensors.h> + + +int st_sensors_allocate_trigger (struct iio_dev *indio_dev, +struct iio_trigger_ops *trigger_ops) +{ +int err; +struct st_sensor_data *sdata =iio_priv (indio_dev); + + sdata->trig =iio_trigger_alloc ("%s-trigger" , indio_dev->name); +if (sdata->trig ==NULL ) { + err = -ENOMEM ; +dev_err (&indio_dev->dev,"failed to allocate iio trigger.\n" ); + goto iio_trigger_alloc_error; + } + + err =request_threaded_irq (sdata->get_irq_data_ready (indio_dev), + iio_trigger_generic_data_rdy_poll, +NULL , +IRQF_TRIGGER_RISING , + sdata->trig->name, + sdata->trig); +if (err) + goto request_irq_error; + + sdata->trig->private_data = indio_dev; + sdata->trig->ops = trigger_ops; + sdata->trig->dev.parent = sdata->dev; + + err =iio_trigger_register (sdata->trig); +if (err <0 ) { +dev_err (&indio_dev->dev,"failed to register iio trigger.\n" ); + goto iio_trigger_register_error; + } + indio_dev->trig = sdata->trig; + +return 0 ; + +iio_trigger_register_error: +free_irq (sdata->get_irq_data_ready (indio_dev), sdata->trig); +request_irq_error: +iio_trigger_free (sdata->trig); +iio_trigger_alloc_error: +return err; +} +EXPORT_SYMBOL (st_sensors_allocate_trigger); + +void st_sensors_deallocate_trigger (struct iio_dev *indio_dev) +{ +struct st_sensor_data *sdata =iio_priv (indio_dev); + +iio_trigger_unregister (sdata->trig); +free_irq (sdata->get_irq_data_ready (indio_dev), sdata->trig); +iio_trigger_free (sdata->trig); +} +EXPORT_SYMBOL (st_sensors_deallocate_trigger); + +MODULE_AUTHOR ("Denis Ciocca <[email protected]>" ); +MODULE_DESCRIPTION ("STMicroelectronics ST-sensors trigger" ); +MODULE_LICENSE ("GPL v2" );include/linux/iio/common/st_sensors.h new file +266
-0@@ -0,0 +1,266 @@ +/* +* STMicroelectronics sensors library driver +* +* Copyright 2012-2013 STMicroelectronics Inc. +* +* Denis Ciocca <[email protected]> +* +* Licensed under the GPL-2. +*/ + +#ifndef ST_SENSORS_H +#define ST_SENSORS_H + +#include <linux/i2c.h> +#include <linux/spi/spi.h> +#include <linux/irqreturn.h> +#include <linux/iio/trigger.h> + + +#define ST_SENSORS_TX_MAX_LENGHT 2 +#define ST_SENSORS_RX_MAX_LENGHT 6 + +#define ST_SENSORS_ODR_LIST_MAX 10 +#define ST_SENSORS_FULLSCALE_AVL_MAX 10 + +#define ST_SENSORS_NUMBER_ALL_CHANNELS 4 +#define ST_SENSORS_NUMBER_DATA_CHANNELS 3 +#define ST_SENSORS_ENABLE_ALL_CHANNELS 0x07 +#define ST_SENSORS_BYTE_FOR_CHANNEL 2 +#define ST_SENSORS_SCAN_X 0 +#define ST_SENSORS_SCAN_Y 1 +#define ST_SENSORS_SCAN_Z 2 +#define ST_SENSORS_DEFAULT_12_REALBITS 12 +#define ST_SENSORS_DEFAULT_16_REALBITS 16 +#define ST_SENSORS_DEFAULT_POWER_ON_VALUE 0x01 +#define ST_SENSORS_DEFAULT_POWER_OFF_VALUE 0x00 +#define ST_SENSORS_DEFAULT_WAI_ADDRESS 0x0f +#define ST_SENSORS_DEFAULT_AXIS_ADDR 0x20 +#define ST_SENSORS_DEFAULT_AXIS_MASK 0x07 +#define ST_SENSORS_DEFAULT_AXIS_N_BIT 3 + +#define ST_SENSORS_MAX_NAME 17 +#define ST_SENSORS_MAX_4WAI 7 + +#define ST_SENSORS_LSM_CHANNELS (device_type, index, mod, endian, bits, addr) \ +{ \ + .type = device_type, \ + .modified = 1, \ + .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ + IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \ + .scan_index = index, \ + .channel2 = mod, \ + .address = addr, \ + .scan_type = { \ + .sign = 's', \ + .realbits = bits, \ + .shift = 16 - bits, \ + .storagebits = 16, \ + .endianness = endian, \ + }, \ +} + +struct st_sensor_odr_avl { +unsigned int hz; +u8 value; +}; + +struct st_sensor_odr { +u8 addr; +u8 mask; +struct st_sensor_odr_avl odr_avl[ST_SENSORS_ODR_LIST_MAX ]; +}; + +struct st_sensor_power { +u8 addr; +u8 mask; +u8 value_off; +u8 value_on; +}; + +struct st_sensor_axis { +u8 addr; +u8 mask; +}; + +struct st_sensor_fullscale_avl { +unsigned int num; +u8 value; +unsigned int gain; +unsigned int gain2; +}; + +struct st_sensor_fullscale { +u8 addr; +u8 mask; +struct st_sensor_fullscale_avl fs_avl[ST_SENSORS_FULLSCALE_AVL_MAX ]; +}; + +/** +* struct st_sensor_bdu - ST sensor device block data update +* @addr: address of the register. +* @mask: mask to write the block data update flag. +*/ +struct st_sensor_bdu { +u8 addr; +u8 mask; +}; + +/** +* struct st_sensor_data_ready_irq - ST sensor device data-ready interrupt +* @addr: address of the register. +* @mask: mask to write the on/off value. +* struct ig1 - represents the Interrupt Generator 1 of sensors. +* @en_addr: address of the enable ig1 register. +* @en_mask: mask to write the on/off value for enable. +*/ +struct st_sensor_data_ready_irq { +u8 addr; +u8 mask; +struct { +u8 en_addr; +u8 en_mask; + } ig1; +}; + +/** +* struct st_sensor_transfer_buffer - ST sensor device I/O buffer +* @buf_lock: Mutex to protect rx and tx buffers. +* @tx_buf: Buffer used by SPI transfer function to send data to the sensors. +* This buffer is used to avoid DMA not-aligned issue. +* @rx_buf: Buffer used by SPI transfer to receive data from sensors. +* This buffer is used to avoid DMA not-aligned issue. +*/ +struct st_sensor_transfer_buffer { +struct mutex buf_lock; +u8 rx_buf[ST_SENSORS_RX_MAX_LENGHT ]; +u8 tx_buf[ST_SENSORS_TX_MAX_LENGHT ]____cacheline_aligned ; +}; + +/** +* struct st_sensor_transfer_function - ST sensor device I/O function +* @read_byte: Function used to read one byte. +* @write_byte: Function used to write one byte. +* @read_multiple_byte: Function used to read multiple byte. +*/ +struct st_sensor_transfer_function { +int (*read_byte) (struct st_sensor_transfer_buffer *tb, +struct device *dev,u8 reg_addr,u8 *res_byte); +int (*write_byte) (struct st_sensor_transfer_buffer *tb, +struct device *dev,u8 reg_addr,u8 data); +int (*read_multiple_byte) (struct st_sensor_transfer_buffer *tb, +struct device *dev,u8 reg_addr,int len,u8 *data, +bool multiread_bit); +}; + +/** +* struct st_sensor_data - ST sensor device status +* @dev: Pointer to instance of struct device (I2C or SPI). +* @trig: The trigger in use by the core driver. +* @current_fullscale: Maximum range of measure by the sensor. +* @enabled: Status of the sensor (false->off, true->on). +* @multiread_bit: Use or not particular bit for [I2C/SPI] multiread. +* @index: Number used to point the sensor being used in the st_sensors struct. +* @buffer_data: Data used by buffer part. +* @odr: Output data rate of the sensor [Hz]. +* @get_irq_data_ready: Function to get the IRQ used for data ready signal. +* @tf: Transfer function structure used by I/O operations. +* @tb: Transfer buffers and mutex used by I/O operations. +*/ +struct st_sensor_data { +struct device *dev; +struct iio_trigger *trig; +struct st_sensor_fullscale_avl *current_fullscale; + +bool enabled; +bool multiread_bit; + +short index; + +char *buffer_data; + +unsigned int odr; + +unsigned int (*get_irq_data_ready) (struct iio_dev *indio_dev); + +const struct st_sensor_transfer_function *tf; +struct st_sensor_transfer_buffer tb; +}; + +/** +* struct st_sensors - ST sensors list +* @wai: Contents of WhoAmI register. +* @sensors_supported: List of supported sensors by struct itself. +* @ch: IIO channels for the sensor. +* @odr: Output data rate register and ODR list available. +* @pw: Power register of the sensor. +* @enable_axis: Enable one or more axis of the sensor. +* @fs: Full scale register and full scale list available. +* @bdu: Block data update register. +* @drdy_irq: Data ready register of the sensor. +* @multi_read_bit: Use or not particular bit for [I2C/SPI] multi-read. +* @bootime: samples to discard when sensor passing from power-down to power-up. +*/ +struct st_sensors { +u8 wai; +char sensors_supported[ST_SENSORS_MAX_4WAI ][ST_SENSORS_MAX_NAME ]; +struct iio_chan_spec *ch; +struct st_sensor_odr odr; +struct st_sensor_power pw; +struct st_sensor_axis enable_axis; +struct st_sensor_fullscale fs; +struct st_sensor_bdu bdu; +struct st_sensor_data_ready_irq drdy_irq; +bool multi_read_bit; +unsigned int bootime; +}; + +#ifdef CONFIG_IIO_BUFFER +int st_sensors_allocate_trigger (struct iio_dev *indio_dev, +struct iio_trigger_ops *trigger_ops); + +void st_sensors_deallocate_trigger (struct iio_dev *indio_dev); + +irqreturn_t st_sensors_trigger_handler (int irq,void *p); + +int st_sensors_get_buffer_element (struct iio_dev *indio_dev,u8 *buf); +#endif + +int st_sensors_init_sensor (struct iio_dev *indio_dev, +const struct st_sensors *sensor); + +int st_sensors_set_enable (struct iio_dev *indio_dev, +const struct st_sensors *sensor,bool enable); + +int st_sensors_set_axis_enable (struct iio_dev *indio_dev, +const struct st_sensors *sensor,u8 axis_enable); + +int st_sensors_write_data_with_mask (struct iio_dev *indio_dev, +u8 reg_addr,u8 mask,u8 data); + +int st_sensors_get_sampling_frequency_avl (struct iio_dev *indio_dev, +const struct st_sensor_odr_avl *odr_avl,char *buf); + +int st_sensors_get_scale_avl (struct iio_dev *indio_dev, +const struct st_sensor_fullscale_avl *fullscale_avl,char *buf); + +int st_sensors_set_fullscale (struct iio_dev *indio_dev, +const struct st_sensors *sensor,unsigned int fs); + +int st_sensors_set_odr (struct iio_dev *indio_dev, +const struct st_sensors *sensor,unsigned int odr); + +int st_sensors_set_dataready_irq (struct iio_dev *indio_dev, +const struct st_sensors *sensor,bool enable); + +int st_sensors_set_fullscale_by_gain (struct iio_dev *indio_dev, +const struct st_sensors *sensor,int scale); + +int st_sensors_read_info_raw (struct iio_dev *indio_dev, +struct iio_chan_spec const *ch,int *val, +const struct st_sensors *sensor); + +int st_sensors_check_device_support (struct iio_dev *indio_dev, +int num_sensors_list,const struct st_sensors *sensors); + +#endif /* ST_SENSORS_H */ include/linux/iio/common/st_sensors_i2c.h new file +20
-0@@ -0,0 +1,20 @@ +/* +* STMicroelectronics sensors i2c library driver +* +* Copyright 2012-2013 STMicroelectronics Inc. +* +* Denis Ciocca <[email protected]> +* +* Licensed under the GPL-2. +*/ + +#ifndef ST_SENSORS_I2C_H +#define ST_SENSORS_I2C_H + +#include <linux/i2c.h> +#include <linux/iio/common/st_sensors.h> + +void st_sensors_i2c_configure (struct iio_dev *indio_dev, +struct i2c_client *client,struct st_sensor_data *sdata); + +#endif /* ST_SENSORS_I2C_H */ include/linux/iio/common/st_sensors_spi.h new file +20
-0@@ -0,0 +1,20 @@ +/* +* STMicroelectronics sensors spi library driver +* +* Copyright 2012-2013 STMicroelectronics Inc. +* +* Denis Ciocca <[email protected]> +* +* Licensed under the GPL-2. +*/ + +#ifndef ST_SENSORS_SPI_H +#define ST_SENSORS_SPI_H + +#include <linux/spi/spi.h> +#include <linux/iio/common/st_sensors.h> + +void st_sensors_spi_configure (struct iio_dev *indio_dev, +struct spi_device *spi,struct st_sensor_data *sdata); + +#endif /* ST_SENSORS_SPI_H */
Jonathan Cameron
maintainercover Some little cleanups and fixlets for the ST sensor drivers
These are a few remaining little bits and bobs for the driver set under review.
Jonathan Cameron (10):
iio:st_sensors drop some unused exports iio:accel:st_accel move the header from include/iio/common to . iio:gyro:st_gyro move header from linux/iio/gyro to . iio:magn:st_magn move header from linux/iio/magn/ to . iio:accel:st_accel drop unwanted EXPORT_SYMBOLS iio:gyro:st_gyro drop unwanted EXPORT_SYMBOLs iio:magn:st_magn drop unwanted EXPORT_SYMBOLs iio:accel:st_accel drop incorrect line from kconfig comment iio:gyro:st_gyro drop incorrect line from kconfig comment iio:magn:st_magn drop incorrect line from Kconfig
drivers/iio/accel/Kconfig | 1 - drivers/iio/accel/st_accel.h | 52 +++++++++++++++++++++++++ drivers/iio/accel/st_accel_buffer.c | 6 +-- drivers/iio/accel/st_accel_core.c | 6 +-- drivers/iio/accel/st_accel_i2c.c | 2 +- drivers/iio/accel/st_accel_spi.c | 2 +- drivers/iio/common/st_sensors/st_sensors_core.c | 6 +-- drivers/iio/gyro/Kconfig | 1 - drivers/iio/gyro/st_gyro.h | 50 ++++++++++++++++++++++++ drivers/iio/gyro/st_gyro_buffer.c | 5 +-- drivers/iio/gyro/st_gyro_core.c | 6 +-- drivers/iio/gyro/st_gyro_i2c.c | 2 +- drivers/iio/gyro/st_gyro_spi.c | 2 +- drivers/iio/magnetometer/Kconfig | 1 - drivers/iio/magnetometer/st_magn_buffer.c | 5 +-- drivers/iio/magnetometer/st_magn_core.c | 4 +- drivers/iio/magnetometer/st_magn_i2c.c | 2 +- drivers/iio/magnetometer/st_magn_spi.c | 2 +- include/linux/iio/accel/st_accel.h | 52 ------------------------- include/linux/iio/common/st_sensors.h | 6 --- include/linux/iio/gyro/st_gyro.h | 50 ------------------------ include/linux/iio/magnetometer/st_magn.h | 47 ---------------------- 22 files changed, 116 insertions(+), 194 deletions(-) create mode 100644 drivers/iio/accel/st_accel.h create mode 100644 drivers/iio/gyro/st_gyro.h delete mode 100644 include/linux/iio/accel/st_accel.h delete mode 100644 include/linux/iio/gyro/st_gyro.h delete mode 100644 include/linux/iio/magnetometer/st_magn.h
Signature · 1 line
1.8.1.1
Jonathan Cameron
maintainerPATCH 1/10 iio:st_sensors drop some unused exports
Apply this to the patch that introduces the library.
--- drivers/iio/common/st_sensors/st_sensors_core.c | 6 ++---- include/linux/iio/common/st_sensors.h | 6 ------ 2 files changed, 2 insertions(+), 10 deletions(-)
drivers/iio/common/st_sensors/st_sensors_core.c +2 -4
@@ -20,7 +20,7 @@#define ST_SENSORS_WAI_ADDRESS 0x0f -int st_sensors_write_data_with_mask (struct iio_dev *indio_dev, +static int st_sensors_write_data_with_mask (struct iio_dev *indio_dev,u8 reg_addr,u8 mask,u8 data) {int err;
@@ -37,7 +37,6 @@ int st_sensors_write_data_with_mask(struct iio_dev *indio_dev, st_sensors_write_data_with_mask_error:return err; } -EXPORT_SYMBOL (st_sensors_write_data_with_mask);int st_sensors_get_sampling_frequency_avl (struct iio_dev *indio_dev,const struct st_sensor_odr_avl *odr_avl,char *buf)
@@ -152,7 +151,7 @@ st_sensors_match_odr_error:return ret; } -int st_sensors_set_fullscale (struct iio_dev *indio_dev, +static int st_sensors_set_fullscale (struct iio_dev *indio_dev,const struct st_sensors *sensor,unsigned int fs) {int err, i;
@@ -175,7 +174,6 @@ st_accel_set_fullscale_error:dev_err (&indio_dev->dev,"failed to set new fullscale.\n" );return err; } -EXPORT_SYMBOL (st_sensors_set_fullscale);int st_sensors_set_enable (struct iio_dev *indio_dev,const struct st_sensors *sensor,bool enable)
include/linux/iio/common/st_sensors.h +0 -6
@@ -235,18 +235,12 @@ int st_sensors_set_enable(struct iio_dev *indio_dev,int st_sensors_set_axis_enable (struct iio_dev *indio_dev,const struct st_sensors *sensor,u8 axis_enable); -int st_sensors_write_data_with_mask (struct iio_dev *indio_dev, -u8 reg_addr,u8 mask,u8 data); -int st_sensors_get_sampling_frequency_avl (struct iio_dev *indio_dev,const struct st_sensor_odr_avl *odr_avl,char *buf);int st_sensors_get_scale_avl (struct iio_dev *indio_dev,const struct st_sensor_fullscale_avl *fullscale_avl,char *buf); -int st_sensors_set_fullscale (struct iio_dev *indio_dev, -const struct st_sensors *sensor,unsigned int fs); -int st_sensors_set_odr (struct iio_dev *indio_dev,const struct st_sensors *sensor,unsigned int odr);
Signature · 1 line
1.8.1.1
Jonathan Cameron
maintainerPATCH 2/10 iio:accel:st_accel move the header from include/iio/common to .
In reply to Jonathan CameronI can't see why this header would want to be globaly visible.
--- drivers/iio/accel/st_accel.h | 52 +++++++++++++++++++++++++++++++++++++ drivers/iio/accel/st_accel_buffer.c | 3 +-- drivers/iio/accel/st_accel_core.c | 3 +-- drivers/iio/accel/st_accel_i2c.c | 2 +- drivers/iio/accel/st_accel_spi.c | 2 +- include/linux/iio/accel/st_accel.h | 52 ------------------------------------- 6 files changed, 56 insertions(+), 58 deletions(-) create mode 100644 drivers/iio/accel/st_accel.h delete mode 100644 include/linux/iio/accel/st_accel.h
drivers/iio/accel/st_accel.h new file +52 -0
@@ -0,0 +1,52 @@ +/* +* STMicroelectronics accelerometers driver +* +* Copyright 2012-2013 STMicroelectronics Inc. +* +* Denis Ciocca <[email protected]> +* v. 1.0.0 +* Licensed under the GPL-2. +*/ + +#ifndef ST_ACCEL_H +#define ST_ACCEL_H + +#include <linux/types.h> +#include <linux/iio/common/st_sensors.h> + +#define LSM303DLH_ACCEL_DEV_NAME "lsm303dlh_accel" +#define LSM303DLHC_ACCEL_DEV_NAME "lsm303dlhc_accel" +#define LIS3DH_ACCEL_DEV_NAME "lis3dh" +#define LSM330D_ACCEL_DEV_NAME "lsm330d_accel" +#define LSM330DL_ACCEL_DEV_NAME "lsm330dl_accel" +#define LSM330DLC_ACCEL_DEV_NAME "lsm330dlc_accel" +#define LIS331DLH_ACCEL_DEV_NAME "lis331dlh" +#define LSM303DL_ACCEL_DEV_NAME "lsm303dl_accel" +#define LSM303DLM_ACCEL_DEV_NAME "lsm303dlm_accel" +#define LSM330_ACCEL_DEV_NAME "lsm330_accel" + +int st_accel_common_probe (struct iio_dev *indio_dev); +void st_accel_common_remove (struct iio_dev *indio_dev); +int st_accel_set_dataready_irq (struct iio_dev *indio_dev,bool state); +int st_accel_set_axis_enable (struct iio_dev *indio_dev,u8 active_bit); +int st_accel_set_enable (struct iio_dev *indio_dev,bool enable); + +#ifdef CONFIG_IIO_BUFFER +int st_accel_allocate_ring (struct iio_dev *indio_dev); +void st_accel_deallocate_ring (struct iio_dev *indio_dev); +int st_accel_trig_set_state (struct iio_trigger *trig,bool state); +#else /* CONFIG_IIO_BUFFER */ +static inline int st_accel_allocate_ring (struct iio_dev *indio_dev) +{ +return 0 ; +} +static inline void st_accel_deallocate_ring (struct iio_dev *indio_dev) +{ +} +static inline int st_accel_trig_set_state (struct iio_trigger *trig,bool state) +{ +return 0 ; +} +#endif /* CONFIG_IIO_BUFFER */ + +#endif /* ST_ACCEL_H */
drivers/iio/accel/st_accel_buffer.c +1 -2
@@ -21,9 +21,8 @@#include <linux/iio/trigger_consumer.h> #include <linux/iio/triggered_buffer.h> -#include <linux/iio/accel/st_accel.h> #include <linux/iio/common/st_sensors.h> - +#include "st_accel.h" int st_accel_trig_set_state (struct iio_trigger *trig,bool state) {
drivers/iio/accel/st_accel_core.c +1 -2
@@ -23,9 +23,8 @@#include <linux/iio/trigger_consumer.h> #include <linux/iio/buffer.h> -#include <linux/iio/accel/st_accel.h> #include <linux/iio/common/st_sensors.h> - +#include "st_accel.h" /* DEFAULT VALUE FOR SENSORS */ #define ST_ACCEL_DEFAULT_OUT_X_L_ADDR 0x28
drivers/iio/accel/st_accel_i2c.c +1 -1
@@ -15,9 +15,9 @@#include <linux/iio/iio.h> #include <linux/iio/trigger.h> -#include <linux/iio/accel/st_accel.h> #include <linux/iio/common/st_sensors.h> #include <linux/iio/common/st_sensors_i2c.h> +#include "st_accel.h" static int st_accel_i2c_probe (struct i2c_client *client,const struct i2c_device_id *id)
drivers/iio/accel/st_accel_spi.c +1 -1
@@ -15,9 +15,9 @@#include <linux/iio/iio.h> #include <linux/iio/trigger.h> -#include <linux/iio/accel/st_accel.h> #include <linux/iio/common/st_sensors.h> #include <linux/iio/common/st_sensors_spi.h> +#include "st_accel.h" static int st_accel_spi_probe (struct spi_device *spi) {
include/linux/iio/accel/st_accel.h deleted +0 -52
52 lines not on this page · raw message
Signature · 1 line
1.8.1.1
Jonathan Cameron
maintainerPATCH 3/10 iio:gyro:st_gyro move header from linux/iio/gyro to .
In reply to Jonathan Cameron--- drivers/iio/gyro/st_gyro.h | 50 +++++++++++++++++++++++++++++++++++++++ drivers/iio/gyro/st_gyro_buffer.c | 2 +- drivers/iio/gyro/st_gyro_core.c | 3 +-- drivers/iio/gyro/st_gyro_i2c.c | 2 +- drivers/iio/gyro/st_gyro_spi.c | 2 +- include/linux/iio/gyro/st_gyro.h | 50 --------------------------------------- 6 files changed, 54 insertions(+), 55 deletions(-) create mode 100644 drivers/iio/gyro/st_gyro.h delete mode 100644 include/linux/iio/gyro/st_gyro.h
drivers/iio/gyro/st_gyro.h new file +50 -0
@@ -0,0 +1,50 @@ +/* +* STMicroelectronics gyroscopes driver +* +* Copyright 2012-2013 STMicroelectronics Inc. +* +* Denis Ciocca <[email protected]> +* v. 1.0.0 +* Licensed under the GPL-2. +*/ + +#ifndef ST_GYRO_H +#define ST_GYRO_H + +#include <linux/types.h> +#include <linux/iio/common/st_sensors.h> + +#define L3G4200D_GYRO_DEV_NAME "l3g4200d" +#define LSM330D_GYRO_DEV_NAME "lsm330d_gyro" +#define LSM330DL_GYRO_DEV_NAME "lsm330dl_gyro" +#define LSM330DLC_GYRO_DEV_NAME "lsm330dlc_gyro" +#define L3GD20_GYRO_DEV_NAME "l3gd20" +#define L3GD20H_GYRO_DEV_NAME "l3gd20h" +#define L3G4IS_GYRO_DEV_NAME "l3g4is_ui" +#define LSM330_GYRO_DEV_NAME "lsm330_gyro" + +int st_gyro_common_probe (struct iio_dev *indio_dev); +void st_gyro_common_remove (struct iio_dev *indio_dev); +int st_gyro_set_dataready_irq (struct iio_dev *indio_dev,bool state); +int st_gyro_set_axis_enable (struct iio_dev *indio_dev,u8 active_bit); +int st_gyro_set_enable (struct iio_dev *indio_dev,bool enable); + +#ifdef CONFIG_IIO_BUFFER +int st_gyro_allocate_ring (struct iio_dev *indio_dev); +void st_gyro_deallocate_ring (struct iio_dev *indio_dev); +int st_gyro_trig_set_state (struct iio_trigger *trig,bool state); +#else /* CONFIG_IIO_BUFFER */ +static inline int st_gyro_allocate_ring (struct iio_dev *indio_dev) +{ +return 0 ; +} +static inline void st_gyro_deallocate_ring (struct iio_dev *indio_dev) +{ +} +static inline int st_gyro_trig_set_state (struct iio_trigger *trig,bool state) +{ +return 0 ; +} +#endif /* CONFIG_IIO_BUFFER */ + +#endif /* ST_GYRO_H */
drivers/iio/gyro/st_gyro_buffer.c +1 -1
@@ -21,8 +21,8 @@#include <linux/iio/trigger_consumer.h> #include <linux/iio/triggered_buffer.h> -#include <linux/iio/gyro/st_gyro.h> #include <linux/iio/common/st_sensors.h> +#include "st_gyro.h" int st_gyro_trig_set_state (struct iio_trigger *trig,bool state)
drivers/iio/gyro/st_gyro_core.c +1 -2
@@ -24,9 +24,8 @@#include <linux/iio/trigger_consumer.h> #include <linux/iio/buffer.h> -#include <linux/iio/gyro/st_gyro.h> #include <linux/iio/common/st_sensors.h> - +#include "st_gyro.h" /* DEFAULT VALUE FOR SENSORS */ #define ST_GYRO_DEFAULT_OUT_X_L_ADDR 0x28
drivers/iio/gyro/st_gyro_i2c.c +1 -1
@@ -15,9 +15,9 @@#include <linux/iio/iio.h> #include <linux/iio/trigger.h> -#include <linux/iio/gyro/st_gyro.h> #include <linux/iio/common/st_sensors.h> #include <linux/iio/common/st_sensors_i2c.h> +#include "st_gyro.h" static int st_gyro_i2c_probe (struct i2c_client *client,const struct i2c_device_id *id)
drivers/iio/gyro/st_gyro_spi.c +1 -1
@@ -15,9 +15,9 @@#include <linux/iio/iio.h> #include <linux/iio/trigger.h> -#include <linux/iio/gyro/st_gyro.h> #include <linux/iio/common/st_sensors.h> #include <linux/iio/common/st_sensors_spi.h> +#include "st_gyro.h" static int st_gyro_spi_probe (struct spi_device *spi) {
include/linux/iio/gyro/st_gyro.h deleted +0 -50
50 lines not on this page · raw message
Signature · 1 line
1.8.1.1
Jonathan Cameron
maintainerPATCH 4/10 iio:magn:st_magn move header from linux/iio/magn/ to .
In reply to Jonathan Cameron--- drivers/iio/magnetometer/st_magn_buffer.c | 3 +- drivers/iio/magnetometer/st_magn_core.c | 2 +- drivers/iio/magnetometer/st_magn_i2c.c | 2 +- drivers/iio/magnetometer/st_magn_spi.c | 2 +- include/linux/iio/magnetometer/st_magn.h | 47 ------------------------------- 5 files changed, 4 insertions(+), 52 deletions(-) delete mode 100644 include/linux/iio/magnetometer/st_magn.h
drivers/iio/magnetometer/st_magn_buffer.c +1 -2
@@ -21,9 +21,8 @@#include <linux/iio/trigger_consumer.h> #include <linux/iio/triggered_buffer.h> -#include <linux/iio/magnetometer/st_magn.h> #include <linux/iio/common/st_sensors.h> - +#include "st_magn.h" static int st_magn_buffer_preenable (struct iio_dev *indio_dev) {
drivers/iio/magnetometer/st_magn_core.c +1 -1
@@ -24,8 +24,8 @@#include <linux/iio/trigger_consumer.h> #include <linux/iio/buffer.h> -#include <linux/iio/magnetometer/st_magn.h> #include <linux/iio/common/st_sensors.h> +#include "st_magn.h" /* DEFAULT VALUE FOR SENSORS */
drivers/iio/magnetometer/st_magn_i2c.c +1 -1
@@ -15,9 +15,9 @@#include <linux/iio/iio.h> #include <linux/iio/trigger.h> -#include <linux/iio/magnetometer/st_magn.h> #include <linux/iio/common/st_sensors.h> #include <linux/iio/common/st_sensors_i2c.h> +#include "st_magn.h" static int st_magn_i2c_probe (struct i2c_client *client,const struct i2c_device_id *id)
drivers/iio/magnetometer/st_magn_spi.c +1 -1
@@ -15,9 +15,9 @@#include <linux/iio/iio.h> #include <linux/iio/trigger.h> -#include <linux/iio/magnetometer/st_magn.h> #include <linux/iio/common/st_sensors.h> #include <linux/iio/common/st_sensors_spi.h> +#include "st_magn.h" static int st_magn_spi_probe (struct spi_device *spi) {
include/linux/iio/magnetometer/st_magn.h deleted +0 -47
47 lines not on this page · raw message
Signature · 1 line
1.8.1.1
Jonathan Cameron
maintainerPATCH 5/10 iio:accel:st_accel drop unwanted EXPORT_SYMBOLS
In reply to Jonathan CameronThese no longer need exporting..
--- drivers/iio/accel/st_accel_buffer.c | 3 --- drivers/iio/accel/st_accel_core.c | 3 --- 2 files changed, 6 deletions(-)
drivers/iio/accel/st_accel_buffer.c +0 -3
@@ -29,7 +29,6 @@ int st_accel_trig_set_state(struct iio_trigger *trig, bool state)struct iio_dev *indio_dev = trig->private_data;return st_accel_set_dataready_irq (indio_dev, state); } -EXPORT_SYMBOL (st_accel_trig_set_state);static int st_accel_buffer_preenable (struct iio_dev *indio_dev) {
@@ -105,13 +104,11 @@ int st_accel_allocate_ring(struct iio_dev *indio_dev)return iio_triggered_buffer_setup (indio_dev, &iio_pollfunc_store_time, &st_sensors_trigger_handler, &st_accel_buffer_setup_ops); } -EXPORT_SYMBOL (st_accel_allocate_ring);void st_accel_deallocate_ring (struct iio_dev *indio_dev) {iio_triggered_buffer_cleanup (indio_dev); } -EXPORT_SYMBOL (st_accel_deallocate_ring);MODULE_AUTHOR ("Denis Ciocca <[email protected]>" );MODULE_DESCRIPTION ("STMicroelectronics accelerometers buffer" );
drivers/iio/accel/st_accel_core.c +0 -3
@@ -407,7 +407,6 @@ int st_accel_set_dataready_irq(struct iio_dev *indio_dev, bool state)return st_sensors_set_dataready_irq (indio_dev, &st_accel_sensors[adata->index], state); } -EXPORT_SYMBOL (st_accel_set_dataready_irq);int st_accel_set_axis_enable (struct iio_dev *indio_dev,u8 active_bit) {
@@ -416,7 +415,6 @@ int st_accel_set_axis_enable(struct iio_dev *indio_dev, u8 active_bit)return st_sensors_set_axis_enable (indio_dev, &st_accel_sensors[adata->index], active_bit); } -EXPORT_SYMBOL (st_accel_set_axis_enable);int st_accel_set_enable (struct iio_dev *indio_dev,bool enable) {
@@ -425,7 +423,6 @@ int st_accel_set_enable(struct iio_dev *indio_dev, bool enable)return st_sensors_set_enable (indio_dev, &st_accel_sensors[adata->index], enable); } -EXPORT_SYMBOL (st_accel_set_enable);static ssize_t st_accel_sysfs_set_sampling_frequency (struct device *dev,struct device_attribute *attr,const char *buf,size_t size)
Signature · 1 line
1.8.1.1
Jonathan Cameron
maintainerPATCH 6/10 iio:gyro:st_gyro drop unwanted EXPORT_SYMBOLs
In reply to Jonathan Cameron--- drivers/iio/gyro/st_gyro_buffer.c | 3 --- drivers/iio/gyro/st_gyro_core.c | 3 --- 2 files changed, 6 deletions(-)
drivers/iio/gyro/st_gyro_buffer.c +0 -3
@@ -30,7 +30,6 @@ int st_gyro_trig_set_state(struct iio_trigger *trig, bool state)struct iio_dev *indio_dev = trig->private_data;return st_gyro_set_dataready_irq (indio_dev, state); } -EXPORT_SYMBOL (st_gyro_trig_set_state);static int st_gyro_buffer_preenable (struct iio_dev *indio_dev) {
@@ -106,13 +105,11 @@ int st_gyro_allocate_ring(struct iio_dev *indio_dev)return iio_triggered_buffer_setup (indio_dev, &iio_pollfunc_store_time, &st_sensors_trigger_handler, &st_gyro_buffer_setup_ops); } -EXPORT_SYMBOL (st_gyro_allocate_ring);void st_gyro_deallocate_ring (struct iio_dev *indio_dev) {iio_triggered_buffer_cleanup (indio_dev); } -EXPORT_SYMBOL (st_gyro_deallocate_ring);MODULE_AUTHOR ("Denis Ciocca <[email protected]>" );MODULE_DESCRIPTION ("STMicroelectronics gyroscopes buffer" );
drivers/iio/gyro/st_gyro_core.c +0 -3
@@ -275,7 +275,6 @@ int st_gyro_set_dataready_irq(struct iio_dev *indio_dev, bool state)return st_sensors_set_dataready_irq (indio_dev, &st_gyro_sensors[gdata->index], state); } -EXPORT_SYMBOL (st_gyro_set_dataready_irq);int st_gyro_set_axis_enable (struct iio_dev *indio_dev,u8 active_bit) {
@@ -284,7 +283,6 @@ int st_gyro_set_axis_enable(struct iio_dev *indio_dev, u8 active_bit)return st_sensors_set_axis_enable (indio_dev, &st_gyro_sensors[gdata->index], active_bit); } -EXPORT_SYMBOL (st_gyro_set_axis_enable);int st_gyro_set_enable (struct iio_dev *indio_dev,bool enable) {
@@ -293,7 +291,6 @@ int st_gyro_set_enable(struct iio_dev *indio_dev, bool enable)return st_sensors_set_enable (indio_dev, &st_gyro_sensors[gdata->index], enable); } -EXPORT_SYMBOL (st_gyro_set_enable);static ssize_t st_gyro_sysfs_set_sampling_frequency (struct device *dev,struct device_attribute *attr,const char *buf,size_t size)
Signature · 1 line
1.8.1.1
Jonathan Cameron
maintainerPATCH 7/10 iio:magn:st_magn drop unwanted EXPORT_SYMBOLs
In reply to Jonathan Cameron--- drivers/iio/magnetometer/st_magn_buffer.c | 2 -- drivers/iio/magnetometer/st_magn_core.c | 2 -- 2 files changed, 4 deletions(-)
drivers/iio/magnetometer/st_magn_buffer.c +0 -2
@@ -88,13 +88,11 @@ int st_magn_allocate_ring(struct iio_dev *indio_dev)return iio_triggered_buffer_setup (indio_dev, &iio_pollfunc_store_time, &st_sensors_trigger_handler, &st_magn_buffer_setup_ops); } -EXPORT_SYMBOL (st_magn_allocate_ring);void st_magn_deallocate_ring (struct iio_dev *indio_dev) {iio_triggered_buffer_cleanup (indio_dev); } -EXPORT_SYMBOL (st_magn_deallocate_ring);MODULE_AUTHOR ("Denis Ciocca <[email protected]>" );MODULE_DESCRIPTION ("STMicroelectronics magnetometers buffer" );
drivers/iio/magnetometer/st_magn_core.c +0 -2
@@ -310,7 +310,6 @@ int st_magn_set_axis_enable(struct iio_dev *indio_dev, u8 active_bit) {return 0 ; } -EXPORT_SYMBOL (st_magn_set_axis_enable);int st_magn_set_enable (struct iio_dev *indio_dev,bool enable) {
@@ -319,7 +318,6 @@ int st_magn_set_enable(struct iio_dev *indio_dev, bool enable)return st_sensors_set_enable (indio_dev, &st_magn_sensors[mdata->index], enable); } -EXPORT_SYMBOL (st_magn_set_enable);static ssize_t st_magn_sysfs_set_sampling_frequency (struct device *dev,struct device_attribute *attr,const char *buf,size_t size)
Signature · 1 line
1.8.1.1
Jonathan Cameron
maintainerPATCH 8/10 iio:accel:st_accel drop incorrect line from kconfig comment
In reply to Jonathan Cameron--- drivers/iio/accel/Kconfig | 1 - 1 file changed, 1 deletion(-)
drivers/iio/accel/Kconfig +0 -1
@@ -39,7 +39,6 @@ config IIO_ST_ACCEL_3AXIS - st_accel (core functions for the driver [it is mandatory]); - st_accel_i2c (necessary for the I2C devices [optional*]); - st_accel_spi (necessary for the SPI devices [optional*]); - - st_accel_buffer (necessary for triggered buffer [optional]); (*) one of these is necessary to do something.
Signature · 1 line
1.8.1.1
Jonathan Cameron
maintainerPATCH 9/10 iio:gyro:st_gyro drop incorrect line from kconfig comment
In reply to Jonathan Cameron--- drivers/iio/gyro/Kconfig | 1 - 1 file changed, 1 deletion(-)
drivers/iio/gyro/Kconfig +0 -1
@@ -40,7 +40,6 @@ config IIO_ST_GYRO_3AXIS - st_gyro (core functions for the driver [it is mandatory]); - st_gyro_i2c (necessary for the I2C devices [optional*]); - st_gyro_spi (necessary for the SPI devices [optional*]); - - st_gyro_buffer (necessary for triggered buffer [optional]); (*) one of these is necessary to do something.
Signature · 1 line
1.8.1.1
Jonathan Cameron
maintainerPATCH 10/10 iio:magn:st_magn drop incorrect line from Kconfig
In reply to Jonathan Cameron--- drivers/iio/magnetometer/Kconfig | 1 - 1 file changed, 1 deletion(-)
drivers/iio/magnetometer/Kconfig +0 -1
@@ -31,7 +31,6 @@ config IIO_ST_MAGN_3AXIS - st_magn (core functions for the driver [it is mandatory]); - st_magn_i2c (necessary for the I2C devices [optional*]); - st_magn_spi (necessary for the SPI devices [optional*]); - - st_magn_buffer (necessary for triggered buffer [optional]); (*) one of these is necessary to do something.
Signature · 1 line
1.8.1.1
Re: [PATCH 1/4] iio:common: Add STMicroelectronics common library
In reply to Denis CIOCCAHi,
I guess we are almost there now. A couple of small things, which need to be fixed though.
Quoted 214 lines · Denis CIOCCA
This patch add a generic library for STMicroelectronics 3-axis sensors.
Signed-off-by Denis Ciocca <[email protected]>--- drivers/iio/common/Kconfig | 1 + drivers/iio/common/Makefile | 1 + drivers/iio/common/st_sensors/Kconfig | 14 + drivers/iio/common/st_sensors/Makefile | 10 + drivers/iio/common/st_sensors/st_sensors_buffer.c | 115 ++++++ drivers/iio/common/st_sensors/st_sensors_core.c | 411 +++++++++++++++++++++ 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 | 77 ++++ include/linux/iio/common/st_sensors.h | 266 +++++++++++++ include/linux/iio/common/st_sensors_i2c.h | 20 + include/linux/iio/common/st_sensors_spi.h | 20 + 12 files changed, 1144 insertions(+) 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 create mode 100644 include/linux/iio/common/st_sensors_i2c.h create mode 100644 include/linux/iio/common/st_sensors_spi.hdrivers/iio/common/Kconfig +1
-0@@ -3,3 +3,4 @@ # source "drivers/iio/common/hid-sensors/Kconfig" +source "drivers/iio/common/st_sensors/Kconfig"drivers/iio/common/Makefile +1
-0@@ -7,3 +7,4 @@ # obj-y += hid-sensors/ +obj-y += st_sensors/drivers/iio/common/st_sensors/Kconfig new file +14
-0@@ -0,0 +1,14 @@ +# +# Hid Sensor common modules +# + +config IIO_ST_SENSORS_I2C + tristate + +config IIO_ST_SENSORS_SPI + tristate + +config IIO_ST_SENSORS_CORE + tristate + select IIO_ST_SENSORS_I2C if I2C + select IIO_ST_SENSORS_SPI if SPI_MASTERdrivers/iio/common/st_sensors/Makefile new file +10
-0@@ -0,0 +1,10 @@ +# +# Makefile for the STMicroelectronics sensor common modules. +# + +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_CORE) += st_sensors.o +st_sensors-y := st_sensors_core.o +st_sensors-$(CONFIG_IIO_BUFFER) += st_sensors_buffer.o +st_sensors-$(CONFIG_IIO_TRIGGER) += st_sensors_trigger.odrivers/iio/common/st_sensors/st_sensors_buffer.c new file +115
-0@@ -0,0 +1,115 @@ +/* +* STMicroelectronics sensors buffer library driver +* +* Copyright 2012-2013 STMicroelectronics Inc. +* +* Denis Ciocca <[email protected]> +* +* Licensed under the GPL-2. +*/ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/slab.h> +#include <linux/iio/iio.h> +#include <linux/iio/trigger.h> +#include <linux/interrupt.h> +#include <linux/iio/buffer.h> +#include <linux/iio/trigger_consumer.h> +#include <linux/iio/triggered_buffer.h> +#include <linux/irqreturn.h> + +#include <linux/iio/common/st_sensors.h> + +int st_sensors_get_buffer_element (struct iio_dev *indio_dev,u8 *buf) +{ +int i, n =0 , len; +u8 addr[ST_SENSORS_NUMBER_DATA_CHANNELS ]; +struct st_sensor_data *sdata =iio_priv (indio_dev); + +for (i =0 ; i <ST_SENSORS_NUMBER_DATA_CHANNELS ; i++) { +if (test_bit (i, indio_dev->active_scan_mask)) { + addr[n] = indio_dev->channels[i].address; + n++; + } + } +switch (n) { +case 1 : + len = sdata->tf->read_multiple_byte (&sdata->tb, sdata->dev, + addr[0 ],ST_SENSORS_BYTE_FOR_CHANNEL , buf, + sdata->multiread_bit); +break ; +case 2 : +if ((addr[1 ] - addr[0 ]) ==ST_SENSORS_BYTE_FOR_CHANNEL ) { + len = sdata->tf->read_multiple_byte (&sdata->tb, + sdata->dev, addr[0 ], +ST_SENSORS_BYTE_FOR_CHANNEL *n, + buf, sdata->multiread_bit); + }else { +u8 rx_array[ST_SENSORS_BYTE_FOR_CHANNEL * +ST_SENSORS_NUMBER_DATA_CHANNELS ]; + len = sdata->tf->read_multiple_byte (&sdata->tb, + sdata->dev, addr[0 ], +ST_SENSORS_BYTE_FOR_CHANNEL * +ST_SENSORS_NUMBER_DATA_CHANNELS , + rx_array, sdata->multiread_bit); +if (len <0 ) + goto read_data_channels_error; + +for (i =0 ; i < n *ST_SENSORS_NUMBER_DATA_CHANNELS ; + i++) { +if (i < n) + buf[i] = rx_array[i]; +else + buf[i] = rx_array[n + i]; + } + len =ST_SENSORS_BYTE_FOR_CHANNEL *n; + } +break ; +case 3 : + len = sdata->tf->read_multiple_byte (&sdata->tb, sdata->dev, + addr[0 ],ST_SENSORS_BYTE_FOR_CHANNEL * +ST_SENSORS_NUMBER_DATA_CHANNELS , + buf, sdata->multiread_bit); +break ; +default : + len = -EINVAL ; + goto read_data_channels_error; + } +if (len !=ST_SENSORS_BYTE_FOR_CHANNEL *n) { + len = -EIO ; + goto read_data_channels_error; + } + +read_data_channels_error: +return len; +} +EXPORT_SYMBOL (st_sensors_get_buffer_element); + +irqreturn_t st_sensors_trigger_handler (int irq,void *p) +{ +int len; +struct iio_poll_func *pf = p; +struct iio_dev *indio_dev = pf->indio_dev; +struct st_sensor_data *sdata =iio_priv (indio_dev); + + len =st_sensors_get_buffer_element (indio_dev, sdata->buffer_data); +if (len <0 ) + goto st_sensors_get_buffer_element_error; + +if (indio_dev->scan_timestamp) + *(s64 *)((u8 *)sdata->buffer_data + +ALIGN (len,sizeof (s64))) = pf->timestamp; + +iio_push_to_buffers (indio_dev, sdata->buffer_data); + +st_sensors_get_buffer_element_error: +iio_trigger_notify_done (indio_dev->trig); + +return IRQ_HANDLED ; +} +EXPORT_SYMBOL (st_sensors_trigger_handler); + +MODULE_AUTHOR ("Denis Ciocca <[email protected]>" ); +MODULE_DESCRIPTION ("STMicroelectronics ST-sensors buffer" ); +MODULE_LICENSE ("GPL v2" );drivers/iio/common/st_sensors/st_sensors_core.c new file +5
-0@@ -0,0 +1,411 @@ +/* +* STMicroelectronics sensors core library driver +* +* Copyright 2012-2013 STMicroelectronics Inc. +*
drivers/iio/common/st_sensors/st_sensors_core.c line 15
Quoted 10 lines
drivers/iio/common/st_sensors/st_sensors_core.c new file +10
-0+* Denis Ciocca <[email protected]> +* +* Licensed under the GPL-2. +*/ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/slab.h> +#include <linux/delay.h> +#include <linux/unaligned/le_byteshift.h>
Never include that file directly. Use asm/unaligned.h, it will provide the best suited implementation of the unaligned functions for the current architecture.
Quoted 5 lines
drivers/iio/common/st_sensors/st_sensors_core.c new file +5
-0+#include <linux/iio/iio.h> + +#include <linux/iio/common/st_sensors.h> + +
[...]
Quoted 18 lines
drivers/iio/common/st_sensors/st_sensors_trigger.c new file +12
-0@@ -0,0 +1,77 @@ +/* +* STMicroelectronics sensors trigger library driver +* +* Copyright 2012-2013 STMicroelectronics Inc. +* +* Denis Ciocca <[email protected]> +* +* Licensed under the GPL-2. +*/ + +#include <linux/kernel.h> +#include <linux/module.h>
drivers/iio/common/st_sensors/st_sensors_trigger.c line 22
Quoted 10 lines
drivers/iio/common/st_sensors/st_sensors_trigger.c new file +10
-0+#include <linux/slab.h> +#include <linux/iio/iio.h> +#include <linux/iio/trigger.h> +#include <linux/interrupt.h> + +#include <linux/iio/common/st_sensors.h> + + +int st_sensors_allocate_trigger (struct iio_dev *indio_dev, +struct iio_trigger_ops *trigger_ops)
const
Quoted 1 line
drivers/iio/common/st_sensors/st_sensors_trigger.c new file +1
-0+{
[...]
PATCH 2/4 iio:accel: Add STMicroelectronics accelerometers driver
In reply to Denis CIOCCAThis patch adds a generic accelerometer driver for STMicroelectronics accelerometers, currently it supports:
LSM303DLH, LSM303DLHC, LIS3DH, LSM330D, LSM330DL, LSM330DLC, LIS331DLH, LSM303DL, LSM303DLM, LSM330.
--- drivers/iio/accel/Kconfig | 32 ++ drivers/iio/accel/Makefile | 7 + drivers/iio/accel/st_accel_buffer.c | 119 ++++++++ drivers/iio/accel/st_accel_core.c | 582 ++++++++++++++++++++++++++++++++++++ drivers/iio/accel/st_accel_i2c.c | 87 ++++++ drivers/iio/accel/st_accel_spi.c | 86 ++++++ include/linux/iio/accel/st_accel.h | 52 ++++ 7 files changed, 965 insertions(+) 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 +32 -0
@@ -14,4 +14,36 @@ 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 + select IIO_ST_ACCEL_I2C_3AXIS if (I2C) + select IIO_ST_ACCEL_SPI_3AXIS if (SPI_MASTER) + select IIO_TRIGGERED_BUFFER if (IIO_BUFFER) + select IIO_ST_ACCEL_BUFFER if (IIO_TRIGGERED_BUFFER) + 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, will be created + these modules: + - st_accel (core functions for the driver [it is mandatory]); + - st_accel_i2c (necessary for the I2C devices [optional*]); + - st_accel_spi (necessary for the SPI devices [optional*]); + - st_accel_buffer (necessary for triggered buffer [optional]); + + (*) one of these is necessary to do something. + +config IIO_ST_ACCEL_I2C_3AXIS + tristate + depends on IIO_ST_ACCEL_3AXIS + depends on IIO_ST_SENSORS_I2C + +config IIO_ST_ACCEL_SPI_3AXIS + tristate + depends on IIO_ST_ACCEL_3AXIS + depends on IIO_ST_SENSORS_SPI + endmenu
drivers/iio/accel/Makefile +7 -0
@@ -3,3 +3,10 @@ # obj-$(CONFIG_HID_SENSOR_ACCEL_3D) += hid-sensor-accel-3d.o + +obj-$(CONFIG_IIO_ST_ACCEL_3AXIS) += st_accel.o +st_accel-y := st_accel_core.o +st_accel-$(CONFIG_IIO_BUFFER) += st_accel_buffer.o + +obj-$(CONFIG_IIO_ST_ACCEL_I2C_3AXIS) += st_accel_i2c.o +obj-$(CONFIG_IIO_ST_ACCEL_SPI_3AXIS) += st_accel_spi.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 +582 -0
582 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 +52 -0
52 lines not on this page · raw message
Signature · 1 line
1.8.0.3
Re: [PATCH 2/4] iio:accel: Add STMicroelectronics accelerometers driver
Same comments apply to the gyro and magnetometer driver
[...]
Quoted 12 lines
drivers/iio/accel/st_accel_buffer.c new file +6
-0@@ -0,0 +1,119 @@ +/* +* STMicroelectronics accelerometers driver +* +* Copyright 2012-2013 STMicroelectronics Inc. +* +* Denis Ciocca <[email protected]>
drivers/iio/accel/st_accel_buffer.c line 16
Quoted 10 lines
drivers/iio/accel/st_accel_buffer.c new file +10
-0+* +* Licensed under the GPL-2. +*/ + +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/slab.h> +#include <linux/stat.h> +#include <linux/interrupt.h> +#include <linux/byteorder/generic.h>
Never include this file directly. Use asm/byteorder.h instead. But I don't think you need it here anyway, so just drop it
Quoted 10 lines
drivers/iio/accel/st_accel_buffer.c new file +10
-0+#include <linux/i2c.h> +#include <linux/delay.h> +#include <linux/iio/iio.h> +#include <linux/iio/buffer.h> +#include <linux/iio/trigger_consumer.h> +#include <linux/iio/triggered_buffer.h> + +#include <linux/iio/accel/st_accel.h> +#include <linux/iio/common/st_sensors.h> +
[...]
Quoted 6 lines
drivers/iio/accel/st_accel_core.c new file +0
-0@@ -0,0 +1,582 @@
[..]
Quoted 132 lines
drivers/iio/accel/st_accel_core.c new file +132
-0+static int st_accel_read_raw (struct iio_dev *indio_dev, +struct iio_chan_spec const *ch,int *val, +int *val2,long mask) +{ +int err; +struct st_sensor_data *adata =iio_priv (indio_dev); + +switch (mask) { +case IIO_CHAN_INFO_RAW : + err =st_sensors_read_info_raw (indio_dev, ch, val, + &st_accel_sensors[adata->index]); +if (err <0 ) + goto read_error; + +return IIO_VAL_INT ; +case IIO_CHAN_INFO_SCALE : + *val =0 ; + *val2 = adata->current_fullscale->gain; +return IIO_VAL_INT_PLUS_MICRO ; +default : +return -EINVAL ; + } + +read_error: +return err; +} + +static int st_accel_write_raw (struct iio_dev *indio_dev, +struct iio_chan_spec const *chan,int val,int val2,long mask) +{ +int err; +struct st_sensor_data *adata =iio_priv (indio_dev); + +switch (mask) { +case IIO_CHAN_INFO_SCALE : + err =st_sensors_set_fullscale_by_gain (indio_dev, + &st_accel_sensors[adata->index], val2); +break ; +default : +return -EINVAL ; + } + +return err; +} + +int st_accel_set_dataready_irq (struct iio_dev *indio_dev,bool state) +{ +struct st_sensor_data *adata =iio_priv (indio_dev); + +return st_sensors_set_dataready_irq (indio_dev, + &st_accel_sensors[adata->index], state); +} +EXPORT_SYMBOL (st_accel_set_dataready_irq); + +int st_accel_set_axis_enable (struct iio_dev *indio_dev,u8 active_bit) +{ +struct st_sensor_data *adata =iio_priv (indio_dev); + +return st_sensors_set_axis_enable (indio_dev, + &st_accel_sensors[adata->index], active_bit); +} +EXPORT_SYMBOL (st_accel_set_axis_enable); + +int st_accel_set_enable (struct iio_dev *indio_dev,bool enable) +{ +struct st_sensor_data *adata =iio_priv (indio_dev); + +return st_sensors_set_enable (indio_dev, + &st_accel_sensors[adata->index], enable); +} +EXPORT_SYMBOL (st_accel_set_enable); + +static ssize_t st_accel_sysfs_set_sampling_frequency (struct device *dev, +struct device_attribute *attr,const char *buf,size_t size) +{ +int err; +unsigned int odr; +struct iio_dev *indio_dev =dev_get_drvdata (dev); +struct st_sensor_data *adata =iio_priv (indio_dev); + + err =kstrtoint (buf,10 , &odr); +if (err <0 ) + goto conversion_error; + +mutex_lock (&indio_dev->mlock); + err =st_sensors_set_odr (indio_dev, + &st_accel_sensors[adata->index], odr); +mutex_unlock (&indio_dev->mlock); + +conversion_error: +return err <0 ? err : size; +} + +static ssize_t st_accel_sysfs_get_sampling_frequency (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct iio_dev *indio_dev =dev_get_drvdata (dev); +struct st_sensor_data *adata =iio_priv (indio_dev); + +return sprintf (buf,"%d\n" , adata->odr); +} + +static ssize_t st_accel_sysfs_scale_avail (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct iio_dev *indio_dev =dev_get_drvdata (dev); +struct st_sensor_data *adata =iio_priv (indio_dev); + +return st_sensors_get_scale_avl (indio_dev, + st_accel_sensors[adata->index].fs.fs_avl, buf); +} + +static ssize_t st_accel_sysfs_sampling_frequency_avail (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct iio_dev *indio_dev =dev_get_drvdata (dev); +struct st_sensor_data *adata =iio_priv (indio_dev); + +return st_sensors_get_sampling_frequency_avl (indio_dev, + st_accel_sensors[adata->index].odr.odr_avl, buf); +} + +static IIO_DEV_ATTR_SAMP_FREQ_AVAIL (st_accel_sysfs_sampling_frequency_avail); + +static IIO_DEVICE_ATTR(in_accel_scale_available, S_IRUGO, + st_accel_sysfs_scale_avail, NULL , 0); + +static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, + st_accel_sysfs_get_sampling_frequency, + st_accel_sysfs_set_sampling_frequency); + +static struct attribute *st_accel_attributes[] = {
drivers/iio/accel/st_accel_core.c line 500
Quoted 10 lines
drivers/iio/accel/st_accel_core.c new file +10
-0+ &iio_dev_attr_sampling_frequency_available.dev_attr.attr, + &iio_dev_attr_in_accel_scale_available.dev_attr.attr, + &iio_dev_attr_sampling_frequency.dev_attr.attr, + NULL, +}; + +static const struct attribute_group st_accel_attribute_group = { + .attrs = st_accel_attributes, +}; +
Still lots of duplication here. But wellm w
drivers/iio/accel/st_accel_core.c line 508
Quoted 8 lines
drivers/iio/accel/st_accel_core.c new file +8
-0+static const struct iio_info accel_info = { + .driver_module =THIS_MODULE , + .attrs = &st_accel_attribute_group, + .read_raw = &st_accel_read_raw, + .write_raw = &st_accel_write_raw, +}; + +static struct iio_trigger_ops st_accel_trigger_ops = {
const
drivers/iio/accel/st_accel_core.c line 510
Quoted 2 lines
drivers/iio/accel/st_accel_core.c new file +2
-0+ .owner = THIS_MODULE, + .set_trigger_state = &st_accel_trig_set_state,
Does this work if CONFIG_IIO_BUFFER is disabled? st_accel_trig_set_state is a static inline in that case. I'd move st_accel_trigger_ops to the st_accel_buffer.c and add a #define st_accel_trigger_ops NULL for the case where IIO_BUFFER is not selected.
Quoted 1 line
+};
PATCH 3/4 iio:gyro: Add STMicroelectronics gyroscopes driver
In reply to Denis CIOCCAThis patch adds a generic gyroscope driver for STMicroelectronics gyroscopes, currently it supports:
L3G4200D, LSM330DL, L3GD20, L3GD20H, LSM330DLC, L3G4IS, LSM330.
--- drivers/iio/gyro/Kconfig | 31 +++ drivers/iio/gyro/Makefile | 7 + drivers/iio/gyro/st_gyro_buffer.c | 119 ++++++++++ drivers/iio/gyro/st_gyro_core.c | 449 ++++++++++++++++++++++++++++++++++++++ drivers/iio/gyro/st_gyro_i2c.c | 85 ++++++++ drivers/iio/gyro/st_gyro_spi.c | 84 +++++++ include/linux/iio/gyro/st_gyro.h | 50 +++++ 7 files changed, 825 insertions(+) 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 +31 -0
@@ -23,4 +23,35 @@ 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 + select IIO_ST_GYRO_I2C_3AXIS if (I2C) + select IIO_ST_GYRO_SPI_3AXIS if (SPI_MASTER) + select IIO_TRIGGERED_BUFFER if (IIO_BUFFER) + select IIO_ST_GYRO_BUFFER if (IIO_TRIGGERED_BUFFER) + 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, will be created + these modules: + - st_gyro (core functions for the driver [it is mandatory]); + - st_gyro_i2c (necessary for the I2C devices [optional*]); + - st_gyro_spi (necessary for the SPI devices [optional*]); + - st_gyro_buffer (necessary for triggered buffer [optional]); + + (*) one of these is necessary to do something. + +config IIO_ST_GYRO_I2C_3AXIS + tristate + depends on IIO_ST_GYRO_3AXIS + depends on IIO_ST_SENSORS_I2C + +config IIO_ST_GYRO_SPI_3AXIS + tristate + depends on IIO_ST_GYRO_3AXIS + depends on IIO_ST_SENSORS_SPI + endmenu
drivers/iio/gyro/Makefile +7 -0
@@ -4,3 +4,10 @@ obj-$(CONFIG_ADIS16136) += adis16136.o obj-$(CONFIG_HID_SENSOR_GYRO_3D) += hid-sensor-gyro-3d.o + +obj-$(CONFIG_IIO_ST_GYRO_3AXIS) += st_gyro.o +st_gyro-y := st_gyro_core.o +st_gyro-$(CONFIG_IIO_BUFFER) += st_gyro_buffer.o + +obj-$(CONFIG_IIO_ST_GYRO_I2C_3AXIS) += st_gyro_i2c.o +obj-$(CONFIG_IIO_ST_GYRO_SPI_3AXIS) += st_gyro_spi.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 +449 -0
449 lines not on this page · raw message
drivers/iio/gyro/st_gyro_i2c.c new file +85 -0
85 lines not on this page · raw message
drivers/iio/gyro/st_gyro_spi.c new file +84 -0
84 lines not on this page · raw message
include/linux/iio/gyro/st_gyro.h new file +50 -0
50 lines not on this page · raw message
Signature · 1 line
1.8.0.3
PATCH 4/4 iio:magnetometer: Add STMicroelectronics magnetometers driver
In reply to Denis CIOCCAThis patch adds a generic magnetometer driver for STMicroelectronics magnetometers, currently it supports:
LSM303DLHC, LSM303DLM, LIS3MDL.
--- drivers/iio/magnetometer/Kconfig | 31 ++ drivers/iio/magnetometer/Makefile | 7 + drivers/iio/magnetometer/st_magn_buffer.c | 102 +++++++ drivers/iio/magnetometer/st_magn_core.c | 468 ++++++++++++++++++++++++++++++ drivers/iio/magnetometer/st_magn_i2c.c | 81 ++++++ drivers/iio/magnetometer/st_magn_spi.c | 80 +++++ include/linux/iio/magnetometer/st_magn.h | 47 +++ 7 files changed, 816 insertions(+) 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 +31 -0
@@ -14,4 +14,35 @@ 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 + select IIO_ST_MAGN_I2C_3AXIS if (I2C) + select IIO_ST_MAGN_SPI_3AXIS if (SPI_MASTER) + select IIO_TRIGGERED_BUFFER if (IIO_BUFFER) + select IIO_ST_MAGN_BUFFER if (IIO_TRIGGERED_BUFFER) + help + Say yes here to build support for STMicroelectronics magnetometers: + LSM303DLHC, LSM303DLM, LIS3MDL. + + This driver can also be built as a module. If so, will be created + these modules: + - st_magn (core functions for the driver [it is mandatory]); + - st_magn_i2c (necessary for the I2C devices [optional*]); + - st_magn_spi (necessary for the SPI devices [optional*]); + - st_magn_buffer (necessary for triggered buffer [optional]); + + (*) one of these is necessary to do something. + +config IIO_ST_MAGN_I2C_3AXIS + tristate + depends on IIO_ST_MAGN_3AXIS + depends on IIO_ST_SENSORS_I2C + +config IIO_ST_MAGN_SPI_3AXIS + tristate + depends on IIO_ST_MAGN_3AXIS + depends on IIO_ST_SENSORS_SPI + endmenu
drivers/iio/magnetometer/Makefile +7 -0
@@ -3,3 +3,10 @@ # obj-$(CONFIG_HID_SENSOR_MAGNETOMETER_3D) += hid-sensor-magn-3d.o + +obj-$(CONFIG_IIO_ST_MAGN_3AXIS) += st_magn.o +st_magn-y := st_magn_core.o +st_magn-$(CONFIG_IIO_BUFFER) += st_magn_buffer.o + +obj-$(CONFIG_IIO_ST_MAGN_I2C_3AXIS) += st_magn_i2c.o +obj-$(CONFIG_IIO_ST_MAGN_SPI_3AXIS) += st_magn_spi.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 +468 -0
468 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 +47 -0
47 lines not on this page · raw message
Signature · 1 line
1.8.0.3