linux/drivers/iio/adc/max1363.c

// SPDX-License-Identifier: GPL-2.0-only
 /*
  * iio/adc/max1363.c
  * Copyright (C) 2008-2010 Jonathan Cameron
  *
  * based on linux/drivers/i2c/chips/max123x
  * Copyright (C) 2002-2004 Stefan Eletzhofer
  *
  * based on linux/drivers/acron/char/pcf8583.c
  * Copyright (C) 2000 Russell King
  *
  * Driver for max1363 and similar chips.
  */

#include <linux/interrupt.h>
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/sysfs.h>
#include <linux/list.h>
#include <linux/i2c.h>
#include <linux/regulator/consumer.h>
#include <linux/slab.h>
#include <linux/err.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/property.h>

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

#define MAX1363_SETUP_BYTE(a)

/* There is a fair bit more defined here than currently
 * used, but the intention is to support everything these
 * chips do in the long run */

/* see data sheets */
/* max1363 and max1236, max1237, max1238, max1239 */
#define MAX1363_SETUP_AIN3_IS_AIN3_REF_IS_VDD
#define MAX1363_SETUP_AIN3_IS_REF_EXT_TO_REF
#define MAX1363_SETUP_AIN3_IS_AIN3_REF_IS_INT
#define MAX1363_SETUP_AIN3_IS_REF_REF_IS_INT
#define MAX1363_SETUP_POWER_UP_INT_REF
#define MAX1363_SETUP_POWER_DOWN_INT_REF

/* think about including max11600 etc - more settings */
#define MAX1363_SETUP_EXT_CLOCK
#define MAX1363_SETUP_INT_CLOCK
#define MAX1363_SETUP_UNIPOLAR
#define MAX1363_SETUP_BIPOLAR
#define MAX1363_SETUP_RESET
#define MAX1363_SETUP_NORESET
/* max1363 only - though don't care on others.
 * For now monitor modes are not implemented as the relevant
 * line is not connected on my test board.
 * The definitions are here as I intend to add this soon.
 */
#define MAX1363_SETUP_MONITOR_SETUP

/* Specific to the max1363 */
#define MAX1363_MON_RESET_CHAN(a)
#define MAX1363_MON_INT_ENABLE

/* defined for readability reasons */
/* All chips */
#define MAX1363_CONFIG_BYTE(a)

#define MAX1363_CONFIG_SE
#define MAX1363_CONFIG_DE
#define MAX1363_CONFIG_SCAN_TO_CS
#define MAX1363_CONFIG_SCAN_SINGLE_8
#define MAX1363_CONFIG_SCAN_MONITOR_MODE
#define MAX1363_CONFIG_SCAN_SINGLE_1
/* max123{6-9} only */
#define MAX1236_SCAN_MID_TO_CHANNEL

/* max1363 only - merely part of channel selects or don't care for others */
#define MAX1363_CONFIG_EN_MON_MODE_READ

#define MAX1363_CHANNEL_SEL(a)

/* max1363 strictly 0x06 - but doesn't matter */
#define MAX1363_CHANNEL_SEL_MASK
#define MAX1363_SCAN_MASK
#define MAX1363_SE_DE_MASK

#define MAX1363_MAX_CHANNELS
/**
 * struct max1363_mode - scan mode information
 * @conf:	The corresponding value of the configuration register
 * @modemask:	Bit mask corresponding to channels enabled in this mode
 */
struct max1363_mode {};

/* This must be maintained along side the max1363_mode_table in max1363_core */
enum max1363_modes {};

/**
 * struct max1363_chip_info - chip specifc information
 * @info:		iio core function callbacks structure
 * @channels:		channel specification
 * @num_channels:       number of channels
 * @mode_list:		array of available scan modes
 * @default_mode:	the scan mode in which the chip starts up
 * @int_vref_mv:	the internal reference voltage
 * @num_modes:		number of modes
 * @bits:		accuracy of the adc in bits
 */
struct max1363_chip_info {};

/**
 * struct max1363_state - driver instance specific data
 * @client:		i2c_client
 * @setupbyte:		cache of current device setup byte
 * @configbyte:		cache of current device config byte
 * @chip_info:		chip model specific constants, available modes, etc.
 * @current_mode:	the scan mode of this chip
 * @requestedmask:	a valid requested set of channels
 * @lock:		lock to ensure state is consistent
 * @monitor_on:		whether monitor mode is enabled
 * @monitor_speed:	parameter corresponding to device monitor speed setting
 * @mask_high:		bitmask for enabled high thresholds
 * @mask_low:		bitmask for enabled low thresholds
 * @thresh_high:	high threshold values
 * @thresh_low:		low threshold values
 * @vref:		Reference voltage regulator
 * @vref_uv:		Actual (external or internal) reference voltage
 * @send:		function used to send data to the chip
 * @recv:		function used to receive data from the chip
 */
struct max1363_state {};

#define MAX1363_MODE_SINGLE(_num, _mask)

#define MAX1363_MODE_SCAN_TO_CHANNEL(_num, _mask)

/* note not available for max1363 hence naming */
#define MAX1236_MODE_SCAN_MID_TO_CHANNEL(_mid, _num, _mask)

#define MAX1363_MODE_DIFF_SINGLE(_nump, _numm, _mask)

