History log of /linux-master/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
Revision Date Author Comments
# c48fb9f9 27-Sep-2023 Andreas Kemnade <andreas@kemnade.info>

iio: imu: mpu6050: add level shifter flag

Some boards fail in magnetometer probe if level shifter flag is not set,
definition was found in the vendor Linux kernel v3.0.

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Link: https://lore.kernel.org/r/20230927173245.2151083-3-andreas@kemnade.info
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 4eaf9286 11-Aug-2023 Yue Haibing <yuehaibing@huawei.com>

iio: Remove unused declarations

Commit 0f3a8c3f34f7 ("iio: Add support for creating IIO devices via configfs")
declared but never implemented iio_sw_device_type_configfs_{un}register().
Commit b662f809d410 ("iio: core: Introduce IIO software triggers") declared but
never implemented iio_sw_trigger_type_configfs_{un}register().
Commit a3e0b51884ee ("iio: accel: add support for FXLS8962AF/FXLS8964AF accelerometers")
declared but never implemented fxls8962af_core_remove().
Commit 8dedcc3eee3a ("iio: core: centralize ioctl() calls to the main chardev")
declared but never implemented iio_device_ioctl().

Commit d430f3c36ca6 ("iio: imu: inv_mpu6050: Use regmap instead of i2c specific functions")
removed inv_mpu6050_write_reg() but not its declaration.

Signed-off-by: Yue Haibing <yuehaibing@huawei.com>
Link: https://lore.kernel.org/r/20230811095701.35372-1-yuehaibing@huawei.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 0829edc4 23-Jun-2023 Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>

iio: imu: inv_mpu6050: read the full fifo when processing data

When processing data read the full fifo data in 1 time. If there
are several samples in the FIFO, it means we are experiencing
system delay. In this case, it is better to read all data with 1
bus access than to add additional latency by doing several ones.

This requires to use a bigger buffer depending on chip FIFO size
and do an additional local data copy before sending. But the cost
is minimal and behavior is still better like this under system
heavy load.

Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Link: https://lore.kernel.org/r/20230623082924.283967-1-inv.git-commit@tdk.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 111e1abd 06-Jun-2023 Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>

iio: imu: inv_mpu6050: use the common inv_sensors timestamp module

Replace timestamping by the new common inv_sensors timestamp
module. The principle behind is the same but the implementation in
the new module is far better providing less jitter and a better
estimation.

Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20230606162147.79667-5-inv.git-commit@tdk.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 23cf1846 04-May-2023 Hermes Zhang <chenhuiz@axis.com>

iio: imu: mpu6050: Add support for the ICM 20600 IMU

The Invensense ICM-20600 is a 6-axis MotionTracking device that combines a
3-axis gyroscope and an 3-axis accelerometer. It is very similar to the
ICM20602 imu which is already supported by the mpu6050 driver. The main
difference is that the ICM-20600 has a different WHOAMI value.

Signed-off-by: Hermes Zhang <chenhuiz@axis.com>
Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Link: https://lore.kernel.org/r/20230505054853.2155326-3-chenhuiz@axis.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 54e03562 08-May-2022 Jonathan Cameron <Jonathan.Cameron@huawei.com>

iio: imu: mpu6050: Fix alignment for DMA safety

____cacheline_aligned is an insufficient guarantee for non-coherent DMA
on platforms with 128 byte cachelines above L1. Switch to the updated
IIO_DMA_MINALIGN definition.

Fixes: 6b0cc5dce072 ("iio:imu:inv_mpu6050 Fix dma and ts alignment and data leak issues.")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Acked-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20220508175712.647246-80-jic23@kernel.org


# 6dc2c871 23-Mar-2022 Michael Srba <Michael.Srba@seznam.cz>

iio: imu: inv_mpu6050: Add support for ICM-20608-D

The difference between the ICM-20608-D and the other ICM-20608
variants is the addition of a DMP (Digital Motion Processor) core.
This difference is deemed substantial enough to change the WHOAMI
register value.
Since this driver doesn't currently acknowledge the exisence of
something like a DMP core, simply copy ICM-20608 except for the
aforementioned WHOAMI register.

Signed-off-by: Michael Srba <Michael.Srba@seznam.cz>
Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Link: https://lore.kernel.org/r/20220323121550.16096-3-michael.srba@seznam.cz
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# e46a36d9 21-Jun-2021 Baptiste Mansuy <bmansuy@invensense.com>

Add startup time for each chip using inv_mpu6050 driver

