Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Generic sigma delta modulator driver
0004  *
0005  * Copyright (C) 2017, STMicroelectronics - All Rights Reserved
0006  * Author: Arnaud Pouliquen <arnaud.pouliquen@st.com>.
0007  */
0008 
0009 #include <linux/iio/iio.h>
0010 #include <linux/iio/triggered_buffer.h>
0011 #include <linux/module.h>
0012 #include <linux/mod_devicetable.h>
0013 #include <linux/platform_device.h>
0014 
0015 static const struct iio_info iio_sd_mod_iio_info;
0016 
0017 static const struct iio_chan_spec iio_sd_mod_ch = {
0018     .type = IIO_VOLTAGE,
0019     .indexed = 1,
0020     .scan_type = {
0021         .sign = 'u',
0022         .realbits = 1,
0023         .shift = 0,
0024     },
0025 };
0026 
0027 static int iio_sd_mod_probe(struct platform_device *pdev)
0028 {
0029     struct device *dev = &pdev->dev;
0030     struct iio_dev *iio;
0031 
0032     iio = devm_iio_device_alloc(dev, 0);
0033     if (!iio)
0034         return -ENOMEM;
0035 
0036     iio->name = dev_name(dev);
0037     iio->info = &iio_sd_mod_iio_info;
0038     iio->modes = INDIO_BUFFER_HARDWARE;
0039 
0040     iio->num_channels = 1;
0041     iio->channels = &iio_sd_mod_ch;
0042 
0043     platform_set_drvdata(pdev, iio);
0044 
0045     return devm_iio_device_register(&pdev->dev, iio);
0046 }
0047 
0048 static const struct of_device_id sd_adc_of_match[] = {
0049     { .compatible = "sd-modulator" },
0050     { .compatible = "ads1201" },
0051     { }
0052 };
0053 MODULE_DEVICE_TABLE(of, sd_adc_of_match);
0054 
0055 static struct platform_driver iio_sd_mod_adc = {
0056     .driver = {
0057         .name = "iio_sd_adc_mod",
0058         .of_match_table = sd_adc_of_match,
0059     },
0060     .probe = iio_sd_mod_probe,
0061 };
0062 
0063 module_platform_driver(iio_sd_mod_adc);
0064 
0065 MODULE_DESCRIPTION("Basic sigma delta modulator");
0066 MODULE_AUTHOR("Arnaud Pouliquen <arnaud.pouliquen@st.com>");
0067 MODULE_LICENSE("GPL v2");