hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
....@@ -1,17 +1,11 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2015 Intel Corporation Inc.
3
-*
4
-* This software is licensed under the terms of the GNU General Public
5
-* License version 2, as published by the Free Software Foundation, and
6
-* may be copied, distributed, and modified under those terms.
7
-*
8
-* This program is distributed in the hope that it will be useful,
9
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
-* GNU General Public License for more details.
124 */
135 #include <linux/module.h>
146 #include <linux/acpi.h>
7
+#include <linux/of.h>
8
+#include <linux/property.h>
159 #include <linux/spi/spi.h>
1610 #include <linux/regmap.h>
1711 #include <linux/iio/iio.h>
....@@ -27,10 +21,6 @@
2721 struct inv_mpu6050_state *st = iio_priv(indio_dev);
2822 int ret = 0;
2923
30
- ret = inv_mpu6050_set_power_itg(st, true);
31
- if (ret)
32
- return ret;
33
-
3424 if (st->reg->i2c_if) {
3525 ret = regmap_write(st->map, st->reg->i2c_if,
3626 INV_ICM20602_BIT_I2C_IF_DIS);
....@@ -39,35 +29,32 @@
3929 ret = regmap_write(st->map, st->reg->user_ctrl,
4030 st->chip_config.user_ctrl);
4131 }
42
- if (ret) {
43
- inv_mpu6050_set_power_itg(st, false);
44
- return ret;
45
- }
4632
47
- return inv_mpu6050_set_power_itg(st, false);
33
+ return ret;
4834 }
4935
5036 static int inv_mpu_probe(struct spi_device *spi)
5137 {
38
+ const void *match;
5239 struct regmap *regmap;
5340 const struct spi_device_id *spi_id;
54
- const struct acpi_device_id *acpi_id;
5541 const char *name = NULL;
5642 enum inv_devices chip_type;
5743
5844 if ((spi_id = spi_get_device_id(spi))) {
5945 chip_type = (enum inv_devices)spi_id->driver_data;
6046 name = spi_id->name;
61
- } else if ((acpi_id = acpi_match_device(spi->dev.driver->acpi_match_table, &spi->dev))) {
62
- chip_type = (enum inv_devices)acpi_id->driver_data;
47
+ } else if ((match = device_get_match_data(&spi->dev))) {
48
+ chip_type = (enum inv_devices)match;
49
+ name = dev_name(&spi->dev);
6350 } else {
6451 return -ENODEV;
6552 }
6653
6754 regmap = devm_regmap_init_spi(spi, &inv_mpu_regmap_config);
6855 if (IS_ERR(regmap)) {
69
- dev_err(&spi->dev, "Failed to register spi regmap %d\n",
70
- (int)PTR_ERR(regmap));
56
+ dev_err(&spi->dev, "Failed to register spi regmap: %pe\n",
57
+ regmap);
7158 return PTR_ERR(regmap);
7259 }
7360
....@@ -82,15 +69,68 @@
8269 static const struct spi_device_id inv_mpu_id[] = {
8370 {"mpu6000", INV_MPU6000},
8471 {"mpu6500", INV_MPU6500},
85
- {"mpu9150", INV_MPU9150},
72
+ {"mpu6515", INV_MPU6515},
8673 {"mpu9250", INV_MPU9250},
8774 {"mpu9255", INV_MPU9255},
8875 {"icm20608", INV_ICM20608},
76
+ {"icm20609", INV_ICM20609},
77
+ {"icm20689", INV_ICM20689},
8978 {"icm20602", INV_ICM20602},
79
+ {"icm20690", INV_ICM20690},
80
+ {"iam20680", INV_IAM20680},
9081 {}
9182 };
9283
9384 MODULE_DEVICE_TABLE(spi, inv_mpu_id);
85
+
86
+static const struct of_device_id inv_of_match[] = {
87
+ {
88
+ .compatible = "invensense,mpu6000",
89
+ .data = (void *)INV_MPU6000
90
+ },
91
+ {
92
+ .compatible = "invensense,mpu6500",
93
+ .data = (void *)INV_MPU6500
94
+ },
95
+ {
96
+ .compatible = "invensense,mpu6515",
97
+ .data = (void *)INV_MPU6515
98
+ },
99
+ {
100
+ .compatible = "invensense,mpu9250",
101
+ .data = (void *)INV_MPU9250
102
+ },
103
+ {
104
+ .compatible = "invensense,mpu9255",
105
+ .data = (void *)INV_MPU9255
106
+ },
107
+ {
108
+ .compatible = "invensense,icm20608",
109
+ .data = (void *)INV_ICM20608
110
+ },
111
+ {
112
+ .compatible = "invensense,icm20609",
113
+ .data = (void *)INV_ICM20609
114
+ },
115
+ {
116
+ .compatible = "invensense,icm20689",
117
+ .data = (void *)INV_ICM20689
118
+ },
119
+ {
120
+ .compatible = "invensense,icm20602",
121
+ .data = (void *)INV_ICM20602
122
+ },
123
+ {
124
+ .compatible = "invensense,icm20690",
125
+ .data = (void *)INV_ICM20690
126
+ },
127
+ {
128
+ .compatible = "invensense,iam20680",
129
+ .data = (void *)INV_IAM20680
130
+ },
131
+ { }
132
+};
133
+MODULE_DEVICE_TABLE(of, inv_of_match);
94134
95135 static const struct acpi_device_id inv_acpi_match[] = {
96136 {"INVN6000", INV_MPU6000},
....@@ -102,6 +142,7 @@
102142 .probe = inv_mpu_probe,
103143 .id_table = inv_mpu_id,
104144 .driver = {
145
+ .of_match_table = inv_of_match,
105146 .acpi_match_table = ACPI_PTR(inv_acpi_match),
106147 .name = "inv-mpu6000-spi",
107148 .pm = &inv_mpu_pmops,