forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/drivers/iio/gyro/itg3200_core.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * itg3200_core.c -- support InvenSense ITG3200
34 * Digital 3-Axis Gyroscope driver
....@@ -5,10 +6,6 @@
56 * Copyright (c) 2011 Christian Strobel <christian.strobel@iis.fraunhofer.de>
67 * Copyright (c) 2011 Manuel Stahl <manuel.stahl@iis.fraunhofer.de>
78 * 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.
129 *
1310 * TODO:
1411 * - Support digital low pass filter
....@@ -18,7 +15,6 @@
1815 #include <linux/interrupt.h>
1916 #include <linux/irq.h>
2017 #include <linux/i2c.h>
21
-#include <linux/gpio.h>
2218 #include <linux/slab.h>
2319 #include <linux/stat.h>
2420 #include <linux/module.h>
....@@ -157,7 +153,7 @@
157153 t);
158154
159155 mutex_unlock(&indio_dev->mlock);
160
- return ret;
156
+ return ret;
161157
162158 default:
163159 return -EINVAL;
....@@ -242,6 +238,20 @@
242238 return ret;
243239 }
244240
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
+
245255 #define ITG3200_ST \
246256 { .sign = 's', .realbits = 16, .storagebits = 16, .endianness = IIO_BE }
247257
....@@ -255,6 +265,7 @@
255265 .address = ITG3200_REG_GYRO_ ## _mod ## OUT_H, \
256266 .scan_index = ITG3200_SCAN_GYRO_ ## _mod, \
257267 .scan_type = ITG3200_ST, \
268
+ .ext_info = itg3200_ext_info, \
258269 }
259270
260271 static const struct iio_chan_spec itg3200_channels[] = {
....@@ -297,10 +308,14 @@
297308
298309 st = iio_priv(indio_dev);
299310
311
+ ret = iio_read_mount_matrix(&client->dev, "mount-matrix",
312
+ &st->orientation);
313
+ if (ret)
314
+ return ret;
315
+
300316 i2c_set_clientdata(client, indio_dev);
301317 st->i2c = client;
302318
303
- indio_dev->dev.parent = &client->dev;
304319 indio_dev->name = client->dev.driver->name;
305320 indio_dev->channels = itg3200_channels;
306321 indio_dev->num_channels = ARRAY_SIZE(itg3200_channels);