#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 { … };
struct at91_adc_temp_sensor_clb { … };
enum at91_adc_ts_clb_idx { … };
#define AT91_ADC_TS_VTEMP_DT …
struct at91_adc_soc_info { … };
struct at91_adc_trigger { … };
struct at91_adc_dma { … };
struct at91_adc_touch { … };
struct at91_adc_temp { … };
#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)
{ … }
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(…) …;