linux/drivers/iio/imu/bmi323/bmi323_core.c

// SPDX-License-Identifier: GPL-2.0
/*
 * IIO core driver for Bosch BMI323 6-Axis IMU.
 *
 * Copyright (C) 2023, Jagath Jog J <[email protected]>
 *
 * Datasheet: https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmi323-ds000.pdf
 */

#include <linux/bitfield.h>
#include <linux/cleanup.h>
#include <linux/device.h>
#include <linux/interrupt.h>
#include <linux/minmax.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/units.h>

#include <asm/unaligned.h>

#include <linux/iio/buffer.h>
#include <linux/iio/events.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/trigger.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/triggered_buffer.h>

#include "bmi323.h"

enum bmi323_sensor_type {};

enum bmi323_opr_mode {};

enum bmi323_state {};

enum bmi323_irq_pin {};

enum bmi323_3db_bw {};

enum bmi323_scan {};

struct bmi323_hw {};

/*
 * The accelerometer supports +-2G/4G/8G/16G ranges, and the resolution of
 * each sample is 16 bits, signed.
 * At +-8G the scale can calculated by
 * ((8 + 8) * 9.80665 / (2^16 - 1)) * 10^6 = 2394.23819 scale in micro
 *
 */
static const int bmi323_accel_scale[][2] =;

static const int bmi323_gyro_scale[][2] =;

static const int bmi323_accel_gyro_avrg[] =;

static const struct bmi323_hw bmi323_hw[2] =;

struct bmi323_data {};

static const struct iio_mount_matrix *
bmi323_get_mount_matrix(const struct iio_dev *idev,
			const struct iio_chan_spec *chan)
{}

static const struct iio_chan_spec_ext_info bmi323_ext_info[] =;

static const struct iio_event_spec bmi323_step_wtrmrk_event =;

static const struct iio_event_spec bmi323_accel_event[] =;

#define BMI323_ACCEL_CHANNEL(_type, _axis, _index)

#define BMI323_GYRO_CHANNEL(_type, _axis, _index)

static const struct iio_chan_spec bmi323_channels[] =;

static const int bmi323_acc_gyro_odr[][2] =;

static const int bmi323_acc_gyro_odrns[] =;

static enum bmi323_sensor_type bmi323_iio_to_sensor(enum iio_chan_type iio_type)
{}

static int bmi323_set_mode(struct bmi323_data *data,
			   enum bmi323_sensor_type sensor,
			   enum bmi323_opr_mode mode)
{}

/*
 * When writing data to extended register there must be no communication to
 * any other register before write transaction is complete.
 * See datasheet section 6.2 Extended Register Map Description.
 */
static int bmi323_write_ext_reg(struct bmi323_data *data, unsigned int ext_addr,
				unsigned int ext_data)
{}

/*
 * When reading data from extended register there must be no communication to
 * any other register before read transaction is complete.
 * See datasheet section 6.2 Extended Register Map Description.
 */
static int bmi323_read_ext_reg(struct bmi323_data *data, unsigned int ext_addr,
			       unsigned int *ext_data)
{}

static int bmi323_update_ext_reg(struct bmi323_data *data,
				 unsigned int ext_addr,
				 unsigned int mask, unsigned int ext_data)
{}

static int bmi323_get_error_status(struct bmi323_data *data)
{}

static int bmi323_feature_engine_events(struct bmi323_data *data,
					const unsigned int event_mask,
					bool state)
{}

static int bmi323_step_wtrmrk_en(struct bmi323_data *data, int state)
{}

static int bmi323_motion_config_reg(enum iio_event_direction dir)
{}

static int bmi323_motion_event_en(struct bmi323_data *data,
				  enum iio_event_direction dir, int state)
{}

static int bmi323_tap_event_en(struct bmi323_data *data,
			       enum iio_event_direction dir, int state)
{}

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

static ssize_t in_accel_gesture_tap_wait_dur_store(struct device *dev,
						   struct device_attribute *attr,
						   const char *buf, size_t len)
{}

/*
 * Maximum duration from first tap within the second tap is expected to happen.
 * This timeout is applicable only if gesture_tap_wait_timeout is enabled.
 */
static IIO_DEVICE_ATTR_RW(in_accel_gesture_tap_wait_dur, 0);

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

static ssize_t in_accel_gesture_tap_wait_timeout_store(struct device *dev,
						       struct device_attribute *attr,
						       const char *buf,
						       size_t len)
{}

/* Enable/disable gesture confirmation with wait time */
static IIO_DEVICE_ATTR_RW(in_accel_gesture_tap_wait_timeout, 0);

static IIO_CONST_ATTR(in_accel_gesture_tap_wait_dur_available,
		      "[0.0 0.04 2.52]");

static IIO_CONST_ATTR(in_accel_gesture_doubletap_tap2_min_delay_available,
		      "[0.005 0.005 0.075]");

static IIO_CONST_ATTR(in_accel_gesture_tap_reset_timeout_available,
		      "[0.04 0.04 0.6]");

static IIO_CONST_ATTR(in_accel_gesture_tap_value_available, "[0.0 0.002 1.99]");

static IIO_CONST_ATTR(in_accel_mag_value_available, "[0.0 0.002 7.99]");

