linux/drivers/iio/accel/bma400_core.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Core IIO driver for Bosch BMA400 triaxial acceleration sensor.
 *
 * Copyright 2019 Dan Robertson <[email protected]>
 *
 * TODO:
 *  - Support for power management
 *  - Support events and interrupts
 *  - Create channel for step count
 *  - Create channel for sensor time
 */

#include <linux/bitfield.h>
#include <linux/bitops.h>
#include <linux/cleanup.h>
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/slab.h>

#include <linux/unaligned.h>

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

#include "bma400.h"

/*
 * The G-range selection may be one of 2g, 4g, 8, or 16g. The scale may
 * be selected with the acc_range bits of the ACC_CONFIG1 register.
 * NB: This buffer is populated in the device init.
 */
static int bma400_scales[8];

/*
 * See the ACC_CONFIG1 section of the datasheet.
 * NB: This buffer is populated in the device init.
 */
static int bma400_sample_freqs[14];

static const int bma400_osr_range[] =;

static int tap_reset_timeout[BMA400_TAP_TIM_LIST_LEN] =;

static int tap_max2min_time[BMA400_TAP_TIM_LIST_LEN] =;

static int double_tap2_min_delay[BMA400_TAP_TIM_LIST_LEN] =;

/* See the ACC_CONFIG0 section of the datasheet */
enum bma400_power_mode {};

enum bma400_scan {};

struct bma400_sample_freq {};

enum bma400_activity {};

struct bma400_data {};

static bool bma400_is_writable_reg(struct device *dev, unsigned int reg)
{}

static bool bma400_is_volatile_reg(struct device *dev, unsigned int reg)
{}

const struct regmap_config bma400_regmap_config =;
EXPORT_SYMBOL_NS();

static const struct iio_mount_matrix *
bma400_accel_get_mount_matrix(const struct iio_dev *indio_dev,
			      const struct iio_chan_spec *chan)
{}

static const struct iio_chan_spec_ext_info bma400_ext_info[] =;

static const struct iio_event_spec bma400_step_detect_event =;

static const struct iio_event_spec bma400_activity_event =;

static const struct iio_event_spec bma400_accel_event[] =;

static int usec_to_tapreg_raw(int usec, const int *time_list)
{}

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

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

static IIO_DEVICE_ATTR_RW(in_accel_gesture_tap_maxtomin_time, 0);

/*
 * Tap interrupts works with 200 Hz input data rate and the time based tap
 * controls are in the terms of data samples so the below calculation is
 * used to convert the configuration values into seconds.
 * e.g.:
 * 60 data samples * 0.005 ms = 0.3 seconds.
 * 80 data samples * 0.005 ms = 0.4 seconds.
 */

/* quiet configuration values in seconds */
static IIO_CONST_ATTR(in_accel_gesture_tap_reset_timeout_available,
		      "0.3 0.4 0.5 0.6");

/* tics_th configuration values in seconds */
static IIO_CONST_ATTR(in_accel_gesture_tap_maxtomin_time_available,
		      "0.03 0.045 0.06 0.09");

/* quiet_dt configuration values in seconds */
static IIO_CONST_ATTR(in_accel_gesture_doubletap_tap2_min_delay_available,
		      "0.02 0.04 0.06 0.08");

/* List of sensitivity values available to configure tap interrupts */
static IIO_CONST_ATTR(in_accel_gesture_tap_value_available, "0 1 2 3 4 5 6 7");

static struct attribute *bma400_event_attributes[] =;

static const struct attribute_group bma400_event_attribute_group =;

#define BMA400_ACC_CHANNEL(_index, _axis)

#define BMA400_ACTIVITY_CHANNEL(_chan2)

static const struct iio_chan_spec bma400_channels[] =;

static int bma400_get_temp_reg(struct bma400_data *data, int *val, int *val2)
{}

static int bma400_get_accel_reg(struct bma400_data *data,
				const struct iio_chan_spec *chan,
				int *val)
{}

static void bma400_output_data_rate_from_raw(int raw, unsigned int *val,
					     unsigned int *val2)
{}

static int bma400_get_accel_output_data_rate(struct bma400_data *data)
{}

static int bma400_set_accel_output_data_rate(struct bma400_data *data,
					     int hz, int uhz)
{}

static int bma400_get_accel_oversampling_ratio(struct bma400_data *data)
{}

static int bma400_set_accel_oversampling_ratio(struct bma400_data *data,
					       int val)
{}

static int bma400_accel_scale_to_raw(struct bma400_data *data,
				     unsigned int val)
{}

static int bma400_get_accel_scale(struct bma400_data *data)
{}

static int bma400_set_accel_scale(struct bma400_data *data, unsigned int val)
{}

static int bma400_get_power_mode(struct bma400_data *data)
{}

static int bma400_set_power_mode(struct bma400_data *data,
				 enum bma400_power_mode mode)
{}

static int bma400_enable_steps(struct bma400_data *data, int val)
{}

static int bma400_get_steps_reg(struct bma400_data *data, int *val)
{}

static void bma400_init_tables(void)
{}

static void bma400_power_disable(void *data_ptr)
{}

static enum iio_modifier bma400_act_to_mod(enum bma400_activity activity)
{}

static int bma400_init(struct bma400_data *data)
{}

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

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

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

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

static int bma400_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 bma400_steps_event_enable(struct bma400_data *data, int state)
{}

static int bma400_activity_event_en(struct bma400_data *data,
				    enum iio_event_direction dir,
				    int state)
{}

static int bma400_tap_event_en(struct bma400_data *data,
			       enum iio_event_direction dir, int state)
{}

static int bma400_disable_adv_interrupt(struct bma400_data *data)
{}

static int bma400_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 get_gen_config_reg(enum iio_event_direction dir)
{}

static int bma400_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 bma400_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 bma400_data_rdy_trigger_set_state(struct iio_trigger *trig,
					     bool state)
{}

static const unsigned long bma400_avail_scan_masks[] =;

static const struct iio_info bma400_info =;

static const struct iio_trigger_ops bma400_trigger_ops =;

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

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

int bma400_probe(struct device *dev, struct regmap *regmap, int irq,
		 const char *name)
{}
EXPORT_SYMBOL_NS();

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