linux/drivers/iio/cdc/ad7746.c

// SPDX-License-Identifier: GPL-2.0
/*
 * AD7746 capacitive sensor driver supporting AD7745, AD7746 and AD7747
 *
 * Copyright 2011 Analog Devices Inc.
 */

#include <linux/bitfield.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/stat.h>
#include <linux/sysfs.h>

#include <linux/unaligned.h>

#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>

/* AD7746 Register Definition */

#define AD7746_REG_STATUS
#define AD7746_REG_CAP_DATA_HIGH
#define AD7746_REG_VT_DATA_HIGH
#define AD7746_REG_CAP_SETUP
#define AD7746_REG_VT_SETUP
#define AD7746_REG_EXC_SETUP
#define AD7746_REG_CFG
#define AD7746_REG_CAPDACA
#define AD7746_REG_CAPDACB
#define AD7746_REG_CAP_OFFH
#define AD7746_REG_CAP_GAINH
#define AD7746_REG_VOLT_GAINH

/* Status Register Bit Designations (AD7746_REG_STATUS) */
#define AD7746_STATUS_EXCERR
#define AD7746_STATUS_RDY
#define AD7746_STATUS_RDYVT
#define AD7746_STATUS_RDYCAP

/* Capacitive Channel Setup Register Bit Designations (AD7746_REG_CAP_SETUP) */
#define AD7746_CAPSETUP_CAPEN
#define AD7746_CAPSETUP_CIN2
#define AD7746_CAPSETUP_CAPDIFF
#define AD7746_CAPSETUP_CACHOP

/* Voltage/Temperature Setup Register Bit Designations (AD7746_REG_VT_SETUP) */
#define AD7746_VTSETUP_VTEN
#define AD7746_VTSETUP_VTMD_MASK
#define AD7746_VTSETUP_VTMD_INT_TEMP
#define AD7746_VTSETUP_VTMD_EXT_TEMP
#define AD7746_VTSETUP_VTMD_VDD_MON
#define AD7746_VTSETUP_VTMD_EXT_VIN
#define AD7746_VTSETUP_EXTREF
#define AD7746_VTSETUP_VTSHORT
#define AD7746_VTSETUP_VTCHOP

/* Excitation Setup Register Bit Designations (AD7746_REG_EXC_SETUP) */
#define AD7746_EXCSETUP_CLKCTRL
#define AD7746_EXCSETUP_EXCON
#define AD7746_EXCSETUP_EXCB
#define AD7746_EXCSETUP_NEXCB
#define AD7746_EXCSETUP_EXCA
#define AD7746_EXCSETUP_NEXCA
#define AD7746_EXCSETUP_EXCLVL_MASK

/* Config Register Bit Designations (AD7746_REG_CFG) */
#define AD7746_CONF_VTFS_MASK
#define AD7746_CONF_CAPFS_MASK
#define AD7746_CONF_MODE_MASK
#define AD7746_CONF_MODE_IDLE
#define AD7746_CONF_MODE_CONT_CONV
#define AD7746_CONF_MODE_SINGLE_CONV
#define AD7746_CONF_MODE_PWRDN
#define AD7746_CONF_MODE_OFFS_CAL
#define AD7746_CONF_MODE_GAIN_CAL

/* CAPDAC Register Bit Designations (AD7746_REG_CAPDACx) */
#define AD7746_CAPDAC_DACEN
#define AD7746_CAPDAC_DACP_MASK

struct ad7746_chip_info {};

enum ad7746_chan {};

struct ad7746_chan_info {};

static const struct ad7746_chan_info ad7746_chan_info[] =;

static const struct iio_chan_spec ad7746_channels[] =;

/* Values are Update Rate (Hz), Conversion Time (ms) + 1*/
static const unsigned char ad7746_vt_filter_rate_table[][2] =;

static const unsigned char ad7746_cap_filter_rate_table[][2] =;

static int ad7746_set_capdac(struct ad7746_chip_info *chip, int channel)
{}

static int ad7746_select_channel(struct iio_dev *indio_dev,
				 struct iio_chan_spec const *chan)
{}

static inline ssize_t ad7746_start_calib(struct device *dev,
					 struct device_attribute *attr,
					 const char *buf,
					 size_t len,
					 u8 regval)
{}

static ssize_t ad7746_start_offset_calib(struct device *dev,
					 struct device_attribute *attr,
					 const char *buf,
					 size_t len)
{}

static ssize_t ad7746_start_gain_calib(struct device *dev,
				       struct device_attribute *attr,
				       const char *buf,
				       size_t len)
{}

static IIO_DEVICE_ATTR(in_capacitance0_calibbias_calibration,
		       0200, NULL, ad7746_start_offset_calib, CIN1);
static IIO_DEVICE_ATTR(in_capacitance1_calibbias_calibration,
		       0200, NULL, ad7746_start_offset_calib, CIN2);
static IIO_DEVICE_ATTR(in_capacitance0_calibscale_calibration,
		       0200, NULL, ad7746_start_gain_calib, CIN1);
static IIO_DEVICE_ATTR(in_capacitance1_calibscale_calibration,
		       0200, NULL, ad7746_start_gain_calib, CIN2);
static IIO_DEVICE_ATTR(in_voltage0_calibscale_calibration,
		       0200, NULL, ad7746_start_gain_calib, VIN);

static int ad7746_store_cap_filter_rate_setup(struct ad7746_chip_info *chip,
					      int val)
{}

static int ad7746_store_vt_filter_rate_setup(struct ad7746_chip_info *chip,
					     int val)
{}

static struct attribute *ad7746_attributes[] =;

static const struct attribute_group ad7746_attribute_group =;

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

static const int ad7746_v_samp_freq[] =;
static const int ad7746_cap_samp_freq[] =;

static int ad7746_read_avail(struct iio_dev *indio_dev,
			     struct iio_chan_spec const *chan, const int **vals,
			     int *type, int *length, long mask)
{}

static int ad7746_read_channel(struct iio_dev *indio_dev,
			       struct iio_chan_spec const *chan,
			       int *val)
{}

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

static const struct iio_info ad7746_info =;

static int ad7746_probe(struct i2c_client *client)
{}

static const struct i2c_device_id ad7746_id[] =;
MODULE_DEVICE_TABLE(i2c, ad7746_id);

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

static struct i2c_driver ad7746_driver =;
module_i2c_driver();

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