1 // SPDX-License-Identifier: GPL-2.0
3 * AD7606 Parallel Interface ADC driver
5 * Copyright 2011 Analog Devices Inc.
8 #include <linux/mod_devicetable.h>
9 #include <linux/module.h>
10 #include <linux/platform_device.h>
11 #include <linux/types.h>
12 #include <linux/err.h>
15 #include <linux/iio/iio.h>
18 static int ad7606_par16_read_block(struct device *dev,
21 struct iio_dev *indio_dev = dev_get_drvdata(dev);
22 struct ad7606_state *st = iio_priv(indio_dev);
24 insw((unsigned long)st->base_address, buf, count);
29 static const struct ad7606_bus_ops ad7606_par16_bops = {
30 .read_block = ad7606_par16_read_block,
33 static int ad7606_par8_read_block(struct device *dev,
36 struct iio_dev *indio_dev = dev_get_drvdata(dev);
37 struct ad7606_state *st = iio_priv(indio_dev);
39 insb((unsigned long)st->base_address, buf, count * 2);
44 static const struct ad7606_bus_ops ad7606_par8_bops = {
45 .read_block = ad7606_par8_read_block,
48 static int ad7606_par_probe(struct platform_device *pdev)
50 const struct platform_device_id *id = platform_get_device_id(pdev);
53 resource_size_t remap_size;
56 irq = platform_get_irq(pdev, 0);
60 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
61 addr = devm_ioremap_resource(&pdev->dev, res);
65 remap_size = resource_size(res);
67 return ad7606_probe(&pdev->dev, irq, addr,
68 id->name, id->driver_data,
69 remap_size > 1 ? &ad7606_par16_bops :
73 static const struct platform_device_id ad7606_driver_ids[] = {
74 { .name = "ad7605-4", .driver_data = ID_AD7605_4, },
75 { .name = "ad7606-4", .driver_data = ID_AD7606_4, },
76 { .name = "ad7606-6", .driver_data = ID_AD7606_6, },
77 { .name = "ad7606-8", .driver_data = ID_AD7606_8, },
80 MODULE_DEVICE_TABLE(platform, ad7606_driver_ids);
82 static const struct of_device_id ad7606_of_match[] = {
83 { .compatible = "adi,ad7605-4" },
84 { .compatible = "adi,ad7606-4" },
85 { .compatible = "adi,ad7606-6" },
86 { .compatible = "adi,ad7606-8" },
89 MODULE_DEVICE_TABLE(of, ad7606_of_match);
91 static struct platform_driver ad7606_driver = {
92 .probe = ad7606_par_probe,
93 .id_table = ad7606_driver_ids,
97 .of_match_table = ad7606_of_match,
100 module_platform_driver(ad7606_driver);
102 MODULE_AUTHOR("Michael Hennerich <michael.hennerich@analog.com>");
103 MODULE_DESCRIPTION("Analog Devices AD7606 ADC");
104 MODULE_LICENSE("GPL v2");
105 MODULE_IMPORT_NS(IIO_AD7606);