linux/drivers/staging/iio/accel/adis16240.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * ADIS16240 Programmable Impact Sensor and Recorder driver
 *
 * Copyright 2010 Analog Devices Inc.
 */

#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/spi/spi.h>
#include <linux/sysfs.h>
#include <linux/module.h>

#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/imu/adis.h>

#define ADIS16240_STARTUP_DELAY

/* Flash memory write count */
#define ADIS16240_FLASH_CNT

/* Output, power supply */
#define ADIS16240_SUPPLY_OUT

/* Output, x-axis accelerometer */
#define ADIS16240_XACCL_OUT

/* Output, y-axis accelerometer */
#define ADIS16240_YACCL_OUT

/* Output, z-axis accelerometer */
#define ADIS16240_ZACCL_OUT

/* Output, auxiliary ADC input */
#define ADIS16240_AUX_ADC

/* Output, temperature */
#define ADIS16240_TEMP_OUT

/* Output, x-axis acceleration peak */
#define ADIS16240_XPEAK_OUT

/* Output, y-axis acceleration peak */
#define ADIS16240_YPEAK_OUT

/* Output, z-axis acceleration peak */
#define ADIS16240_ZPEAK_OUT

/* Output, sum-of-squares acceleration peak */
#define ADIS16240_XYZPEAK_OUT

/* Output, Capture Buffer 1, X and Y acceleration */
#define ADIS16240_CAPT_BUF1

/* Output, Capture Buffer 2, Z acceleration */
#define ADIS16240_CAPT_BUF2

/* Diagnostic, error flags */
#define ADIS16240_DIAG_STAT

/* Diagnostic, event counter */
#define ADIS16240_EVNT_CNTR

/* Diagnostic, check sum value from firmware test */
#define ADIS16240_CHK_SUM

/* Calibration, x-axis acceleration offset adjustment */
#define ADIS16240_XACCL_OFF

/* Calibration, y-axis acceleration offset adjustment */
#define ADIS16240_YACCL_OFF

/* Calibration, z-axis acceleration offset adjustment */
#define ADIS16240_ZACCL_OFF

/* Clock, hour and minute */
#define ADIS16240_CLK_TIME

/* Clock, month and day */
#define ADIS16240_CLK_DATE

/* Clock, year */
#define ADIS16240_CLK_YEAR

/* Wake-up setting, hour and minute */
#define ADIS16240_WAKE_TIME

/* Wake-up setting, month and day */
#define ADIS16240_WAKE_DATE

/* Alarm 1 amplitude threshold */
#define ADIS16240_ALM_MAG1

/* Alarm 2 amplitude threshold */
#define ADIS16240_ALM_MAG2

/* Alarm control */
#define ADIS16240_ALM_CTRL

/* Capture, external trigger control */
#define ADIS16240_XTRIG_CTRL

/* Capture, address pointer */
#define ADIS16240_CAPT_PNTR

/* Capture, configuration and control */
#define ADIS16240_CAPT_CTRL

/* General-purpose digital input/output control */
#define ADIS16240_GPIO_CTRL

/* Miscellaneous control */
#define ADIS16240_MSC_CTRL

/* Internal sample period (rate) control */
#define ADIS16240_SMPL_PRD

/* System command */
#define ADIS16240_GLOB_CMD

/* MSC_CTRL */

/* Enables sum-of-squares output (XYZPEAK_OUT) */
#define ADIS16240_MSC_CTRL_XYZPEAK_OUT_EN

/* Enables peak tracking output (XPEAK_OUT, YPEAK_OUT, and ZPEAK_OUT) */
#define ADIS16240_MSC_CTRL_X_Y_ZPEAK_OUT_EN

/* Self-test enable: 1 = apply electrostatic force, 0 = disabled */
#define ADIS16240_MSC_CTRL_SELF_TEST_EN

/* Data-ready enable: 1 = enabled, 0 = disabled */
#define ADIS16240_MSC_CTRL_DATA_RDY_EN

/* Data-ready polarity: 1 = active high, 0 = active low */
#define ADIS16240_MSC_CTRL_ACTIVE_HIGH

/* Data-ready line selection: 1 = DIO2, 0 = DIO1 */
#define ADIS16240_MSC_CTRL_DATA_RDY_DIO2

/* DIAG_STAT */

/* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */
#define ADIS16240_DIAG_STAT_ALARM2

/* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */
#define ADIS16240_DIAG_STAT_ALARM1

/* Capture buffer full: 1 = capture buffer is full */
#define ADIS16240_DIAG_STAT_CPT_BUF_FUL

/* Flash test, checksum flag: 1 = mismatch, 0 = match */
#define ADIS16240_DIAG_STAT_CHKSUM

/* Power-on, self-test flag: 1 = failure, 0 = pass */
#define ADIS16240_DIAG_STAT_PWRON_FAIL_BIT

/* Power-on self-test: 1 = in-progress, 0 = complete */
#define ADIS16240_DIAG_STAT_PWRON_BUSY

/* SPI communications failure */
#define ADIS16240_DIAG_STAT_SPI_FAIL_BIT

/* Flash update failure */
#define ADIS16240_DIAG_STAT_FLASH_UPT_BIT

/* Power supply above 3.625 V */
#define ADIS16240_DIAG_STAT_POWER_HIGH_BIT

 /* Power supply below 2.225 V */
#define ADIS16240_DIAG_STAT_POWER_LOW_BIT

/* GLOB_CMD */

#define ADIS16240_GLOB_CMD_RESUME
#define ADIS16240_GLOB_CMD_SW_RESET
#define ADIS16240_GLOB_CMD_STANDBY

#define ADIS16240_ERROR_ACTIVE

/* At the moment triggers are only used for ring buffer
 * filling. This may change!
 */

enum adis16240_scan {};

static ssize_t adis16240_spi_read_signed(struct device *dev,
					 struct device_attribute *attr,
					 char *buf,
					 unsigned int bits)
{}

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

static IIO_DEVICE_ATTR(in_accel_xyz_squared_peak_raw, 0444,
		       adis16240_read_12bit_signed, NULL,
		       ADIS16240_XYZPEAK_OUT);

static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("4096");

static const u8 adis16240_addresses[][2] =;

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

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

static const struct iio_chan_spec adis16240_channels[] =;

static struct attribute *adis16240_attributes[] =;

static const struct attribute_group adis16240_attribute_group =;

static const struct iio_info adis16240_info =;

static const char * const adis16240_status_error_msgs[] =;

static const struct adis_timeout adis16240_timeouts =;

static const struct adis_data adis16240_data =;

static int adis16240_probe(struct spi_device *spi)
{}

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

static struct spi_driver adis16240_driver =;
module_spi_driver();

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