Add startup time for each chip familly. This allows a better behaviour of
the gyro and the accel. The gyro has now the time to stabilise itself
thus making initial data discarding for gyro irrelevant.

Signed-off-by: Baptiste Mansuy <bmansuy@invensense.com>
Acked-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Link: https://lore.kernel.org/r/20210621085731.9212-1-bmansuy@invensense.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 4df68509 02-Dec-2020 Stephan Gerhold <stephan@gerhold.net>

iio: imu: inv_mpu6050: Add support for MPU-6880

MPU-6880 seems to be very similar to MPU-6500 and it works
fine with some minor additions for the mpu6050 driver.

Add the necessary defines for it and make it use the same registers
as MPU-6500 but with a FIFO size of 4096.

Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Acked-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Cc: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Link: https://lore.kernel.org/r/20201202104656.5119-2-stephan@gerhold.net
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 6b0cc5dc 22-Jul-2020 Jonathan Cameron <Jonathan.Cameron@huawei.com>

iio:imu:inv_mpu6050 Fix dma and ts alignment and data leak issues.

This case is a bit different to the rest of the series. The driver
was doing a regmap_bulk_read into a buffer that wasn't dma safe
as it was on the stack with no guarantee of it being in a cacheline
on it's own. Fixing that also dealt with the data leak and
alignment issues that Lars-Peter pointed out.

Also removed some unaligned handling as we are now aligned.

Fixes tag is for the dma safe buffer issue. Potentially we would
need to backport timestamp alignment futher but that is a totally
different patch.

Fixes: fd64df16f40e ("iio: imu: inv_mpu6050: Add SPI support for MPU6000")
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200722155103.979802-18-jic23@kernel.org


# 4599cac8 19-Feb-2020 Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>

iio: imu: inv_mpu6050: use runtime pm with autosuspend

Use runtime power management for handling chip power and
sensor engines on/off. Simplifies things a lot since pm
runtime already has reference counter.
Usage of autosuspend reduces the number of power on/off. This
makes polling interface now usable to get data at low
frequency.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 4c1e0147 19-Feb-2020 Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>

iio: imu: inv_mpu6050: factorize fifo enable/disable

Rework fifo enable/disable in a separate function.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 92e7407a 19-Feb-2020 Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>

iio: imu: inv_mpu6050: rewrite power and engine management

Rewrite clock management to use automatic clock switching
present since MPU6500.
Sensors engine management can now turn on or off a batch of
sensors which simplifies usage a lot.
Temperature sensor is now turned on/off depending on usage.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# c1bfe9c8 19-Feb-2020 Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>

iio: imu: inv_mpu6050: add all signal path resets at init

Old chips using spi require for a full reset to manually reset
all signal path. This does not harm when using i2c so do it
inconditionally. Exclude i2c only chips.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 5621a63a 19-Feb-2020 Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>

iio: imu: inv_mpu6050: early init of chip_config for use at setup

Init chip_config early and use its values for initial setup.
More coherent, prevent possible mistakes.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 9fc89f79 06-Feb-2020 Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>

iio: imu: inv_mpu6050: update LPF bandwidth settings

As every chip has some little variant in LPF bandwidth values,
use common values that are working for all chips.
Simplify the LPF setting function.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 8abce87d 06-Feb-2020 Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>

iio: imu: inv_mpu6050: add support of ICM20690

Same generation as ICM20602 but different registers.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# d31f74e6 06-Feb-2020 Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>

iio: imu: inv_mpu6050: add support of IAM20680

Automotive certified IMU, similar to ICM20608.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 23db8d69 06-Feb-2020 Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>

iio: imu: inv_mpu6050: add support of ICM20609 & ICM20689

They are similar to ICM20608 chip.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 2e4c0a5e 16-Jan-2020 Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>

iio: imu: inv_mpu6050: add fifo temperature data support

Add support of temperature data in fifo for all chips.
Enable unification of scan elements for icm20602.
Add macros for generating scan elements.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 53eaa9c2 26-Nov-2019 Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>

iio: imu: inv_mpu6050: fix temperature reporting using bad unit

Temperature should be reported in milli-degrees, not degrees. Fix
scale and offset values to use the correct unit.

This is a fix for an issue that has been present for a long time.
The fixes tag reflects the point at which the code last changed in a
fashion that would make this fix patch no longer apply. Backports
will be necessary to fix those elements that predate that patch.

