Skip to content

Commit 812a46b

Browse files
JonnyMeJonathan Cameron
authored andcommitted
iio: imu: bmi160: added mount-matrix support
Add mount-matrix binding support. As chip could have different orientations a mount matrix support is needed to correctly translate these differences. Signed-off-by: Jonathan Albrieux <jonathan.albrieux@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 5dea3fb commit 812a46b

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

‎drivers/iio/imu/bmi160/bmi160.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ struct bmi160_data {
99
struct regmap *regmap;
1010
struct iio_trigger *trig;
1111
struct regulator_bulk_data supplies[2];
12+
struct iio_mount_matrix orientation;
1213
};
1314

1415
extern const struct regmap_config bmi160_regmap_config;

‎drivers/iio/imu/bmi160/bmi160_core.c‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
.storagebits = 16, \
111111
.endianness = IIO_LE, \
112112
}, \
113+
.ext_info = bmi160_ext_info, \
113114
}
114115

115116
/* scan indexes follow DATA register order */
@@ -265,6 +266,20 @@ static const struct bmi160_odr_item bmi160_odr_table[] = {
265266
},
266267
};
267268

269+
static const struct iio_mount_matrix *
270+
bmi160_get_mount_matrix(const struct iio_dev *indio_dev,
271+
const struct iio_chan_spec *chan)
272+
{
273+
struct bmi160_data *data = iio_priv(indio_dev);
274+
275+
return &data->orientation;
276+
}
277+
278+
static const struct iio_chan_spec_ext_info bmi160_ext_info[] = {
279+
IIO_MOUNT_MATRIX(IIO_SHARED_BY_DIR, bmi160_get_mount_matrix),
280+
{ }
281+
};
282+
268283
static const struct iio_chan_spec bmi160_channels[] = {
269284
BMI160_CHANNEL(IIO_ACCEL, X, BMI160_SCAN_ACCEL_X),
270285
BMI160_CHANNEL(IIO_ACCEL, Y, BMI160_SCAN_ACCEL_Y),
@@ -839,6 +854,11 @@ int bmi160_core_probe(struct device *dev, struct regmap *regmap,
839854
return ret;
840855
}
841856

857+
ret = iio_read_mount_matrix(dev, "mount-matrix",
858+
&data->orientation);
859+
if (ret)
860+
return ret;
861+
842862
ret = bmi160_chip_init(data, use_spi);
843863
if (ret)
844864
return ret;

0 commit comments

Comments
 (0)