Skip to content

Commit 8a5f0b6

Browse files
arnopobroonie
authored andcommitted
IIO: ADC: add sigma delta modulator support
Add generic driver to support sigma delta modulators. Typically, this device is hardware connected to an IIO device in charge of the conversion. Devices are bonded through the hardware consumer API. Signed-off-by: Arnaud Pouliquen <[email protected]> Acked-by: Jonathan Cameron <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent af11143 commit 8a5f0b6

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed

drivers/iio/adc/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,18 @@ config SPEAR_ADC
629629
To compile this driver as a module, choose M here: the
630630
module will be called spear_adc.
631631

632+
config SD_ADC_MODULATOR
633+
tristate "Generic sigma delta modulator"
634+
depends on OF
635+
select IIO_BUFFER
636+
select IIO_TRIGGERED_BUFFER
637+
help
638+
Select this option to enables sigma delta modulator. This driver can
639+
support generic sigma delta modulators.
640+
641+
This driver can also be built as a module. If so, the module
642+
will be called sd_adc_modulator.
643+
632644
config STM32_ADC_CORE
633645
tristate "STMicroelectronics STM32 adc core"
634646
depends on ARCH_STM32 || COMPILE_TEST

drivers/iio/adc/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,4 @@ obj-$(CONFIG_VF610_ADC) += vf610_adc.o
8282
obj-$(CONFIG_VIPERBOARD_ADC) += viperboard_adc.o
8383
xilinx-xadc-y := xilinx-xadc-core.o xilinx-xadc-events.o
8484
obj-$(CONFIG_XILINX_XADC) += xilinx-xadc.o
85+
obj-$(CONFIG_SD_ADC_MODULATOR) += sd_adc_modulator.o

drivers/iio/adc/sd_adc_modulator.c

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Generic sigma delta modulator driver
4+
*
5+
* Copyright (C) 2017, STMicroelectronics - All Rights Reserved
6+
* Author: Arnaud Pouliquen <[email protected]>.
7+
*/
8+
9+
#include <linux/iio/iio.h>
10+
#include <linux/iio/triggered_buffer.h>
11+
#include <linux/module.h>
12+
#include <linux/of_device.h>
13+
14+
static const struct iio_info iio_sd_mod_iio_info;
15+
16+
static const struct iio_chan_spec iio_sd_mod_ch = {
17+
.type = IIO_VOLTAGE,
18+
.indexed = 1,
19+
.scan_type = {
20+
.sign = 'u',
21+
.realbits = 1,
22+
.shift = 0,
23+
},
24+
};
25+
26+
static int iio_sd_mod_probe(struct platform_device *pdev)
27+
{
28+
struct device *dev = &pdev->dev;
29+
struct iio_dev *iio;
30+
31+
iio = devm_iio_device_alloc(dev, 0);
32+
if (!iio)
33+
return -ENOMEM;
34+
35+
iio->dev.parent = dev;
36+
iio->dev.of_node = dev->of_node;
37+
iio->name = dev_name(dev);
38+
iio->info = &iio_sd_mod_iio_info;
39+
iio->modes = INDIO_BUFFER_HARDWARE;
40+
41+
iio->num_channels = 1;
42+
iio->channels = &iio_sd_mod_ch;
43+
44+
platform_set_drvdata(pdev, iio);
45+
46+
return devm_iio_device_register(&pdev->dev, iio);
47+
}
48+
49+
static const struct of_device_id sd_adc_of_match[] = {
50+
{ .compatible = "sd-modulator" },
51+
{ .compatible = "ads1201" },
52+
{ }
53+
};
54+
MODULE_DEVICE_TABLE(of, sd_adc_of_match);
55+
56+
static struct platform_driver iio_sd_mod_adc = {
57+
.driver = {
58+
.name = "iio_sd_adc_mod",
59+
.of_match_table = of_match_ptr(sd_adc_of_match),
60+
},
61+
.probe = iio_sd_mod_probe,
62+
};
63+
64+
module_platform_driver(iio_sd_mod_adc);
65+
66+
MODULE_DESCRIPTION("Basic sigma delta modulator");
67+
MODULE_AUTHOR("Arnaud Pouliquen <[email protected]>");
68+
MODULE_LICENSE("GPL v2");

0 commit comments

Comments
 (0)