linux/drivers/iio/imu/adis16475.c

// SPDX-License-Identifier: GPL-2.0
/*
 * ADIS16475 IMU driver
 *
 * Copyright 2019 Analog Devices Inc.
 */
#include <linux/bitfield.h>
#include <linux/bitops.h>
#include <linux/clk.h>
#include <linux/debugfs.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/iio/buffer.h>
#include <linux/iio/iio.h>
#include <linux/iio/imu/adis.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/irq.h>
#include <linux/lcm.h>
#include <linux/math.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/property.h>
#include <linux/spi/spi.h>

#define ADIS16475_REG_DIAG_STAT
#define ADIS16475_REG_X_GYRO_L
#define ADIS16475_REG_Y_GYRO_L
#define ADIS16475_REG_Z_GYRO_L
#define ADIS16475_REG_X_ACCEL_L
#define ADIS16475_REG_Y_ACCEL_L
#define ADIS16475_REG_Z_ACCEL_L
#define ADIS16475_REG_TEMP_OUT
#define ADIS16475_REG_X_DELTANG_L
#define ADIS16475_REG_Y_DELTANG_L
#define ADIS16475_REG_Z_DELTANG_L
#define ADIS16475_REG_X_DELTVEL_L
#define ADIS16475_REG_Y_DELTVEL_L
#define ADIS16475_REG_Z_DELTVEL_L
#define ADIS16475_REG_X_GYRO_BIAS_L
#define ADIS16475_REG_Y_GYRO_BIAS_L
#define ADIS16475_REG_Z_GYRO_BIAS_L
#define ADIS16475_REG_X_ACCEL_BIAS_L
#define ADIS16475_REG_Y_ACCEL_BIAS_L
#define ADIS16475_REG_Z_ACCEL_BIAS_L
#define ADIS16475_REG_FILT_CTRL
#define ADIS16475_FILT_CTRL_MASK
#define ADIS16475_FILT_CTRL(x)
#define ADIS16475_REG_MSG_CTRL
#define ADIS16475_MSG_CTRL_DR_POL_MASK
#define ADIS16475_MSG_CTRL_DR_POL(x)
#define ADIS16475_SYNC_MODE_MASK
#define ADIS16475_SYNC_MODE(x)
#define ADIS16575_SYNC_4KHZ_MASK
#define ADIS16575_SYNC_4KHZ(x)
#define ADIS16475_REG_UP_SCALE
#define ADIS16475_REG_DEC_RATE
#define ADIS16475_REG_GLOB_CMD
#define ADIS16475_REG_FIRM_REV
#define ADIS16475_REG_FIRM_DM
#define ADIS16475_REG_FIRM_Y
#define ADIS16475_REG_PROD_ID
#define ADIS16475_REG_SERIAL_NUM
#define ADIS16475_REG_FLASH_CNT
#define ADIS16500_BURST_DATA_SEL_MASK
#define ADIS16500_BURST32_MASK
#define ADIS16500_BURST32(x)
/* number of data elements in burst mode */
#define ADIS16475_BURST32_MAX_DATA_NO_TS32
#define ADIS16575_BURST32_DATA_TS32
#define ADIS16475_BURST_MAX_DATA
#define ADIS16475_MAX_SCAN_DATA
/* spi max speed in brust mode */
#define ADIS16475_BURST_MAX_SPEED
#define ADIS16575_BURST_MAX_SPEED
#define ADIS16475_LSB_DEC_MASK
#define ADIS16475_LSB_FIR_MASK
#define ADIS16500_BURST_DATA_SEL_0_CHN_MASK
#define ADIS16500_BURST_DATA_SEL_1_CHN_MASK
#define ADIS16575_MAX_FIFO_WM
#define ADIS16475_REG_FIFO_CTRL
#define ADIS16575_WM_LVL_MASK
#define ADIS16575_WM_LVL(x)
#define ADIS16575_WM_POL_MASK
#define ADIS16575_WM_POL(x)
#define ADIS16575_WM_EN_MASK
#define ADIS16575_WM_EN(x)
#define ADIS16575_OVERFLOW_MASK
#define ADIS16575_STOP_ENQUEUE
#define ADIS16575_OVERWRITE_OLDEST
#define ADIS16575_FIFO_EN_MASK
#define ADIS16575_FIFO_EN(x)
#define ADIS16575_FIFO_FLUSH_CMD
#define ADIS16575_REG_FIFO_CNT

enum {};

struct adis16475_sync {};

struct adis16475_chip_info {};

struct adis16475 {};

enum {};

static bool low_rate_allow;
module_param(low_rate_allow, bool, 0444);
MODULE_PARM_DESC();

#ifdef CONFIG_DEBUG_FS
static ssize_t adis16475_show_firmware_revision(struct file *file,
						char __user *userbuf,
						size_t count, loff_t *ppos)
{}

static const struct file_operations adis16475_firmware_revision_fops =;

static ssize_t adis16475_show_firmware_date(struct file *file,
					    char __user *userbuf,
					    size_t count, loff_t *ppos)
{}

static const struct file_operations adis16475_firmware_date_fops =;

