linux/drivers/iio/adc/ti-adc108s102.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * TI ADC108S102 SPI ADC driver
 *
 * Copyright (c) 2013-2015 Intel Corporation.
 * Copyright (c) 2017 Siemens AG
 *
 * This IIO device driver is designed to work with the following
 * analog to digital converters from Texas Instruments:
 *  ADC108S102
 *  ADC128S102
 * The communication with ADC chip is via the SPI bus (mode 3).
 */

#include <linux/acpi.h>
#include <linux/iio/iio.h>
#include <linux/iio/buffer.h>
#include <linux/iio/types.h>
#include <linux/iio/triggered_buffer.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/property.h>
#include <linux/regulator/consumer.h>
#include <linux/spi/spi.h>

/*
 * In case of ACPI, we use the hard-wired 5000 mV of the Galileo and IOT2000
 * boards as default for the reference pin VA. Device tree users encode that
 * via the vref-supply regulator.
 */
#define ADC108S102_VA_MV_ACPI_DEFAULT

/*
 * Defining the ADC resolution being 12 bits, we can use the same driver for
 * both ADC108S102 (10 bits resolution) and ADC128S102 (12 bits resolution)
 * chips. The ADC108S102 effectively returns a 12-bit result with the 2
 * least-significant bits unset.
 */
#define ADC108S102_BITS
#define ADC108S102_MAX_CHANNELS

/*
 * 16-bit SPI command format:
 *   [15:14] Ignored
 *   [13:11] 3-bit channel address
 *   [10:0]  Ignored
 */
#define ADC108S102_CMD(ch)

/*
 * 16-bit SPI response format:
 *   [15:12] Zeros
 *   [11:0]  12-bit ADC sample (for ADC108S102, [1:0] will always be 0).
 */
#define ADC108S102_RES_DATA(res)

struct adc108s102_state {};

#define ADC108S102_V_CHAN(index)

static const struct iio_chan_spec adc108s102_channels[] =;

static int adc108s102_update_scan_mode(struct iio_dev *indio_dev,
		unsigned long const *active_scan_mask)
{}

static irqreturn_t adc108s102_trigger_handler(int irq, void *p)
{}

static int adc108s102_scan_direct(struct adc108s102_state *st, unsigned int ch)
{}

static int adc108s102_read_raw(struct iio_dev *indio_dev,
			       struct iio_chan_spec const *chan,
			       int *val, int *val2, long m)
{}

static const struct iio_info adc108s102_info =;

static int adc108s102_probe(struct spi_device *spi)
{}

static const struct of_device_id adc108s102_of_match[] =;
MODULE_DEVICE_TABLE(of, adc108s102_of_match);

static const struct acpi_device_id adc108s102_acpi_ids[] =;
MODULE_DEVICE_TABLE(acpi, adc108s102_acpi_ids);

static const struct spi_device_id adc108s102_id[] =;
MODULE_DEVICE_TABLE(spi, adc108s102_id);

static struct spi_driver adc108s102_driver =;
module_spi_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();