.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * TI ADC081C/ADC101C/ADC121C 8/10/12-bit ADC driver |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2012 Avionic Design GmbH |
---|
5 | 6 | * Copyright (C) 2016 Intel |
---|
6 | 7 | * |
---|
7 | | - * This program is free software; you can redistribute it and/or modify |
---|
8 | | - * it under the terms of the GNU General Public License version 2 as |
---|
9 | | - * published by the Free Software Foundation. |
---|
10 | | - * |
---|
11 | 8 | * Datasheets: |
---|
12 | | - * http://www.ti.com/lit/ds/symlink/adc081c021.pdf |
---|
13 | | - * http://www.ti.com/lit/ds/symlink/adc101c021.pdf |
---|
14 | | - * http://www.ti.com/lit/ds/symlink/adc121c021.pdf |
---|
| 9 | + * https://www.ti.com/lit/ds/symlink/adc081c021.pdf |
---|
| 10 | + * https://www.ti.com/lit/ds/symlink/adc101c021.pdf |
---|
| 11 | + * https://www.ti.com/lit/ds/symlink/adc121c021.pdf |
---|
15 | 12 | * |
---|
16 | 13 | * The devices have a very similar interface and differ mostly in the number of |
---|
17 | 14 | * bits handled. For the 8-bit and 10-bit models the least-significant 4 or 2 |
---|
.. | .. |
---|
21 | 18 | #include <linux/err.h> |
---|
22 | 19 | #include <linux/i2c.h> |
---|
23 | 20 | #include <linux/module.h> |
---|
24 | | -#include <linux/of.h> |
---|
25 | | -#include <linux/acpi.h> |
---|
| 21 | +#include <linux/mod_devicetable.h> |
---|
| 22 | +#include <linux/property.h> |
---|
26 | 23 | |
---|
27 | 24 | #include <linux/iio/iio.h> |
---|
28 | 25 | #include <linux/iio/buffer.h> |
---|
.. | .. |
---|
155 | 152 | { |
---|
156 | 153 | struct iio_dev *iio; |
---|
157 | 154 | struct adc081c *adc; |
---|
158 | | - struct adcxx1c_model *model; |
---|
| 155 | + const struct adcxx1c_model *model; |
---|
159 | 156 | int err; |
---|
160 | 157 | |
---|
161 | 158 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA)) |
---|
162 | 159 | return -EOPNOTSUPP; |
---|
163 | 160 | |
---|
164 | | - if (ACPI_COMPANION(&client->dev)) { |
---|
165 | | - const struct acpi_device_id *ad_id; |
---|
166 | | - |
---|
167 | | - ad_id = acpi_match_device(client->dev.driver->acpi_match_table, |
---|
168 | | - &client->dev); |
---|
169 | | - if (!ad_id) |
---|
170 | | - return -ENODEV; |
---|
171 | | - model = &adcxx1c_models[ad_id->driver_data]; |
---|
172 | | - } else { |
---|
| 161 | + if (dev_fwnode(&client->dev)) |
---|
| 162 | + model = device_get_match_data(&client->dev); |
---|
| 163 | + else |
---|
173 | 164 | model = &adcxx1c_models[id->driver_data]; |
---|
174 | | - } |
---|
175 | 165 | |
---|
176 | 166 | iio = devm_iio_device_alloc(&client->dev, sizeof(*adc)); |
---|
177 | 167 | if (!iio) |
---|
.. | .. |
---|
189 | 179 | if (err < 0) |
---|
190 | 180 | return err; |
---|
191 | 181 | |
---|
192 | | - iio->dev.parent = &client->dev; |
---|
193 | | - iio->dev.of_node = client->dev.of_node; |
---|
194 | 182 | iio->name = dev_name(&client->dev); |
---|
195 | 183 | iio->modes = INDIO_DIRECT_MODE; |
---|
196 | 184 | iio->info = &adc081c_info; |
---|
.. | .. |
---|
240 | 228 | }; |
---|
241 | 229 | MODULE_DEVICE_TABLE(i2c, adc081c_id); |
---|
242 | 230 | |
---|
243 | | -#ifdef CONFIG_OF |
---|
244 | | -static const struct of_device_id adc081c_of_match[] = { |
---|
245 | | - { .compatible = "ti,adc081c" }, |
---|
246 | | - { .compatible = "ti,adc101c" }, |
---|
247 | | - { .compatible = "ti,adc121c" }, |
---|
248 | | - { } |
---|
249 | | -}; |
---|
250 | | -MODULE_DEVICE_TABLE(of, adc081c_of_match); |
---|
251 | | -#endif |
---|
252 | | - |
---|
253 | | -#ifdef CONFIG_ACPI |
---|
254 | 231 | static const struct acpi_device_id adc081c_acpi_match[] = { |
---|
255 | | - { "ADC081C", ADC081C }, |
---|
256 | | - { "ADC101C", ADC101C }, |
---|
257 | | - { "ADC121C", ADC121C }, |
---|
| 232 | + /* Used on some AAEON boards */ |
---|
| 233 | + { "ADC081C", (kernel_ulong_t)&adcxx1c_models[ADC081C] }, |
---|
258 | 234 | { } |
---|
259 | 235 | }; |
---|
260 | 236 | MODULE_DEVICE_TABLE(acpi, adc081c_acpi_match); |
---|
261 | | -#endif |
---|
| 237 | + |
---|
| 238 | +static const struct of_device_id adc081c_of_match[] = { |
---|
| 239 | + { .compatible = "ti,adc081c", .data = &adcxx1c_models[ADC081C] }, |
---|
| 240 | + { .compatible = "ti,adc101c", .data = &adcxx1c_models[ADC101C] }, |
---|
| 241 | + { .compatible = "ti,adc121c", .data = &adcxx1c_models[ADC121C] }, |
---|
| 242 | + { } |
---|
| 243 | +}; |
---|
| 244 | +MODULE_DEVICE_TABLE(of, adc081c_of_match); |
---|
262 | 245 | |
---|
263 | 246 | static struct i2c_driver adc081c_driver = { |
---|
264 | 247 | .driver = { |
---|
265 | 248 | .name = "adc081c", |
---|
266 | | - .of_match_table = of_match_ptr(adc081c_of_match), |
---|
267 | | - .acpi_match_table = ACPI_PTR(adc081c_acpi_match), |
---|
| 249 | + .of_match_table = adc081c_of_match, |
---|
| 250 | + .acpi_match_table = adc081c_acpi_match, |
---|
268 | 251 | }, |
---|
269 | 252 | .probe = adc081c_probe, |
---|
270 | 253 | .remove = adc081c_remove, |
---|