linux/drivers/iio/adc/ad7606.c

// SPDX-License-Identifier: GPL-2.0
/*
 * AD7606 SPI ADC driver
 *
 * Copyright 2011 Analog Devices Inc.
 */

#include <linux/delay.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/gpio/consumer.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/property.h>
#include <linux/regulator/consumer.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/sysfs.h>
#include <linux/util_macros.h>

#include <linux/iio/iio.h>
#include <linux/iio/buffer.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/trigger.h>
#include <linux/iio/triggered_buffer.h>
#include <linux/iio/trigger_consumer.h>

#include "ad7606.h"

/*
 * Scales are computed as 5000/32768 and 10000/32768 respectively,
 * so that when applied to the raw values they provide mV values
 */
static const unsigned int ad7606_scale_avail[2] =;


static const unsigned int ad7616_sw_scale_avail[3] =;

static const unsigned int ad7606_oversampling_avail[7] =;

static const unsigned int ad7616_oversampling_avail[8] =;

static int ad7606_reset(struct ad7606_state *st)
{}

static int ad7606_reg_access(struct iio_dev *indio_dev,
			     unsigned int reg,
			     unsigned int writeval,
			     unsigned int *readval)
{}

static int ad7606_read_samples(struct ad7606_state *st)
{}

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

static int ad7606_scan_direct(struct iio_dev *indio_dev, unsigned int ch)
{}

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

static ssize_t ad7606_show_avail(char *buf, const unsigned int *vals,
				 unsigned int n, bool micros)
{}

static ssize_t in_voltage_scale_available_show(struct device *dev,
					       struct device_attribute *attr,
					       char *buf)
{}

static IIO_DEVICE_ATTR_RO(in_voltage_scale_available, 0);

static int ad7606_write_scale_hw(struct iio_dev *indio_dev, int ch, int val)
{}

static int ad7606_write_os_hw(struct iio_dev *indio_dev, int val)
{}

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

static ssize_t ad7606_oversampling_ratio_avail(struct device *dev,
					       struct device_attribute *attr,
					       char *buf)
{}

static IIO_DEVICE_ATTR(oversampling_ratio_available, 0444,
		       ad7606_oversampling_ratio_avail, NULL, 0);

static struct attribute *ad7606_attributes_os_and_range[] =;

static const struct attribute_group ad7606_attribute_group_os_and_range =;

static struct attribute *ad7606_attributes_os[] =;

static const struct attribute_group ad7606_attribute_group_os =;

static struct attribute *ad7606_attributes_range[] =;

static const struct attribute_group ad7606_attribute_group_range =;

static const struct iio_chan_spec ad7605_channels[] =;

static const struct iio_chan_spec ad7606_channels[] =;

/*
 * The current assumption that this driver makes for AD7616, is that it's
 * working in Hardware Mode with Serial, Burst and Sequencer modes activated.
 * To activate them, following pins must be pulled high:
 *	-SER/PAR
 *	-SEQEN
 * And following pins must be pulled low:
 *	-WR/BURST
 *	-DB4/SER1W
 */
static const struct iio_chan_spec ad7616_channels[] =;

static const struct ad7606_chip_info ad7606_chip_info_tbl[] =;

static int ad7606_request_gpios(struct ad7606_state *st)
{}

/*
 * The BUSY signal indicates when conversions are in progress, so when a rising
 * edge of CONVST is applied, BUSY goes logic high and transitions low at the
 * end of the entire conversion process. The falling edge of the BUSY signal
 * triggers this interrupt.
 */
static irqreturn_t ad7606_interrupt(int irq, void *dev_id)
{
	struct iio_dev *indio_dev = dev_id;
	struct ad7606_state *st = iio_priv(indio_dev);

	if (iio_buffer_enabled(indio_dev)) {
		gpiod_set_value(st->gpio_convst, 0);
		iio_trigger_poll_nested(st->trig);
	} else {
		complete(&st->completion);
	}

	return IRQ_HANDLED;
};

static int ad7606_validate_trigger(struct iio_dev *indio_dev,
				   struct iio_trigger *trig)
{}

static int ad7606_buffer_postenable(struct iio_dev *indio_dev)
{}

static int ad7606_buffer_predisable(struct iio_dev *indio_dev)
{}

static const struct iio_buffer_setup_ops ad7606_buffer_ops =;

static const struct iio_info ad7606_info_no_os_or_range =;

static const struct iio_info ad7606_info_os_and_range =;

static const struct iio_info ad7606_info_os_range_and_debug =;

static const struct iio_info ad7606_info_os =;

static const struct iio_info ad7606_info_range =;

static const struct iio_trigger_ops ad7606_trigger_ops =;

int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
		 const char *name, unsigned int id,
		 const struct ad7606_bus_ops *bops)
{}
EXPORT_SYMBOL_NS_GPL();

#ifdef CONFIG_PM_SLEEP

static int ad7606_suspend(struct device *dev)
{}

static int ad7606_resume(struct device *dev)
{}

SIMPLE_DEV_PM_OPS(ad7606_pm_ops, ad7606_suspend, ad7606_resume);
EXPORT_SYMBOL_NS_GPL();

#endif

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