Fixes: 1615fe41a195 ("iio: imu: mpu6050: Fix FIFO layout for ICM20602")
Cc: stable@vger.kernel.org
Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 26a0ffee 07-Nov-2019 Stephan Gerhold <stephan@gerhold.net>

iio: imu: mpu6050: Add support for vdd-supply regulator

MPU6050 has two power supply pins: VDD and VLOGIC, but the
mpu6050 driver only supports enabling one of them at the moment.
In some cases, they may need to be enabled separately.

Add an additional "vdd-supply" that stays enabled for as long as
the driver is loaded. We cannot turn off the VDD regulator during
suspend as this would cause register settings (FSR, sampling rate, ...)
to be lost.

Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Reviewed-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 6e82ae6b 16-Oct-2019 Jean-Baptiste Maneyrol <JManeyrol@invensense.com>

iio: imu: inv_mpu6050: fix no data on MPU6050

Some chips have a fifo overflow bit issue where the bit is always
set. The result is that every data is dropped.

Change fifo overflow management by checking fifo count against
a maximum value.

Add fifo size in chip hardware set of values.

Fixes: f5057e7b2dba ("iio: imu: inv_mpu6050: better fifo overflow handling")
Cc: stable@vger.kernel.org
Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# e764fb4e 16-Sep-2019 Jean-Baptiste Maneyrol <JManeyrol@invensense.com>

iio: imu: inv_mpu6050: add fifo support for magnetometer data

Put read magnetometer data by mpu inside the fifo.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# b1392de0 16-Sep-2019 Jean-Baptiste Maneyrol <JManeyrol@invensense.com>

iio: imu: inv_mpu6050: add MPU925x magnetometer support

Add support of driving MPU9250 magnetometer connected on i2c
auxiliary bus using the MPU i2c master.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 68fd019b 16-Sep-2019 Jean-Baptiste Maneyrol <JManeyrol@invensense.com>

iio: imu: inv_mpu6050: add defines for supporting 9-axis chips

Add registers defines required for driving chip i2c master ip.
Add MPU9xxx magnetometer scan elements and update data bytes size.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 5ffd0248 16-Sep-2019 Jean-Baptiste Maneyrol <JManeyrol@invensense.com>

iio: imu: inv_mpu6050: add header include protection macro

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# ca4a6496 16-Sep-2019 Jean-Baptiste Maneyrol <JManeyrol@invensense.com>

iio: imu: inv_mpu6050: disable i2c mux for MPU925x

Disable i2c mux for supported 9xxx chips. This is a
pre-requesite for controling 9xxx magnetometer using the
i2c master of the chip.

Check in device-tree that there is no i2c-gate device declared
for ensuring backward compatibility with existing setups.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 9c92ab61 29-May-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 282

Based on 1 normalized pattern(s):

this software is licensed under the terms of the gnu general public
license version 2 as published by the free software foundation and
may be copied distributed and modified under those terms this
program is distributed in the hope that it will be useful but
without any warranty without even the implied warranty of
merchantability or fitness for a particular purpose see the gnu
general public license for more details

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-only

has been chosen to replace the boilerplate/reference in 285 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190529141900.642774971@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1615fe41 03-Apr-2019 Steve Moskovchenko <stevemo@skydio.com>

iio: imu: mpu6050: Fix FIFO layout for ICM20602

The MPU6050 driver has recently gained support for the
ICM20602 IMU, which is very similar to MPU6xxx. However,
the ICM20602's FIFO data specifically includes temperature
readings, which were not present on MPU6xxx parts. As a
result, the driver will under-read the ICM20602's FIFO
register, causing the same (partial) sample to be returned
for all reads, until the FIFO overflows.

Fix this by adding a table of scan elements specifically
for the ICM20602, which takes the extra temperature data
into consideration.

While we're at it, fix the temperature offset and scaling
on ICM20602, since it uses different scale/offset constants
than the rest of the MPU6xxx devices.

Signed-off-by: Steve Moskovchenko <stevemo@skydio.com>
Fixes: 22904bdff978 ("iio: imu: mpu6050: Add support for the ICM 20602 IMU")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 22904bdf 28-Jan-2019 Randolph Maaßen <gaireg@gaireg.de>

iio: imu: mpu6050: Add support for the ICM 20602 IMU

The Invensense ICM-20602 is a 6-axis MotionTracking device that
combines a 3-axis gyroscope and an 3-axis accelerometer. It is very
similar to the ICM-20608 imu which is already supported by the mpu6050
driver. The main difference is that the ICM-20602 has the i2c bus
disable bit in a separate register.

