linux/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * STMicroelectronics st_lsm6dsx FIFO buffer library driver
 *
 * Pattern FIFO:
 * The FIFO buffer can be configured to store data from gyroscope and
 * accelerometer. Samples are queued without any tag according to a
 * specific pattern based on 'FIFO data sets' (6 bytes each):
 *  - 1st data set is reserved for gyroscope data
 *  - 2nd data set is reserved for accelerometer data
 * The FIFO pattern changes depending on the ODRs and decimation factors
 * assigned to the FIFO data sets. The first sequence of data stored in FIFO
 * buffer contains the data of all the enabled FIFO data sets
 * (e.g. Gx, Gy, Gz, Ax, Ay, Az), then data are repeated depending on the
 * value of the decimation factor and ODR set for each FIFO data set.
 *
 * Supported devices:
 * - ISM330DLC
 * - LSM6DS3
 * - LSM6DS3H
 * - LSM6DS3TR-C
 * - LSM6DSL
 * - LSM6DSM
 *
 * Tagged FIFO:
 * The FIFO buffer can be configured to store data from gyroscope and
 * accelerometer. Each sample is queued with a tag (1B) indicating data
 * source (gyroscope, accelerometer, hw timer).
 *
 * Supported devices:
 * - ASM330LHB
 * - ASM330LHH
 * - ASM330LHHX
 * - ASM330LHHXG1
 * - ISM330DHCX
 * - LSM6DSO
 * - LSM6DSOP
 * - LSM6DSOX
 * - LSM6DSR
 * - LSM6DSRX
 * - LSM6DST
 * - LSM6DSTX
 * - LSM6DSV
 *
 * FIFO supported modes:
 *  - BYPASS: FIFO disabled
 *  - CONTINUOUS: FIFO enabled. When the buffer is full, the FIFO index
 *    restarts from the beginning and the oldest sample is overwritten
 *
 * Copyright 2016 STMicroelectronics Inc.
 *
 * Lorenzo Bianconi <[email protected]>
 * Denis Ciocca <[email protected]>
 */
#include <linux/module.h>
#include <linux/iio/kfifo_buf.h>
#include <linux/iio/iio.h>
#include <linux/iio/buffer.h>
#include <linux/regmap.h>
#include <linux/bitfield.h>

#include <linux/platform_data/st_sensors_pdata.h>

#include "st_lsm6dsx.h"

#define ST_LSM6DSX_REG_FIFO_MODE_ADDR
#define ST_LSM6DSX_FIFO_MODE_MASK
#define ST_LSM6DSX_FIFO_ODR_MASK
#define ST_LSM6DSX_FIFO_EMPTY_MASK
#define ST_LSM6DSX_REG_FIFO_OUTL_ADDR
#define ST_LSM6DSX_REG_FIFO_OUT_TAG_ADDR
#define ST_LSM6DSX_REG_TS_RESET_ADDR

#define ST_LSM6DSX_MAX_FIFO_ODR_VAL

#define ST_LSM6DSX_TS_RESET_VAL

struct st_lsm6dsx_decimator_entry {};

enum st_lsm6dsx_fifo_tag {};

static const
struct st_lsm6dsx_decimator_entry st_lsm6dsx_decimator_table[] =;

static int
st_lsm6dsx_get_decimator_val(struct st_lsm6dsx_sensor *sensor, u32 max_odr)
{}

static void st_lsm6dsx_get_max_min_odr(struct st_lsm6dsx_hw *hw,
				       u32 *max_odr, u32 *min_odr)
{}

static u8 st_lsm6dsx_get_sip(struct st_lsm6dsx_sensor *sensor, u32 min_odr)
{}

static int st_lsm6dsx_update_decimators(struct st_lsm6dsx_hw *hw)
{}

static int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw,
				    enum st_lsm6dsx_fifo_mode fifo_mode)
{}

static int st_lsm6dsx_set_fifo_odr(struct st_lsm6dsx_sensor *sensor,
				   bool enable)
{}

int st_lsm6dsx_update_watermark(struct st_lsm6dsx_sensor *sensor, u16 watermark)
{}

static int st_lsm6dsx_reset_hw_ts(struct st_lsm6dsx_hw *hw)
{}

int st_lsm6dsx_resume_fifo(struct st_lsm6dsx_hw *hw)
{}

/*
 * Set max bulk read to ST_LSM6DSX_MAX_WORD_LEN/ST_LSM6DSX_MAX_TAGGED_WORD_LEN
 * in order to avoid a kmalloc for each bus access
 */
static inline int st_lsm6dsx_read_block(struct st_lsm6dsx_hw *hw, u8 addr,
					u8 *data, unsigned int data_len,
					unsigned int max_word_len)
{}

#define ST_LSM6DSX_IIO_BUFF_SIZE
/**
 * st_lsm6dsx_read_fifo() - hw FIFO read routine
 * @hw: Pointer to instance of struct st_lsm6dsx_hw.
 *
 * Read samples from the hw FIFO and push them to IIO buffers.
 *
 * Return: Number of bytes read from the FIFO
 */
int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw)
{}

#define ST_LSM6DSX_INVALID_SAMPLE
static int
st_lsm6dsx_push_tagged_data(struct st_lsm6dsx_hw *hw, u8 tag,
			    u8 *data, s64 ts)
{}

/**
 * st_lsm6dsx_read_tagged_fifo() - tagged hw FIFO read routine
 * @hw: Pointer to instance of struct st_lsm6dsx_hw.
 *
 * Read samples from the hw FIFO and push them to IIO buffers.
 *
 * Return: Number of bytes read from the FIFO
 */
int st_lsm6dsx_read_tagged_fifo(struct st_lsm6dsx_hw *hw)
{}

int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw)
{}

static void
st_lsm6dsx_update_samples_to_discard(struct st_lsm6dsx_sensor *sensor)
{}

int st_lsm6dsx_update_fifo(struct st_lsm6dsx_sensor *sensor, bool enable)
{}

static int st_lsm6dsx_buffer_preenable(struct iio_dev *iio_dev)
{}

static int st_lsm6dsx_buffer_postdisable(struct iio_dev *iio_dev)
{}

static const struct iio_buffer_setup_ops st_lsm6dsx_buffer_ops =;

int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw)
{}