diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2016-09-01 05:44:49 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2016-09-18 06:36:32 -0400 |
commit | 12884004f17f1c469d1f9a9a9db6147694db57d0 (patch) | |
tree | 4590ad86ddd8150fabbc5ca5f7d2fd8be89348e5 /drivers/iio | |
parent | 9a9a369d6178dd4e263c49085ce1b37e1e8f63a0 (diff) |
iio: accel: kxsd9: Support reading a mounting matrix
This adds support for the mounting matrix to the KXSD9 driver.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/accel/kxsd9.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c index a28163b76e12..9af60ac70738 100644 --- a/drivers/iio/accel/kxsd9.c +++ b/drivers/iio/accel/kxsd9.c | |||
@@ -68,12 +68,14 @@ | |||
68 | * struct kxsd9_state - device related storage | 68 | * struct kxsd9_state - device related storage |
69 | * @dev: pointer to the parent device | 69 | * @dev: pointer to the parent device |
70 | * @map: regmap to the device | 70 | * @map: regmap to the device |
71 | * @orientation: mounting matrix, flipped axis etc | ||
71 | * @regs: regulators for this device, VDD and IOVDD | 72 | * @regs: regulators for this device, VDD and IOVDD |
72 | * @scale: the current scaling setting | 73 | * @scale: the current scaling setting |
73 | */ | 74 | */ |
74 | struct kxsd9_state { | 75 | struct kxsd9_state { |
75 | struct device *dev; | 76 | struct device *dev; |
76 | struct regmap *map; | 77 | struct regmap *map; |
78 | struct iio_mount_matrix orientation; | ||
77 | struct regulator_bulk_data regs[2]; | 79 | struct regulator_bulk_data regs[2]; |
78 | u8 scale; | 80 | u8 scale; |
79 | }; | 81 | }; |
@@ -258,6 +260,20 @@ static const struct iio_buffer_setup_ops kxsd9_buffer_setup_ops = { | |||
258 | .postdisable = kxsd9_buffer_postdisable, | 260 | .postdisable = kxsd9_buffer_postdisable, |
259 | }; | 261 | }; |
260 | 262 | ||
263 | static const struct iio_mount_matrix * | ||
264 | kxsd9_get_mount_matrix(const struct iio_dev *indio_dev, | ||
265 | const struct iio_chan_spec *chan) | ||
266 | { | ||
267 | struct kxsd9_state *st = iio_priv(indio_dev); | ||
268 | |||
269 | return &st->orientation; | ||
270 | } | ||
271 | |||
272 | static const struct iio_chan_spec_ext_info kxsd9_ext_info[] = { | ||
273 | IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, kxsd9_get_mount_matrix), | ||
274 | { }, | ||
275 | }; | ||
276 | |||
261 | #define KXSD9_ACCEL_CHAN(axis, index) \ | 277 | #define KXSD9_ACCEL_CHAN(axis, index) \ |
262 | { \ | 278 | { \ |
263 | .type = IIO_ACCEL, \ | 279 | .type = IIO_ACCEL, \ |
@@ -266,6 +282,7 @@ static const struct iio_buffer_setup_ops kxsd9_buffer_setup_ops = { | |||
266 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ | 282 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ |
267 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \ | 283 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \ |
268 | BIT(IIO_CHAN_INFO_OFFSET), \ | 284 | BIT(IIO_CHAN_INFO_OFFSET), \ |
285 | .ext_info = kxsd9_ext_info, \ | ||
269 | .address = KXSD9_REG_##axis, \ | 286 | .address = KXSD9_REG_##axis, \ |
270 | .scan_index = index, \ | 287 | .scan_index = index, \ |
271 | .scan_type = { \ | 288 | .scan_type = { \ |
@@ -403,6 +420,13 @@ int kxsd9_common_probe(struct device *dev, | |||
403 | indio_dev->modes = INDIO_DIRECT_MODE; | 420 | indio_dev->modes = INDIO_DIRECT_MODE; |
404 | indio_dev->available_scan_masks = kxsd9_scan_masks; | 421 | indio_dev->available_scan_masks = kxsd9_scan_masks; |
405 | 422 | ||
423 | /* Read the mounting matrix, if present */ | ||
424 | ret = of_iio_read_mount_matrix(dev, | ||
425 | "mount-matrix", | ||
426 | &st->orientation); | ||
427 | if (ret) | ||
428 | return ret; | ||
429 | |||
406 | /* Fetch and turn on regulators */ | 430 | /* Fetch and turn on regulators */ |
407 | st->regs[0].supply = kxsd9_reg_vdd; | 431 | st->regs[0].supply = kxsd9_reg_vdd; |
408 | st->regs[1].supply = kxsd9_reg_iovdd; | 432 | st->regs[1].supply = kxsd9_reg_iovdd; |