static int adis16475_show_serial_number(void *arg, u64 *val)
{}
DEFINE_DEBUGFS_ATTRIBUTE();

static int adis16475_show_product_id(void *arg, u64 *val)
{}
DEFINE_DEBUGFS_ATTRIBUTE();

static int adis16475_show_flash_count(void *arg, u64 *val)
{}
DEFINE_DEBUGFS_ATTRIBUTE();

static void adis16475_debugfs_init(struct iio_dev *indio_dev)
{}
#else
static void adis16475_debugfs_init(struct iio_dev *indio_dev)
{
}
#endif

static int adis16475_get_freq(struct adis16475 *st, u32 *freq)
{}

static int adis16475_set_freq(struct adis16475 *st, const u32 freq)
{}

/* The values are approximated. */
static const u32 adis16475_3db_freqs[] =;

static int adis16475_get_filter(struct adis16475 *st, u32 *filter)
{}

static int adis16475_set_filter(struct adis16475 *st, const u32 filter)
{}

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

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

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

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

static IIO_DEVICE_ATTR_RO(hwfifo_watermark_min, 0);
static IIO_DEVICE_ATTR_RO(hwfifo_watermark_max, 0);
static IIO_DEVICE_ATTR(hwfifo_watermark, 0444,
		       adis16475_get_fifo_watermark, NULL, 0);
static IIO_DEVICE_ATTR(hwfifo_enabled, 0444,
		       adis16475_get_fifo_enabled, NULL, 0);

static const struct iio_dev_attr *adis16475_fifo_attributes[] =;

static int adis16475_buffer_postenable(struct iio_dev *indio_dev)
{}

static int adis16475_buffer_postdisable(struct iio_dev *indio_dev)
{}

static const struct iio_buffer_setup_ops adis16475_buffer_ops =;

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

static const u32 adis16475_calib_regs[] =;

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

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

#define ADIS16475_MOD_CHAN(_type, _mod, _address, _si, _r_bits, _s_bits)

#define ADIS16475_GYRO_CHANNEL(_mod)

#define ADIS16475_ACCEL_CHANNEL(_mod)

#define ADIS16475_TEMP_CHANNEL()

#define ADIS16475_MOD_CHAN_DELTA(_type, _mod, _address, _si, _r_bits, _s_bits)

#define ADIS16475_DELTANG_CHAN(_mod)

#define ADIS16475_DELTVEL_CHAN(_mod)

#define ADIS16475_DELTANG_CHAN_NO_SCAN(_mod)

#define ADIS16475_DELTVEL_CHAN_NO_SCAN(_mod)

static const struct iio_chan_spec adis16477_channels[] =;

static const struct iio_chan_spec adis16475_channels[] =;

static const struct iio_chan_spec adis16575_channels[] =;

enum adis16475_variant {};

enum {};

static const char * const adis16475_status_error_msgs[] =;

#define ADIS16475_DATA(_prod_id, _timeouts, _burst_max_len, _burst_max_speed_hz, _has_fifo)

static const struct adis16475_sync adis16475_sync_mode[] =;

static const struct adis16475_sync adis16575_sync_mode[] =;

static const struct adis_timeout adis16475_timeouts =;

static const struct adis_timeout adis1650x_timeouts =;

static const struct adis16475_chip_info adis16475_chip_info[] =;

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

static const struct iio_info adis16475_info =;

static const struct iio_info adis16575_info =;

static bool adis16475_validate_crc(const u8 *buffer, u16 crc,
				   u16 burst_size, u16 start_idx)
{}

static void adis16475_burst32_check(struct adis16475 *st)
{}

static int adis16475_push_single_sample(struct iio_poll_func *pf)
{}

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

/*
 * This function updates the first tx byte from the adis message based on the
 * given burst request.
 */
static void adis16575_update_msg_for_burst(struct adis *adis, u8 burst_req)
{}

static int adis16575_custom_burst_read(struct iio_poll_func *pf, u8 burst_req)
{}

/*
 * This handler is meant to be used for devices which support burst readings
 * from FIFO (namely devices from adis1657x family).
 * In order to pop the FIFO the 0x68 0x00 FIFO pop burst request has to be sent.
 * If the previous device command was not a FIFO pop burst request, the FIFO pop
 * burst request will simply pop the FIFO without returning valid data.
 * For the nth consecutive burst request, thedevice will send the data popped
 * with the (n-1)th consecutive burst request.
 * In order to read the data which was popped previously, without popping the
 * FIFO, the 0x00 0x00 burst request has to be sent.
 * If after a 0x68 0x00 FIFO pop burst request, there is any other device access
 * different from a 0x68 0x00 or a 0x00 0x00 burst request, the FIFO data popped
 * previously will be lost.
 */
static irqreturn_t adis16475_trigger_handler_with_fifo(int irq, void *p)
{}

static int adis16475_config_sync_mode(struct adis16475 *st)
{}

static int adis16475_config_irq_pin(struct adis16475 *st)
{}


static int adis16475_probe(struct spi_device *spi)
{}

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

static const struct spi_device_id adis16475_ids[] =;
MODULE_DEVICE_TABLE(spi, adis16475_ids);

static struct spi_driver adis16475_driver =;
module_spi_driver();

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