Signed-off-by: Randolph Maaßen <gaireg@gaireg.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 07c12b1c 02-Aug-2018 Brian Masney <masneyb@onstation.org>

iio: imu: mpu6050: add support for regulator framework

This patch adds support for the regulator framework to the mpu6050
driver.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# de8df0b9 10-Jul-2018 Brian Masney <masneyb@onstation.org>

iio: imu: mpu6050: add support for 6515 variant

This patch adds support for the MPU 6515 variant. Confirmed that the
driver functions correctly on a LG Nexus 5 (hammerhead) phone.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 4bcc19f1 28-May-2018 Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>

iio: imu: inv_mpu6050: new timestamp mechanism

Check validity of interrupt timestamps by computing time between
2 interrupts. If it matches the chip frequency modulo 4%, it is
used as the data timestamp and also for estimating the chip
frequency measured from the system. Otherwise timestamp is
computed using the estimated chip frequency.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# f5057e7b 22-May-2018 Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>

iio: imu: inv_mpu6050: better fifo overflow handling

Use fifo overflow bit from int status rather than using an
arbitrary threshold.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 7b782508 22-May-2018 Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>

iio: imu: inv_mpu6050: switch to use sample rate divider

Instead of storing fifo rate in Hz, store the chip internal sample
rate divider. This will be more useful for timestamping. There
are both equivalent.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 3ca4fb43 22-May-2018 Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>

iio: imu: inv_mpu6050: replace timestamp fifo by generic timestamp

Using a fifo for storing timestamps is useless since the interrupt
is in one-shot mode, preventing the hard irq handler to be called
when the irq thread is running. Instead use the generic timestamp
function iio_pollfunc_store_time.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# edddddd9 29-Apr-2018 Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>

iio: imu: inv_mpu6050: fix user_ctrl register overwritten

When in spi mode, we are setting i2c disable bit in user_ctrl
register. But the register is overwritten after when turning fifo
on. So save user_ctrl init value and always use it when updating
the register.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# c2b82a69 29-Apr-2018 Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>

iio: imu: inv_mpu6050: skip first sample when gyro is on

Implement generic skip first samples mechanism and use it to
filter out first sample when gyro is on.

The problem for these chips is that the first sample of the gyro
is out of specs, because gyro is not completely stabilized. To
ensure all data are within sensor specs, we just skip the first
sample when turning gyro on.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 57f1677b 22-Apr-2018 Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>

iio: imu: inv_mpu6050: use devm_* at init and delete remove

Use devm_* for iio_triggered_buffer_setup, iio_device_register,
iio_trigger_register. Delete unneeded inv_mpu6050_remove_trigger,
inv_mpu_core_remove, and inv_mpu_remove for spi driver.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 5ec6486d 20-Apr-2018 Martin Kelly <mkelly@xevo.com>

iio:imu: inv_mpu6050: support more interrupt types

Currently, we support only rising edge interrupts, and in fact we assume
that the interrupt we're given is rising edge (and things won't work if
it's not). However, the device supports rising edge, falling edge, level
low, and level high interrupts.

Empirically, on my system, switching to level interrupts has fixed a
problem I had with significant (~40%) interrupt loss with edge
interrupts. This issue is likely related to the SoC I'm using (Allwinner
H3), but being able to switch the interrupt type is still a very useful
workaround.

I tested this with each interrupt type and verified correct behavior in
a logic analyzer.

Add support for these interrupt types while also eliminating the error
case of the device tree and driver using different interrupt types.

Signed-off-by: Martin Kelly <mkelly@xevo.com>
Acked-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 685cc61b 02-Apr-2018 Douglas Fischer <fischerdouglasc@gmail.com>

iio: imu: Add mpu9255 support to mpu6050 driver

Added support for the mpu9255 IMU to the mpu6050 driver. The
register map is the same as the other chips; the only driver
difference is the compatible string and the WHOAMI register
value.

Signed-off-by: Douglas Fischer <fischerdouglasc@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# d12ceffd 26-Mar-2018 Jean-Baptiste Maneyrol <JManeyrol@invensense.com>

iio: imu: inv_mpu6050: clean double declaration of set_power_itg

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 68cd6e5b 07-Jun-2017 Jean-Baptiste Maneyrol <JManeyrol@invensense.com>

iio: imu: inv_mpu6050: fix lock issues by using our own mutex