/* Can't think how to automate naming so specify for now */
#define MAX1363_MODE_DIFF_SCAN_TO_CHANNEL(_num, _numvals, _mask)

/* note only available for max1363 hence naming */
#define MAX1236_MODE_DIFF_SCAN_MID_TO_CHANNEL(_num, _numvals, _mask)

static const struct max1363_mode max1363_mode_table[] =;

static const struct max1363_mode
*max1363_match_mode(const unsigned long *mask,
	const struct max1363_chip_info *ci)
{}

static int max1363_smbus_send(const struct i2c_client *client, const char *buf,
		int count)
{}

static int max1363_smbus_recv(const struct i2c_client *client, char *buf,
		int count)
{}

static int max1363_write_basic_config(struct max1363_state *st)
{}

static int max1363_set_scan_mode(struct max1363_state *st)
{}

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

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

/* Applies to max1363 */
static const enum max1363_modes max1363_mode_list[] =;

static const struct iio_event_spec max1363_events[] =;

#define MAX1363_CHAN_U(num, addr, si, bits, ev_spec, num_ev_spec)

/* bipolar channel */
#define MAX1363_CHAN_B(num, num2, addr, si, bits, ev_spec, num_ev_spec)

#define MAX1363_4X_CHANS(bits, ev_spec, num_ev_spec)

static const struct iio_chan_spec max1036_channels[] =;
static const struct iio_chan_spec max1136_channels[] =;
static const struct iio_chan_spec max1236_channels[] =;
static const struct iio_chan_spec max1361_channels[] =;
static const struct iio_chan_spec max1363_channels[] =;

/* Applies to max1236, max1237 */
static const enum max1363_modes max1236_mode_list[] =;

/* Applies to max1238, max1239 */
static const enum max1363_modes max1238_mode_list[] =;

#define MAX1363_12X_CHANS(bits)
static const struct iio_chan_spec max1038_channels[] =;
static const struct iio_chan_spec max1138_channels[] =;
static const struct iio_chan_spec max1238_channels[] =;

static const enum max1363_modes max11607_mode_list[] =;

static const enum max1363_modes max11608_mode_list[] =;

#define MAX1363_8X_CHANS(bits)
static const struct iio_chan_spec max11602_channels[] =;
static const struct iio_chan_spec max11608_channels[] =;
static const struct iio_chan_spec max11614_channels[] =;

static const enum max1363_modes max11644_mode_list[] =;

#define MAX1363_2X_CHANS(bits)

static const struct iio_chan_spec max11646_channels[] =;
static const struct iio_chan_spec max11644_channels[] =;

enum {};

static const int max1363_monitor_speeds[] =;

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

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

static IIO_DEV_ATTR_SAMP_FREQ(S_IRUGO | S_IWUSR,
			max1363_monitor_show_freq,
			max1363_monitor_store_freq);

static IIO_CONST_ATTR(sampling_frequency_available,
		"133000 665000 33300 16600 8300 4200 2000 1000");

static int max1363_read_thresh(struct iio_dev *indio_dev,
	const struct iio_chan_spec *chan, enum iio_event_type type,
	enum iio_event_direction dir, enum iio_event_info info, int *val,
	int *val2)
{}

static int max1363_write_thresh(struct iio_dev *indio_dev,
	const struct iio_chan_spec *chan, enum iio_event_type type,
	enum iio_event_direction dir, enum iio_event_info info, int val,
	int val2)
{}

static const u64 max1363_event_codes[] =;

static irqreturn_t max1363_event_handler(int irq, void *private)
{}

static int max1363_read_event_config(struct iio_dev *indio_dev,
	const struct iio_chan_spec *chan, enum iio_event_type type,
	enum iio_event_direction dir)
{}

static int max1363_monitor_mode_update(struct max1363_state *st, int enabled)
{}

/*
 * To keep this manageable we always use one of 3 scan modes.
 * Scan 0...3, 0-1,2-3 and 1-0,3-2
 */

static inline int __max1363_check_event_mask(int thismask, int checkmask)
{}

static int max1363_write_event_config(struct iio_dev *indio_dev,
	const struct iio_chan_spec *chan, enum iio_event_type type,
	enum iio_event_direction dir, int state)
{}

/*
 * As with scan_elements, only certain sets of these can
 * be combined.
 */
static struct attribute *max1363_event_attributes[] =;

static const struct attribute_group max1363_event_attribute_group =;

static int max1363_update_scan_mode(struct iio_dev *indio_dev,
				    const unsigned long *scan_mask)
{}

static const struct iio_info max1238_info =;

static const struct iio_info max1363_info =;

/* max1363 and max1368 tested - rest from data sheet */
static const struct max1363_chip_info max1363_chip_info_tbl[] =;

static int max1363_initial_setup(struct max1363_state *st)
{}

static int max1363_alloc_scan_masks(struct iio_dev *indio_dev)
{}

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

#define MAX1363_COMPATIBLE(of_compatible, cfg)

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

static int max1363_probe(struct i2c_client *client)
{}

#define MAX1363_ID_TABLE(_name, cfg)

static const struct i2c_device_id max1363_id[] =;

MODULE_DEVICE_TABLE(i2c, max1363_id);

static struct i2c_driver max1363_driver =;
module_i2c_driver();

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