linux/drivers/iio/adc/at91-sama5d2_adc.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Atmel ADC driver for SAMA5D2 devices and compatible.
 *
 * Copyright (C) 2015 Atmel,
 *               2015 Ludovic Desroches <[email protected]>
 *		 2021 Microchip Technology, Inc. and its subsidiaries
 *		 2021 Eugen Hristev <[email protected]>
 */

#include <linux/bitops.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/dma-mapping.h>
#include <linux/dmaengine.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/sched.h>
#include <linux/units.h>
#include <linux/wait.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/buffer.h>
#include <linux/iio/trigger.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/triggered_buffer.h>
#include <linux/nvmem-consumer.h>
#include <linux/pinctrl/consumer.h>
#include <linux/pm_runtime.h>
#include <linux/regulator/consumer.h>

#include <dt-bindings/iio/adc/at91-sama5d2_adc.h>

struct at91_adc_reg_layout {};

static const struct at91_adc_reg_layout sama5d2_layout =;

static const struct at91_adc_reg_layout sama7g5_layout =;

#define AT91_SAMA5D2_TOUCH_SAMPLE_PERIOD_US
#define AT91_SAMA5D2_TOUCH_PEN_DETECT_DEBOUNCE_US

#define AT91_SAMA5D2_XYZ_MASK

#define AT91_SAMA5D2_MAX_POS_BITS

#define AT91_HWFIFO_MAX_SIZE_STR
#define AT91_HWFIFO_MAX_SIZE

#define AT91_SAMA5D2_CHAN_SINGLE(index, num, addr)

#define AT91_SAMA5D2_CHAN_DIFF(index, num, num2, addr)

#define AT91_SAMA5D2_CHAN_TOUCH(num, name, mod)
#define AT91_SAMA5D2_CHAN_PRESSURE(num, name)

#define AT91_SAMA5D2_CHAN_TEMP(num, name, addr)

#define at91_adc_readl(st, reg)
#define at91_adc_read_chan(st, reg)
#define at91_adc_writel(st, reg, val)

/**
 * struct at91_adc_platform - at91-sama5d2 platform information struct
 * @layout:		pointer to the reg layout struct
 * @adc_channels:	pointer to an array of channels for registering in
 *			the iio subsystem
 * @nr_channels:	number of physical channels available
 * @touch_chan_x:	index of the touchscreen X channel
 * @touch_chan_y:	index of the touchscreen Y channel
 * @touch_chan_p:	index of the touchscreen P channel
 * @max_channels:	number of total channels
 * @max_index:		highest channel index (highest index may be higher
 *			than the total channel number)
 * @hw_trig_cnt:	number of possible hardware triggers
 * @osr_mask:		oversampling ratio bitmask on EMR register
 * @oversampling_avail:	available oversampling values
 * @oversampling_avail_no: number of available oversampling values
 * @chan_realbits:	realbits for registered channels
 * @temp_chan:		temperature channel index
 * @temp_sensor:	temperature sensor supported
 */
struct at91_adc_platform {};

/**
 * struct at91_adc_temp_sensor_clb - at91-sama5d2 temperature sensor
 * calibration data structure
 * @p1: P1 calibration temperature
 * @p4: P4 calibration voltage
 * @p6: P6 calibration voltage
 */
struct at91_adc_temp_sensor_clb {};

/**
 * enum at91_adc_ts_clb_idx - calibration indexes in NVMEM buffer
 * @AT91_ADC_TS_CLB_IDX_P1: index for P1
 * @AT91_ADC_TS_CLB_IDX_P4: index for P4
 * @AT91_ADC_TS_CLB_IDX_P6: index for P6
 * @AT91_ADC_TS_CLB_IDX_MAX: max index for temperature calibration packet in OTP
 */
enum at91_adc_ts_clb_idx {};

/* Temperature sensor calibration - Vtemp voltage sensitivity to temperature. */
#define AT91_ADC_TS_VTEMP_DT

