#include <linux/module.h>
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/err.h>
#include <linux/delay.h>
#include <linux/sysfs.h>
#include <linux/jiffies.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <linux/acpi.h>
#include <linux/platform_device.h>
#include <linux/regulator/consumer.h>
#include <linux/math64.h>
#include <linux/minmax.h>
#include <linux/pm.h>
#include <linux/pm_runtime.h>
#include <linux/property.h>
#include <linux/iio/common/inv_sensors_timestamp.h>
#include <linux/iio/iio.h>
#include "inv_mpu_iio.h"
#include "inv_mpu_magn.h"
static const int gyro_scale_6050[] = …;
static const int accel_scale[] = …;
static const struct inv_mpu6050_reg_map reg_set_icm20602 = …;
static const struct inv_mpu6050_reg_map reg_set_6500 = …;
static const struct inv_mpu6050_reg_map reg_set_6050 = …;
static const struct inv_mpu6050_chip_config chip_config_6050 = …;
static const struct inv_mpu6050_chip_config chip_config_6500 = …;
static const struct inv_mpu6050_hw hw_info[] = …;
static int inv_mpu6050_pwr_mgmt_1_write(struct inv_mpu6050_state *st, bool sleep,
bool cycle, int clock, int temp_dis)
{ … }
static int inv_mpu6050_clock_switch(struct inv_mpu6050_state *st,
unsigned int clock)
{ … }
int inv_mpu6050_switch_engine(struct inv_mpu6050_state *st, bool en,
unsigned int mask)
{ … }
static int inv_mpu6050_set_power_itg(struct inv_mpu6050_state *st,
bool power_on)
{ … }
static int inv_mpu6050_set_gyro_fsr(struct inv_mpu6050_state *st,
enum inv_mpu6050_fsr_e val)
{ … }
static int inv_mpu6050_set_accel_lpf_regs(struct inv_mpu6050_state *st,
enum inv_mpu6050_filter_e val)
{ … }
static int inv_mpu6050_set_lpf_regs(struct inv_mpu6050_state *st,
enum inv_mpu6050_filter_e val)
{ … }
static int inv_mpu6050_init_config(struct iio_dev *indio_dev)
{ … }
static int inv_mpu6050_sensor_set(struct inv_mpu6050_state *st, int reg,
int axis, int val)
{ … }
static int inv_mpu6050_sensor_show(struct inv_mpu6050_state *st, int reg,
int axis, int *val)
{ … }
static int inv_mpu6050_read_channel_data(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val)
{ … }
static int
inv_mpu6050_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long mask)
{ … }
static int inv_mpu6050_write_gyro_scale(struct inv_mpu6050_state *st, int val,
int val2)
{ … }
static int inv_write_raw_get_fmt(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan, long mask)
{ … }
static int inv_mpu6050_write_accel_scale(struct inv_mpu6050_state *st, int val,
int val2)
{ … }
static int inv_mpu6050_write_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int val, int val2, long mask)
{ … }
static u64 inv_mpu6050_convert_wom_to_roc(unsigned int threshold, unsigned int freq_div)
{ … }
static unsigned int inv_mpu6050_convert_roc_to_wom(u64 roc, unsigned int freq_div)
{ … }
static int inv_mpu6050_set_wom_int(struct inv_mpu6050_state *st, bool on)
{ … }
static int inv_mpu6050_set_wom_threshold(struct inv_mpu6050_state *st, u64 value,
unsigned int freq_div)
{ … }
static int inv_mpu6050_set_lp_odr(struct inv_mpu6050_state *st, unsigned int freq_div,
unsigned int *lp_div)
{ … }
static int inv_mpu6050_set_wom_lp(struct inv_mpu6050_state *st, bool on)
{ … }
static int inv_mpu6050_enable_wom(struct inv_mpu6050_state *st, bool en)
{ … }
static int inv_mpu6050_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 inv_mpu6050_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 inv_mpu6050_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 inv_mpu6050_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 inv_mpu6050_set_lpf(struct inv_mpu6050_state *st, int rate)
{ … }
static ssize_t
inv_mpu6050_fifo_rate_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static ssize_t
inv_fifo_rate_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static ssize_t inv_attr_show(struct device *dev, struct device_attribute *attr,
char *buf)
{ … }
static int inv_mpu6050_validate_trigger(struct iio_dev *indio_dev,
struct iio_trigger *trig)
{ … }
static const struct iio_mount_matrix *
inv_get_mount_matrix(const struct iio_dev *indio_dev,
const struct iio_chan_spec *chan)
{ … }
static const struct iio_chan_spec_ext_info inv_ext_info[] = …;
static const struct iio_event_spec inv_wom_events[] = …;
#define INV_MPU6050_CHAN(_type, _channel2, _index) …
#define INV_MPU6050_TEMP_CHAN(_index) …
#define INV_MPU6050_EVENT_CHAN(_type, _channel2, _events, _events_nb) …
static const struct iio_chan_spec inv_mpu6050_channels[] = …;
static const struct iio_chan_spec inv_mpu6500_channels[] = …;
#define INV_MPU6050_SCAN_MASK_3AXIS_ACCEL …
#define INV_MPU6050_SCAN_MASK_3AXIS_GYRO …
#define INV_MPU6050_SCAN_MASK_TEMP …
static const unsigned long inv_mpu_scan_masks[] = …;
#define INV_MPU9X50_MAGN_CHAN(_chan2, _bits, _index) …
static const struct iio_chan_spec inv_mpu9150_channels[] = …;
static const struct iio_chan_spec inv_mpu9250_channels[] = …;
#define INV_MPU9X50_SCAN_MASK_3AXIS_MAGN …
static const unsigned long inv_mpu9x50_scan_masks[] = …;
static const unsigned long inv_icm20602_scan_masks[] = …;
static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("10 20 50 100 200 500");
static IIO_CONST_ATTR(in_anglvel_scale_available,
"0.000133090 0.000266181 0.000532362 0.001064724");
static IIO_CONST_ATTR(in_accel_scale_available,
"0.000598 0.001196 0.002392 0.004785");
static IIO_DEV_ATTR_SAMP_FREQ(S_IRUGO | S_IWUSR, inv_fifo_rate_show,
inv_mpu6050_fifo_rate_store);
static IIO_DEVICE_ATTR(in_gyro_matrix, S_IRUGO, inv_attr_show, NULL,
ATTR_GYRO_MATRIX);
static IIO_DEVICE_ATTR(in_accel_matrix, S_IRUGO, inv_attr_show, NULL,
ATTR_ACCL_MATRIX);
static struct attribute *inv_attributes[] = …;
static const struct attribute_group inv_attribute_group = …;
static int inv_mpu6050_reg_access(struct iio_dev *indio_dev,
unsigned int reg,
unsigned int writeval,
unsigned int *readval)
{ … }
static const struct iio_info mpu_info = …;
static int inv_check_and_setup_chip(struct inv_mpu6050_state *st)
{ … }
static int inv_mpu_core_enable_regulator_vddio(struct inv_mpu6050_state *st)
{ … }
static int inv_mpu_core_disable_regulator_vddio(struct inv_mpu6050_state *st)
{ … }
static void inv_mpu_core_disable_regulator_action(void *_data)
{ … }
static void inv_mpu_pm_disable(void *data)
{ … }
int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
int (*inv_mpu_bus_setup)(struct iio_dev *), int chip_type)
{ … }
EXPORT_SYMBOL_NS_GPL(…);
static int inv_mpu_resume(struct device *dev)
{ … }
static int inv_mpu_suspend(struct device *dev)
{ … }
static int inv_mpu_runtime_suspend(struct device *dev)
{ … }
static int inv_mpu_runtime_resume(struct device *dev)
{ … }
EXPORT_NS_GPL_DEV_PM_OPS(inv_mpu_pmops, IIO_MPU6050) = …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
MODULE_IMPORT_NS(…);