Commit 38934daf authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Jonathan Cameron

iio: magnetometer: st_magn: Provide default platform data

Provide default platform data for magnetometer in case it supports DRDY.

One case is LSM9DS0 IMU, on which it is the case. Since accelerometer
is using INT1, default magnetometer to INT2.

While at it, update description of the drdy_int_pin field.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210414195454.84183-3-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent dffdd756
...@@ -383,6 +383,11 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = { ...@@ -383,6 +383,11 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = {
}, },
}; };
/* Default magn DRDY is available on INT2 pin */
static const struct st_sensors_platform_data default_magn_pdata = {
.drdy_int_pin = 2,
};
static int st_magn_read_raw(struct iio_dev *indio_dev, static int st_magn_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *ch, int *val, struct iio_chan_spec const *ch, int *val,
int *val2, long mask) int *val2, long mask)
...@@ -490,6 +495,7 @@ EXPORT_SYMBOL(st_magn_get_settings); ...@@ -490,6 +495,7 @@ EXPORT_SYMBOL(st_magn_get_settings);
int st_magn_common_probe(struct iio_dev *indio_dev) int st_magn_common_probe(struct iio_dev *indio_dev)
{ {
struct st_sensor_data *mdata = iio_priv(indio_dev); struct st_sensor_data *mdata = iio_priv(indio_dev);
struct st_sensors_platform_data *pdata = dev_get_platdata(mdata->dev);
int err; int err;
indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->modes = INDIO_DIRECT_MODE;
...@@ -510,7 +516,10 @@ int st_magn_common_probe(struct iio_dev *indio_dev) ...@@ -510,7 +516,10 @@ int st_magn_common_probe(struct iio_dev *indio_dev)
mdata->current_fullscale = &mdata->sensor_settings->fs.fs_avl[0]; mdata->current_fullscale = &mdata->sensor_settings->fs.fs_avl[0];
mdata->odr = mdata->sensor_settings->odr.odr_avl[0].hz; mdata->odr = mdata->sensor_settings->odr.odr_avl[0].hz;
err = st_sensors_init_sensor(indio_dev, NULL); if (!pdata)
pdata = (struct st_sensors_platform_data *)&default_magn_pdata;
err = st_sensors_init_sensor(indio_dev, pdata);
if (err < 0) if (err < 0)
goto st_magn_power_off; goto st_magn_power_off;
......
...@@ -13,8 +13,9 @@ ...@@ -13,8 +13,9 @@
/** /**
* struct st_sensors_platform_data - Platform data for the ST sensors * struct st_sensors_platform_data - Platform data for the ST sensors
* @drdy_int_pin: Redirect DRDY on pin 1 (1) or pin 2 (2). * @drdy_int_pin: Redirect DRDY on pin 1 (1) or pin 2 (2).
* Available only for accelerometer and pressure sensors. * Available only for accelerometer, magnetometer and pressure sensors.
* Accelerometer DRDY on LSM330 available only on pin 1 (see datasheet). * Accelerometer DRDY on LSM330 available only on pin 1 (see datasheet).
* Magnetometer DRDY is supported only on LSM9DS0.
* @open_drain: set the interrupt line to be open drain if possible. * @open_drain: set the interrupt line to be open drain if possible.
* @spi_3wire: enable spi-3wire mode. * @spi_3wire: enable spi-3wire mode.
* @pullups: enable/disable i2c controller pullup resistors. * @pullups: enable/disable i2c controller pullup resistors.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment