.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * 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. |
---|
12 | 4 | */ |
---|
13 | 5 | #include <linux/module.h> |
---|
14 | 6 | #include <linux/acpi.h> |
---|
| 7 | +#include <linux/of.h> |
---|
| 8 | +#include <linux/property.h> |
---|
15 | 9 | #include <linux/spi/spi.h> |
---|
16 | 10 | #include <linux/regmap.h> |
---|
17 | 11 | #include <linux/iio/iio.h> |
---|
.. | .. |
---|
27 | 21 | struct inv_mpu6050_state *st = iio_priv(indio_dev); |
---|
28 | 22 | int ret = 0; |
---|
29 | 23 | |
---|
30 | | - ret = inv_mpu6050_set_power_itg(st, true); |
---|
31 | | - if (ret) |
---|
32 | | - return ret; |
---|
33 | | - |
---|
34 | 24 | if (st->reg->i2c_if) { |
---|
35 | 25 | ret = regmap_write(st->map, st->reg->i2c_if, |
---|
36 | 26 | INV_ICM20602_BIT_I2C_IF_DIS); |
---|
.. | .. |
---|
39 | 29 | ret = regmap_write(st->map, st->reg->user_ctrl, |
---|
40 | 30 | st->chip_config.user_ctrl); |
---|
41 | 31 | } |
---|
42 | | - if (ret) { |
---|
43 | | - inv_mpu6050_set_power_itg(st, false); |
---|
44 | | - return ret; |
---|
45 | | - } |
---|
46 | 32 | |
---|
47 | | - return inv_mpu6050_set_power_itg(st, false); |
---|
| 33 | + return ret; |
---|
48 | 34 | } |
---|
49 | 35 | |
---|
50 | 36 | static int inv_mpu_probe(struct spi_device *spi) |
---|
51 | 37 | { |
---|
| 38 | + const void *match; |
---|
52 | 39 | struct regmap *regmap; |
---|
53 | 40 | const struct spi_device_id *spi_id; |
---|
54 | | - const struct acpi_device_id *acpi_id; |
---|
55 | 41 | const char *name = NULL; |
---|
56 | 42 | enum inv_devices chip_type; |
---|
57 | 43 | |
---|
58 | 44 | if ((spi_id = spi_get_device_id(spi))) { |
---|
59 | 45 | chip_type = (enum inv_devices)spi_id->driver_data; |
---|
60 | 46 | 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); |
---|
63 | 50 | } else { |
---|
64 | 51 | return -ENODEV; |
---|
65 | 52 | } |
---|
66 | 53 | |
---|
67 | 54 | regmap = devm_regmap_init_spi(spi, &inv_mpu_regmap_config); |
---|
68 | 55 | 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); |
---|
71 | 58 | return PTR_ERR(regmap); |
---|
72 | 59 | } |
---|
73 | 60 | |
---|
.. | .. |
---|
82 | 69 | static const struct spi_device_id inv_mpu_id[] = { |
---|
83 | 70 | {"mpu6000", INV_MPU6000}, |
---|
84 | 71 | {"mpu6500", INV_MPU6500}, |
---|
85 | | - {"mpu9150", INV_MPU9150}, |
---|
| 72 | + {"mpu6515", INV_MPU6515}, |
---|
86 | 73 | {"mpu9250", INV_MPU9250}, |
---|
87 | 74 | {"mpu9255", INV_MPU9255}, |
---|
88 | 75 | {"icm20608", INV_ICM20608}, |
---|
| 76 | + {"icm20609", INV_ICM20609}, |
---|
| 77 | + {"icm20689", INV_ICM20689}, |
---|
89 | 78 | {"icm20602", INV_ICM20602}, |
---|
| 79 | + {"icm20690", INV_ICM20690}, |
---|
| 80 | + {"iam20680", INV_IAM20680}, |
---|
90 | 81 | {} |
---|
91 | 82 | }; |
---|
92 | 83 | |
---|
93 | 84 | 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); |
---|
94 | 134 | |
---|
95 | 135 | static const struct acpi_device_id inv_acpi_match[] = { |
---|
96 | 136 | {"INVN6000", INV_MPU6000}, |
---|
.. | .. |
---|
102 | 142 | .probe = inv_mpu_probe, |
---|
103 | 143 | .id_table = inv_mpu_id, |
---|
104 | 144 | .driver = { |
---|
| 145 | + .of_match_table = inv_of_match, |
---|
105 | 146 | .acpi_match_table = ACPI_PTR(inv_acpi_match), |
---|
106 | 147 | .name = "inv-mpu6000-spi", |
---|
107 | 148 | .pm = &inv_mpu_pmops, |
---|