static IIO_CONST_ATTR(in_accel_mag_period_available, "[0.0 0.02 162.0]");

static IIO_CONST_ATTR(in_accel_mag_hysteresis_available, "[0.0 0.002 1.99]");

static struct attribute *bmi323_event_attributes[] =;

static const struct attribute_group bmi323_event_attribute_group =;

static int bmi323_write_event_config(struct iio_dev *indio_dev,
				     const struct iio_chan_spec *chan,
				     enum iio_event_type type,
				     enum iio_event_direction dir, int state)
{}

static int bmi323_read_event_config(struct iio_dev *indio_dev,
				    const struct iio_chan_spec *chan,
				    enum iio_event_type type,
				    enum iio_event_direction dir)
{}

static int bmi323_write_event_value(struct iio_dev *indio_dev,
				    const struct iio_chan_spec *chan,
				    enum iio_event_type type,
				    enum iio_event_direction dir,
				    enum iio_event_info info,
				    int val, int val2)
{}

static int bmi323_read_event_value(struct iio_dev *indio_dev,
				   const struct iio_chan_spec *chan,
				   enum iio_event_type type,
				   enum iio_event_direction dir,
				   enum iio_event_info info,
				   int *val, int *val2)
{}

static int __bmi323_fifo_flush(struct iio_dev *indio_dev)
{}

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

static int bmi323_fifo_disable(struct bmi323_data *data)
{}

static int bmi323_buffer_predisable(struct iio_dev *indio_dev)
{}

static int bmi323_update_watermark(struct bmi323_data *data)
{}

static int bmi323_fifo_enable(struct bmi323_data *data)
{}

static int bmi323_buffer_preenable(struct iio_dev *indio_dev)
{}

static int bmi323_buffer_postenable(struct iio_dev *indio_dev)
{}

static ssize_t hwfifo_watermark_show(struct device *dev,
				     struct device_attribute *attr, char *buf)
{}
static IIO_DEVICE_ATTR_RO(hwfifo_watermark, 0);

static ssize_t hwfifo_enabled_show(struct device *dev,
				   struct device_attribute *attr,
				   char *buf)
{}
static IIO_DEVICE_ATTR_RO(hwfifo_enabled, 0);

static const struct iio_dev_attr *bmi323_fifo_attributes[] =;

static const struct iio_buffer_setup_ops bmi323_buffer_ops =;

static irqreturn_t bmi323_irq_thread_handler(int irq, void *private)
{}

static int bmi323_set_drdy_irq(struct bmi323_data *data,
			       enum bmi323_irq_pin irq_pin)
{}

static int bmi323_data_rdy_trigger_set_state(struct iio_trigger *trig,
					     bool state)
{}

static const struct iio_trigger_ops bmi323_trigger_ops =;

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

static int bmi323_set_average(struct bmi323_data *data,
			      enum bmi323_sensor_type sensor, int avg)
{}

static int bmi323_get_average(struct bmi323_data *data,
			      enum bmi323_sensor_type sensor, int *avg)
{}

static int bmi323_enable_steps(struct bmi323_data *data, int val)
{}

static int bmi323_read_steps(struct bmi323_data *data, int *val)
{}

static int bmi323_read_axis(struct bmi323_data *data,
			    struct iio_chan_spec const *chan, int *val)
{}

static int bmi323_get_temp_data(struct bmi323_data *data, int *val)
{}

static int bmi323_get_odr(struct bmi323_data *data,
			  enum bmi323_sensor_type sensor, int *odr, int *uodr)
{}

static int bmi323_configure_power_mode(struct bmi323_data *data,
				       enum bmi323_sensor_type sensor,
				       int odr_index)
{}

static int bmi323_set_odr(struct bmi323_data *data,
			  enum bmi323_sensor_type sensor, int odr, int uodr)
{}

static int bmi323_get_scale(struct bmi323_data *data,
			    enum bmi323_sensor_type sensor, int *val2)
{}

static int bmi323_set_scale(struct bmi323_data *data,
			    enum bmi323_sensor_type sensor, int val, int val2)
{}

static int bmi323_read_avail(struct iio_dev *indio_dev,
			     struct iio_chan_spec const *chan,
			     const int **vals, int *type, int *length,
			     long mask)
{}

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

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

static const struct iio_info bmi323_info =;

#define BMI323_SCAN_MASK_ACCEL_3AXIS

#define BMI323_SCAN_MASK_GYRO_3AXIS

static const unsigned long bmi323_avail_scan_masks[] =;

static int bmi323_int_pin_config(struct bmi323_data *data,
				 enum bmi323_irq_pin irq_pin,
				 bool active_high, bool open_drain, bool latch)
{}

static int bmi323_trigger_probe(struct bmi323_data *data,
				struct iio_dev *indio_dev)
{}

static int bmi323_feature_engine_enable(struct bmi323_data *data, bool en)
{}

static void bmi323_disable(void *data_ptr)
{}

static int bmi323_set_bw(struct bmi323_data *data,
			 enum bmi323_sensor_type sensor, enum bmi323_3db_bw bw)
{}

static int bmi323_init(struct bmi323_data *data)
{}

int bmi323_core_probe(struct device *dev)
{}
EXPORT_SYMBOL_NS_GPL();

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