| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * itg3200_core.c -- support InvenSense ITG3200 |
|---|
| 3 | 4 | * Digital 3-Axis Gyroscope driver |
|---|
| .. | .. |
|---|
| 5 | 6 | * Copyright (c) 2011 Christian Strobel <christian.strobel@iis.fraunhofer.de> |
|---|
| 6 | 7 | * Copyright (c) 2011 Manuel Stahl <manuel.stahl@iis.fraunhofer.de> |
|---|
| 7 | 8 | * Copyright (c) 2012 Thorsten Nowak <thorsten.nowak@iis.fraunhofer.de> |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 10 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 11 | | - * published by the Free Software Foundation. |
|---|
| 12 | 9 | * |
|---|
| 13 | 10 | * TODO: |
|---|
| 14 | 11 | * - Support digital low pass filter |
|---|
| .. | .. |
|---|
| 18 | 15 | #include <linux/interrupt.h> |
|---|
| 19 | 16 | #include <linux/irq.h> |
|---|
| 20 | 17 | #include <linux/i2c.h> |
|---|
| 21 | | -#include <linux/gpio.h> |
|---|
| 22 | 18 | #include <linux/slab.h> |
|---|
| 23 | 19 | #include <linux/stat.h> |
|---|
| 24 | 20 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 157 | 153 | t); |
|---|
| 158 | 154 | |
|---|
| 159 | 155 | mutex_unlock(&indio_dev->mlock); |
|---|
| 160 | | - return ret; |
|---|
| 156 | + return ret; |
|---|
| 161 | 157 | |
|---|
| 162 | 158 | default: |
|---|
| 163 | 159 | return -EINVAL; |
|---|
| .. | .. |
|---|
| 242 | 238 | return ret; |
|---|
| 243 | 239 | } |
|---|
| 244 | 240 | |
|---|
| 241 | +static const struct iio_mount_matrix * |
|---|
| 242 | +itg3200_get_mount_matrix(const struct iio_dev *indio_dev, |
|---|
| 243 | + const struct iio_chan_spec *chan) |
|---|
| 244 | +{ |
|---|
| 245 | + struct itg3200 *data = iio_priv(indio_dev); |
|---|
| 246 | + |
|---|
| 247 | + return &data->orientation; |
|---|
| 248 | +} |
|---|
| 249 | + |
|---|
| 250 | +static const struct iio_chan_spec_ext_info itg3200_ext_info[] = { |
|---|
| 251 | + IIO_MOUNT_MATRIX(IIO_SHARED_BY_DIR, itg3200_get_mount_matrix), |
|---|
| 252 | + { } |
|---|
| 253 | +}; |
|---|
| 254 | + |
|---|
| 245 | 255 | #define ITG3200_ST \ |
|---|
| 246 | 256 | { .sign = 's', .realbits = 16, .storagebits = 16, .endianness = IIO_BE } |
|---|
| 247 | 257 | |
|---|
| .. | .. |
|---|
| 255 | 265 | .address = ITG3200_REG_GYRO_ ## _mod ## OUT_H, \ |
|---|
| 256 | 266 | .scan_index = ITG3200_SCAN_GYRO_ ## _mod, \ |
|---|
| 257 | 267 | .scan_type = ITG3200_ST, \ |
|---|
| 268 | + .ext_info = itg3200_ext_info, \ |
|---|
| 258 | 269 | } |
|---|
| 259 | 270 | |
|---|
| 260 | 271 | static const struct iio_chan_spec itg3200_channels[] = { |
|---|
| .. | .. |
|---|
| 297 | 308 | |
|---|
| 298 | 309 | st = iio_priv(indio_dev); |
|---|
| 299 | 310 | |
|---|
| 311 | + ret = iio_read_mount_matrix(&client->dev, "mount-matrix", |
|---|
| 312 | + &st->orientation); |
|---|
| 313 | + if (ret) |
|---|
| 314 | + return ret; |
|---|
| 315 | + |
|---|
| 300 | 316 | i2c_set_clientdata(client, indio_dev); |
|---|
| 301 | 317 | st->i2c = client; |
|---|
| 302 | 318 | |
|---|
| 303 | | - indio_dev->dev.parent = &client->dev; |
|---|
| 304 | 319 | indio_dev->name = client->dev.driver->name; |
|---|
| 305 | 320 | indio_dev->channels = itg3200_channels; |
|---|
| 306 | 321 | indio_dev->num_channels = ARRAY_SIZE(itg3200_channels); |
|---|