hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/iio/adc/ti-adc128s052.c
....@@ -1,21 +1,21 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Copyright (C) 2014 Angelo Compagnucci <angelo.compagnucci@gmail.com>
34 *
45 * Driver for Texas Instruments' ADC128S052, ADC122S021 and ADC124S021 ADC chip.
56 * Datasheets can be found here:
6
- * http://www.ti.com/lit/ds/symlink/adc128s052.pdf
7
- * http://www.ti.com/lit/ds/symlink/adc122s021.pdf
8
- * http://www.ti.com/lit/ds/symlink/adc124s021.pdf
9
- *
10
- * This program is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License version 2 as
12
- * published by the Free Software Foundation.
7
+ * https://www.ti.com/lit/ds/symlink/adc128s052.pdf
8
+ * https://www.ti.com/lit/ds/symlink/adc122s021.pdf
9
+ * https://www.ti.com/lit/ds/symlink/adc124s021.pdf
1310 */
1411
12
+#include <linux/acpi.h>
1513 #include <linux/err.h>
1614 #include <linux/spi/spi.h>
1715 #include <linux/module.h>
16
+#include <linux/mod_devicetable.h>
1817 #include <linux/iio/iio.h>
18
+#include <linux/property.h>
1919 #include <linux/regulator/consumer.h>
2020
2121 struct adc128_configuration {
....@@ -135,9 +135,14 @@
135135 static int adc128_probe(struct spi_device *spi)
136136 {
137137 struct iio_dev *indio_dev;
138
+ unsigned int config;
138139 struct adc128 *adc;
139
- int config = spi_get_device_id(spi)->driver_data;
140140 int ret;
141
+
142
+ if (dev_fwnode(&spi->dev))
143
+ config = (unsigned long) device_get_match_data(&spi->dev);
144
+ else
145
+ config = spi_get_device_id(spi)->driver_data;
141146
142147 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc));
143148 if (!indio_dev)
....@@ -148,8 +153,6 @@
148153
149154 spi_set_drvdata(spi, indio_dev);
150155
151
- indio_dev->dev.parent = &spi->dev;
152
- indio_dev->dev.of_node = spi->dev.of_node;
153156 indio_dev->name = spi_get_device_id(spi)->name;
154157 indio_dev->modes = INDIO_DIRECT_MODE;
155158 indio_dev->info = &adc128_info;
....@@ -190,25 +193,42 @@
190193 }
191194
192195 static const struct of_device_id adc128_of_match[] = {
193
- { .compatible = "ti,adc128s052", },
194
- { .compatible = "ti,adc122s021", },
195
- { .compatible = "ti,adc124s021", },
196
+ { .compatible = "ti,adc128s052", .data = (void*)0L, },
197
+ { .compatible = "ti,adc122s021", .data = (void*)1L, },
198
+ { .compatible = "ti,adc122s051", .data = (void*)1L, },
199
+ { .compatible = "ti,adc122s101", .data = (void*)1L, },
200
+ { .compatible = "ti,adc124s021", .data = (void*)2L, },
201
+ { .compatible = "ti,adc124s051", .data = (void*)2L, },
202
+ { .compatible = "ti,adc124s101", .data = (void*)2L, },
196203 { /* sentinel */ },
197204 };
198205 MODULE_DEVICE_TABLE(of, adc128_of_match);
199206
200207 static const struct spi_device_id adc128_id[] = {
201
- { "adc128s052", 0}, /* index into adc128_config */
202
- { "adc122s021", 1},
203
- { "adc124s021", 2},
208
+ { "adc128s052", 0 }, /* index into adc128_config */
209
+ { "adc122s021", 1 },
210
+ { "adc122s051", 1 },
211
+ { "adc122s101", 1 },
212
+ { "adc124s021", 2 },
213
+ { "adc124s051", 2 },
214
+ { "adc124s101", 2 },
204215 { }
205216 };
206217 MODULE_DEVICE_TABLE(spi, adc128_id);
207218
219
+#ifdef CONFIG_ACPI
220
+static const struct acpi_device_id adc128_acpi_match[] = {
221
+ { "AANT1280", 2 }, /* ADC124S021 compatible ACPI ID */
222
+ { }
223
+};
224
+MODULE_DEVICE_TABLE(acpi, adc128_acpi_match);
225
+#endif
226
+
208227 static struct spi_driver adc128_driver = {
209228 .driver = {
210229 .name = "adc128s052",
211
- .of_match_table = of_match_ptr(adc128_of_match),
230
+ .of_match_table = adc128_of_match,
231
+ .acpi_match_table = ACPI_PTR(adc128_acpi_match),
212232 },
213233 .probe = adc128_probe,
214234 .remove = adc128_remove,