1#ifndef SPI_ADIS16220_H_ 2#define SPI_ADIS16220_H_ 3 4#include <linux/iio/imu/adis.h> 5 6#define ADIS16220_STARTUP_DELAY 220 /* ms */ 7 8/* Flash memory write count */ 9#define ADIS16220_FLASH_CNT 0x00 10/* Control, acceleration offset adjustment control */ 11#define ADIS16220_ACCL_NULL 0x02 12/* Control, AIN1 offset adjustment control */ 13#define ADIS16220_AIN1_NULL 0x04 14/* Control, AIN2 offset adjustment control */ 15#define ADIS16220_AIN2_NULL 0x06 16/* Output, power supply during capture */ 17#define ADIS16220_CAPT_SUPPLY 0x0A 18/* Output, temperature during capture */ 19#define ADIS16220_CAPT_TEMP 0x0C 20/* Output, peak acceleration during capture */ 21#define ADIS16220_CAPT_PEAKA 0x0E 22/* Output, peak AIN1 level during capture */ 23#define ADIS16220_CAPT_PEAK1 0x10 24/* Output, peak AIN2 level during capture */ 25#define ADIS16220_CAPT_PEAK2 0x12 26/* Output, capture buffer for acceleration */ 27#define ADIS16220_CAPT_BUFA 0x14 28/* Output, capture buffer for AIN1 */ 29#define ADIS16220_CAPT_BUF1 0x16 30/* Output, capture buffer for AIN2 */ 31#define ADIS16220_CAPT_BUF2 0x18 32/* Control, capture buffer address pointer */ 33#define ADIS16220_CAPT_PNTR 0x1A 34/* Control, capture control register */ 35#define ADIS16220_CAPT_CTRL 0x1C 36/* Control, capture period (automatic mode) */ 37#define ADIS16220_CAPT_PRD 0x1E 38/* Control, Alarm A, acceleration peak threshold */ 39#define ADIS16220_ALM_MAGA 0x20 40/* Control, Alarm 1, AIN1 peak threshold */ 41#define ADIS16220_ALM_MAG1 0x22 42/* Control, Alarm 2, AIN2 peak threshold */ 43#define ADIS16220_ALM_MAG2 0x24 44/* Control, Alarm S, peak threshold */ 45#define ADIS16220_ALM_MAGS 0x26 46/* Control, alarm configuration register */ 47#define ADIS16220_ALM_CTRL 0x28 48/* Control, general I/O configuration */ 49#define ADIS16220_GPIO_CTRL 0x32 50/* Control, self-test control, AIN configuration */ 51#define ADIS16220_MSC_CTRL 0x34 52/* Control, digital I/O configuration */ 53#define ADIS16220_DIO_CTRL 0x36 54/* Control, filter configuration */ 55#define ADIS16220_AVG_CNT 0x38 56/* Status, system status */ 57#define ADIS16220_DIAG_STAT 0x3C 58/* Control, system commands */ 59#define ADIS16220_GLOB_CMD 0x3E 60/* Status, self-test response */ 61#define ADIS16220_ST_DELTA 0x40 62/* Lot Identification Code 1 */ 63#define ADIS16220_LOT_ID1 0x52 64/* Lot Identification Code 2 */ 65#define ADIS16220_LOT_ID2 0x54 66/* Product identifier; convert to decimal = 16220 */ 67#define ADIS16220_PROD_ID 0x56 68/* Serial number */ 69#define ADIS16220_SERIAL_NUM 0x58 70 71#define ADIS16220_CAPTURE_SIZE 2048 72 73/* MSC_CTRL */ 74#define ADIS16220_MSC_CTRL_SELF_TEST_EN (1 << 8) 75#define ADIS16220_MSC_CTRL_POWER_SUP_COM_AIN1 (1 << 1) 76#define ADIS16220_MSC_CTRL_POWER_SUP_COM_AIN2 (1 << 0) 77 78/* DIO_CTRL */ 79#define ADIS16220_MSC_CTRL_DIO2_BUSY_IND (3<<4) 80#define ADIS16220_MSC_CTRL_DIO1_BUSY_IND (3<<2) 81#define ADIS16220_MSC_CTRL_DIO2_ACT_HIGH (1<<1) 82#define ADIS16220_MSC_CTRL_DIO1_ACT_HIGH (1<<0) 83 84/* DIAG_STAT */ 85/* AIN2 sample > ALM_MAG2 */ 86#define ADIS16220_DIAG_STAT_ALM_MAG2 (1<<14) 87/* AIN1 sample > ALM_MAG1 */ 88#define ADIS16220_DIAG_STAT_ALM_MAG1 (1<<13) 89/* Acceleration sample > ALM_MAGA */ 90#define ADIS16220_DIAG_STAT_ALM_MAGA (1<<12) 91/* Error condition programmed into ALM_MAGS[11:0] and ALM_CTRL[5:4] is true */ 92#define ADIS16220_DIAG_STAT_ALM_MAGS (1<<11) 93/* |Peak value in AIN2 data capture| > ALM_MAG2 */ 94#define ADIS16220_DIAG_STAT_PEAK_AIN2 (1<<10) 95/* |Peak value in AIN1 data capture| > ALM_MAG1 */ 96#define ADIS16220_DIAG_STAT_PEAK_AIN1 (1<<9) 97/* |Peak value in acceleration data capture| > ALM_MAGA */ 98#define ADIS16220_DIAG_STAT_PEAK_ACCEL (1<<8) 99/* Data ready, capture complete */ 100#define ADIS16220_DIAG_STAT_DATA_RDY (1<<7) 101#define ADIS16220_DIAG_STAT_FLASH_CHK (1<<6) 102#define ADIS16220_DIAG_STAT_SELF_TEST (1<<5) 103/* Capture period violation/interruption */ 104#define ADIS16220_DIAG_STAT_VIOLATION_BIT 4 105/* SPI communications failure */ 106#define ADIS16220_DIAG_STAT_SPI_FAIL_BIT 3 107/* Flash update failure */ 108#define ADIS16220_DIAG_STAT_FLASH_UPT_BIT 2 109/* Power supply above 3.625 V */ 110#define ADIS16220_DIAG_STAT_POWER_HIGH_BIT 1 111/* Power supply below 3.15 V */ 112#define ADIS16220_DIAG_STAT_POWER_LOW_BIT 0 113 114/* GLOB_CMD */ 115#define ADIS16220_GLOB_CMD_SW_RESET (1<<7) 116#define ADIS16220_GLOB_CMD_SELF_TEST (1<<2) 117#define ADIS16220_GLOB_CMD_PWR_DOWN (1<<1) 118 119#define ADIS16220_MAX_TX 2048 120#define ADIS16220_MAX_RX 2048 121 122#define ADIS16220_SPI_BURST (u32)(1000 * 1000) 123#define ADIS16220_SPI_FAST (u32)(2000 * 1000) 124 125/** 126 * struct adis16220_state - device instance specific data 127 * @adis: adis device 128 * @tx: transmit buffer 129 * @rx: receive buffer 130 * @buf_lock: mutex to protect tx and rx 131 **/ 132struct adis16220_state { 133 struct adis adis; 134 135 struct mutex buf_lock; 136 u8 tx[ADIS16220_MAX_TX] ____cacheline_aligned; 137 u8 rx[ADIS16220_MAX_RX]; 138}; 139 140#endif /* SPI_ADIS16220_H_ */ 141