2019-05-29 14:17:56 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2013-02-02 00:26:00 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 Invensense, Inc.
|
|
|
|
*/
|
2019-09-16 09:42:00 +00:00
|
|
|
|
|
|
|
#ifndef INV_MPU_IIO_H_
|
|
|
|
#define INV_MPU_IIO_H_
|
|
|
|
|
2013-02-02 00:26:00 +00:00
|
|
|
#include <linux/i2c.h>
|
2016-04-20 06:40:49 +00:00
|
|
|
#include <linux/i2c-mux.h>
|
2017-06-07 13:41:42 +00:00
|
|
|
#include <linux/mutex.h>
|
2013-02-02 00:26:00 +00:00
|
|
|
#include <linux/iio/iio.h>
|
|
|
|
#include <linux/iio/buffer.h>
|
2016-02-12 11:44:43 +00:00
|
|
|
#include <linux/regmap.h>
|
2013-02-02 00:26:00 +00:00
|
|
|
#include <linux/iio/sysfs.h>
|
|
|
|
#include <linux/iio/kfifo_buf.h>
|
|
|
|
#include <linux/iio/trigger.h>
|
|
|
|
#include <linux/iio/triggered_buffer.h>
|
|
|
|
#include <linux/iio/trigger_consumer.h>
|
|
|
|
#include <linux/platform_data/invensense_mpu6050.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct inv_mpu6050_reg_map - Notable registers.
|
|
|
|
* @sample_rate_div: Divider applied to gyro output rate.
|
|
|
|
* @lpf: Configures internal low pass filter.
|
2017-05-29 09:59:40 +00:00
|
|
|
* @accel_lpf: Configures accelerometer low pass filter.
|
2013-02-02 00:26:00 +00:00
|
|
|
* @user_ctrl: Enables/resets the FIFO.
|
|
|
|
* @fifo_en: Determines which data will appear in FIFO.
|
|
|
|
* @gyro_config: gyro config register.
|
|
|
|
* @accl_config: accel config register
|
|
|
|
* @fifo_count_h: Upper byte of FIFO count.
|
|
|
|
* @fifo_r_w: FIFO register.
|
|
|
|
* @raw_gyro: Address of first gyro register.
|
|
|
|
* @raw_accl: Address of first accel register.
|
|
|
|
* @temperature: temperature register
|
|
|
|
* @int_enable: Interrupt enable register.
|
2018-04-20 16:54:00 +00:00
|
|
|
* @int_status: Interrupt status register.
|
2013-02-02 00:26:00 +00:00
|
|
|
* @pwr_mgmt_1: Controls chip's power state and clock source.
|
|
|
|
* @pwr_mgmt_2: Controls power state of individual sensors.
|
2016-02-22 21:39:09 +00:00
|
|
|
* @int_pin_cfg; Controls interrupt pin configuration.
|
2016-02-22 21:39:10 +00:00
|
|
|
* @accl_offset: Controls the accelerometer calibration offset.
|
|
|
|
* @gyro_offset: Controls the gyroscope calibration offset.
|
2019-01-28 18:50:03 +00:00
|
|
|
* @i2c_if: Controls the i2c interface
|
2013-02-02 00:26:00 +00:00
|
|
|
*/
|
|
|
|
struct inv_mpu6050_reg_map {
|
|
|
|
u8 sample_rate_div;
|
|
|
|
u8 lpf;
|
2017-05-29 09:59:40 +00:00
|
|
|
u8 accel_lpf;
|
2013-02-02 00:26:00 +00:00
|
|
|
u8 user_ctrl;
|
|
|
|
u8 fifo_en;
|
|
|
|
u8 gyro_config;
|
|
|
|
u8 accl_config;
|
|
|
|
u8 fifo_count_h;
|
|
|
|
u8 fifo_r_w;
|
|
|
|
u8 raw_gyro;
|
|
|
|
u8 raw_accl;
|
|
|
|
u8 temperature;
|
|
|
|
u8 int_enable;
|
2018-04-20 16:54:00 +00:00
|
|
|
u8 int_status;
|
2013-02-02 00:26:00 +00:00
|
|
|
u8 pwr_mgmt_1;
|
|
|
|
u8 pwr_mgmt_2;
|
2014-12-05 22:52:09 +00:00
|
|
|
u8 int_pin_cfg;
|
2016-02-22 21:39:10 +00:00
|
|
|
u8 accl_offset;
|
|
|
|
u8 gyro_offset;
|
2019-01-28 18:50:03 +00:00
|
|
|
u8 i2c_if;
|
2013-02-02 00:26:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*device enum */
|
|
|
|
enum inv_devices {
|
|
|
|
INV_MPU6050,
|
2014-03-19 16:56:00 +00:00
|
|
|
INV_MPU6500,
|
2018-07-11 01:09:30 +00:00
|
|
|
INV_MPU6515,
|
2016-02-12 11:44:45 +00:00
|
|
|
INV_MPU6000,
|
2016-04-20 13:15:13 +00:00
|
|
|
INV_MPU9150,
|
2017-03-26 11:11:00 +00:00
|
|
|
INV_MPU9250,
|
2018-04-02 22:42:00 +00:00
|
|
|
INV_MPU9255,
|
2016-06-30 17:06:34 +00:00
|
|
|
INV_ICM20608,
|
2020-02-06 10:31:01 +00:00
|
|
|
INV_ICM20609,
|
|
|
|
INV_ICM20689,
|
2019-01-28 18:50:03 +00:00
|
|
|
INV_ICM20602,
|
2020-02-06 10:31:03 +00:00
|
|
|
INV_ICM20690,
|
2020-02-06 10:31:02 +00:00
|
|
|
INV_IAM20680,
|
2013-02-02 00:26:00 +00:00
|
|
|
INV_NUM_PARTS
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct inv_mpu6050_chip_config - Cached chip configuration data.
|
|
|
|
* @fsr: Full scale range.
|
|
|
|
* @lpf: Digital low pass filter frequency.
|
|
|
|
* @accl_fs: accel full scale range.
|
|
|
|
* @accl_fifo_enable: enable accel data output
|
|
|
|
* @gyro_fifo_enable: enable gyro data output
|
2020-01-16 17:56:45 +00:00
|
|
|
* @temp_fifo_enable: enable temp data output
|
2019-09-16 09:42:09 +00:00
|
|
|
* @magn_fifo_enable: enable magn data output
|
2018-05-22 14:18:19 +00:00
|
|
|
* @divider: chip sample rate divider (sample rate divider - 1)
|
2013-02-02 00:26:00 +00:00
|
|
|
*/
|
|
|
|
struct inv_mpu6050_chip_config {
|
|
|
|
unsigned int fsr:2;
|
|
|
|
unsigned int lpf:3;
|
|
|
|
unsigned int accl_fs:2;
|
|
|
|
unsigned int accl_fifo_enable:1;
|
|
|
|
unsigned int gyro_fifo_enable:1;
|
2020-01-16 17:56:45 +00:00
|
|
|
unsigned int temp_fifo_enable:1;
|
2019-09-16 09:42:09 +00:00
|
|
|
unsigned int magn_fifo_enable:1;
|
2018-05-22 14:18:19 +00:00
|
|
|
u8 divider;
|
2018-04-30 10:14:11 +00:00
|
|
|
u8 user_ctrl;
|
2013-02-02 00:26:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct inv_mpu6050_hw - Other important hardware information.
|
2016-04-20 13:15:11 +00:00
|
|
|
* @whoami: Self identification byte from WHO_AM_I register
|
2013-02-02 00:26:00 +00:00
|
|
|
* @name: name of the chip.
|
|
|
|
* @reg: register map of the chip.
|
|
|
|
* @config: configuration of the chip.
|
2019-10-16 14:43:28 +00:00
|
|
|
* @fifo_size: size of the FIFO in bytes.
|
2019-11-26 16:19:12 +00:00
|
|
|
* @temp: offset and scale to apply to raw temperature.
|
2013-02-02 00:26:00 +00:00
|
|
|
*/
|
|
|
|
struct inv_mpu6050_hw {
|
2016-04-20 13:15:11 +00:00
|
|
|
u8 whoami;
|
2013-02-02 00:26:00 +00:00
|
|
|
u8 *name;
|
|
|
|
const struct inv_mpu6050_reg_map *reg;
|
|
|
|
const struct inv_mpu6050_chip_config *config;
|
2019-10-16 14:43:28 +00:00
|
|
|
size_t fifo_size;
|
2019-11-26 16:19:12 +00:00
|
|
|
struct {
|
|
|
|
int offset;
|
|
|
|
int scale;
|
|
|
|
} temp;
|
2013-02-02 00:26:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* struct inv_mpu6050_state - Driver state variables.
|
2017-06-07 13:41:42 +00:00
|
|
|
* @lock: Chip access lock.
|
2013-02-02 00:26:00 +00:00
|
|
|
* @trig: IIO trigger.
|
|
|
|
* @chip_config: Cached attribute information.
|
|
|
|
* @reg: Map of important registers.
|
|
|
|
* @hw: Other hardware-specific information.
|
|
|
|
* @chip_type: chip type.
|
2016-04-20 17:23:45 +00:00
|
|
|
* @plat_data: platform data (deprecated in favor of @orientation).
|
|
|
|
* @orientation: sensor chip orientation relative to main hardware.
|
2016-02-12 11:44:44 +00:00
|
|
|
* @map regmap pointer.
|
|
|
|
* @irq interrupt number.
|
2018-04-20 16:54:00 +00:00
|
|
|
* @irq_mask the int_pin_cfg mask to configure interrupt type.
|
2018-05-28 13:22:04 +00:00
|
|
|
* @chip_period: chip internal period estimation (~1kHz).
|
|
|
|
* @it_timestamp: timestamp from previous interrupt.
|
|
|
|
* @data_timestamp: timestamp for next data sample.
|
2019-11-07 18:43:42 +00:00
|
|
|
* @vdd_supply: VDD voltage regulator for the chip.
|
|
|
|
* @vddio_supply I/O voltage regulator for the chip.
|
2019-09-16 09:41:58 +00:00
|
|
|
* @magn_disabled: magnetometer disabled for backward compatibility reason.
|
2019-09-16 09:42:07 +00:00
|
|
|
* @magn_raw_to_gauss: coefficient to convert mag raw value to Gauss.
|
|
|
|
* @magn_orient: magnetometer sensor chip orientation if available.
|
2013-02-02 00:26:00 +00:00
|
|
|
*/
|
|
|
|
struct inv_mpu6050_state {
|
2017-06-07 13:41:42 +00:00
|
|
|
struct mutex lock;
|
2013-02-02 00:26:00 +00:00
|
|
|
struct iio_trigger *trig;
|
|
|
|
struct inv_mpu6050_chip_config chip_config;
|
|
|
|
const struct inv_mpu6050_reg_map *reg;
|
|
|
|
const struct inv_mpu6050_hw *hw;
|
|
|
|
enum inv_devices chip_type;
|
2016-04-20 06:40:49 +00:00
|
|
|
struct i2c_mux_core *muxc;
|
iio: imu: inv_mpu6050: Create mux clients for ACPI
This is a follow up patches after adding i2c mux adapter for bypass
mode. Potentially many different types of sensor can be attached to
INVMPU6XXX device, which can be connected to main cpu i2c bus in
bypass mode.
Why do we need this?
The system ACPI table entry will consist of only one device for
INV6XXX, assuming that this driver will handle all connected sensors.
That is not true for the Linux driver. There are bunch of IIO drivers
for each sensors, hence we created a mux on this device. So to load
these additional drivers, we need to create i2c devices for them
in this driver using this mux adapter.
There are multiple options:
1. Use the auto detect feature, this needs a new i2c class for the
adapter as the existing HWMON class is not acceptable. Also the
autodetect has overhead of executing detect method for each
matching class of adapters.
This is a simple implementation. This option was previously submitted
with not a happy feedback.
2. Option is use ACPI magic and parse the configuration data. What
we need to create a i2c device at a minimum is address and a name.
Address can be obtained for secondary device in more or less in a
standard way from using _CRS element. But there is no name. To get
name we need to process proprietary vendor data. Not having name is
not fun, as you have to create device using the device name of
INVN6XXXX, respecting driver duplicate name space restriction.
Also each client driver needs to have this name in the id table.
Since multiple driver can be loaded, the driver should be able to
detect its presence and gracefully exit for the other client driver
to take it over.
So we use two step process:
- Use DMI to id platform and parse propritery data. This is not uncommon
for many x86 platform specific driver. We will get both name and address.
The change created necessary infrastructure to add more properitery vendor
data parsing.
- If DMI match fails, then create device on INV6XXX-client (we can't
create with same name as INV6XXX as it will cause duplicate name and driver
model will reject.) With this each client sensor driver which needs to get
attached via INV6XXXX, need this name in the id table and detect the
physical presence of sensor in probe and exit if not found.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-01-30 22:25:45 +00:00
|
|
|
struct i2c_client *mux_client;
|
2014-12-05 22:52:09 +00:00
|
|
|
unsigned int powerup_count;
|
2013-02-02 00:26:00 +00:00
|
|
|
struct inv_mpu6050_platform_data plat_data;
|
2016-04-20 17:23:45 +00:00
|
|
|
struct iio_mount_matrix orientation;
|
2016-02-12 11:44:43 +00:00
|
|
|
struct regmap *map;
|
2016-02-12 11:44:44 +00:00
|
|
|
int irq;
|
2018-04-20 16:54:00 +00:00
|
|
|
u8 irq_mask;
|
2018-04-30 10:14:10 +00:00
|
|
|
unsigned skip_samples;
|
2018-05-28 13:22:04 +00:00
|
|
|
s64 chip_period;
|
|
|
|
s64 it_timestamp;
|
|
|
|
s64 data_timestamp;
|
2019-11-07 18:43:42 +00:00
|
|
|
struct regulator *vdd_supply;
|
2018-08-03 00:18:52 +00:00
|
|
|
struct regulator *vddio_supply;
|
2019-09-16 09:41:58 +00:00
|
|
|
bool magn_disabled;
|
2019-09-16 09:42:07 +00:00
|
|
|
s32 magn_raw_to_gauss[3];
|
|
|
|
struct iio_mount_matrix magn_orient;
|
2013-02-02 00:26:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*register and associated bit definition*/
|
2016-02-22 21:39:10 +00:00
|
|
|
#define INV_MPU6050_REG_ACCEL_OFFSET 0x06
|
|
|
|
#define INV_MPU6050_REG_GYRO_OFFSET 0x13
|
|
|
|
|
2013-02-02 00:26:00 +00:00
|
|
|
#define INV_MPU6050_REG_SAMPLE_RATE_DIV 0x19
|
|
|
|
#define INV_MPU6050_REG_CONFIG 0x1A
|
|
|
|
#define INV_MPU6050_REG_GYRO_CONFIG 0x1B
|
2014-05-02 09:34:00 +00:00
|
|
|
#define INV_MPU6050_REG_ACCEL_CONFIG 0x1C
|
2013-02-02 00:26:00 +00:00
|
|
|
|
|
|
|
#define INV_MPU6050_REG_FIFO_EN 0x23
|
2019-09-16 09:42:02 +00:00
|
|
|
#define INV_MPU6050_BIT_SLAVE_0 0x01
|
|
|
|
#define INV_MPU6050_BIT_SLAVE_1 0x02
|
|
|
|
#define INV_MPU6050_BIT_SLAVE_2 0x04
|
2014-05-02 09:34:00 +00:00
|
|
|
#define INV_MPU6050_BIT_ACCEL_OUT 0x08
|
|
|
|
#define INV_MPU6050_BITS_GYRO_OUT 0x70
|
2020-01-16 17:56:45 +00:00
|
|
|
#define INV_MPU6050_BIT_TEMP_OUT 0x80
|
2013-02-02 00:26:00 +00:00
|
|
|
|
2019-09-16 09:42:02 +00:00
|
|
|
#define INV_MPU6050_REG_I2C_MST_CTRL 0x24
|
|
|
|
#define INV_MPU6050_BITS_I2C_MST_CLK_400KHZ 0x0D
|
|
|
|
#define INV_MPU6050_BIT_I2C_MST_P_NSR 0x10
|
|
|
|
#define INV_MPU6050_BIT_SLV3_FIFO_EN 0x20
|
|
|
|
#define INV_MPU6050_BIT_WAIT_FOR_ES 0x40
|
|
|
|
#define INV_MPU6050_BIT_MULT_MST_EN 0x80
|
|
|
|
|
|
|
|
/* control I2C slaves from 0 to 3 */
|
|
|
|
#define INV_MPU6050_REG_I2C_SLV_ADDR(_x) (0x25 + 3 * (_x))
|
|
|
|
#define INV_MPU6050_BIT_I2C_SLV_RNW 0x80
|
|
|
|
|
|
|
|
#define INV_MPU6050_REG_I2C_SLV_REG(_x) (0x26 + 3 * (_x))
|
|
|
|
|
|
|
|
#define INV_MPU6050_REG_I2C_SLV_CTRL(_x) (0x27 + 3 * (_x))
|
|
|
|
#define INV_MPU6050_BIT_SLV_GRP 0x10
|
|
|
|
#define INV_MPU6050_BIT_SLV_REG_DIS 0x20
|
|
|
|
#define INV_MPU6050_BIT_SLV_BYTE_SW 0x40
|
|
|
|
#define INV_MPU6050_BIT_SLV_EN 0x80
|
|
|
|
|
|
|
|
/* I2C master delay register */
|
|
|
|
#define INV_MPU6050_REG_I2C_SLV4_CTRL 0x34
|
|
|
|
#define INV_MPU6050_BITS_I2C_MST_DLY(_x) ((_x) & 0x1F)
|
|
|
|
|
|
|
|
#define INV_MPU6050_REG_I2C_MST_STATUS 0x36
|
|
|
|
#define INV_MPU6050_BIT_I2C_SLV0_NACK 0x01
|
|
|
|
#define INV_MPU6050_BIT_I2C_SLV1_NACK 0x02
|
|
|
|
#define INV_MPU6050_BIT_I2C_SLV2_NACK 0x04
|
|
|
|
#define INV_MPU6050_BIT_I2C_SLV3_NACK 0x08
|
|
|
|
|
2013-02-02 00:26:00 +00:00
|
|
|
#define INV_MPU6050_REG_INT_ENABLE 0x38
|
2014-05-02 09:34:00 +00:00
|
|
|
#define INV_MPU6050_BIT_DATA_RDY_EN 0x01
|
|
|
|
#define INV_MPU6050_BIT_DMP_INT_EN 0x02
|
2013-02-02 00:26:00 +00:00
|
|
|
|
|
|
|
#define INV_MPU6050_REG_RAW_ACCEL 0x3B
|
|
|
|
#define INV_MPU6050_REG_TEMPERATURE 0x41
|
|
|
|
#define INV_MPU6050_REG_RAW_GYRO 0x43
|
|
|
|
|
2018-04-20 16:54:00 +00:00
|
|
|
#define INV_MPU6050_REG_INT_STATUS 0x3A
|
2018-05-22 14:18:21 +00:00
|
|
|
#define INV_MPU6050_BIT_FIFO_OVERFLOW_INT 0x10
|
2018-04-20 16:54:00 +00:00
|
|
|
#define INV_MPU6050_BIT_RAW_DATA_RDY_INT 0x01
|
|
|
|
|
2019-09-16 09:42:02 +00:00
|
|
|
#define INV_MPU6050_REG_EXT_SENS_DATA 0x49
|
|
|
|
|
|
|
|
/* I2C slaves data output from 0 to 3 */
|
|
|
|
#define INV_MPU6050_REG_I2C_SLV_DO(_x) (0x63 + (_x))
|
|
|
|
|
|
|
|
#define INV_MPU6050_REG_I2C_MST_DELAY_CTRL 0x67
|
|
|
|
#define INV_MPU6050_BIT_I2C_SLV0_DLY_EN 0x01
|
|
|
|
#define INV_MPU6050_BIT_I2C_SLV1_DLY_EN 0x02
|
|
|
|
#define INV_MPU6050_BIT_I2C_SLV2_DLY_EN 0x04
|
|
|
|
#define INV_MPU6050_BIT_I2C_SLV3_DLY_EN 0x08
|
|
|
|
#define INV_MPU6050_BIT_DELAY_ES_SHADOW 0x80
|
|
|
|
|
2013-02-02 00:26:00 +00:00
|
|
|
#define INV_MPU6050_REG_USER_CTRL 0x6A
|
2014-05-02 09:34:00 +00:00
|
|
|
#define INV_MPU6050_BIT_FIFO_RST 0x04
|
|
|
|
#define INV_MPU6050_BIT_DMP_RST 0x08
|
|
|
|
#define INV_MPU6050_BIT_I2C_MST_EN 0x20
|
|
|
|
#define INV_MPU6050_BIT_FIFO_EN 0x40
|
|
|
|
#define INV_MPU6050_BIT_DMP_EN 0x80
|
2016-02-12 11:44:45 +00:00
|
|
|
#define INV_MPU6050_BIT_I2C_IF_DIS 0x10
|
2013-02-02 00:26:00 +00:00
|
|
|
|
|
|
|
#define INV_MPU6050_REG_PWR_MGMT_1 0x6B
|
2014-05-02 09:34:00 +00:00
|
|
|
#define INV_MPU6050_BIT_H_RESET 0x80
|
|
|
|
#define INV_MPU6050_BIT_SLEEP 0x40
|
|
|
|
#define INV_MPU6050_BIT_CLK_MASK 0x7
|
2013-02-02 00:26:00 +00:00
|
|
|
|
|
|
|
#define INV_MPU6050_REG_PWR_MGMT_2 0x6C
|
2014-05-02 09:34:00 +00:00
|
|
|
#define INV_MPU6050_BIT_PWR_ACCL_STBY 0x38
|
|
|
|
#define INV_MPU6050_BIT_PWR_GYRO_STBY 0x07
|
2013-02-02 00:26:00 +00:00
|
|
|
|
2019-01-28 18:50:03 +00:00
|
|
|
/* ICM20602 register */
|
|
|
|
#define INV_ICM20602_REG_I2C_IF 0x70
|
|
|
|
#define INV_ICM20602_BIT_I2C_IF_DIS 0x40
|
|
|
|
|
2013-02-02 00:26:00 +00:00
|
|
|
#define INV_MPU6050_REG_FIFO_COUNT_H 0x72
|
|
|
|
#define INV_MPU6050_REG_FIFO_R_W 0x74
|
|
|
|
|
|
|
|
#define INV_MPU6050_BYTES_PER_3AXIS_SENSOR 6
|
|
|
|
#define INV_MPU6050_FIFO_COUNT_BYTE 2
|
2016-02-22 21:39:08 +00:00
|
|
|
|
2019-09-16 09:42:02 +00:00
|
|
|
/* MPU9X50 9-axis magnetometer */
|
|
|
|
#define INV_MPU9X50_BYTES_MAGN 7
|
|
|
|
|
2020-01-16 17:56:45 +00:00
|
|
|
/* FIFO temperature sample size */
|
|
|
|
#define INV_MPU6050_BYTES_PER_TEMP_SENSOR 2
|
2019-04-03 06:28:56 +00:00
|
|
|
|
2016-02-22 21:39:10 +00:00
|
|
|
/* mpu6500 registers */
|
2017-05-29 09:59:40 +00:00
|
|
|
#define INV_MPU6500_REG_ACCEL_CONFIG_2 0x1D
|
2020-02-06 10:31:01 +00:00
|
|
|
#define INV_ICM20689_BITS_FIFO_SIZE_MAX 0xC0
|
2016-02-22 21:39:10 +00:00
|
|
|
#define INV_MPU6500_REG_ACCEL_OFFSET 0x77
|
|
|
|
|
2016-02-22 21:39:08 +00:00
|
|
|
/* delay time in milliseconds */
|
2013-02-02 00:26:00 +00:00
|
|
|
#define INV_MPU6050_POWER_UP_TIME 100
|
|
|
|
#define INV_MPU6050_TEMP_UP_TIME 100
|
|
|
|
#define INV_MPU6050_SENSOR_UP_TIME 30
|
2016-02-22 21:39:08 +00:00
|
|
|
|
|
|
|
/* delay time in microseconds */
|
|
|
|
#define INV_MPU6050_REG_UP_TIME_MIN 5000
|
|
|
|
#define INV_MPU6050_REG_UP_TIME_MAX 10000
|
2013-02-02 00:26:00 +00:00
|
|
|
|
2019-11-26 16:19:12 +00:00
|
|
|
#define INV_MPU6050_TEMP_OFFSET 12420
|
|
|
|
#define INV_MPU6050_TEMP_SCALE 2941176
|
2013-02-02 00:26:00 +00:00
|
|
|
#define INV_MPU6050_MAX_GYRO_FS_PARAM 3
|
|
|
|
#define INV_MPU6050_MAX_ACCL_FS_PARAM 3
|
|
|
|
#define INV_MPU6050_THREE_AXIS 3
|
|
|
|
#define INV_MPU6050_GYRO_CONFIG_FSR_SHIFT 3
|
2020-02-06 10:31:03 +00:00
|
|
|
#define INV_ICM20690_GYRO_CONFIG_FSR_SHIFT 2
|
2013-02-02 00:26:00 +00:00
|
|
|
#define INV_MPU6050_ACCL_CONFIG_FSR_SHIFT 3
|
|
|
|
|
2019-11-26 16:19:12 +00:00
|
|
|
#define INV_MPU6500_TEMP_OFFSET 7011
|
|
|
|
#define INV_MPU6500_TEMP_SCALE 2995178
|
|
|
|
|
|
|
|
#define INV_ICM20608_TEMP_OFFSET 8170
|
|
|
|
#define INV_ICM20608_TEMP_SCALE 3059976
|
2019-04-03 06:28:56 +00:00
|
|
|
|
2020-01-16 17:56:45 +00:00
|
|
|
/* 6 + 6 + 2 + 7 (for MPU9x50) = 21 round up to 24 and plus 8 */
|
2019-09-16 09:42:02 +00:00
|
|
|
#define INV_MPU6050_OUTPUT_DATA_SIZE 32
|
2013-02-02 00:26:00 +00:00
|
|
|
|
2014-12-05 22:52:09 +00:00
|
|
|
#define INV_MPU6050_REG_INT_PIN_CFG 0x37
|
2018-04-20 16:54:00 +00:00
|
|
|
#define INV_MPU6050_ACTIVE_HIGH 0x00
|
|
|
|
#define INV_MPU6050_ACTIVE_LOW 0x80
|
|
|
|
/* enable level triggering */
|
|
|
|
#define INV_MPU6050_LATCH_INT_EN 0x20
|
2014-12-05 22:52:09 +00:00
|
|
|
#define INV_MPU6050_BIT_BYPASS_EN 0x2
|
2018-04-20 16:54:00 +00:00
|
|
|
|
2018-05-28 13:22:04 +00:00
|
|
|
/* Allowed timestamp period jitter in percent */
|
|
|
|
#define INV_MPU6050_TS_PERIOD_JITTER 4
|
2014-12-05 22:52:09 +00:00
|
|
|
|
2013-02-02 00:26:00 +00:00
|
|
|
/* init parameters */
|
|
|
|
#define INV_MPU6050_INIT_FIFO_RATE 50
|
2014-05-02 09:34:00 +00:00
|
|
|
#define INV_MPU6050_MAX_FIFO_RATE 1000
|
|
|
|
#define INV_MPU6050_MIN_FIFO_RATE 4
|
2018-05-22 14:18:19 +00:00
|
|
|
|
|
|
|
/* chip internal frequency: 1KHz */
|
|
|
|
#define INV_MPU6050_INTERNAL_FREQ_HZ 1000
|
|
|
|
/* return the frequency divider (chip sample rate divider + 1) */
|
|
|
|
#define INV_MPU6050_FREQ_DIVIDER(st) \
|
|
|
|
((st)->chip_config.divider + 1)
|
|
|
|
/* chip sample rate divider to fifo rate */
|
|
|
|
#define INV_MPU6050_FIFO_RATE_TO_DIVIDER(fifo_rate) \
|
|
|
|
((INV_MPU6050_INTERNAL_FREQ_HZ / (fifo_rate)) - 1)
|
|
|
|
#define INV_MPU6050_DIVIDER_TO_FIFO_RATE(divider) \
|
|
|
|
(INV_MPU6050_INTERNAL_FREQ_HZ / ((divider) + 1))
|
2013-02-02 00:26:00 +00:00
|
|
|
|
2016-04-20 13:15:11 +00:00
|
|
|
#define INV_MPU6050_REG_WHOAMI 117
|
|
|
|
|
|
|
|
#define INV_MPU6000_WHOAMI_VALUE 0x68
|
|
|
|
#define INV_MPU6050_WHOAMI_VALUE 0x68
|
|
|
|
#define INV_MPU6500_WHOAMI_VALUE 0x70
|
2016-04-20 13:15:13 +00:00
|
|
|
#define INV_MPU9150_WHOAMI_VALUE 0x68
|
2017-03-26 11:11:00 +00:00
|
|
|
#define INV_MPU9250_WHOAMI_VALUE 0x71
|
2018-04-02 22:42:00 +00:00
|
|
|
#define INV_MPU9255_WHOAMI_VALUE 0x73
|
2018-07-11 01:09:30 +00:00
|
|
|
#define INV_MPU6515_WHOAMI_VALUE 0x74
|
2016-06-30 17:06:34 +00:00
|
|
|
#define INV_ICM20608_WHOAMI_VALUE 0xAF
|
2020-02-06 10:31:01 +00:00
|
|
|
#define INV_ICM20609_WHOAMI_VALUE 0xA6
|
|
|
|
#define INV_ICM20689_WHOAMI_VALUE 0x98
|
2019-01-28 18:50:03 +00:00
|
|
|
#define INV_ICM20602_WHOAMI_VALUE 0x12
|
2020-02-06 10:31:03 +00:00
|
|
|
#define INV_ICM20690_WHOAMI_VALUE 0x20
|
2020-02-06 10:31:02 +00:00
|
|
|
#define INV_IAM20680_WHOAMI_VALUE 0xA9
|
2016-04-20 13:15:11 +00:00
|
|
|
|
2019-04-03 06:28:56 +00:00
|
|
|
/* scan element definition for generic MPU6xxx devices */
|
2013-02-02 00:26:00 +00:00
|
|
|
enum inv_mpu6050_scan {
|
|
|
|
INV_MPU6050_SCAN_ACCL_X,
|
|
|
|
INV_MPU6050_SCAN_ACCL_Y,
|
|
|
|
INV_MPU6050_SCAN_ACCL_Z,
|
2020-01-16 17:56:45 +00:00
|
|
|
INV_MPU6050_SCAN_TEMP,
|
2013-02-02 00:26:00 +00:00
|
|
|
INV_MPU6050_SCAN_GYRO_X,
|
|
|
|
INV_MPU6050_SCAN_GYRO_Y,
|
|
|
|
INV_MPU6050_SCAN_GYRO_Z,
|
|
|
|
INV_MPU6050_SCAN_TIMESTAMP,
|
2019-09-16 09:42:02 +00:00
|
|
|
|
|
|
|
INV_MPU9X50_SCAN_MAGN_X = INV_MPU6050_SCAN_GYRO_Z + 1,
|
|
|
|
INV_MPU9X50_SCAN_MAGN_Y,
|
|
|
|
INV_MPU9X50_SCAN_MAGN_Z,
|
|
|
|
INV_MPU9X50_SCAN_TIMESTAMP,
|
2013-02-02 00:26:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum inv_mpu6050_filter_e {
|
|
|
|
INV_MPU6050_FILTER_256HZ_NOLPF2 = 0,
|
|
|
|
INV_MPU6050_FILTER_188HZ,
|
|
|
|
INV_MPU6050_FILTER_98HZ,
|
|
|
|
INV_MPU6050_FILTER_42HZ,
|
|
|
|
INV_MPU6050_FILTER_20HZ,
|
|
|
|
INV_MPU6050_FILTER_10HZ,
|
|
|
|
INV_MPU6050_FILTER_5HZ,
|
|
|
|
INV_MPU6050_FILTER_2100HZ_NOLPF,
|
|
|
|
NUM_MPU6050_FILTER
|
|
|
|
};
|
|
|
|
|
|
|
|
/* IIO attribute address */
|
|
|
|
enum INV_MPU6050_IIO_ATTR_ADDR {
|
|
|
|
ATTR_GYRO_MATRIX,
|
|
|
|
ATTR_ACCL_MATRIX,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum inv_mpu6050_accl_fs_e {
|
|
|
|
INV_MPU6050_FS_02G = 0,
|
|
|
|
INV_MPU6050_FS_04G,
|
|
|
|
INV_MPU6050_FS_08G,
|
|
|
|
INV_MPU6050_FS_16G,
|
|
|
|
NUM_ACCL_FSR
|
|
|
|
};
|
|
|
|
|
|
|
|
enum inv_mpu6050_fsr_e {
|
|
|
|
INV_MPU6050_FSR_250DPS = 0,
|
|
|
|
INV_MPU6050_FSR_500DPS,
|
|
|
|
INV_MPU6050_FSR_1000DPS,
|
|
|
|
INV_MPU6050_FSR_2000DPS,
|
|
|
|
NUM_MPU6050_FSR
|
|
|
|
};
|
|
|
|
|
|
|
|
enum inv_mpu6050_clock_sel_e {
|
|
|
|
INV_CLK_INTERNAL = 0,
|
|
|
|
INV_CLK_PLL,
|
|
|
|
NUM_CLK
|
|
|
|
};
|
|
|
|
|
|
|
|
irqreturn_t inv_mpu6050_read_fifo(int irq, void *p);
|
2018-04-20 16:54:00 +00:00
|
|
|
int inv_mpu6050_probe_trigger(struct iio_dev *indio_dev, int irq_type);
|
2013-02-02 00:26:00 +00:00
|
|
|
int inv_reset_fifo(struct iio_dev *indio_dev);
|
|
|
|
int inv_mpu6050_switch_engine(struct inv_mpu6050_state *st, bool en, u32 mask);
|
|
|
|
int inv_mpu6050_write_reg(struct inv_mpu6050_state *st, int reg, u8 val);
|
|
|
|
int inv_mpu6050_set_power_itg(struct inv_mpu6050_state *st, bool power_on);
|
2016-02-12 11:44:44 +00:00
|
|
|
int inv_mpu_acpi_create_mux_client(struct i2c_client *client);
|
|
|
|
void inv_mpu_acpi_delete_mux_client(struct i2c_client *client);
|
2016-02-12 11:44:45 +00:00
|
|
|
int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
|
2016-02-22 21:39:11 +00:00
|
|
|
int (*inv_mpu_bus_setup)(struct iio_dev *), int chip_type);
|
2016-02-12 11:44:44 +00:00
|
|
|
extern const struct dev_pm_ops inv_mpu_pmops;
|
2019-09-16 09:42:00 +00:00
|
|
|
|
|
|
|
#endif
|