/**
 * struct at91_adc_soc_info - at91-sama5d2 soc information struct
 * @startup_time:	device startup time
 * @min_sample_rate:	minimum sample rate in Hz
 * @max_sample_rate:	maximum sample rate in Hz
 * @platform:		pointer to the platform structure
 * @temp_sensor_clb:	temperature sensor calibration data structure
 */
struct at91_adc_soc_info {};

struct at91_adc_trigger {};

/**
 * struct at91_adc_dma - at91-sama5d2 dma information struct
 * @dma_chan:		the dma channel acquired
 * @rx_buf:		dma coherent allocated area
 * @rx_dma_buf:		dma handler for the buffer
 * @phys_addr:		physical address of the ADC base register
 * @buf_idx:		index inside the dma buffer where reading was last done
 * @rx_buf_sz:		size of buffer used by DMA operation
 * @watermark:		number of conversions to copy before DMA triggers irq
 * @dma_ts:		hold the start timestamp of dma operation
 */
struct at91_adc_dma {};

/**
 * struct at91_adc_touch - at91-sama5d2 touchscreen information struct
 * @sample_period_val:		the value for periodic trigger interval
 * @touching:			is the pen touching the screen or not
 * @x_pos:			temporary placeholder for pressure computation
 * @channels_bitmask:		bitmask with the touchscreen channels enabled
 * @workq:			workqueue for buffer data pushing
 */
struct at91_adc_touch {};

/**
 * struct at91_adc_temp - at91-sama5d2 temperature information structure
 * @sample_period_val:	sample period value
 * @saved_sample_rate:	saved sample rate
 * @saved_oversampling:	saved oversampling
 */
struct at91_adc_temp {};

/*
 * Buffer size requirements:
 * No channels * bytes_per_channel(2) + timestamp bytes (8)
 * Divided by 2 because we need half words.
 * We assume 32 channels for now, has to be increased if needed.
 * Nobody minds a buffer being too big.
 */
#define AT91_BUFFER_MAX_HWORDS

struct at91_adc_state {};

static const struct at91_adc_trigger at91_adc_trigger_list[] =;

static const struct iio_chan_spec at91_sama5d2_adc_channels[] =;

static const struct iio_chan_spec at91_sama7g5_adc_channels[] =;

static const struct at91_adc_platform sama5d2_platform =;

static const struct at91_adc_platform sama7g5_platform =;

static int at91_adc_chan_xlate(struct iio_dev *indio_dev, int chan)
{}

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

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

static unsigned int at91_adc_active_scan_mask_to_reg(struct iio_dev *indio_dev)
{}

static void at91_adc_cor(struct at91_adc_state *st,
			 struct iio_chan_spec const *chan)
{}

static void at91_adc_irq_status(struct at91_adc_state *st, u32 *status,
				u32 *eoc)
{}

static void at91_adc_irq_mask(struct at91_adc_state *st, u32 *status, u32 *eoc)
{}

static void at91_adc_eoc_dis(struct at91_adc_state *st, unsigned int channel)
{}

static void at91_adc_eoc_ena(struct at91_adc_state *st, unsigned int channel)
{}

static int at91_adc_config_emr(struct at91_adc_state *st,
			       u32 oversampling_ratio, u32 trackx)
{}

static int at91_adc_adjust_val_osr(struct at91_adc_state *st, int *val)
{}

static void at91_adc_adjust_val_osr_array(struct at91_adc_state *st, void *buf,
					  int len)
{}

static int at91_adc_configure_touch(struct at91_adc_state *st, bool state)
{}

static u16 at91_adc_touch_pos(struct at91_adc_state *st, int reg)
{}

static u16 at91_adc_touch_x_pos(struct at91_adc_state *st)
{}

static u16 at91_adc_touch_y_pos(struct at91_adc_state *st)
{}

static u16 at91_adc_touch_pressure(struct at91_adc_state *st)
{}

static int at91_adc_read_position(struct at91_adc_state *st, int chan, u16 *val)
{}