There are several locks issues when using buffer and direct polling
data at the same time. Use our own mutex for managing locking and
block simultaneous use of buffer and direct polling by using
iio_device_{claim/release}_direct_mode. This makes chip_config
enable bit obsolete, so delete it.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 948588e2 29-May-2017 Jean-Baptiste Maneyrol <JManeyrol@invensense.com>

iio: imu: inv_mpu6050: add accel lpf setting for chip >= MPU6500

Starting from MPU6500, accelerometer dlpf is set in a separate
register named ACCEL_CONFIG_2.
Add this new register in the map and set it for the corresponding
chips.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Cc: stable@vger.kernel.org
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 0c8f492d 25-Mar-2017 Jonathan Cameron <jic23@kernel.org>

iio:imu:mpu6050 add explicit mpu9250 support

The mpu9250 is a SIP containing an mpu6500 and an ak8975. If this was all
there was too it there would be no need for explicit handling in the driver.
Arguably the bindings would also only reflect the presence of an mpu6500 with
the ak8975 hanging off it, as the kernel doesn't care that they are in one
package.

However, the WHOAMI value changes as well so best to add explicit support.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 468c5620 30-Jun-2016 Gregor Boirie <gregor.boirie@parrot.com>

iio:imu:mpu6050: icm20608 initial support

Introduce support for Invense ICM20608 IMU, a 6-axis motion tracking device
that combines a 3-axis gyroscope and a 3-axis accelerometer:
http://www.invensense.com/products/motion-tracking/6-axis/icm-20608-2

Signed-off-by: Gregor Boirie <gregor.boirie@parrot.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# fbced0e9 20-Apr-2016 Crestez Dan Leonard <leonard.crestez@intel.com>

iio: inv_mpu6050: Add explicit support for MPU9150

This device is a package containing a MPU6050-like sensor and an AK8975
magnetometer. The magnetometer component is supported by the existing
ak8975 driver.

This patch also rephrases the Kconfig descriptions.

Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com>
Acked-by: Ge Gao <ggao@invensense.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# cec01545 20-Apr-2016 Crestez Dan Leonard <leonard.crestez@intel.com>

iio: inv_mpu6050: Check WHO_AM_I register on probe

This can be used to distinguish mpu6500. This is a warning rather than
an error because the differences are mostly irrelevant and it's nice to
avoid breaking users with slightly incorrect ACPI/DT.

Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com>
Acked-by: Ge Gao <ggao@invensense.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 7bdd31815 20-Apr-2016 Crestez Dan Leonard <leonard.crestez@intel.com>

iio: inv_mpu6050: Remove inv_mpu6050_hw.num_reg

This field was unused and incorrect for mpu6500.

Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# eb379846 20-Apr-2016 Gregor Boirie <gregor.boirie@parrot.com>

iio:imu:mpu6050: enhance mounting matrix support

Add a new rotation matrix sysfs attribute compliant with IIO core
mounting matrix API.
Matrix is retrieved from "in_anglvel_mount_matrix" and
"in_accel_mount_matrix" sysfs attributes. It is declared into mpu6050 DTS
entry as a "mount-matrix" property.

Old interface is kept for backward userspace compatibility and may be
retrieved from legacy platform_data mechanism only.

Signed-off-by: Gregor Boirie <gregor.boirie@parrot.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 51f97f6d 20-Apr-2016 Peter Rosin <peda@axentia.se>

iio: imu: inv_mpu6050: convert to use an explicit i2c mux core

Allocate an explicit i2c mux core to handle parent and child adapters
etc. Update the select/deselect ops to be in terms of the i2c mux core
instead of the child adapter.

Acked-by: Jonathan Cameron <jic23@kernel.org>
Tested-by: Crestez Dan Leonard <leonard.crestez@intel.com>
Signed-off-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# 33da559f 22-Feb-2016 Matt Ranostay <mranostay@gmail.com>

iio: imu: mpu6050: add mpu6500 register settings

Signed-off-by: Matt Ranostay <matt.ranostay@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# d5098447 22-Feb-2016 Matt Ranostay <mranostay@gmail.com>

iio: imu: mpu6050: add calibration offset support

Allow setting of the x/y/z axes calibration offsets for the gyroscope
and accelerometer.

Signed-off-by: Matt Ranostay <matt.ranostay@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 725f645d 22-Feb-2016 Matt Ranostay <mranostay@gmail.com>

iio: imu: mpu6050: add missing docstring for int_pin_cfg

Signed-off-by: Matt Ranostay <matt.ranostay@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 8f356be3 22-Feb-2016 Matt Ranostay <mranostay@gmail.com>

