1 // SPDX-License-Identifier: GPL-2.0
3 * AD7606 Parallel Interface ADC driver
5 * Copyright 2011 Analog Devices Inc.
8 #include <linux/module.h>
9 #include <linux/platform_device.h>
10 #include <linux/types.h>
11 #include <linux/err.h>
14 #include <linux/iio/iio.h>
17 static int ad7606_par16_read_block(struct device
*dev
,
20 struct iio_dev
*indio_dev
= dev_get_drvdata(dev
);
21 struct ad7606_state
*st
= iio_priv(indio_dev
);
23 insw((unsigned long)st
->base_address
, buf
, count
);
28 static const struct ad7606_bus_ops ad7606_par16_bops
= {
29 .read_block
= ad7606_par16_read_block
,
32 static int ad7606_par8_read_block(struct device
*dev
,
35 struct iio_dev
*indio_dev
= dev_get_drvdata(dev
);
36 struct ad7606_state
*st
= iio_priv(indio_dev
);
38 insb((unsigned long)st
->base_address
, buf
, count
* 2);
43 static const struct ad7606_bus_ops ad7606_par8_bops
= {
44 .read_block
= ad7606_par8_read_block
,
47 static int ad7606_par_probe(struct platform_device
*pdev
)
49 const struct platform_device_id
*id
= platform_get_device_id(pdev
);
52 resource_size_t remap_size
;
55 irq
= platform_get_irq(pdev
, 0);
59 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
60 addr
= devm_ioremap_resource(&pdev
->dev
, res
);
64 remap_size
= resource_size(res
);
66 return ad7606_probe(&pdev
->dev
, irq
, addr
,
67 id
->name
, id
->driver_data
,
68 remap_size
> 1 ? &ad7606_par16_bops
:
72 static const struct platform_device_id ad7606_driver_ids
[] = {
73 { .name
= "ad7605-4", .driver_data
= ID_AD7605_4
, },
74 { .name
= "ad7606-4", .driver_data
= ID_AD7606_4
, },
75 { .name
= "ad7606-6", .driver_data
= ID_AD7606_6
, },
76 { .name
= "ad7606-8", .driver_data
= ID_AD7606_8
, },
79 MODULE_DEVICE_TABLE(platform
, ad7606_driver_ids
);
81 static const struct of_device_id ad7606_of_match
[] = {
82 { .compatible
= "adi,ad7605-4" },
83 { .compatible
= "adi,ad7606-4" },
84 { .compatible
= "adi,ad7606-6" },
85 { .compatible
= "adi,ad7606-8" },
88 MODULE_DEVICE_TABLE(of
, ad7606_of_match
);
90 static struct platform_driver ad7606_driver
= {
91 .probe
= ad7606_par_probe
,
92 .id_table
= ad7606_driver_ids
,
96 .of_match_table
= ad7606_of_match
,
99 module_platform_driver(ad7606_driver
);
101 MODULE_AUTHOR("Michael Hennerich <michael.hennerich@analog.com>");
102 MODULE_DESCRIPTION("Analog Devices AD7606 ADC");
103 MODULE_LICENSE("GPL v2");