Linux 4.19.133
[linux/fpc-iii.git] / drivers / iio / adc / sd_adc_modulator.c
blob560d8c7d9d8625ecc2dc2108882a866e3032bc13
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Generic sigma delta modulator driver
5 * Copyright (C) 2017, STMicroelectronics - All Rights Reserved
6 * Author: Arnaud Pouliquen <arnaud.pouliquen@st.com>.
7 */
9 #include <linux/iio/iio.h>
10 #include <linux/iio/triggered_buffer.h>
11 #include <linux/module.h>
12 #include <linux/of_device.h>
14 static const struct iio_info iio_sd_mod_iio_info;
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,
26 static int iio_sd_mod_probe(struct platform_device *pdev)
28 struct device *dev = &pdev->dev;
29 struct iio_dev *iio;
31 iio = devm_iio_device_alloc(dev, 0);
32 if (!iio)
33 return -ENOMEM;
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;
41 iio->num_channels = 1;
42 iio->channels = &iio_sd_mod_ch;
44 platform_set_drvdata(pdev, iio);
46 return devm_iio_device_register(&pdev->dev, iio);
49 static const struct of_device_id sd_adc_of_match[] = {
50 { .compatible = "sd-modulator" },
51 { .compatible = "ads1201" },
52 { }
54 MODULE_DEVICE_TABLE(of, sd_adc_of_match);
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),
61 .probe = iio_sd_mod_probe,
64 module_platform_driver(iio_sd_mod_adc);
66 MODULE_DESCRIPTION("Basic sigma delta modulator");
67 MODULE_AUTHOR("Arnaud Pouliquen <arnaud.pouliquen@st.com>");
68 MODULE_LICENSE("GPL v2");