#include <linux/module.h>
#include <linux/regmap.h>
#include <linux/delay.h>
#include <linux/irq.h>
#include <linux/property.h>
#include <linux/regulator/consumer.h>
#include <linux/iio/iio.h>
#include <linux/iio/triggered_buffer.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/buffer.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/trigger.h>
#include "bmi160.h"
#define BMI160_REG_CHIP_ID …
#define BMI120_CHIP_ID_VAL …
#define BMI160_CHIP_ID_VAL …
#define BMI160_REG_PMU_STATUS …
#define BMI160_REG_DATA_MAGN_XOUT_L …
#define BMI160_REG_DATA_GYRO_XOUT_L …
#define BMI160_REG_DATA_ACCEL_XOUT_L …
#define BMI160_REG_ACCEL_CONFIG …
#define BMI160_ACCEL_CONFIG_ODR_MASK …
#define BMI160_ACCEL_CONFIG_BWP_MASK …
#define BMI160_REG_ACCEL_RANGE …
#define BMI160_ACCEL_RANGE_2G …
#define BMI160_ACCEL_RANGE_4G …
#define BMI160_ACCEL_RANGE_8G …
#define BMI160_ACCEL_RANGE_16G …
#define BMI160_REG_GYRO_CONFIG …
#define BMI160_GYRO_CONFIG_ODR_MASK …
#define BMI160_GYRO_CONFIG_BWP_MASK …
#define BMI160_REG_GYRO_RANGE …
#define BMI160_GYRO_RANGE_2000DPS …
#define BMI160_GYRO_RANGE_1000DPS …
#define BMI160_GYRO_RANGE_500DPS …
#define BMI160_GYRO_RANGE_250DPS …
#define BMI160_GYRO_RANGE_125DPS …
#define BMI160_REG_CMD …
#define BMI160_CMD_ACCEL_PM_SUSPEND …
#define BMI160_CMD_ACCEL_PM_NORMAL …
#define BMI160_CMD_ACCEL_PM_LOW_POWER …
#define BMI160_CMD_GYRO_PM_SUSPEND …
#define BMI160_CMD_GYRO_PM_NORMAL …
#define BMI160_CMD_GYRO_PM_FAST_STARTUP …
#define BMI160_CMD_SOFTRESET …
#define BMI160_REG_INT_EN …
#define BMI160_DRDY_INT_EN …
#define BMI160_REG_INT_OUT_CTRL …
#define BMI160_INT_OUT_CTRL_MASK …
#define BMI160_INT1_OUT_CTRL_SHIFT …
#define BMI160_INT2_OUT_CTRL_SHIFT …
#define BMI160_EDGE_TRIGGERED …
#define BMI160_ACTIVE_HIGH …
#define BMI160_OPEN_DRAIN …
#define BMI160_OUTPUT_EN …
#define BMI160_REG_INT_LATCH …
#define BMI160_INT1_LATCH_MASK …
#define BMI160_INT2_LATCH_MASK …
#define BMI160_REG_INT_MAP …
#define BMI160_INT1_MAP_DRDY_EN …
#define BMI160_INT2_MAP_DRDY_EN …
#define BMI160_REG_DUMMY …
#define BMI160_NORMAL_WRITE_USLEEP …
#define BMI160_SUSPENDED_WRITE_USLEEP …
#define BMI160_ACCEL_PMU_MIN_USLEEP …
#define BMI160_GYRO_PMU_MIN_USLEEP …
#define BMI160_SOFTRESET_USLEEP …
#define BMI160_CHANNEL(_type, _axis, _index) …
static const u8 bmi_chip_ids[] = …;
enum bmi160_scan_axis { … };
enum bmi160_sensor_type { … };
enum bmi160_int_pin { … };
const struct regmap_config bmi160_regmap_config = …;
EXPORT_SYMBOL_NS(…);
struct bmi160_regs { … };
static struct bmi160_regs bmi160_regs[] = …;
static unsigned long bmi160_pmu_time[] = …;
struct bmi160_scale { … };
struct bmi160_odr { … };
static const struct bmi160_scale bmi160_accel_scale[] = …;
static const struct bmi160_scale bmi160_gyro_scale[] = …;
struct bmi160_scale_item { … };
static const struct bmi160_scale_item bmi160_scale_table[] = …;
static const struct bmi160_odr bmi160_accel_odr[] = …;
static const struct bmi160_odr bmi160_gyro_odr[] = …;
struct bmi160_odr_item { … };
static const struct bmi160_odr_item bmi160_odr_table[] = …;
static const struct iio_mount_matrix *
bmi160_get_mount_matrix(const struct iio_dev *indio_dev,
const struct iio_chan_spec *chan)
{ … }
static const struct iio_chan_spec_ext_info bmi160_ext_info[] = …;
static const struct iio_chan_spec bmi160_channels[] = …;
static enum bmi160_sensor_type bmi160_to_sensor(enum iio_chan_type iio_type)
{ … }
static
int bmi160_set_mode(struct bmi160_data *data, enum bmi160_sensor_type t,
bool mode)
{ … }
static
int bmi160_set_scale(struct bmi160_data *data, enum bmi160_sensor_type t,
int uscale)
{ … }
static
int bmi160_get_scale(struct bmi160_data *data, enum bmi160_sensor_type t,
int *uscale)
{ … }
static int bmi160_get_data(struct bmi160_data *data, int chan_type,
int axis, int *val)
{ … }
static
int bmi160_set_odr(struct bmi160_data *data, enum bmi160_sensor_type t,
int odr, int uodr)
{ … }
static int bmi160_get_odr(struct bmi160_data *data, enum bmi160_sensor_type t,
int *odr, int *uodr)
{ … }
static irqreturn_t bmi160_trigger_handler(int irq, void *p)
{ … }
static int bmi160_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long mask)
{ … }
static int bmi160_write_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int val, int val2, long mask)
{ … }
static
IIO_CONST_ATTR(in_accel_sampling_frequency_available,
"0.78125 1.5625 3.125 6.25 12.5 25 50 100 200 400 800 1600");
static
IIO_CONST_ATTR(in_anglvel_sampling_frequency_available,
"25 50 100 200 400 800 1600 3200");
static
IIO_CONST_ATTR(in_accel_scale_available,
"0.000598 0.001197 0.002394 0.004788");
static
IIO_CONST_ATTR(in_anglvel_scale_available,
"0.001065 0.000532 0.000266 0.000133 0.000066");
static struct attribute *bmi160_attrs[] = …;
static const struct attribute_group bmi160_attrs_group = …;
static const struct iio_info bmi160_info = …;
static int bmi160_write_conf_reg(struct regmap *regmap, unsigned int reg,
unsigned int mask, unsigned int bits,
unsigned int write_usleep)
{ … }
static int bmi160_config_pin(struct regmap *regmap, enum bmi160_int_pin pin,
bool open_drain, u8 irq_mask,
unsigned long write_usleep)
{ … }
int bmi160_enable_irq(struct regmap *regmap, bool enable)
{ … }
EXPORT_SYMBOL_NS(…);
static int bmi160_get_irq(struct fwnode_handle *fwnode, enum bmi160_int_pin *pin)
{ … }
static int bmi160_config_device_irq(struct iio_dev *indio_dev, int irq_type,
enum bmi160_int_pin pin)
{ … }
static int bmi160_setup_irq(struct iio_dev *indio_dev, int irq,
enum bmi160_int_pin pin)
{ … }
static int bmi160_check_chip_id(const u8 chip_id)
{ … }
static int bmi160_chip_init(struct bmi160_data *data, bool use_spi)
{ … }
static int bmi160_data_rdy_trigger_set_state(struct iio_trigger *trig,
bool enable)
{ … }
static const struct iio_trigger_ops bmi160_trigger_ops = …;
int bmi160_probe_trigger(struct iio_dev *indio_dev, int irq, u32 irq_type)
{ … }
static void bmi160_chip_uninit(void *data)
{ … }
int bmi160_core_probe(struct device *dev, struct regmap *regmap,
const char *name, bool use_spi)
{ … }
EXPORT_SYMBOL_NS_GPL(…);
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;