* [PATCH V4 0/5] Added ST LSM303AGR sensor
@ 2015-07-21 8:35 Giuseppe Barba
2015-07-21 8:35 ` [PATCH V4 1/5] iio: st-sensors: add configuration for WhoAmI address Giuseppe Barba
` (4 more replies)
0 siblings, 5 replies; 14+ messages in thread
From: Giuseppe Barba @ 2015-07-21 8:35 UTC (permalink / raw)
To: linux-iio; +Cc: denis.ciocca, jic23, Giuseppe Barba
This patch set add support for STMicroelectronics LSM303AGR device,
which embeds an accelerometer and a magnetometer sensors.
These patches have been rebased on iio repo testing branch and tested on
Panda board.
V4:
this patch set remove some goto statement respect to V2 version and fix a
a unwrapped commit description of V3.
Giuseppe Barba (5):
iio: st-sensors: add configuration for WhoAmI address
iio: st-sensors: add support for single full scale device
iio: st_magn: Add irq trigger handling
iio: st-accel: add support for lsm303agr accelerometer
iio: st-magn: add support for lsm303agr magnetometer
.../devicetree/bindings/iio/st-sensors.txt | 2 +
drivers/iio/accel/st_accel.h | 1 +
drivers/iio/accel/st_accel_core.c | 6 ++
drivers/iio/accel/st_accel_i2c.c | 5 ++
drivers/iio/accel/st_accel_spi.c | 1 +
drivers/iio/common/st_sensors/st_sensors_core.c | 52 ++++++------
drivers/iio/gyro/st_gyro_core.c | 3 +
drivers/iio/magnetometer/st_magn.h | 3 +
drivers/iio/magnetometer/st_magn_buffer.c | 7 ++
drivers/iio/magnetometer/st_magn_core.c | 98 +++++++++++++++++++++-
drivers/iio/magnetometer/st_magn_i2c.c | 5 ++
drivers/iio/magnetometer/st_magn_spi.c | 1 +
drivers/iio/pressure/st_pressure_core.c | 3 +
include/linux/iio/common/st_sensors.h | 2 +
14 files changed, 162 insertions(+), 27 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH V4 1/5] iio: st-sensors: add configuration for WhoAmI address
2015-07-21 8:35 [PATCH V4 0/5] Added ST LSM303AGR sensor Giuseppe Barba
@ 2015-07-21 8:35 ` Giuseppe Barba
2015-07-21 10:43 ` Denis Ciocca
2015-07-21 8:35 ` [PATCH V4 2/5] iio: st-sensors: add support for single full scale device Giuseppe Barba
` (3 subsequent siblings)
4 siblings, 1 reply; 14+ messages in thread
From: Giuseppe Barba @ 2015-07-21 8:35 UTC (permalink / raw)
To: linux-iio; +Cc: denis.ciocca, jic23, Giuseppe Barba
This patch permits to configure the WhoAmI register address
because some device could have not a standard address for
this register.
Signed-off-by: Giuseppe Barba <giuseppe.barba@st.com>
---
drivers/iio/accel/st_accel_core.c | 5 +++
drivers/iio/common/st_sensors/st_sensors_core.c | 49 ++++++++++++-------------
drivers/iio/gyro/st_gyro_core.c | 3 ++
drivers/iio/magnetometer/st_magn_core.c | 3 ++
drivers/iio/pressure/st_pressure_core.c | 3 ++
include/linux/iio/common/st_sensors.h | 2 +
6 files changed, 39 insertions(+), 26 deletions(-)
diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
index 4002e64..12b42f6 100644
--- a/drivers/iio/accel/st_accel_core.c
+++ b/drivers/iio/accel/st_accel_core.c
@@ -226,6 +226,7 @@ static const struct iio_chan_spec st_accel_16bit_channels[] = {
static const struct st_sensor_settings st_accel_sensors_settings[] = {
{
.wai = ST_ACCEL_1_WAI_EXP,
+ .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
.sensors_supported = {
[0] = LIS3DH_ACCEL_DEV_NAME,
[1] = LSM303DLHC_ACCEL_DEV_NAME,
@@ -297,6 +298,7 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
},
{
.wai = ST_ACCEL_2_WAI_EXP,
+ .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
.sensors_supported = {
[0] = LIS331DLH_ACCEL_DEV_NAME,
[1] = LSM303DL_ACCEL_DEV_NAME,
@@ -359,6 +361,7 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
},
{
.wai = ST_ACCEL_3_WAI_EXP,
+ .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
.sensors_supported = {
[0] = LSM330_ACCEL_DEV_NAME,
},
@@ -437,6 +440,7 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
},
{
.wai = ST_ACCEL_4_WAI_EXP,
+ .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
.sensors_supported = {
[0] = LIS3LV02DL_ACCEL_DEV_NAME,
},
@@ -494,6 +498,7 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
},
{
.wai = ST_ACCEL_5_WAI_EXP,
+ .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
.sensors_supported = {
[0] = LIS331DL_ACCEL_DEV_NAME,
},
diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
index 8086cbc..d44bf16 100644
--- a/drivers/iio/common/st_sensors/st_sensors_core.c
+++ b/drivers/iio/common/st_sensors/st_sensors_core.c
@@ -479,46 +479,43 @@ int st_sensors_check_device_support(struct iio_dev *indio_dev,
int num_sensors_list,
const struct st_sensor_settings *sensor_settings)
{
- u8 wai;
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 (sensor_settings[i].wai == wai)
+ for (n = 0; n < ST_SENSORS_MAX_4WAI; n++) {
+ if (strcmp(indio_dev->name,
+ sensor_settings[i].sensors_supported[n]) == 0) {
+ break;
+ }
+ }
+ if (n < ST_SENSORS_MAX_4WAI)
break;
}
- if (i == num_sensors_list)
- goto device_not_supported;
+ if (i == num_sensors_list) {
+ dev_err(&indio_dev->dev, "device name %s not recognized.\n",
+ indio_dev->name);
+ return -ENODEV;
+ }
- for (n = 0; n < ARRAY_SIZE(sensor_settings[i].sensors_supported); n++) {
- if (strcmp(indio_dev->name,
- &sensor_settings[i].sensors_supported[n][0]) == 0)
- break;
+ err = sdata->tf->read_byte(&sdata->tb, sdata->dev,
+ sensor_settings[i].wai_addr, &wai);
+ if (err < 0) {
+ dev_err(&indio_dev->dev, "failed to read Who-Am-I register.\n");
+ return err;
}
- if (n == ARRAY_SIZE(sensor_settings[i].sensors_supported)) {
- dev_err(&indio_dev->dev, "device name \"%s\" and WhoAmI (0x%02x) mismatch",
- indio_dev->name, wai);
- goto sensor_name_mismatch;
+
+ if (sensor_settings[i].wai != wai) {
+ dev_err(&indio_dev->dev, "%s: WhoAmI mismatch (0x%x).\n",
+ indio_dev->name, wai);
+ return -EINVAL;
}
sdata->sensor_settings =
(struct st_sensor_settings *)&sensor_settings[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);
diff --git a/drivers/iio/gyro/st_gyro_core.c b/drivers/iio/gyro/st_gyro_core.c
index ffe9664..4b993a5 100644
--- a/drivers/iio/gyro/st_gyro_core.c
+++ b/drivers/iio/gyro/st_gyro_core.c
@@ -131,6 +131,7 @@ static const struct iio_chan_spec st_gyro_16bit_channels[] = {
static const struct st_sensor_settings st_gyro_sensors_settings[] = {
{
.wai = ST_GYRO_1_WAI_EXP,
+ .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
.sensors_supported = {
[0] = L3G4200D_GYRO_DEV_NAME,
[1] = LSM330DL_GYRO_DEV_NAME,
@@ -190,6 +191,7 @@ static const struct st_sensor_settings st_gyro_sensors_settings[] = {
},
{
.wai = ST_GYRO_2_WAI_EXP,
+ .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
.sensors_supported = {
[0] = L3GD20_GYRO_DEV_NAME,
[1] = LSM330D_GYRO_DEV_NAME,
@@ -252,6 +254,7 @@ static const struct st_sensor_settings st_gyro_sensors_settings[] = {
},
{
.wai = ST_GYRO_3_WAI_EXP,
+ .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
.sensors_supported = {
[0] = L3GD20_GYRO_DEV_NAME,
},
diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c
index b4bcfb7..8d7d3a1 100644
--- a/drivers/iio/magnetometer/st_magn_core.c
+++ b/drivers/iio/magnetometer/st_magn_core.c
@@ -192,6 +192,7 @@ static const struct iio_chan_spec st_magn_2_16bit_channels[] = {
static const struct st_sensor_settings st_magn_sensors_settings[] = {
{
.wai = 0, /* This sensor has no valid WhoAmI report 0 */
+ .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
.sensors_supported = {
[0] = LSM303DLH_MAGN_DEV_NAME,
},
@@ -268,6 +269,7 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = {
},
{
.wai = ST_MAGN_1_WAI_EXP,
+ .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
.sensors_supported = {
[0] = LSM303DLHC_MAGN_DEV_NAME,
[1] = LSM303DLM_MAGN_DEV_NAME,
@@ -346,6 +348,7 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = {
},
{
.wai = ST_MAGN_2_WAI_EXP,
+ .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
.sensors_supported = {
[0] = LIS3MDL_MAGN_DEV_NAME,
},
diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c
index e881fa6..eb41d2b 100644
--- a/drivers/iio/pressure/st_pressure_core.c
+++ b/drivers/iio/pressure/st_pressure_core.c
@@ -178,6 +178,7 @@ static const struct iio_chan_spec st_press_lps001wp_channels[] = {
static const struct st_sensor_settings st_press_sensors_settings[] = {
{
.wai = ST_PRESS_LPS331AP_WAI_EXP,
+ .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
.sensors_supported = {
[0] = LPS331AP_PRESS_DEV_NAME,
},
@@ -225,6 +226,7 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
},
{
.wai = ST_PRESS_LPS001WP_WAI_EXP,
+ .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
.sensors_supported = {
[0] = LPS001WP_PRESS_DEV_NAME,
},
@@ -260,6 +262,7 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
},
{
.wai = ST_PRESS_LPS25H_WAI_EXP,
+ .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
.sensors_supported = {
[0] = LPS25H_PRESS_DEV_NAME,
},
diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h
index 2c476ac..3c17cd7 100644
--- a/include/linux/iio/common/st_sensors.h
+++ b/include/linux/iio/common/st_sensors.h
@@ -166,6 +166,7 @@ struct st_sensor_transfer_function {
/**
* struct st_sensor_settings - ST specific sensor settings
* @wai: Contents of WhoAmI register.
+ * @wai_addr: The address 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.
@@ -179,6 +180,7 @@ struct st_sensor_transfer_function {
*/
struct st_sensor_settings {
u8 wai;
+ u8 wai_addr;
char sensors_supported[ST_SENSORS_MAX_4WAI][ST_SENSORS_MAX_NAME];
struct iio_chan_spec *ch;
int num_ch;
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH V4 2/5] iio: st-sensors: add support for single full scale device
2015-07-21 8:35 [PATCH V4 0/5] Added ST LSM303AGR sensor Giuseppe Barba
2015-07-21 8:35 ` [PATCH V4 1/5] iio: st-sensors: add configuration for WhoAmI address Giuseppe Barba
@ 2015-07-21 8:35 ` Giuseppe Barba
2015-07-21 10:44 ` Denis Ciocca
2015-07-21 8:35 ` [PATCH V4 3/5] iio: st_magn: Add irq trigger handling Giuseppe Barba
` (2 subsequent siblings)
4 siblings, 1 reply; 14+ messages in thread
From: Giuseppe Barba @ 2015-07-21 8:35 UTC (permalink / raw)
To: linux-iio; +Cc: denis.ciocca, jic23, Giuseppe Barba
Some sensors could have only one full scale value. This means that the
sensor hasn't a full scale register. This commit add a check on the
configured full scale address to support such kind of sensors.
Signed-off-by: Giuseppe Barba <giuseppe.barba@st.com>
---
drivers/iio/common/st_sensors/st_sensors_core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
index d44bf16..2e7fdb5 100644
--- a/drivers/iio/common/st_sensors/st_sensors_core.c
+++ b/drivers/iio/common/st_sensors/st_sensors_core.c
@@ -126,6 +126,9 @@ static int st_sensors_set_fullscale(struct iio_dev *indio_dev, unsigned int fs)
int err, i = 0;
struct st_sensor_data *sdata = iio_priv(indio_dev);
+ if (sdata->sensor_settings->fs.addr == 0)
+ return 0;
+
err = st_sensors_match_fs(sdata->sensor_settings, fs, &i);
if (err < 0)
goto st_accel_set_fullscale_error;
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH V4 3/5] iio: st_magn: Add irq trigger handling
2015-07-21 8:35 [PATCH V4 0/5] Added ST LSM303AGR sensor Giuseppe Barba
2015-07-21 8:35 ` [PATCH V4 1/5] iio: st-sensors: add configuration for WhoAmI address Giuseppe Barba
2015-07-21 8:35 ` [PATCH V4 2/5] iio: st-sensors: add support for single full scale device Giuseppe Barba
@ 2015-07-21 8:35 ` Giuseppe Barba
2015-07-21 10:44 ` Denis Ciocca
2015-07-21 8:35 ` [PATCH V4 4/5] iio: st-accel: add support for lsm303agr accelerometer Giuseppe Barba
2015-07-21 8:35 ` [PATCH V4 5/5] iio: st-magn: add support for lsm303agr magnetometer Giuseppe Barba
4 siblings, 1 reply; 14+ messages in thread
From: Giuseppe Barba @ 2015-07-21 8:35 UTC (permalink / raw)
To: linux-iio; +Cc: denis.ciocca, jic23, Giuseppe Barba
Add irq trigger handling for magnetometer also
Signed-off-by: Giuseppe Barba <giuseppe.barba@st.com>
---
drivers/iio/magnetometer/st_magn.h | 2 ++
drivers/iio/magnetometer/st_magn_buffer.c | 7 +++++++
drivers/iio/magnetometer/st_magn_core.c | 13 ++++++++++++-
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/magnetometer/st_magn.h b/drivers/iio/magnetometer/st_magn.h
index 287691c..60441023 100644
--- a/drivers/iio/magnetometer/st_magn.h
+++ b/drivers/iio/magnetometer/st_magn.h
@@ -25,6 +25,8 @@ void st_magn_common_remove(struct iio_dev *indio_dev);
#ifdef CONFIG_IIO_BUFFER
int st_magn_allocate_ring(struct iio_dev *indio_dev);
void st_magn_deallocate_ring(struct iio_dev *indio_dev);
+int st_magn_trig_set_state(struct iio_trigger *trig, bool state);
+#define ST_MAGN_TRIGGER_SET_STATE (&st_magn_trig_set_state)
#else /* CONFIG_IIO_BUFFER */
static inline int st_magn_probe_trigger(struct iio_dev *indio_dev, int irq)
{
diff --git a/drivers/iio/magnetometer/st_magn_buffer.c b/drivers/iio/magnetometer/st_magn_buffer.c
index bf427dc..ecd3bd0 100644
--- a/drivers/iio/magnetometer/st_magn_buffer.c
+++ b/drivers/iio/magnetometer/st_magn_buffer.c
@@ -23,6 +23,13 @@
#include <linux/iio/common/st_sensors.h>
#include "st_magn.h"
+int st_magn_trig_set_state(struct iio_trigger *trig, bool state)
+{
+ struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
+
+ return st_sensors_set_dataready_irq(indio_dev, state);
+}
+
static int st_magn_buffer_preenable(struct iio_dev *indio_dev)
{
return st_sensors_set_enable(indio_dev, true);
diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c
index 8d7d3a1..4c0cef8 100644
--- a/drivers/iio/magnetometer/st_magn_core.c
+++ b/drivers/iio/magnetometer/st_magn_core.c
@@ -480,6 +480,16 @@ static const struct iio_info magn_info = {
.write_raw = &st_magn_write_raw,
};
+#ifdef CONFIG_IIO_TRIGGER
+static const struct iio_trigger_ops st_magn_trigger_ops = {
+ .owner = THIS_MODULE,
+ .set_trigger_state = ST_MAGN_TRIGGER_SET_STATE,
+};
+#define ST_MAGN_TRIGGER_OPS (&st_magn_trigger_ops)
+#else
+#define ST_MAGN_TRIGGER_OPS NULL
+#endif
+
int st_magn_common_probe(struct iio_dev *indio_dev)
{
struct st_sensor_data *mdata = iio_priv(indio_dev);
@@ -516,7 +526,8 @@ int st_magn_common_probe(struct iio_dev *indio_dev)
return err;
if (irq > 0) {
- err = st_sensors_allocate_trigger(indio_dev, NULL);
+ err = st_sensors_allocate_trigger(indio_dev,
+ ST_MAGN_TRIGGER_OPS);
if (err < 0)
goto st_magn_probe_trigger_error;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH V4 4/5] iio: st-accel: add support for lsm303agr accelerometer
2015-07-21 8:35 [PATCH V4 0/5] Added ST LSM303AGR sensor Giuseppe Barba
` (2 preceding siblings ...)
2015-07-21 8:35 ` [PATCH V4 3/5] iio: st_magn: Add irq trigger handling Giuseppe Barba
@ 2015-07-21 8:35 ` Giuseppe Barba
2015-07-21 10:44 ` Denis Ciocca
2015-07-21 8:35 ` [PATCH V4 5/5] iio: st-magn: add support for lsm303agr magnetometer Giuseppe Barba
4 siblings, 1 reply; 14+ messages in thread
From: Giuseppe Barba @ 2015-07-21 8:35 UTC (permalink / raw)
To: linux-iio; +Cc: denis.ciocca, jic23, Giuseppe Barba
This adds support for the lsm303agr accelerometer.
Signed-off-by: Giuseppe Barba <giuseppe.barba@st.com>
---
Documentation/devicetree/bindings/iio/st-sensors.txt | 1 +
drivers/iio/accel/st_accel.h | 1 +
drivers/iio/accel/st_accel_core.c | 1 +
drivers/iio/accel/st_accel_i2c.c | 5 +++++
drivers/iio/accel/st_accel_spi.c | 1 +
5 files changed, 9 insertions(+)
diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt
index 8a6be3b..d80bdaa 100644
--- a/Documentation/devicetree/bindings/iio/st-sensors.txt
+++ b/Documentation/devicetree/bindings/iio/st-sensors.txt
@@ -35,6 +35,7 @@ Accelerometers:
- st,lsm303dl-accel
- st,lsm303dlm-accel
- st,lsm330-accel
+- st,lsm303agr-accel
Gyroscopes:
- st,l3g4200d-gyro
diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h
index aa10019..468f21f 100644
--- a/drivers/iio/accel/st_accel.h
+++ b/drivers/iio/accel/st_accel.h
@@ -26,6 +26,7 @@
#define LSM303DLH_ACCEL_DEV_NAME "lsm303dlh_accel"
#define LSM303DLM_ACCEL_DEV_NAME "lsm303dlm_accel"
#define LSM330_ACCEL_DEV_NAME "lsm330_accel"
+#define LSM303AGR_ACCEL_DEV_NAME "lsm303agr_accel"
/**
* struct st_sensors_platform_data - default accel platform data
diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
index 12b42f6..ff30f88 100644
--- a/drivers/iio/accel/st_accel_core.c
+++ b/drivers/iio/accel/st_accel_core.c
@@ -233,6 +233,7 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
[2] = LSM330D_ACCEL_DEV_NAME,
[3] = LSM330DL_ACCEL_DEV_NAME,
[4] = LSM330DLC_ACCEL_DEV_NAME,
+ [5] = LSM303AGR_ACCEL_DEV_NAME,
},
.ch = (struct iio_chan_spec *)st_accel_12bit_channels,
.odr = {
diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c
index a2f1c20..8b9cc84 100644
--- a/drivers/iio/accel/st_accel_i2c.c
+++ b/drivers/iio/accel/st_accel_i2c.c
@@ -68,6 +68,10 @@ static const struct of_device_id st_accel_of_match[] = {
.compatible = "st,lsm330-accel",
.data = LSM330_ACCEL_DEV_NAME,
},
+ {
+ .compatible = "st,lsm303agr-accel",
+ .data = LSM303AGR_ACCEL_DEV_NAME,
+ },
{},
};
MODULE_DEVICE_TABLE(of, st_accel_of_match);
@@ -116,6 +120,7 @@ static const struct i2c_device_id st_accel_id_table[] = {
{ LSM303DL_ACCEL_DEV_NAME },
{ LSM303DLM_ACCEL_DEV_NAME },
{ LSM330_ACCEL_DEV_NAME },
+ { LSM303AGR_ACCEL_DEV_NAME },
{},
};
MODULE_DEVICE_TABLE(i2c, st_accel_id_table);
diff --git a/drivers/iio/accel/st_accel_spi.c b/drivers/iio/accel/st_accel_spi.c
index 12ec293..54b61a3 100644
--- a/drivers/iio/accel/st_accel_spi.c
+++ b/drivers/iio/accel/st_accel_spi.c
@@ -57,6 +57,7 @@ static const struct spi_device_id st_accel_id_table[] = {
{ LSM303DL_ACCEL_DEV_NAME },
{ LSM303DLM_ACCEL_DEV_NAME },
{ LSM330_ACCEL_DEV_NAME },
+ { LSM303AGR_ACCEL_DEV_NAME },
{},
};
MODULE_DEVICE_TABLE(spi, st_accel_id_table);
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH V4 5/5] iio: st-magn: add support for lsm303agr magnetometer
2015-07-21 8:35 [PATCH V4 0/5] Added ST LSM303AGR sensor Giuseppe Barba
` (3 preceding siblings ...)
2015-07-21 8:35 ` [PATCH V4 4/5] iio: st-accel: add support for lsm303agr accelerometer Giuseppe Barba
@ 2015-07-21 8:35 ` Giuseppe Barba
2015-07-21 10:44 ` Denis Ciocca
4 siblings, 1 reply; 14+ messages in thread
From: Giuseppe Barba @ 2015-07-21 8:35 UTC (permalink / raw)
To: linux-iio; +Cc: denis.ciocca, jic23, Giuseppe Barba
This adds support for the lsm303agr magnetometer.
Signed-off-by: Giuseppe Barba <giuseppe.barba@st.com>
---
.../devicetree/bindings/iio/st-sensors.txt | 1 +
drivers/iio/magnetometer/st_magn.h | 1 +
drivers/iio/magnetometer/st_magn_core.c | 82 ++++++++++++++++++++++
drivers/iio/magnetometer/st_magn_i2c.c | 5 ++
drivers/iio/magnetometer/st_magn_spi.c | 1 +
5 files changed, 90 insertions(+)
diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt
index d80bdaa..d3ccdb1 100644
--- a/Documentation/devicetree/bindings/iio/st-sensors.txt
+++ b/Documentation/devicetree/bindings/iio/st-sensors.txt
@@ -47,6 +47,7 @@ Gyroscopes:
- st,lsm330-gyro
Magnetometers:
+- st,lsm303agr-magn
- st,lsm303dlh-magn
- st,lsm303dlhc-magn
- st,lsm303dlm-magn
diff --git a/drivers/iio/magnetometer/st_magn.h b/drivers/iio/magnetometer/st_magn.h
index 60441023..06a4d9c 100644
--- a/drivers/iio/magnetometer/st_magn.h
+++ b/drivers/iio/magnetometer/st_magn.h
@@ -18,6 +18,7 @@
#define LSM303DLHC_MAGN_DEV_NAME "lsm303dlhc_magn"
#define LSM303DLM_MAGN_DEV_NAME "lsm303dlm_magn"
#define LIS3MDL_MAGN_DEV_NAME "lis3mdl"
+#define LSM303AGR_MAGN_DEV_NAME "lsm303agr_magn"
int st_magn_common_probe(struct iio_dev *indio_dev);
void st_magn_common_remove(struct iio_dev *indio_dev);
diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c
index 4c0cef8..f8dc4b8 100644
--- a/drivers/iio/magnetometer/st_magn_core.c
+++ b/drivers/iio/magnetometer/st_magn_core.c
@@ -43,6 +43,7 @@
#define ST_MAGN_FS_AVL_8000MG 8000
#define ST_MAGN_FS_AVL_8100MG 8100
#define ST_MAGN_FS_AVL_12000MG 12000
+#define ST_MAGN_FS_AVL_15000MG 15000
#define ST_MAGN_FS_AVL_16000MG 16000
/* CUSTOM VALUES FOR SENSOR 0 */
@@ -157,6 +158,29 @@
#define ST_MAGN_2_OUT_Y_L_ADDR 0x2a
#define ST_MAGN_2_OUT_Z_L_ADDR 0x2c
+/* CUSTOM VALUES FOR SENSOR 3 */
+#define ST_MAGN_3_WAI_ADDR 0x4f
+#define ST_MAGN_3_WAI_EXP 0x40
+#define ST_MAGN_3_ODR_ADDR 0x60
+#define ST_MAGN_3_ODR_MASK 0x0c
+#define ST_MAGN_3_ODR_AVL_10HZ_VAL 0x00
+#define ST_MAGN_3_ODR_AVL_20HZ_VAL 0x01
+#define ST_MAGN_3_ODR_AVL_50HZ_VAL 0x02
+#define ST_MAGN_3_ODR_AVL_100HZ_VAL 0x03
+#define ST_MAGN_3_PW_ADDR 0x60
+#define ST_MAGN_3_PW_MASK 0x03
+#define ST_MAGN_3_PW_ON 0x00
+#define ST_MAGN_3_PW_OFF 0x03
+#define ST_MAGN_3_BDU_ADDR 0x62
+#define ST_MAGN_3_BDU_MASK 0x10
+#define ST_MAGN_3_DRDY_IRQ_ADDR 0x62
+#define ST_MAGN_3_DRDY_INT_MASK 0x01
+#define ST_MAGN_3_FS_AVL_15000_GAIN 1500
+#define ST_MAGN_3_MULTIREAD_BIT false
+#define ST_MAGN_3_OUT_X_L_ADDR 0x68
+#define ST_MAGN_3_OUT_Y_L_ADDR 0x6a
+#define ST_MAGN_3_OUT_Z_L_ADDR 0x6c
+
static const struct iio_chan_spec st_magn_16bit_channels[] = {
ST_SENSORS_LSM_CHANNELS(IIO_MAGN,
BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
@@ -189,6 +213,22 @@ static const struct iio_chan_spec st_magn_2_16bit_channels[] = {
IIO_CHAN_SOFT_TIMESTAMP(3)
};
+static const struct iio_chan_spec st_magn_3_16bit_channels[] = {
+ ST_SENSORS_LSM_CHANNELS(IIO_MAGN,
+ BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
+ ST_SENSORS_SCAN_X, 1, IIO_MOD_X, 's', IIO_LE, 16, 16,
+ ST_MAGN_3_OUT_X_L_ADDR),
+ ST_SENSORS_LSM_CHANNELS(IIO_MAGN,
+ BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
+ ST_SENSORS_SCAN_Y, 1, IIO_MOD_Y, 's', IIO_LE, 16, 16,
+ ST_MAGN_3_OUT_Y_L_ADDR),
+ ST_SENSORS_LSM_CHANNELS(IIO_MAGN,
+ BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
+ ST_SENSORS_SCAN_Z, 1, IIO_MOD_Z, 's', IIO_LE, 16, 16,
+ ST_MAGN_3_OUT_Z_L_ADDR),
+ IIO_CHAN_SOFT_TIMESTAMP(3)
+};
+
static const struct st_sensor_settings st_magn_sensors_settings[] = {
{
.wai = 0, /* This sensor has no valid WhoAmI report 0 */
@@ -402,6 +442,48 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = {
.multi_read_bit = ST_MAGN_2_MULTIREAD_BIT,
.bootime = 2,
},
+ {
+ .wai = ST_MAGN_3_WAI_EXP,
+ .wai_addr = ST_MAGN_3_WAI_ADDR,
+ .sensors_supported = {
+ [0] = LSM303AGR_MAGN_DEV_NAME,
+ },
+ .ch = (struct iio_chan_spec *)st_magn_3_16bit_channels,
+ .odr = {
+ .addr = ST_MAGN_3_ODR_ADDR,
+ .mask = ST_MAGN_3_ODR_MASK,
+ .odr_avl = {
+ { 10, ST_MAGN_3_ODR_AVL_10HZ_VAL, },
+ { 20, ST_MAGN_3_ODR_AVL_20HZ_VAL, },
+ { 50, ST_MAGN_3_ODR_AVL_50HZ_VAL, },
+ { 100, ST_MAGN_3_ODR_AVL_100HZ_VAL, },
+ },
+ },
+ .pw = {
+ .addr = ST_MAGN_3_PW_ADDR,
+ .mask = ST_MAGN_3_PW_MASK,
+ .value_on = ST_MAGN_3_PW_ON,
+ .value_off = ST_MAGN_3_PW_OFF,
+ },
+ .fs = {
+ .fs_avl = {
+ [0] = {
+ .num = ST_MAGN_FS_AVL_15000MG,
+ .gain = ST_MAGN_3_FS_AVL_15000_GAIN,
+ },
+ },
+ },
+ .bdu = {
+ .addr = ST_MAGN_3_BDU_ADDR,
+ .mask = ST_MAGN_3_BDU_MASK,
+ },
+ .drdy_irq = {
+ .addr = ST_MAGN_3_DRDY_IRQ_ADDR,
+ .mask_int1 = ST_MAGN_3_DRDY_INT_MASK,
+ },
+ .multi_read_bit = ST_MAGN_3_MULTIREAD_BIT,
+ .bootime = 2,
+ },
};
static int st_magn_read_raw(struct iio_dev *indio_dev,
diff --git a/drivers/iio/magnetometer/st_magn_i2c.c b/drivers/iio/magnetometer/st_magn_i2c.c
index 28aa807..8aa37af 100644
--- a/drivers/iio/magnetometer/st_magn_i2c.c
+++ b/drivers/iio/magnetometer/st_magn_i2c.c
@@ -36,6 +36,10 @@ static const struct of_device_id st_magn_of_match[] = {
.compatible = "st,lis3mdl-magn",
.data = LIS3MDL_MAGN_DEV_NAME,
},
+ {
+ .compatible = "st,lsm303agr-magn",
+ .data = LSM303AGR_MAGN_DEV_NAME,
+ },
{},
};
MODULE_DEVICE_TABLE(of, st_magn_of_match);
@@ -79,6 +83,7 @@ static const struct i2c_device_id st_magn_id_table[] = {
{ LSM303DLHC_MAGN_DEV_NAME },
{ LSM303DLM_MAGN_DEV_NAME },
{ LIS3MDL_MAGN_DEV_NAME },
+ { LSM303AGR_MAGN_DEV_NAME },
{},
};
MODULE_DEVICE_TABLE(i2c, st_magn_id_table);
diff --git a/drivers/iio/magnetometer/st_magn_spi.c b/drivers/iio/magnetometer/st_magn_spi.c
index 7adacf1..0abca2c 100644
--- a/drivers/iio/magnetometer/st_magn_spi.c
+++ b/drivers/iio/magnetometer/st_magn_spi.c
@@ -51,6 +51,7 @@ static const struct spi_device_id st_magn_id_table[] = {
{ LSM303DLHC_MAGN_DEV_NAME },
{ LSM303DLM_MAGN_DEV_NAME },
{ LIS3MDL_MAGN_DEV_NAME },
+ { LSM303AGR_MAGN_DEV_NAME },
{},
};
MODULE_DEVICE_TABLE(spi, st_magn_id_table);
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH V4 1/5] iio: st-sensors: add configuration for WhoAmI address
2015-07-21 8:35 ` [PATCH V4 1/5] iio: st-sensors: add configuration for WhoAmI address Giuseppe Barba
@ 2015-07-21 10:43 ` Denis Ciocca
2015-07-23 19:36 ` Jonathan Cameron
0 siblings, 1 reply; 14+ messages in thread
From: Denis Ciocca @ 2015-07-21 10:43 UTC (permalink / raw)
To: Giuseppe BARBA, linux-iio; +Cc: jic23
Thanks Giuseppe,
good for me.
Reviewed-by: Denis Ciocca <denis.ciocca@st.com>
Acked-by: Denis Ciocca <denis.ciocca@st.com>
BR,
Denis
On 07/21/2015 04:35 PM, Giuseppe BARBA wrote:
> This patch permits to configure the WhoAmI register address
> because some device could have not a standard address for
> this register.
>
> Signed-off-by: Giuseppe Barba <giuseppe.barba@st.com>
> ---
> drivers/iio/accel/st_accel_core.c | 5 +++
> drivers/iio/common/st_sensors/st_sensors_core.c | 49 ++++++++++++-------------
> drivers/iio/gyro/st_gyro_core.c | 3 ++
> drivers/iio/magnetometer/st_magn_core.c | 3 ++
> drivers/iio/pressure/st_pressure_core.c | 3 ++
> include/linux/iio/common/st_sensors.h | 2 +
> 6 files changed, 39 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
> index 4002e64..12b42f6 100644
> --- a/drivers/iio/accel/st_accel_core.c
> +++ b/drivers/iio/accel/st_accel_core.c
> @@ -226,6 +226,7 @@ static const struct iio_chan_spec st_accel_16bit_channels[] = {
> static const struct st_sensor_settings st_accel_sensors_settings[] = {
> {
> .wai = ST_ACCEL_1_WAI_EXP,
> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
> .sensors_supported = {
> [0] = LIS3DH_ACCEL_DEV_NAME,
> [1] = LSM303DLHC_ACCEL_DEV_NAME,
> @@ -297,6 +298,7 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
> },
> {
> .wai = ST_ACCEL_2_WAI_EXP,
> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
> .sensors_supported = {
> [0] = LIS331DLH_ACCEL_DEV_NAME,
> [1] = LSM303DL_ACCEL_DEV_NAME,
> @@ -359,6 +361,7 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
> },
> {
> .wai = ST_ACCEL_3_WAI_EXP,
> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
> .sensors_supported = {
> [0] = LSM330_ACCEL_DEV_NAME,
> },
> @@ -437,6 +440,7 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
> },
> {
> .wai = ST_ACCEL_4_WAI_EXP,
> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
> .sensors_supported = {
> [0] = LIS3LV02DL_ACCEL_DEV_NAME,
> },
> @@ -494,6 +498,7 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
> },
> {
> .wai = ST_ACCEL_5_WAI_EXP,
> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
> .sensors_supported = {
> [0] = LIS331DL_ACCEL_DEV_NAME,
> },
> diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
> index 8086cbc..d44bf16 100644
> --- a/drivers/iio/common/st_sensors/st_sensors_core.c
> +++ b/drivers/iio/common/st_sensors/st_sensors_core.c
> @@ -479,46 +479,43 @@ int st_sensors_check_device_support(struct iio_dev *indio_dev,
> int num_sensors_list,
> const struct st_sensor_settings *sensor_settings)
> {
> - u8 wai;
> 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 (sensor_settings[i].wai == wai)
> + for (n = 0; n < ST_SENSORS_MAX_4WAI; n++) {
> + if (strcmp(indio_dev->name,
> + sensor_settings[i].sensors_supported[n]) == 0) {
> + break;
> + }
> + }
> + if (n < ST_SENSORS_MAX_4WAI)
> break;
> }
> - if (i == num_sensors_list)
> - goto device_not_supported;
> + if (i == num_sensors_list) {
> + dev_err(&indio_dev->dev, "device name %s not recognized.\n",
> + indio_dev->name);
> + return -ENODEV;
> + }
>
> - for (n = 0; n < ARRAY_SIZE(sensor_settings[i].sensors_supported); n++) {
> - if (strcmp(indio_dev->name,
> - &sensor_settings[i].sensors_supported[n][0]) == 0)
> - break;
> + err = sdata->tf->read_byte(&sdata->tb, sdata->dev,
> + sensor_settings[i].wai_addr, &wai);
> + if (err < 0) {
> + dev_err(&indio_dev->dev, "failed to read Who-Am-I register.\n");
> + return err;
> }
> - if (n == ARRAY_SIZE(sensor_settings[i].sensors_supported)) {
> - dev_err(&indio_dev->dev, "device name \"%s\" and WhoAmI (0x%02x) mismatch",
> - indio_dev->name, wai);
> - goto sensor_name_mismatch;
> +
> + if (sensor_settings[i].wai != wai) {
> + dev_err(&indio_dev->dev, "%s: WhoAmI mismatch (0x%x).\n",
> + indio_dev->name, wai);
> + return -EINVAL;
> }
>
> sdata->sensor_settings =
> (struct st_sensor_settings *)&sensor_settings[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);
>
> diff --git a/drivers/iio/gyro/st_gyro_core.c b/drivers/iio/gyro/st_gyro_core.c
> index ffe9664..4b993a5 100644
> --- a/drivers/iio/gyro/st_gyro_core.c
> +++ b/drivers/iio/gyro/st_gyro_core.c
> @@ -131,6 +131,7 @@ static const struct iio_chan_spec st_gyro_16bit_channels[] = {
> static const struct st_sensor_settings st_gyro_sensors_settings[] = {
> {
> .wai = ST_GYRO_1_WAI_EXP,
> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
> .sensors_supported = {
> [0] = L3G4200D_GYRO_DEV_NAME,
> [1] = LSM330DL_GYRO_DEV_NAME,
> @@ -190,6 +191,7 @@ static const struct st_sensor_settings st_gyro_sensors_settings[] = {
> },
> {
> .wai = ST_GYRO_2_WAI_EXP,
> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
> .sensors_supported = {
> [0] = L3GD20_GYRO_DEV_NAME,
> [1] = LSM330D_GYRO_DEV_NAME,
> @@ -252,6 +254,7 @@ static const struct st_sensor_settings st_gyro_sensors_settings[] = {
> },
> {
> .wai = ST_GYRO_3_WAI_EXP,
> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
> .sensors_supported = {
> [0] = L3GD20_GYRO_DEV_NAME,
> },
> diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c
> index b4bcfb7..8d7d3a1 100644
> --- a/drivers/iio/magnetometer/st_magn_core.c
> +++ b/drivers/iio/magnetometer/st_magn_core.c
> @@ -192,6 +192,7 @@ static const struct iio_chan_spec st_magn_2_16bit_channels[] = {
> static const struct st_sensor_settings st_magn_sensors_settings[] = {
> {
> .wai = 0, /* This sensor has no valid WhoAmI report 0 */
> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
> .sensors_supported = {
> [0] = LSM303DLH_MAGN_DEV_NAME,
> },
> @@ -268,6 +269,7 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = {
> },
> {
> .wai = ST_MAGN_1_WAI_EXP,
> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
> .sensors_supported = {
> [0] = LSM303DLHC_MAGN_DEV_NAME,
> [1] = LSM303DLM_MAGN_DEV_NAME,
> @@ -346,6 +348,7 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = {
> },
> {
> .wai = ST_MAGN_2_WAI_EXP,
> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
> .sensors_supported = {
> [0] = LIS3MDL_MAGN_DEV_NAME,
> },
> diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c
> index e881fa6..eb41d2b 100644
> --- a/drivers/iio/pressure/st_pressure_core.c
> +++ b/drivers/iio/pressure/st_pressure_core.c
> @@ -178,6 +178,7 @@ static const struct iio_chan_spec st_press_lps001wp_channels[] = {
> static const struct st_sensor_settings st_press_sensors_settings[] = {
> {
> .wai = ST_PRESS_LPS331AP_WAI_EXP,
> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
> .sensors_supported = {
> [0] = LPS331AP_PRESS_DEV_NAME,
> },
> @@ -225,6 +226,7 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
> },
> {
> .wai = ST_PRESS_LPS001WP_WAI_EXP,
> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
> .sensors_supported = {
> [0] = LPS001WP_PRESS_DEV_NAME,
> },
> @@ -260,6 +262,7 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
> },
> {
> .wai = ST_PRESS_LPS25H_WAI_EXP,
> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
> .sensors_supported = {
> [0] = LPS25H_PRESS_DEV_NAME,
> },
> diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h
> index 2c476ac..3c17cd7 100644
> --- a/include/linux/iio/common/st_sensors.h
> +++ b/include/linux/iio/common/st_sensors.h
> @@ -166,6 +166,7 @@ struct st_sensor_transfer_function {
> /**
> * struct st_sensor_settings - ST specific sensor settings
> * @wai: Contents of WhoAmI register.
> + * @wai_addr: The address 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.
> @@ -179,6 +180,7 @@ struct st_sensor_transfer_function {
> */
> struct st_sensor_settings {
> u8 wai;
> + u8 wai_addr;
> char sensors_supported[ST_SENSORS_MAX_4WAI][ST_SENSORS_MAX_NAME];
> struct iio_chan_spec *ch;
> int num_ch;
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH V4 2/5] iio: st-sensors: add support for single full scale device
2015-07-21 8:35 ` [PATCH V4 2/5] iio: st-sensors: add support for single full scale device Giuseppe Barba
@ 2015-07-21 10:44 ` Denis Ciocca
0 siblings, 0 replies; 14+ messages in thread
From: Denis Ciocca @ 2015-07-21 10:44 UTC (permalink / raw)
To: Giuseppe BARBA, linux-iio; +Cc: jic23
Acked-by: Denis Ciocca <denis.ciocca@st.com>
On 07/21/2015 04:35 PM, Giuseppe BARBA wrote:
> Some sensors could have only one full scale value. This means that the
> sensor hasn't a full scale register. This commit add a check on the
> configured full scale address to support such kind of sensors.
>
> Signed-off-by: Giuseppe Barba <giuseppe.barba@st.com>
> ---
> drivers/iio/common/st_sensors/st_sensors_core.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
> index d44bf16..2e7fdb5 100644
> --- a/drivers/iio/common/st_sensors/st_sensors_core.c
> +++ b/drivers/iio/common/st_sensors/st_sensors_core.c
> @@ -126,6 +126,9 @@ static int st_sensors_set_fullscale(struct iio_dev *indio_dev, unsigned int fs)
> int err, i = 0;
> struct st_sensor_data *sdata = iio_priv(indio_dev);
>
> + if (sdata->sensor_settings->fs.addr == 0)
> + return 0;
> +
> err = st_sensors_match_fs(sdata->sensor_settings, fs, &i);
> if (err < 0)
> goto st_accel_set_fullscale_error;
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH V4 3/5] iio: st_magn: Add irq trigger handling
2015-07-21 8:35 ` [PATCH V4 3/5] iio: st_magn: Add irq trigger handling Giuseppe Barba
@ 2015-07-21 10:44 ` Denis Ciocca
0 siblings, 0 replies; 14+ messages in thread
From: Denis Ciocca @ 2015-07-21 10:44 UTC (permalink / raw)
To: Giuseppe BARBA, linux-iio; +Cc: jic23
Acked-by: Denis Ciocca <denis.ciocca@st.com>
On 07/21/2015 04:35 PM, Giuseppe BARBA wrote:
> Add irq trigger handling for magnetometer also
>
> Signed-off-by: Giuseppe Barba <giuseppe.barba@st.com>
> ---
> drivers/iio/magnetometer/st_magn.h | 2 ++
> drivers/iio/magnetometer/st_magn_buffer.c | 7 +++++++
> drivers/iio/magnetometer/st_magn_core.c | 13 ++++++++++++-
> 3 files changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/magnetometer/st_magn.h b/drivers/iio/magnetometer/st_magn.h
> index 287691c..60441023 100644
> --- a/drivers/iio/magnetometer/st_magn.h
> +++ b/drivers/iio/magnetometer/st_magn.h
> @@ -25,6 +25,8 @@ void st_magn_common_remove(struct iio_dev *indio_dev);
> #ifdef CONFIG_IIO_BUFFER
> int st_magn_allocate_ring(struct iio_dev *indio_dev);
> void st_magn_deallocate_ring(struct iio_dev *indio_dev);
> +int st_magn_trig_set_state(struct iio_trigger *trig, bool state);
> +#define ST_MAGN_TRIGGER_SET_STATE (&st_magn_trig_set_state)
> #else /* CONFIG_IIO_BUFFER */
> static inline int st_magn_probe_trigger(struct iio_dev *indio_dev, int irq)
> {
> diff --git a/drivers/iio/magnetometer/st_magn_buffer.c b/drivers/iio/magnetometer/st_magn_buffer.c
> index bf427dc..ecd3bd0 100644
> --- a/drivers/iio/magnetometer/st_magn_buffer.c
> +++ b/drivers/iio/magnetometer/st_magn_buffer.c
> @@ -23,6 +23,13 @@
> #include <linux/iio/common/st_sensors.h>
> #include "st_magn.h"
>
> +int st_magn_trig_set_state(struct iio_trigger *trig, bool state)
> +{
> + struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
> +
> + return st_sensors_set_dataready_irq(indio_dev, state);
> +}
> +
> static int st_magn_buffer_preenable(struct iio_dev *indio_dev)
> {
> return st_sensors_set_enable(indio_dev, true);
> diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c
> index 8d7d3a1..4c0cef8 100644
> --- a/drivers/iio/magnetometer/st_magn_core.c
> +++ b/drivers/iio/magnetometer/st_magn_core.c
> @@ -480,6 +480,16 @@ static const struct iio_info magn_info = {
> .write_raw = &st_magn_write_raw,
> };
>
> +#ifdef CONFIG_IIO_TRIGGER
> +static const struct iio_trigger_ops st_magn_trigger_ops = {
> + .owner = THIS_MODULE,
> + .set_trigger_state = ST_MAGN_TRIGGER_SET_STATE,
> +};
> +#define ST_MAGN_TRIGGER_OPS (&st_magn_trigger_ops)
> +#else
> +#define ST_MAGN_TRIGGER_OPS NULL
> +#endif
> +
> int st_magn_common_probe(struct iio_dev *indio_dev)
> {
> struct st_sensor_data *mdata = iio_priv(indio_dev);
> @@ -516,7 +526,8 @@ int st_magn_common_probe(struct iio_dev *indio_dev)
> return err;
>
> if (irq > 0) {
> - err = st_sensors_allocate_trigger(indio_dev, NULL);
> + err = st_sensors_allocate_trigger(indio_dev,
> + ST_MAGN_TRIGGER_OPS);
> if (err < 0)
> goto st_magn_probe_trigger_error;
> }
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH V4 4/5] iio: st-accel: add support for lsm303agr accelerometer
2015-07-21 8:35 ` [PATCH V4 4/5] iio: st-accel: add support for lsm303agr accelerometer Giuseppe Barba
@ 2015-07-21 10:44 ` Denis Ciocca
2015-07-23 19:40 ` Jonathan Cameron
0 siblings, 1 reply; 14+ messages in thread
From: Denis Ciocca @ 2015-07-21 10:44 UTC (permalink / raw)
To: Giuseppe BARBA, linux-iio; +Cc: jic23
Acked-by: Denis Ciocca <denis.ciocca@st.com>
On 07/21/2015 04:35 PM, Giuseppe BARBA wrote:
> This adds support for the lsm303agr accelerometer.
>
> Signed-off-by: Giuseppe Barba <giuseppe.barba@st.com>
> ---
> Documentation/devicetree/bindings/iio/st-sensors.txt | 1 +
> drivers/iio/accel/st_accel.h | 1 +
> drivers/iio/accel/st_accel_core.c | 1 +
> drivers/iio/accel/st_accel_i2c.c | 5 +++++
> drivers/iio/accel/st_accel_spi.c | 1 +
> 5 files changed, 9 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt
> index 8a6be3b..d80bdaa 100644
> --- a/Documentation/devicetree/bindings/iio/st-sensors.txt
> +++ b/Documentation/devicetree/bindings/iio/st-sensors.txt
> @@ -35,6 +35,7 @@ Accelerometers:
> - st,lsm303dl-accel
> - st,lsm303dlm-accel
> - st,lsm330-accel
> +- st,lsm303agr-accel
>
> Gyroscopes:
> - st,l3g4200d-gyro
> diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h
> index aa10019..468f21f 100644
> --- a/drivers/iio/accel/st_accel.h
> +++ b/drivers/iio/accel/st_accel.h
> @@ -26,6 +26,7 @@
> #define LSM303DLH_ACCEL_DEV_NAME "lsm303dlh_accel"
> #define LSM303DLM_ACCEL_DEV_NAME "lsm303dlm_accel"
> #define LSM330_ACCEL_DEV_NAME "lsm330_accel"
> +#define LSM303AGR_ACCEL_DEV_NAME "lsm303agr_accel"
>
> /**
> * struct st_sensors_platform_data - default accel platform data
> diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
> index 12b42f6..ff30f88 100644
> --- a/drivers/iio/accel/st_accel_core.c
> +++ b/drivers/iio/accel/st_accel_core.c
> @@ -233,6 +233,7 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
> [2] = LSM330D_ACCEL_DEV_NAME,
> [3] = LSM330DL_ACCEL_DEV_NAME,
> [4] = LSM330DLC_ACCEL_DEV_NAME,
> + [5] = LSM303AGR_ACCEL_DEV_NAME,
> },
> .ch = (struct iio_chan_spec *)st_accel_12bit_channels,
> .odr = {
> diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c
> index a2f1c20..8b9cc84 100644
> --- a/drivers/iio/accel/st_accel_i2c.c
> +++ b/drivers/iio/accel/st_accel_i2c.c
> @@ -68,6 +68,10 @@ static const struct of_device_id st_accel_of_match[] = {
> .compatible = "st,lsm330-accel",
> .data = LSM330_ACCEL_DEV_NAME,
> },
> + {
> + .compatible = "st,lsm303agr-accel",
> + .data = LSM303AGR_ACCEL_DEV_NAME,
> + },
> {},
> };
> MODULE_DEVICE_TABLE(of, st_accel_of_match);
> @@ -116,6 +120,7 @@ static const struct i2c_device_id st_accel_id_table[] = {
> { LSM303DL_ACCEL_DEV_NAME },
> { LSM303DLM_ACCEL_DEV_NAME },
> { LSM330_ACCEL_DEV_NAME },
> + { LSM303AGR_ACCEL_DEV_NAME },
> {},
> };
> MODULE_DEVICE_TABLE(i2c, st_accel_id_table);
> diff --git a/drivers/iio/accel/st_accel_spi.c b/drivers/iio/accel/st_accel_spi.c
> index 12ec293..54b61a3 100644
> --- a/drivers/iio/accel/st_accel_spi.c
> +++ b/drivers/iio/accel/st_accel_spi.c
> @@ -57,6 +57,7 @@ static const struct spi_device_id st_accel_id_table[] = {
> { LSM303DL_ACCEL_DEV_NAME },
> { LSM303DLM_ACCEL_DEV_NAME },
> { LSM330_ACCEL_DEV_NAME },
> + { LSM303AGR_ACCEL_DEV_NAME },
> {},
> };
> MODULE_DEVICE_TABLE(spi, st_accel_id_table);
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH V4 5/5] iio: st-magn: add support for lsm303agr magnetometer
2015-07-21 8:35 ` [PATCH V4 5/5] iio: st-magn: add support for lsm303agr magnetometer Giuseppe Barba
@ 2015-07-21 10:44 ` Denis Ciocca
2015-07-23 19:42 ` Jonathan Cameron
0 siblings, 1 reply; 14+ messages in thread
From: Denis Ciocca @ 2015-07-21 10:44 UTC (permalink / raw)
To: Giuseppe BARBA, linux-iio; +Cc: jic23
Acked-by: Denis Ciocca <denis.ciocca@st.com>
On 07/21/2015 04:35 PM, Giuseppe BARBA wrote:
> This adds support for the lsm303agr magnetometer.
>
> Signed-off-by: Giuseppe Barba <giuseppe.barba@st.com>
> ---
> .../devicetree/bindings/iio/st-sensors.txt | 1 +
> drivers/iio/magnetometer/st_magn.h | 1 +
> drivers/iio/magnetometer/st_magn_core.c | 82 ++++++++++++++++++++++
> drivers/iio/magnetometer/st_magn_i2c.c | 5 ++
> drivers/iio/magnetometer/st_magn_spi.c | 1 +
> 5 files changed, 90 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt
> index d80bdaa..d3ccdb1 100644
> --- a/Documentation/devicetree/bindings/iio/st-sensors.txt
> +++ b/Documentation/devicetree/bindings/iio/st-sensors.txt
> @@ -47,6 +47,7 @@ Gyroscopes:
> - st,lsm330-gyro
>
> Magnetometers:
> +- st,lsm303agr-magn
> - st,lsm303dlh-magn
> - st,lsm303dlhc-magn
> - st,lsm303dlm-magn
> diff --git a/drivers/iio/magnetometer/st_magn.h b/drivers/iio/magnetometer/st_magn.h
> index 60441023..06a4d9c 100644
> --- a/drivers/iio/magnetometer/st_magn.h
> +++ b/drivers/iio/magnetometer/st_magn.h
> @@ -18,6 +18,7 @@
> #define LSM303DLHC_MAGN_DEV_NAME "lsm303dlhc_magn"
> #define LSM303DLM_MAGN_DEV_NAME "lsm303dlm_magn"
> #define LIS3MDL_MAGN_DEV_NAME "lis3mdl"
> +#define LSM303AGR_MAGN_DEV_NAME "lsm303agr_magn"
>
> int st_magn_common_probe(struct iio_dev *indio_dev);
> void st_magn_common_remove(struct iio_dev *indio_dev);
> diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c
> index 4c0cef8..f8dc4b8 100644
> --- a/drivers/iio/magnetometer/st_magn_core.c
> +++ b/drivers/iio/magnetometer/st_magn_core.c
> @@ -43,6 +43,7 @@
> #define ST_MAGN_FS_AVL_8000MG 8000
> #define ST_MAGN_FS_AVL_8100MG 8100
> #define ST_MAGN_FS_AVL_12000MG 12000
> +#define ST_MAGN_FS_AVL_15000MG 15000
> #define ST_MAGN_FS_AVL_16000MG 16000
>
> /* CUSTOM VALUES FOR SENSOR 0 */
> @@ -157,6 +158,29 @@
> #define ST_MAGN_2_OUT_Y_L_ADDR 0x2a
> #define ST_MAGN_2_OUT_Z_L_ADDR 0x2c
>
> +/* CUSTOM VALUES FOR SENSOR 3 */
> +#define ST_MAGN_3_WAI_ADDR 0x4f
> +#define ST_MAGN_3_WAI_EXP 0x40
> +#define ST_MAGN_3_ODR_ADDR 0x60
> +#define ST_MAGN_3_ODR_MASK 0x0c
> +#define ST_MAGN_3_ODR_AVL_10HZ_VAL 0x00
> +#define ST_MAGN_3_ODR_AVL_20HZ_VAL 0x01
> +#define ST_MAGN_3_ODR_AVL_50HZ_VAL 0x02
> +#define ST_MAGN_3_ODR_AVL_100HZ_VAL 0x03
> +#define ST_MAGN_3_PW_ADDR 0x60
> +#define ST_MAGN_3_PW_MASK 0x03
> +#define ST_MAGN_3_PW_ON 0x00
> +#define ST_MAGN_3_PW_OFF 0x03
> +#define ST_MAGN_3_BDU_ADDR 0x62
> +#define ST_MAGN_3_BDU_MASK 0x10
> +#define ST_MAGN_3_DRDY_IRQ_ADDR 0x62
> +#define ST_MAGN_3_DRDY_INT_MASK 0x01
> +#define ST_MAGN_3_FS_AVL_15000_GAIN 1500
> +#define ST_MAGN_3_MULTIREAD_BIT false
> +#define ST_MAGN_3_OUT_X_L_ADDR 0x68
> +#define ST_MAGN_3_OUT_Y_L_ADDR 0x6a
> +#define ST_MAGN_3_OUT_Z_L_ADDR 0x6c
> +
> static const struct iio_chan_spec st_magn_16bit_channels[] = {
> ST_SENSORS_LSM_CHANNELS(IIO_MAGN,
> BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> @@ -189,6 +213,22 @@ static const struct iio_chan_spec st_magn_2_16bit_channels[] = {
> IIO_CHAN_SOFT_TIMESTAMP(3)
> };
>
> +static const struct iio_chan_spec st_magn_3_16bit_channels[] = {
> + ST_SENSORS_LSM_CHANNELS(IIO_MAGN,
> + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> + ST_SENSORS_SCAN_X, 1, IIO_MOD_X, 's', IIO_LE, 16, 16,
> + ST_MAGN_3_OUT_X_L_ADDR),
> + ST_SENSORS_LSM_CHANNELS(IIO_MAGN,
> + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> + ST_SENSORS_SCAN_Y, 1, IIO_MOD_Y, 's', IIO_LE, 16, 16,
> + ST_MAGN_3_OUT_Y_L_ADDR),
> + ST_SENSORS_LSM_CHANNELS(IIO_MAGN,
> + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> + ST_SENSORS_SCAN_Z, 1, IIO_MOD_Z, 's', IIO_LE, 16, 16,
> + ST_MAGN_3_OUT_Z_L_ADDR),
> + IIO_CHAN_SOFT_TIMESTAMP(3)
> +};
> +
> static const struct st_sensor_settings st_magn_sensors_settings[] = {
> {
> .wai = 0, /* This sensor has no valid WhoAmI report 0 */
> @@ -402,6 +442,48 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = {
> .multi_read_bit = ST_MAGN_2_MULTIREAD_BIT,
> .bootime = 2,
> },
> + {
> + .wai = ST_MAGN_3_WAI_EXP,
> + .wai_addr = ST_MAGN_3_WAI_ADDR,
> + .sensors_supported = {
> + [0] = LSM303AGR_MAGN_DEV_NAME,
> + },
> + .ch = (struct iio_chan_spec *)st_magn_3_16bit_channels,
> + .odr = {
> + .addr = ST_MAGN_3_ODR_ADDR,
> + .mask = ST_MAGN_3_ODR_MASK,
> + .odr_avl = {
> + { 10, ST_MAGN_3_ODR_AVL_10HZ_VAL, },
> + { 20, ST_MAGN_3_ODR_AVL_20HZ_VAL, },
> + { 50, ST_MAGN_3_ODR_AVL_50HZ_VAL, },
> + { 100, ST_MAGN_3_ODR_AVL_100HZ_VAL, },
> + },
> + },
> + .pw = {
> + .addr = ST_MAGN_3_PW_ADDR,
> + .mask = ST_MAGN_3_PW_MASK,
> + .value_on = ST_MAGN_3_PW_ON,
> + .value_off = ST_MAGN_3_PW_OFF,
> + },
> + .fs = {
> + .fs_avl = {
> + [0] = {
> + .num = ST_MAGN_FS_AVL_15000MG,
> + .gain = ST_MAGN_3_FS_AVL_15000_GAIN,
> + },
> + },
> + },
> + .bdu = {
> + .addr = ST_MAGN_3_BDU_ADDR,
> + .mask = ST_MAGN_3_BDU_MASK,
> + },
> + .drdy_irq = {
> + .addr = ST_MAGN_3_DRDY_IRQ_ADDR,
> + .mask_int1 = ST_MAGN_3_DRDY_INT_MASK,
> + },
> + .multi_read_bit = ST_MAGN_3_MULTIREAD_BIT,
> + .bootime = 2,
> + },
> };
>
> static int st_magn_read_raw(struct iio_dev *indio_dev,
> diff --git a/drivers/iio/magnetometer/st_magn_i2c.c b/drivers/iio/magnetometer/st_magn_i2c.c
> index 28aa807..8aa37af 100644
> --- a/drivers/iio/magnetometer/st_magn_i2c.c
> +++ b/drivers/iio/magnetometer/st_magn_i2c.c
> @@ -36,6 +36,10 @@ static const struct of_device_id st_magn_of_match[] = {
> .compatible = "st,lis3mdl-magn",
> .data = LIS3MDL_MAGN_DEV_NAME,
> },
> + {
> + .compatible = "st,lsm303agr-magn",
> + .data = LSM303AGR_MAGN_DEV_NAME,
> + },
> {},
> };
> MODULE_DEVICE_TABLE(of, st_magn_of_match);
> @@ -79,6 +83,7 @@ static const struct i2c_device_id st_magn_id_table[] = {
> { LSM303DLHC_MAGN_DEV_NAME },
> { LSM303DLM_MAGN_DEV_NAME },
> { LIS3MDL_MAGN_DEV_NAME },
> + { LSM303AGR_MAGN_DEV_NAME },
> {},
> };
> MODULE_DEVICE_TABLE(i2c, st_magn_id_table);
> diff --git a/drivers/iio/magnetometer/st_magn_spi.c b/drivers/iio/magnetometer/st_magn_spi.c
> index 7adacf1..0abca2c 100644
> --- a/drivers/iio/magnetometer/st_magn_spi.c
> +++ b/drivers/iio/magnetometer/st_magn_spi.c
> @@ -51,6 +51,7 @@ static const struct spi_device_id st_magn_id_table[] = {
> { LSM303DLHC_MAGN_DEV_NAME },
> { LSM303DLM_MAGN_DEV_NAME },
> { LIS3MDL_MAGN_DEV_NAME },
> + { LSM303AGR_MAGN_DEV_NAME },
> {},
> };
> MODULE_DEVICE_TABLE(spi, st_magn_id_table);
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH V4 1/5] iio: st-sensors: add configuration for WhoAmI address
2015-07-21 10:43 ` Denis Ciocca
@ 2015-07-23 19:36 ` Jonathan Cameron
0 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2015-07-23 19:36 UTC (permalink / raw)
To: Denis Ciocca, Giuseppe BARBA, linux-iio
On 21/07/15 11:43, Denis Ciocca wrote:
> Thanks Giuseppe,
>
> good for me.
>
> Reviewed-by: Denis Ciocca <denis.ciocca@st.com>
> Acked-by: Denis Ciocca <denis.ciocca@st.com>
Applied to the togreg branch of iio.git. Initially pushed out
as testing for the autobuilders to play with it.
>
>
> BR,
> Denis
>
>
> On 07/21/2015 04:35 PM, Giuseppe BARBA wrote:
>> This patch permits to configure the WhoAmI register address
>> because some device could have not a standard address for
>> this register.
>>
>> Signed-off-by: Giuseppe Barba <giuseppe.barba@st.com>
>> ---
>> drivers/iio/accel/st_accel_core.c | 5 +++
>> drivers/iio/common/st_sensors/st_sensors_core.c | 49 ++++++++++++-------------
>> drivers/iio/gyro/st_gyro_core.c | 3 ++
>> drivers/iio/magnetometer/st_magn_core.c | 3 ++
>> drivers/iio/pressure/st_pressure_core.c | 3 ++
>> include/linux/iio/common/st_sensors.h | 2 +
>> 6 files changed, 39 insertions(+), 26 deletions(-)
>>
>> diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
>> index 4002e64..12b42f6 100644
>> --- a/drivers/iio/accel/st_accel_core.c
>> +++ b/drivers/iio/accel/st_accel_core.c
>> @@ -226,6 +226,7 @@ static const struct iio_chan_spec st_accel_16bit_channels[] = {
>> static const struct st_sensor_settings st_accel_sensors_settings[] = {
>> {
>> .wai = ST_ACCEL_1_WAI_EXP,
>> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
>> .sensors_supported = {
>> [0] = LIS3DH_ACCEL_DEV_NAME,
>> [1] = LSM303DLHC_ACCEL_DEV_NAME,
>> @@ -297,6 +298,7 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
>> },
>> {
>> .wai = ST_ACCEL_2_WAI_EXP,
>> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
>> .sensors_supported = {
>> [0] = LIS331DLH_ACCEL_DEV_NAME,
>> [1] = LSM303DL_ACCEL_DEV_NAME,
>> @@ -359,6 +361,7 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
>> },
>> {
>> .wai = ST_ACCEL_3_WAI_EXP,
>> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
>> .sensors_supported = {
>> [0] = LSM330_ACCEL_DEV_NAME,
>> },
>> @@ -437,6 +440,7 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
>> },
>> {
>> .wai = ST_ACCEL_4_WAI_EXP,
>> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
>> .sensors_supported = {
>> [0] = LIS3LV02DL_ACCEL_DEV_NAME,
>> },
>> @@ -494,6 +498,7 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
>> },
>> {
>> .wai = ST_ACCEL_5_WAI_EXP,
>> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
>> .sensors_supported = {
>> [0] = LIS331DL_ACCEL_DEV_NAME,
>> },
>> diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
>> index 8086cbc..d44bf16 100644
>> --- a/drivers/iio/common/st_sensors/st_sensors_core.c
>> +++ b/drivers/iio/common/st_sensors/st_sensors_core.c
>> @@ -479,46 +479,43 @@ int st_sensors_check_device_support(struct iio_dev *indio_dev,
>> int num_sensors_list,
>> const struct st_sensor_settings *sensor_settings)
>> {
>> - u8 wai;
>> 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 (sensor_settings[i].wai == wai)
>> + for (n = 0; n < ST_SENSORS_MAX_4WAI; n++) {
>> + if (strcmp(indio_dev->name,
>> + sensor_settings[i].sensors_supported[n]) == 0) {
>> + break;
>> + }
>> + }
>> + if (n < ST_SENSORS_MAX_4WAI)
>> break;
>> }
>> - if (i == num_sensors_list)
>> - goto device_not_supported;
>> + if (i == num_sensors_list) {
>> + dev_err(&indio_dev->dev, "device name %s not recognized.\n",
>> + indio_dev->name);
>> + return -ENODEV;
>> + }
>> - for (n = 0; n < ARRAY_SIZE(sensor_settings[i].sensors_supported); n++) {
>> - if (strcmp(indio_dev->name,
>> - &sensor_settings[i].sensors_supported[n][0]) == 0)
>> - break;
>> + err = sdata->tf->read_byte(&sdata->tb, sdata->dev,
>> + sensor_settings[i].wai_addr, &wai);
>> + if (err < 0) {
>> + dev_err(&indio_dev->dev, "failed to read Who-Am-I register.\n");
>> + return err;
>> }
>> - if (n == ARRAY_SIZE(sensor_settings[i].sensors_supported)) {
>> - dev_err(&indio_dev->dev, "device name \"%s\" and WhoAmI (0x%02x) mismatch",
>> - indio_dev->name, wai);
>> - goto sensor_name_mismatch;
>> +
>> + if (sensor_settings[i].wai != wai) {
>> + dev_err(&indio_dev->dev, "%s: WhoAmI mismatch (0x%x).\n",
>> + indio_dev->name, wai);
>> + return -EINVAL;
>> }
>> sdata->sensor_settings =
>> (struct st_sensor_settings *)&sensor_settings[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);
>> diff --git a/drivers/iio/gyro/st_gyro_core.c b/drivers/iio/gyro/st_gyro_core.c
>> index ffe9664..4b993a5 100644
>> --- a/drivers/iio/gyro/st_gyro_core.c
>> +++ b/drivers/iio/gyro/st_gyro_core.c
>> @@ -131,6 +131,7 @@ static const struct iio_chan_spec st_gyro_16bit_channels[] = {
>> static const struct st_sensor_settings st_gyro_sensors_settings[] = {
>> {
>> .wai = ST_GYRO_1_WAI_EXP,
>> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
>> .sensors_supported = {
>> [0] = L3G4200D_GYRO_DEV_NAME,
>> [1] = LSM330DL_GYRO_DEV_NAME,
>> @@ -190,6 +191,7 @@ static const struct st_sensor_settings st_gyro_sensors_settings[] = {
>> },
>> {
>> .wai = ST_GYRO_2_WAI_EXP,
>> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
>> .sensors_supported = {
>> [0] = L3GD20_GYRO_DEV_NAME,
>> [1] = LSM330D_GYRO_DEV_NAME,
>> @@ -252,6 +254,7 @@ static const struct st_sensor_settings st_gyro_sensors_settings[] = {
>> },
>> {
>> .wai = ST_GYRO_3_WAI_EXP,
>> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
>> .sensors_supported = {
>> [0] = L3GD20_GYRO_DEV_NAME,
>> },
>> diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c
>> index b4bcfb7..8d7d3a1 100644
>> --- a/drivers/iio/magnetometer/st_magn_core.c
>> +++ b/drivers/iio/magnetometer/st_magn_core.c
>> @@ -192,6 +192,7 @@ static const struct iio_chan_spec st_magn_2_16bit_channels[] = {
>> static const struct st_sensor_settings st_magn_sensors_settings[] = {
>> {
>> .wai = 0, /* This sensor has no valid WhoAmI report 0 */
>> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
>> .sensors_supported = {
>> [0] = LSM303DLH_MAGN_DEV_NAME,
>> },
>> @@ -268,6 +269,7 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = {
>> },
>> {
>> .wai = ST_MAGN_1_WAI_EXP,
>> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
>> .sensors_supported = {
>> [0] = LSM303DLHC_MAGN_DEV_NAME,
>> [1] = LSM303DLM_MAGN_DEV_NAME,
>> @@ -346,6 +348,7 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = {
>> },
>> {
>> .wai = ST_MAGN_2_WAI_EXP,
>> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
>> .sensors_supported = {
>> [0] = LIS3MDL_MAGN_DEV_NAME,
>> },
>> diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c
>> index e881fa6..eb41d2b 100644
>> --- a/drivers/iio/pressure/st_pressure_core.c
>> +++ b/drivers/iio/pressure/st_pressure_core.c
>> @@ -178,6 +178,7 @@ static const struct iio_chan_spec st_press_lps001wp_channels[] = {
>> static const struct st_sensor_settings st_press_sensors_settings[] = {
>> {
>> .wai = ST_PRESS_LPS331AP_WAI_EXP,
>> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
>> .sensors_supported = {
>> [0] = LPS331AP_PRESS_DEV_NAME,
>> },
>> @@ -225,6 +226,7 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
>> },
>> {
>> .wai = ST_PRESS_LPS001WP_WAI_EXP,
>> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
>> .sensors_supported = {
>> [0] = LPS001WP_PRESS_DEV_NAME,
>> },
>> @@ -260,6 +262,7 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
>> },
>> {
>> .wai = ST_PRESS_LPS25H_WAI_EXP,
>> + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
>> .sensors_supported = {
>> [0] = LPS25H_PRESS_DEV_NAME,
>> },
>> diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h
>> index 2c476ac..3c17cd7 100644
>> --- a/include/linux/iio/common/st_sensors.h
>> +++ b/include/linux/iio/common/st_sensors.h
>> @@ -166,6 +166,7 @@ struct st_sensor_transfer_function {
>> /**
>> * struct st_sensor_settings - ST specific sensor settings
>> * @wai: Contents of WhoAmI register.
>> + * @wai_addr: The address 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.
>> @@ -179,6 +180,7 @@ struct st_sensor_transfer_function {
>> */
>> struct st_sensor_settings {
>> u8 wai;
>> + u8 wai_addr;
>> char sensors_supported[ST_SENSORS_MAX_4WAI][ST_SENSORS_MAX_NAME];
>> struct iio_chan_spec *ch;
>> int num_ch;
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH V4 4/5] iio: st-accel: add support for lsm303agr accelerometer
2015-07-21 10:44 ` Denis Ciocca
@ 2015-07-23 19:40 ` Jonathan Cameron
0 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2015-07-23 19:40 UTC (permalink / raw)
To: Denis Ciocca, Giuseppe BARBA, linux-iio
On 21/07/15 11:44, Denis Ciocca wrote:
> Acked-by: Denis Ciocca <denis.ciocca@st.com>
Applied.
>
>
> On 07/21/2015 04:35 PM, Giuseppe BARBA wrote:
>> This adds support for the lsm303agr accelerometer.
>>
>> Signed-off-by: Giuseppe Barba <giuseppe.barba@st.com>
>> ---
>> Documentation/devicetree/bindings/iio/st-sensors.txt | 1 +
>> drivers/iio/accel/st_accel.h | 1 +
>> drivers/iio/accel/st_accel_core.c | 1 +
>> drivers/iio/accel/st_accel_i2c.c | 5 +++++
>> drivers/iio/accel/st_accel_spi.c | 1 +
>> 5 files changed, 9 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt
>> index 8a6be3b..d80bdaa 100644
>> --- a/Documentation/devicetree/bindings/iio/st-sensors.txt
>> +++ b/Documentation/devicetree/bindings/iio/st-sensors.txt
>> @@ -35,6 +35,7 @@ Accelerometers:
>> - st,lsm303dl-accel
>> - st,lsm303dlm-accel
>> - st,lsm330-accel
>> +- st,lsm303agr-accel
>> Gyroscopes:
>> - st,l3g4200d-gyro
>> diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h
>> index aa10019..468f21f 100644
>> --- a/drivers/iio/accel/st_accel.h
>> +++ b/drivers/iio/accel/st_accel.h
>> @@ -26,6 +26,7 @@
>> #define LSM303DLH_ACCEL_DEV_NAME "lsm303dlh_accel"
>> #define LSM303DLM_ACCEL_DEV_NAME "lsm303dlm_accel"
>> #define LSM330_ACCEL_DEV_NAME "lsm330_accel"
>> +#define LSM303AGR_ACCEL_DEV_NAME "lsm303agr_accel"
>> /**
>> * struct st_sensors_platform_data - default accel platform data
>> diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
>> index 12b42f6..ff30f88 100644
>> --- a/drivers/iio/accel/st_accel_core.c
>> +++ b/drivers/iio/accel/st_accel_core.c
>> @@ -233,6 +233,7 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
>> [2] = LSM330D_ACCEL_DEV_NAME,
>> [3] = LSM330DL_ACCEL_DEV_NAME,
>> [4] = LSM330DLC_ACCEL_DEV_NAME,
>> + [5] = LSM303AGR_ACCEL_DEV_NAME,
>> },
>> .ch = (struct iio_chan_spec *)st_accel_12bit_channels,
>> .odr = {
>> diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c
>> index a2f1c20..8b9cc84 100644
>> --- a/drivers/iio/accel/st_accel_i2c.c
>> +++ b/drivers/iio/accel/st_accel_i2c.c
>> @@ -68,6 +68,10 @@ static const struct of_device_id st_accel_of_match[] = {
>> .compatible = "st,lsm330-accel",
>> .data = LSM330_ACCEL_DEV_NAME,
>> },
>> + {
>> + .compatible = "st,lsm303agr-accel",
>> + .data = LSM303AGR_ACCEL_DEV_NAME,
>> + },
>> {},
>> };
>> MODULE_DEVICE_TABLE(of, st_accel_of_match);
>> @@ -116,6 +120,7 @@ static const struct i2c_device_id st_accel_id_table[] = {
>> { LSM303DL_ACCEL_DEV_NAME },
>> { LSM303DLM_ACCEL_DEV_NAME },
>> { LSM330_ACCEL_DEV_NAME },
>> + { LSM303AGR_ACCEL_DEV_NAME },
>> {},
>> };
>> MODULE_DEVICE_TABLE(i2c, st_accel_id_table);
>> diff --git a/drivers/iio/accel/st_accel_spi.c b/drivers/iio/accel/st_accel_spi.c
>> index 12ec293..54b61a3 100644
>> --- a/drivers/iio/accel/st_accel_spi.c
>> +++ b/drivers/iio/accel/st_accel_spi.c
>> @@ -57,6 +57,7 @@ static const struct spi_device_id st_accel_id_table[] = {
>> { LSM303DL_ACCEL_DEV_NAME },
>> { LSM303DLM_ACCEL_DEV_NAME },
>> { LSM330_ACCEL_DEV_NAME },
>> + { LSM303AGR_ACCEL_DEV_NAME },
>> {},
>> };
>> MODULE_DEVICE_TABLE(spi, st_accel_id_table);
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH V4 5/5] iio: st-magn: add support for lsm303agr magnetometer
2015-07-21 10:44 ` Denis Ciocca
@ 2015-07-23 19:42 ` Jonathan Cameron
0 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2015-07-23 19:42 UTC (permalink / raw)
To: Denis Ciocca, Giuseppe BARBA, linux-iio
On 21/07/15 11:44, Denis Ciocca wrote:
> Acked-by: Denis Ciocca <denis.ciocca@st.com>
Applied.
Nice little series. Thanks.
Denis, thanks for the fine grained ack/reviewed tags
as well.
Jonathan
>
>
> On 07/21/2015 04:35 PM, Giuseppe BARBA wrote:
>> This adds support for the lsm303agr magnetometer.
>>
>> Signed-off-by: Giuseppe Barba <giuseppe.barba@st.com>
>> ---
>> .../devicetree/bindings/iio/st-sensors.txt | 1 +
>> drivers/iio/magnetometer/st_magn.h | 1 +
>> drivers/iio/magnetometer/st_magn_core.c | 82 ++++++++++++++++++++++
>> drivers/iio/magnetometer/st_magn_i2c.c | 5 ++
>> drivers/iio/magnetometer/st_magn_spi.c | 1 +
>> 5 files changed, 90 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt
>> index d80bdaa..d3ccdb1 100644
>> --- a/Documentation/devicetree/bindings/iio/st-sensors.txt
>> +++ b/Documentation/devicetree/bindings/iio/st-sensors.txt
>> @@ -47,6 +47,7 @@ Gyroscopes:
>> - st,lsm330-gyro
>> Magnetometers:
>> +- st,lsm303agr-magn
>> - st,lsm303dlh-magn
>> - st,lsm303dlhc-magn
>> - st,lsm303dlm-magn
>> diff --git a/drivers/iio/magnetometer/st_magn.h b/drivers/iio/magnetometer/st_magn.h
>> index 60441023..06a4d9c 100644
>> --- a/drivers/iio/magnetometer/st_magn.h
>> +++ b/drivers/iio/magnetometer/st_magn.h
>> @@ -18,6 +18,7 @@
>> #define LSM303DLHC_MAGN_DEV_NAME "lsm303dlhc_magn"
>> #define LSM303DLM_MAGN_DEV_NAME "lsm303dlm_magn"
>> #define LIS3MDL_MAGN_DEV_NAME "lis3mdl"
>> +#define LSM303AGR_MAGN_DEV_NAME "lsm303agr_magn"
>> int st_magn_common_probe(struct iio_dev *indio_dev);
>> void st_magn_common_remove(struct iio_dev *indio_dev);
>> diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c
>> index 4c0cef8..f8dc4b8 100644
>> --- a/drivers/iio/magnetometer/st_magn_core.c
>> +++ b/drivers/iio/magnetometer/st_magn_core.c
>> @@ -43,6 +43,7 @@
>> #define ST_MAGN_FS_AVL_8000MG 8000
>> #define ST_MAGN_FS_AVL_8100MG 8100
>> #define ST_MAGN_FS_AVL_12000MG 12000
>> +#define ST_MAGN_FS_AVL_15000MG 15000
>> #define ST_MAGN_FS_AVL_16000MG 16000
>> /* CUSTOM VALUES FOR SENSOR 0 */
>> @@ -157,6 +158,29 @@
>> #define ST_MAGN_2_OUT_Y_L_ADDR 0x2a
>> #define ST_MAGN_2_OUT_Z_L_ADDR 0x2c
>> +/* CUSTOM VALUES FOR SENSOR 3 */
>> +#define ST_MAGN_3_WAI_ADDR 0x4f
>> +#define ST_MAGN_3_WAI_EXP 0x40
>> +#define ST_MAGN_3_ODR_ADDR 0x60
>> +#define ST_MAGN_3_ODR_MASK 0x0c
>> +#define ST_MAGN_3_ODR_AVL_10HZ_VAL 0x00
>> +#define ST_MAGN_3_ODR_AVL_20HZ_VAL 0x01
>> +#define ST_MAGN_3_ODR_AVL_50HZ_VAL 0x02
>> +#define ST_MAGN_3_ODR_AVL_100HZ_VAL 0x03
>> +#define ST_MAGN_3_PW_ADDR 0x60
>> +#define ST_MAGN_3_PW_MASK 0x03
>> +#define ST_MAGN_3_PW_ON 0x00
>> +#define ST_MAGN_3_PW_OFF 0x03
>> +#define ST_MAGN_3_BDU_ADDR 0x62
>> +#define ST_MAGN_3_BDU_MASK 0x10
>> +#define ST_MAGN_3_DRDY_IRQ_ADDR 0x62
>> +#define ST_MAGN_3_DRDY_INT_MASK 0x01
>> +#define ST_MAGN_3_FS_AVL_15000_GAIN 1500
>> +#define ST_MAGN_3_MULTIREAD_BIT false
>> +#define ST_MAGN_3_OUT_X_L_ADDR 0x68
>> +#define ST_MAGN_3_OUT_Y_L_ADDR 0x6a
>> +#define ST_MAGN_3_OUT_Z_L_ADDR 0x6c
>> +
>> static const struct iio_chan_spec st_magn_16bit_channels[] = {
>> ST_SENSORS_LSM_CHANNELS(IIO_MAGN,
>> BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
>> @@ -189,6 +213,22 @@ static const struct iio_chan_spec st_magn_2_16bit_channels[] = {
>> IIO_CHAN_SOFT_TIMESTAMP(3)
>> };
>> +static const struct iio_chan_spec st_magn_3_16bit_channels[] = {
>> + ST_SENSORS_LSM_CHANNELS(IIO_MAGN,
>> + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
>> + ST_SENSORS_SCAN_X, 1, IIO_MOD_X, 's', IIO_LE, 16, 16,
>> + ST_MAGN_3_OUT_X_L_ADDR),
>> + ST_SENSORS_LSM_CHANNELS(IIO_MAGN,
>> + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
>> + ST_SENSORS_SCAN_Y, 1, IIO_MOD_Y, 's', IIO_LE, 16, 16,
>> + ST_MAGN_3_OUT_Y_L_ADDR),
>> + ST_SENSORS_LSM_CHANNELS(IIO_MAGN,
>> + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
>> + ST_SENSORS_SCAN_Z, 1, IIO_MOD_Z, 's', IIO_LE, 16, 16,
>> + ST_MAGN_3_OUT_Z_L_ADDR),
>> + IIO_CHAN_SOFT_TIMESTAMP(3)
>> +};
>> +
>> static const struct st_sensor_settings st_magn_sensors_settings[] = {
>> {
>> .wai = 0, /* This sensor has no valid WhoAmI report 0 */
>> @@ -402,6 +442,48 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = {
>> .multi_read_bit = ST_MAGN_2_MULTIREAD_BIT,
>> .bootime = 2,
>> },
>> + {
>> + .wai = ST_MAGN_3_WAI_EXP,
>> + .wai_addr = ST_MAGN_3_WAI_ADDR,
>> + .sensors_supported = {
>> + [0] = LSM303AGR_MAGN_DEV_NAME,
>> + },
>> + .ch = (struct iio_chan_spec *)st_magn_3_16bit_channels,
>> + .odr = {
>> + .addr = ST_MAGN_3_ODR_ADDR,
>> + .mask = ST_MAGN_3_ODR_MASK,
>> + .odr_avl = {
>> + { 10, ST_MAGN_3_ODR_AVL_10HZ_VAL, },
>> + { 20, ST_MAGN_3_ODR_AVL_20HZ_VAL, },
>> + { 50, ST_MAGN_3_ODR_AVL_50HZ_VAL, },
>> + { 100, ST_MAGN_3_ODR_AVL_100HZ_VAL, },
>> + },
>> + },
>> + .pw = {
>> + .addr = ST_MAGN_3_PW_ADDR,
>> + .mask = ST_MAGN_3_PW_MASK,
>> + .value_on = ST_MAGN_3_PW_ON,
>> + .value_off = ST_MAGN_3_PW_OFF,
>> + },
>> + .fs = {
>> + .fs_avl = {
>> + [0] = {
>> + .num = ST_MAGN_FS_AVL_15000MG,
>> + .gain = ST_MAGN_3_FS_AVL_15000_GAIN,
>> + },
>> + },
>> + },
>> + .bdu = {
>> + .addr = ST_MAGN_3_BDU_ADDR,
>> + .mask = ST_MAGN_3_BDU_MASK,
>> + },
>> + .drdy_irq = {
>> + .addr = ST_MAGN_3_DRDY_IRQ_ADDR,
>> + .mask_int1 = ST_MAGN_3_DRDY_INT_MASK,
>> + },
>> + .multi_read_bit = ST_MAGN_3_MULTIREAD_BIT,
>> + .bootime = 2,
>> + },
>> };
>> static int st_magn_read_raw(struct iio_dev *indio_dev,
>> diff --git a/drivers/iio/magnetometer/st_magn_i2c.c b/drivers/iio/magnetometer/st_magn_i2c.c
>> index 28aa807..8aa37af 100644
>> --- a/drivers/iio/magnetometer/st_magn_i2c.c
>> +++ b/drivers/iio/magnetometer/st_magn_i2c.c
>> @@ -36,6 +36,10 @@ static const struct of_device_id st_magn_of_match[] = {
>> .compatible = "st,lis3mdl-magn",
>> .data = LIS3MDL_MAGN_DEV_NAME,
>> },
>> + {
>> + .compatible = "st,lsm303agr-magn",
>> + .data = LSM303AGR_MAGN_DEV_NAME,
>> + },
>> {},
>> };
>> MODULE_DEVICE_TABLE(of, st_magn_of_match);
>> @@ -79,6 +83,7 @@ static const struct i2c_device_id st_magn_id_table[] = {
>> { LSM303DLHC_MAGN_DEV_NAME },
>> { LSM303DLM_MAGN_DEV_NAME },
>> { LIS3MDL_MAGN_DEV_NAME },
>> + { LSM303AGR_MAGN_DEV_NAME },
>> {},
>> };
>> MODULE_DEVICE_TABLE(i2c, st_magn_id_table);
>> diff --git a/drivers/iio/magnetometer/st_magn_spi.c b/drivers/iio/magnetometer/st_magn_spi.c
>> index 7adacf1..0abca2c 100644
>> --- a/drivers/iio/magnetometer/st_magn_spi.c
>> +++ b/drivers/iio/magnetometer/st_magn_spi.c
>> @@ -51,6 +51,7 @@ static const struct spi_device_id st_magn_id_table[] = {
>> { LSM303DLHC_MAGN_DEV_NAME },
>> { LSM303DLM_MAGN_DEV_NAME },
>> { LIS3MDL_MAGN_DEV_NAME },
>> + { LSM303AGR_MAGN_DEV_NAME },
>> {},
>> };
>> MODULE_DEVICE_TABLE(spi, st_magn_id_table);
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2015-07-23 19:42 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-21 8:35 [PATCH V4 0/5] Added ST LSM303AGR sensor Giuseppe Barba
2015-07-21 8:35 ` [PATCH V4 1/5] iio: st-sensors: add configuration for WhoAmI address Giuseppe Barba
2015-07-21 10:43 ` Denis Ciocca
2015-07-23 19:36 ` Jonathan Cameron
2015-07-21 8:35 ` [PATCH V4 2/5] iio: st-sensors: add support for single full scale device Giuseppe Barba
2015-07-21 10:44 ` Denis Ciocca
2015-07-21 8:35 ` [PATCH V4 3/5] iio: st_magn: Add irq trigger handling Giuseppe Barba
2015-07-21 10:44 ` Denis Ciocca
2015-07-21 8:35 ` [PATCH V4 4/5] iio: st-accel: add support for lsm303agr accelerometer Giuseppe Barba
2015-07-21 10:44 ` Denis Ciocca
2015-07-23 19:40 ` Jonathan Cameron
2015-07-21 8:35 ` [PATCH V4 5/5] iio: st-magn: add support for lsm303agr magnetometer Giuseppe Barba
2015-07-21 10:44 ` Denis Ciocca
2015-07-23 19:42 ` Jonathan Cameron
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.