static int at91_adc_read_pressure(struct at91_adc_state *st, int chan, u16 *val)
{}

static void at91_adc_configure_trigger_registers(struct at91_adc_state *st,
						 bool state)
{}

static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
{}

static void at91_adc_reenable_trigger(struct iio_trigger *trig)
{}

static const struct iio_trigger_ops at91_adc_trigger_ops =;

static int at91_adc_dma_size_done(struct at91_adc_state *st)
{}

static void at91_dma_buffer_done(void *data)
{}

static int at91_adc_dma_start(struct iio_dev *indio_dev)
{}

static bool at91_adc_buffer_check_use_irq(struct iio_dev *indio,
					  struct at91_adc_state *st)
{}

static bool at91_adc_current_chan_is_touch(struct iio_dev *indio_dev)
{}

static int at91_adc_buffer_prepare(struct iio_dev *indio_dev)
{}

static int at91_adc_buffer_postdisable(struct iio_dev *indio_dev)
{}

static const struct iio_buffer_setup_ops at91_buffer_setup_ops =;

static struct iio_trigger *at91_adc_allocate_trigger(struct iio_dev *indio,
						     char *trigger_name)
{}

static void at91_adc_trigger_handler_nodma(struct iio_dev *indio_dev,
					   struct iio_poll_func *pf)
{}

static void at91_adc_trigger_handler_dma(struct iio_dev *indio_dev)
{}

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

static unsigned at91_adc_startup_time(unsigned startup_time_min,
				      unsigned adc_clk_khz)
{}

static void at91_adc_setup_samp_freq(struct iio_dev *indio_dev, unsigned freq,
				     unsigned int startup_time,
				     unsigned int tracktim)
{}

static inline unsigned at91_adc_get_sample_freq(struct at91_adc_state *st)
{}

static void at91_adc_touch_data_handler(struct iio_dev *indio_dev)
{}

static void at91_adc_pen_detect_interrupt(struct at91_adc_state *st)
{}

static void at91_adc_no_pen_detect_interrupt(struct iio_dev *indio_dev)
{}

static void at91_adc_workq_handler(struct work_struct *workq)
{}

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

/* This needs to be called with direct mode claimed and st->lock locked. */
static int at91_adc_read_info_raw(struct iio_dev *indio_dev,
				  struct iio_chan_spec const *chan, int *val)
{}

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

static void at91_adc_temp_sensor_configure(struct at91_adc_state *st,
					   bool start)
{}

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

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

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

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

static void at91_adc_dma_init(struct at91_adc_state *st)
{}

static void at91_adc_dma_disable(struct at91_adc_state *st)
{}

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

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

static void at91_adc_hw_init(struct iio_dev *indio_dev)
{}

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

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

static IIO_DEVICE_ATTR(hwfifo_enabled, 0444,
		       at91_adc_get_fifo_state, NULL, 0);
static IIO_DEVICE_ATTR(hwfifo_watermark, 0444,
		       at91_adc_get_watermark, NULL, 0);

IIO_STATIC_CONST_DEVICE_ATTR();
IIO_STATIC_CONST_DEVICE_ATTR();

static const struct iio_dev_attr *at91_adc_fifo_attributes[] =;

static const struct iio_info at91_adc_info =;

static int at91_adc_buffer_and_trigger_init(struct device *dev,
					    struct iio_dev *indio)
{}

static int at91_adc_temp_sensor_init(struct at91_adc_state *st,
				     struct device *dev)
{}

static int at91_adc_probe(struct platform_device *pdev)
{}

static void at91_adc_remove(struct platform_device *pdev)
{}

static int at91_adc_suspend(struct device *dev)
{}

static int at91_adc_resume(struct device *dev)
{}

static int at91_adc_runtime_suspend(struct device *dev)
{}

static int at91_adc_runtime_resume(struct device *dev)
{}

static const struct dev_pm_ops at91_adc_pm_ops =;

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

static struct platform_driver at91_adc_driver =;
module_platform_driver()

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