linux/drivers/iio/imu/bmi323/bmi323.h

/* SPDX-License-Identifier: GPL-2.0 */
/*
 * IIO driver for Bosch BMI323 6-Axis IMU
 *
 * Copyright (C) 2023, Jagath Jog J <[email protected]>
 */

#ifndef _BMI323_H_
#define _BMI323_H_

#include <linux/bits.h>
#include <linux/regmap.h>
#include <linux/units.h>

#define BMI323_I2C_DUMMY
#define BMI323_SPI_DUMMY

/* Register map */

#define BMI323_CHIP_ID_REG
#define BMI323_CHIP_ID_VAL
#define BMI323_CHIP_ID_MSK
#define BMI323_ERR_REG
#define BMI323_STATUS_REG
#define BMI323_STATUS_POR_MSK

/* Accelero/Gyro/Temp data registers */
#define BMI323_ACCEL_X_REG
#define BMI323_GYRO_X_REG
#define BMI323_TEMP_REG
#define BMI323_ALL_CHAN_MSK

/* Status registers */
#define BMI323_STATUS_INT1_REG
#define BMI323_STATUS_INT2_REG
#define BMI323_STATUS_NOMOTION_MSK
#define BMI323_STATUS_MOTION_MSK
#define BMI323_STATUS_STP_WTR_MSK
#define BMI323_STATUS_TAP_MSK
#define BMI323_STATUS_ERROR_MSK
#define BMI323_STATUS_TMP_DRDY_MSK
#define BMI323_STATUS_GYR_DRDY_MSK
#define BMI323_STATUS_ACC_DRDY_MSK
#define BMI323_STATUS_ACC_GYR_DRDY_MSK
#define BMI323_STATUS_FIFO_WTRMRK_MSK
#define BMI323_STATUS_FIFO_FULL_MSK

/* Feature registers */
#define BMI323_FEAT_IO0_REG
#define BMI323_FEAT_IO0_XYZ_NOMOTION_MSK
#define BMI323_FEAT_IO0_XYZ_MOTION_MSK
#define BMI323_FEAT_XYZ_MSK
#define BMI323_FEAT_IO0_STP_CNT_MSK
#define BMI323_FEAT_IO0_S_TAP_MSK
#define BMI323_FEAT_IO0_D_TAP_MSK
#define BMI323_FEAT_IO1_REG
#define BMI323_FEAT_IO1_ERR_MSK
#define BMI323_FEAT_IO2_REG
#define BMI323_FEAT_IO_STATUS_REG
#define BMI323_FEAT_IO_STATUS_MSK
#define BMI323_FEAT_ENG_POLL
#define BMI323_FEAT_ENG_TIMEOUT

/* FIFO registers */
#define BMI323_FIFO_FILL_LEVEL_REG
#define BMI323_FIFO_DATA_REG

/* Accelero/Gyro config registers */
#define BMI323_ACC_CONF_REG
#define BMI323_GYRO_CONF_REG
#define BMI323_ACC_GYRO_CONF_MODE_MSK
#define BMI323_ACC_GYRO_CONF_ODR_MSK
#define BMI323_ACC_GYRO_CONF_SCL_MSK
#define BMI323_ACC_GYRO_CONF_BW_MSK
#define BMI323_ACC_GYRO_CONF_AVG_MSK

/* FIFO registers */
#define BMI323_FIFO_WTRMRK_REG
#define BMI323_FIFO_CONF_REG
#define BMI323_FIFO_CONF_STP_FUL_MSK
#define BMI323_FIFO_CONF_ACC_GYR_EN_MSK
#define BMI323_FIFO_ACC_GYR_MSK
#define BMI323_FIFO_CTRL_REG
#define BMI323_FIFO_FLUSH_MSK

/* Interrupt pin config registers */
#define BMI323_IO_INT_CTR_REG
#define BMI323_IO_INT1_LVL_MSK
#define BMI323_IO_INT1_OD_MSK
#define BMI323_IO_INT1_OP_EN_MSK
#define BMI323_IO_INT1_LVL_OD_OP_MSK
#define BMI323_IO_INT2_LVL_MSK
#define BMI323_IO_INT2_OD_MSK
#define BMI323_IO_INT2_OP_EN_MSK
#define BMI323_IO_INT2_LVL_OD_OP_MSK
#define BMI323_IO_INT_CONF_REG
#define BMI323_IO_INT_LTCH_MSK
#define BMI323_INT_MAP1_REG
#define BMI323_INT_MAP2_REG
#define BMI323_NOMOTION_MSK
#define BMI323_MOTION_MSK
#define BMI323_STEP_CNT_MSK
#define BMI323_TAP_MSK
#define BMI323_TMP_DRDY_MSK
#define BMI323_GYR_DRDY_MSK
#define BMI323_ACC_DRDY_MSK
#define BMI323_FIFO_WTRMRK_MSK
#define BMI323_FIFO_FULL_MSK

