|
25 | 25 | #include <linux/spi/spi.h>
|
26 | 26 | #include <linux/slab.h>
|
27 | 27 | #include <linux/of_device.h>
|
28 |
| - |
| 28 | +#include <linux/acpi.h> |
29 | 29 |
|
30 | 30 | #define DRVNAME "lm70"
|
31 | 31 |
|
@@ -148,18 +148,50 @@ static const struct of_device_id lm70_of_ids[] = {
|
148 | 148 | MODULE_DEVICE_TABLE(of, lm70_of_ids);
|
149 | 149 | #endif
|
150 | 150 |
|
| 151 | +#ifdef CONFIG_ACPI |
| 152 | +static const struct acpi_device_id lm70_acpi_ids[] = { |
| 153 | + { |
| 154 | + .id = "LM000070", |
| 155 | + .driver_data = LM70_CHIP_LM70, |
| 156 | + }, |
| 157 | + { |
| 158 | + .id = "TMP00121", |
| 159 | + .driver_data = LM70_CHIP_TMP121, |
| 160 | + }, |
| 161 | + { |
| 162 | + .id = "LM000071", |
| 163 | + .driver_data = LM70_CHIP_LM71, |
| 164 | + }, |
| 165 | + { |
| 166 | + .id = "LM000074", |
| 167 | + .driver_data = LM70_CHIP_LM74, |
| 168 | + }, |
| 169 | + {}, |
| 170 | +}; |
| 171 | +MODULE_DEVICE_TABLE(acpi, lm70_acpi_ids); |
| 172 | +#endif |
| 173 | + |
151 | 174 | static int lm70_probe(struct spi_device *spi)
|
152 | 175 | {
|
153 |
| - const struct of_device_id *match; |
| 176 | + const struct of_device_id *of_match; |
154 | 177 | struct device *hwmon_dev;
|
155 | 178 | struct lm70 *p_lm70;
|
156 | 179 | int chip;
|
157 | 180 |
|
158 |
| - match = of_match_device(lm70_of_ids, &spi->dev); |
159 |
| - if (match) |
160 |
| - chip = (int)(uintptr_t)match->data; |
161 |
| - else |
162 |
| - chip = spi_get_device_id(spi)->driver_data; |
| 181 | + of_match = of_match_device(lm70_of_ids, &spi->dev); |
| 182 | + if (of_match) |
| 183 | + chip = (int)(uintptr_t)of_match->data; |
| 184 | + else { |
| 185 | +#ifdef CONFIG_ACPI |
| 186 | + const struct acpi_device_id *acpi_match; |
| 187 | + |
| 188 | + acpi_match = acpi_match_device(lm70_acpi_ids, &spi->dev); |
| 189 | + if (acpi_match) |
| 190 | + chip = (int)(uintptr_t)acpi_match->driver_data; |
| 191 | + else |
| 192 | +#endif |
| 193 | + chip = spi_get_device_id(spi)->driver_data; |
| 194 | + } |
163 | 195 |
|
164 | 196 | /* signaling is SPI_MODE_0 */
|
165 | 197 | if (spi->mode & (SPI_CPOL | SPI_CPHA))
|
@@ -195,6 +227,7 @@ static struct spi_driver lm70_driver = {
|
195 | 227 | .driver = {
|
196 | 228 | .name = "lm70",
|
197 | 229 | .of_match_table = of_match_ptr(lm70_of_ids),
|
| 230 | + .acpi_match_table = ACPI_PTR(lm70_acpi_ids), |
198 | 231 | },
|
199 | 232 | .id_table = lm70_ids,
|
200 | 233 | .probe = lm70_probe,
|
|
0 commit comments