linux/drivers/iio/adc/qcom-spmi-vadc.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
 */

#include <linux/bitops.h>
#include <linux/completion.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/iio/adc/qcom-vadc-common.h>
#include <linux/iio/iio.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/math64.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <linux/log2.h>

#include <dt-bindings/iio/qcom,spmi-vadc.h>

/* VADC register and bit definitions */
#define VADC_REVISION2
#define VADC_REVISION2_SUPPORTED_VADC

#define VADC_PERPH_TYPE
#define VADC_PERPH_TYPE_ADC

#define VADC_PERPH_SUBTYPE
#define VADC_PERPH_SUBTYPE_VADC

#define VADC_STATUS1
#define VADC_STATUS1_OP_MODE
#define VADC_STATUS1_REQ_STS
#define VADC_STATUS1_EOC
#define VADC_STATUS1_REQ_STS_EOC_MASK

#define VADC_MODE_CTL
#define VADC_OP_MODE_SHIFT
#define VADC_OP_MODE_NORMAL
#define VADC_AMUX_TRIM_EN
#define VADC_ADC_TRIM_EN

#define VADC_EN_CTL1
#define VADC_EN_CTL1_SET

#define VADC_ADC_CH_SEL_CTL

#define VADC_ADC_DIG_PARAM
#define VADC_ADC_DIG_DEC_RATIO_SEL_SHIFT

#define VADC_HW_SETTLE_DELAY

#define VADC_CONV_REQ
#define VADC_CONV_REQ_SET

#define VADC_FAST_AVG_CTL
#define VADC_FAST_AVG_EN
#define VADC_FAST_AVG_EN_SET

#define VADC_ACCESS
#define VADC_ACCESS_DATA

#define VADC_PERH_RESET_CTL3
#define VADC_FOLLOW_WARM_RB

#define VADC_DATA

#define VADC_CHAN_MIN
#define VADC_CHAN_MAX

/**
 * struct vadc_channel_prop - VADC channel property.
 * @channel: channel number, refer to the channel list.
 * @calibration: calibration type.
 * @decimation: sampling rate supported for the channel.
 * @prescale: channel scaling performed on the input signal.
 * @hw_settle_time: the time between AMUX being configured and the
 *	start of conversion.
 * @avg_samples: ability to provide single result from the ADC
 *	that is an average of multiple measurements.
 * @scale_fn_type: Represents the scaling function to convert voltage
 *	physical units desired by the client for the channel.
 * @channel_name: Channel name used in device tree.
 */
struct vadc_channel_prop {};

/**
 * struct vadc_priv - VADC private structure.
 * @regmap: pointer to struct regmap.
 * @dev: pointer to struct device.
 * @base: base address for the ADC peripheral.
 * @nchannels: number of VADC channels.
 * @chan_props: array of VADC channel properties.
 * @iio_chans: array of IIO channels specification.
 * @are_ref_measured: are reference points measured.
 * @poll_eoc: use polling instead of interrupt.
 * @complete: VADC result notification after interrupt is received.
 * @graph: store parameters for calibration.
 * @lock: ADC lock for access to the peripheral.
 */
struct vadc_priv {};

static const struct u32_fract vadc_prescale_ratios[] =;

static int vadc_read(struct vadc_priv *vadc, u16 offset, u8 *data)
{}

static int vadc_write(struct vadc_priv *vadc, u16 offset, u8 data)
{}

static int vadc_reset(struct vadc_priv *vadc)
{}

static int vadc_set_state(struct vadc_priv *vadc, bool state)
{}

static void vadc_show_status(struct vadc_priv *vadc)
{}

static int vadc_configure(struct vadc_priv *vadc,
			  struct vadc_channel_prop *prop)
{}

static int vadc_poll_wait_eoc(struct vadc_priv *vadc, unsigned int interval_us)
{}

static int vadc_read_result(struct vadc_priv *vadc, u16 *data)
{}

static struct vadc_channel_prop *vadc_get_channel(struct vadc_priv *vadc,
						  unsigned int num)
{}

static int vadc_do_conversion(struct vadc_priv *vadc,
			      struct vadc_channel_prop *prop, u16 *data)
{}

static int vadc_measure_ref_points(struct vadc_priv *vadc)
{}

static int vadc_prescaling_from_dt(u32 numerator, u32 denominator)
{}

static int vadc_hw_settle_time_from_dt(u32 value)
{}

static int vadc_avg_samples_from_dt(u32 value)
{}

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

static int vadc_fwnode_xlate(struct iio_dev *indio_dev,
			     const struct fwnode_reference_args *iiospec)
{}

static int vadc_read_label(struct iio_dev *indio_dev,
			   struct iio_chan_spec const *chan, char *label)
{}

static const struct iio_info vadc_info =;

struct vadc_channels {};

#define VADC_CHAN(_dname, _type, _mask, _pre, _scale)								\

#define VADC_NO_CHAN(_dname, _type, _mask, _pre)

#define VADC_CHAN_TEMP(_dname, _pre, _scale)						\

#define VADC_CHAN_VOLT(_dname, _pre, _scale)						\

#define VADC_CHAN_NO_SCALE(_dname, _pre)							\

/*
 * The array represents all possible ADC channels found in the supported PMICs.
 * Every index in the array is equal to the channel number per datasheet. The
 * gaps in the array should be treated as reserved channels.
 */
static const struct vadc_channels vadc_chans[] =;

static int vadc_get_fw_channel_data(struct device *dev,
				    struct vadc_channel_prop *prop,
				    struct fwnode_handle *fwnode)
{}

static int vadc_get_fw_data(struct vadc_priv *vadc)
{}

static irqreturn_t vadc_isr(int irq, void *dev_id)
{}

static int vadc_check_revision(struct vadc_priv *vadc)
{}

static int vadc_probe(struct platform_device *pdev)
{}

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

static struct platform_driver vadc_driver =;
module_platform_driver();

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