/* Feature registers */
#define BMI323_FEAT_CTRL_REG
#define BMI323_FEAT_ENG_EN_MSK
#define BMI323_FEAT_DATA_ADDR
#define BMI323_FEAT_DATA_TX
#define BMI323_FEAT_DATA_STATUS
#define BMI323_FEAT_DATA_TX_RDY_MSK
#define BMI323_FEAT_EVNT_EXT_REG
#define BMI323_FEAT_EVNT_EXT_S_MSK
#define BMI323_FEAT_EVNT_EXT_D_MSK

#define BMI323_CMD_REG
#define BMI323_RST_VAL
#define BMI323_CFG_RES_REG

/* Extended registers */
#define BMI323_GEN_SET1_REG
#define BMI323_GEN_SET1_MODE_MSK
#define BMI323_GEN_HOLD_DUR_MSK

/* Any Motion/No Motion config registers */
#define BMI323_ANYMO1_REG
#define BMI323_NOMO1_REG
#define BMI323_MO2_OFFSET
#define BMI323_MO3_OFFSET
#define BMI323_MO1_REF_UP_MSK
#define BMI323_MO1_SLOPE_TH_MSK
#define BMI323_MO2_HYSTR_MSK
#define BMI323_MO3_DURA_MSK

/* Step counter config registers */
#define BMI323_STEP_SC1_REG
#define BMI323_STEP_SC1_WTRMRK_MSK
#define BMI323_STEP_SC1_RST_CNT_MSK
#define BMI323_STEP_SC1_REG
#define BMI323_STEP_LEN

/* Tap gesture config registers */
#define BMI323_TAP1_REG
#define BMI323_TAP1_AXIS_SEL_MSK
#define BMI323_AXIS_XYZ_MSK
#define BMI323_TAP1_TIMOUT_MSK
#define BMI323_TAP1_MAX_PEAKS_MSK
#define BMI323_TAP1_MODE_MSK
#define BMI323_TAP2_REG
#define BMI323_TAP2_THRES_MSK
#define BMI323_TAP2_MAX_DUR_MSK
#define BMI323_TAP3_REG
#define BMI323_TAP3_QUIET_TIM_MSK
#define BMI323_TAP3_QT_BW_TAP_MSK
#define BMI323_TAP3_QT_AFT_GES_MSK

#define BMI323_MOTION_THRES_SCALE
#define BMI323_MOTION_HYSTR_SCALE
#define BMI323_MOTION_DURAT_SCALE
#define BMI323_TAP_THRES_SCALE
#define BMI323_DUR_BW_TAP_SCALE
#define BMI323_QUITE_TIM_GES_SCALE
#define BMI323_MAX_GES_DUR_SCALE

/*
 * The formula to calculate temperature in C.
 * See datasheet section 6.1.1, Register Map Overview
 *
 * T_C = (temp_raw / 512) + 23
 */
#define BMI323_TEMP_OFFSET
#define BMI323_TEMP_SCALE

/*
 * The BMI323 features a FIFO with a capacity of 2048 bytes. Each frame
 * consists of accelerometer (X, Y, Z) data and gyroscope (X, Y, Z) data,
 * totaling 6 words or 12 bytes. The FIFO buffer can hold a total of
 * 170 frames.
 *
 * If a watermark interrupt is configured for 170 frames, the interrupt will
 * trigger when the FIFO reaches 169 frames, so limit the maximum watermark
 * level to 169 frames. In terms of data, 169 frames would equal 1014 bytes,
 * which is approximately 2 frames before the FIFO reaches its full capacity.
 * See datasheet section 5.7.3 FIFO Buffer Interrupts
 */
#define BMI323_BYTES_PER_SAMPLE
#define BMI323_FIFO_LENGTH_IN_BYTES
#define BMI323_FIFO_FRAME_LENGTH
#define BMI323_FIFO_FULL_IN_FRAMES
#define BMI323_FIFO_FULL_IN_WORDS

#define BMI323_INT_MICRO_TO_RAW(val, val2, scale)

#define BMI323_RAW_TO_MICRO(raw, scale)

struct device;
int bmi323_core_probe(struct device *dev);
extern const struct regmap_config bmi323_regmap_config;

#endif