Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / iio / adc / sd_adc_modulator.c
blob327cc2097f6c7222e3a9fc61fcae43a27501df4a
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/mod_devicetable.h>
13 #include <linux/platform_device.h>
15 static const struct iio_info iio_sd_mod_iio_info;
17 static const struct iio_chan_spec iio_sd_mod_ch = {
18 .type = IIO_VOLTAGE,
19 .indexed = 1,
20 .scan_type = {
21 .sign = 'u',
22 .realbits = 1,
23 .shift = 0,
27 static int iio_sd_mod_probe(struct platform_device *pdev)
29 struct device *dev = &pdev->dev;
30 struct iio_dev *iio;
32 iio = devm_iio_device_alloc(dev, 0);
33 if (!iio)
34 return -ENOMEM;
36 iio->name = dev_name(dev);
37 iio->info = &iio_sd_mod_iio_info;
38 iio->modes = INDIO_BUFFER_HARDWARE;
40 iio->num_channels = 1;
41 iio->channels = &iio_sd_mod_ch;
43 platform_set_drvdata(pdev, iio);
45 return devm_iio_device_register(&pdev->dev, iio);
48 static const struct of_device_id sd_adc_of_match[] = {
49 { .compatible = "sd-modulator" },
50 { .compatible = "ads1201" },
51 { }
53 MODULE_DEVICE_TABLE(of, sd_adc_of_match);
55 static struct platform_driver iio_sd_mod_adc = {
56 .driver = {
57 .name = "iio_sd_adc_mod",
58 .of_match_table = sd_adc_of_match,
60 .probe = iio_sd_mod_probe,
63 module_platform_driver(iio_sd_mod_adc);
65 MODULE_DESCRIPTION("Basic sigma delta modulator");
66 MODULE_AUTHOR("Arnaud Pouliquen <arnaud.pouliquen@st.com>");
67 MODULE_LICENSE("GPL v2");