iio: imu: mpu6050: fix INV_MPU6050_REG_UP_TIME delay

replace msleep(INV_MPU6050_REG_UP_TIME) with usleep_range calls
due to fact the wait time is under 20 milliseconds.

Signed-off-by: Matt Ranostay <matt.ranostay@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# fd64df16 12-Feb-2016 Adriana Reus <adi.reus@gmail.com>

iio: imu: inv_mpu6050: Add SPI support for MPU6000

The only difference between the MPU6000 and the
MPU6050 is that the first also supports SPI.
Add SPI driver for this chip.

Signed-off-by: Adriana Reus <adriana.reus@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# b3eea8da 12-Feb-2016 Adriana Reus <adi.reus@gmail.com>

iio: imu: inv_mpu6050: Separate driver into core and i2c functionality.

Separate this driver into core and i2c functionality.
This is in preparation for adding spi support.

Signed-off-by: Adriana Reus <adriana.reus@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# d430f3c3 12-Feb-2016 Adriana Reus <adi.reus@gmail.com>

iio: imu: inv_mpu6050: Use regmap instead of i2c specific functions

Use regmap instead of i2c specific functions.
This is in preparation of splitting this driver into core and
i2c specific functionality.

Signed-off-by: Adriana Reus <adriana.reus@intel.com>
Acked-by: Crt Mori <cmo@melexis.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# c278ac0e 12-Feb-2016 Adriana Reus <adi.reus@gmail.com>

iio: imu: inv-mpu6050: Fix interrupt pin configuration

The select/deselect_bypass duo writes the irq number into the interrupt
configuration register.
If there is a i2c slave device connected to the mpu (eg. a magnetometer)
then this can hinder interrupt delivery for the accelerometer and
gyroscope.
Set this register to the default configuration.

Signed-off-by: Adriana Reus <adriana.reus@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# a35c5d1a 30-Jan-2015 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

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>


# 3a2ecc3d 05-Dec-2014 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

iio: imu: inv_mpu6050: Add i2c mux for by pass

This chip allows some limited number of sensors connected to it as
slaves, which can be directly accessed by register interface of this
driver.But the current upstream driver doesn't support such mode.
To attach such slaves to main processor i2c bus, chip has to be set
up in bypass mode. This change adds i2c mux, which will enable/disable
this mode for transaction to/from such slave devices.
This was discussed for a while in mailing list, this was the outcome:
Reference:
http://www.spinics.net/lists/linux-iio/msg12126.html
http://comments.gmane.org/gmane.linux.kernel.iio/11470

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 6f174fd3 19-Mar-2014 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

iio: imu: inv_mpu6050: Add compatibity with MPU6500

Adding MPU6500 in target list for this driver.

Description:
Source
Document: MPU-6500 Register Map and Descriptions Revision 2.1
Section 3: Register Map

This section describes difference in terms device programmability
between MPU6050 and MPU6500.
These are different registers, which differs between MPU6050 and
MPU6500.

Addr Name
---------------------
1E LP_ACCEL_ODR
6C PWR_MGMT_2
77 XA_OFFSET_H
78 XA_OFFSET_L
7A YA_OFFSET_H
7B YA_OFFSET_L
7D ZA_OFFSET_H
7E ZA_OFFSET_L

But the current MPU6050 driver doesn't use registers which are different
except PWR_MGMT_2. The difference is support of "LP_WAKE_CTRL" at bit6-7
in MPU6050 mode. In MPU6500 they are not defined.
In current mpu6050 driver, only values used for this register are for
standby mode for gyro and accelerometer.
In both case frequency of wakeups is set to default and not using
bit 6-7.

So this driver van as well support MPU6500. In addition MPU6500 can
run MPU6050 mode by changing device trim settings.

So changing config comments to allow MPU6500 to use this driver.
When the driver is enhanced to support more functions, i2c driver
data INV_MPU6500 or "WHO_AM_I" register can be used to add additional
functionality.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 7da773e6 02-May-2014 Manuel Stahl <manuel.stahl@iis.fraunhofer.de>

iio: imu: inv_mpu6050: Fix typo and formatting

Signed-off-by: Manuel Stahl <manuel.stahl@iis.fraunhofer.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 09a642b7 01-Feb-2013 Ge Gao <ggao@invensense.com>

Invensense MPU6050 Device Driver.

This the basic functional Invensense MPU6050 Device driver.

Signed-off-by: Ge Gao <ggao@invensense.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>