History log of /linux-master/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
Revision Date Author Comments
# 39dac9d0 29-Oct-2023 Su Hui <suhui@nfschina.com>

iio: imu: inv_mpu6050: return callee's error code rather than -EINVAL

regmap_bulk_write()/regmap_bulk_read() return zero or negative error
code, return the callee's error code is better than '-EINVAL'.

Signed-off-by: Su Hui <suhui@nfschina.com>
Link: https://lore.kernel.org/r/20231030020752.67630-1-suhui@nfschina.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# c3df0e29 29-Oct-2023 Su Hui <suhui@nfschina.com>

iio: imu: inv_mpu6050: fix an error code problem in inv_mpu6050_read_raw

inv_mpu6050_sensor_show() can return -EINVAL or IIO_VAL_INT. Return the
true value rather than only return IIO_VAL_INT.

Fixes: d5098447147c ("iio: imu: mpu6050: add calibration offset support")
Signed-off-by: Su Hui <suhui@nfschina.com>
Link: https://lore.kernel.org/r/20231030020218.65728-1-suhui@nfschina.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 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>


# 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>


# 62bfa12c 25-Sep-2022 Jonathan Cameron <Jonathan.Cameron@huawei.com>

iio: imu: inv_mpu: Move exports to IIO_MPU6050 namespace

As these exports are only relevant to core module and users in the
bus specific modules, move them out of the main kernel namespace.

Includes using EXPORT_NS_GPL_DEV_PM_OPS() and the simplifications that
brings by allowing the compiler to remove unused struct dev_pm_ops
and callbacks without needing explicit __maybe_unused markings.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Cc: Linus Walleij <linus.walleij@linaro.org>

--
Dropped Linus' tag as the new patch is significantly different.

v2: Switch to more flexible version of EXPORT* macro from Paul.
Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Link: https://lore.kernel.org/r/20220925155719.3316280-6-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 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>


# 40b54cbe 16-May-2021 Jonathan Cameron <Jonathan.Cameron@huawei.com>

iio: imu: mpu6050: Balance runtime pm + use pm_runtime_resume_and_get()

Remove an unblanced pm_runtime_put_sync_suspend() call
in inv_pu_pm_disable(). Not this call is not a bug, because the runtime
pm core will not allow the reference counter to go negative. It is
however confusing and serves no purpose.

pm_runtime_resume_and_get() case found using coccicheck script under
review at:
https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/

pm_runtime_resume_and_get() returns <= 0 only so simplify related checks
to bring this more inline with nearby calls.

This is a prequel to taking a closer look at the runtime pm in IIO drivers
in general.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210516162103.1332291-2-jic23@kernel.org


# e8951f08 03-Jun-2021 Jonathan Cameron <Jonathan.Cameron@huawei.com>

iio: imu: inv_mpu6050: Drop use of %hhx format string.

Since:
commit cbacb5ab0aa0 ("docs: printk-formats: Stop encouraging use of
unnecessary %h[xudi] and %hh[xudi]")
use of these format strings has been discouraged.

Use the 0x02x form as the length specifier when used with # includes
the 0x prefix and is very unlikely to be what was intended by the author.

Part of a series removing all uses from IIO in the interestings of
avoiding providing bad examples for people to copy.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20210603180612.3635250-4-jic23@kernel.org


# b892770a 18-May-2021 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

iio: Drop Duplicated "mount-matrix" parameter

All of the users of iio_read_mount_matrix() are using the very same
property name. Moreover, the property name is hard coded in the API
documentation.

Make this clear and avoid duplication now and in the future.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Sean Nyekjaer <sean@geanix.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20210518112546.44592-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# e09fe913 05-Apr-2021 Lars-Peter Clausen <lars@metafoo.de>

iio: inv_mpu6050: Fully validate gyro and accel scale writes

When setting the gyro or accelerometer scale the inv_mpu6050 driver ignores
the integer part of the value. As a result e.g. all of 0.13309, 1.13309,
12345.13309, ... are accepted as a valid gyro scale and 0.13309 is the
scale that gets set in all those cases.

Make sure to check that the integer part of the scale value is 0 and reject
it otherwise.

Fixes: 09a642b78523 ("Invensense MPU6050 Device Driver.")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Link: https://lore.kernel.org/r/20210405114441.24167-1-lars@metafoo.de
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# a71654af 25-Mar-2021 Lars-Peter Clausen <lars@metafoo.de>

iio: inv_mpu6050: Make interrupt optional

The inv_mpu6050 driver requires an interrupt for buffered capture. But non
buffered reading for measurements works just fine without an interrupt
connected.

Make the interrupt optional to support this case.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Link: https://lore.kernel.org/r/20210325131046.13383-2-lars@metafoo.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 0d41da03 25-Mar-2021 Lars-Peter Clausen <lars@metafoo.de>

iio: inv_mpu6050: Remove superfluous indio_dev->modes assignment

The inv_mpu6050 driver manually assigns the indio_dev->modes property. But
this is not necessary since it will be setup in iio_trigger_buffer_setup().

Remove the manual assignment.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Link: https://lore.kernel.org/r/20210325131046.13383-1-lars@metafoo.de
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>


# 75e13a76 29-Aug-2020 Krzysztof Kozlowski <krzk@kernel.org>

iio: imu: inv_mpu6050: Simplify with dev_err_probe()

Common pattern of handling deferred probe can be simplified with
dev_err_probe(). Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Link: https://lore.kernel.org/r/20200829064726.26268-13-krzk@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# ecf8d08f 17-Jul-2020 Lee Jones <lee.jones@linaro.org>

iio: imu: inv_mpu6050: inv_mpu_core: Demote obvious misuse of kerneldoc to standard comment blocks

No attempt has been made to document any of the demoted functions here.

Fixes the following W=1 kernel build warning(s):

drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:444: warning: Function parameter or member 'st' not described in 'inv_mpu6050_set_lpf_regs'
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:444: warning: Function parameter or member 'val' not described in 'inv_mpu6050_set_lpf_regs'
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:480: warning: Function parameter or member 'indio_dev' not described in 'inv_mpu6050_init_config'
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:862: warning: Function parameter or member 'st' not described in 'inv_mpu6050_set_lpf'
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:862: warning: Function parameter or member 'rate' not described in 'inv_mpu6050_set_lpf'
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:893: warning: Function parameter or member 'dev' not described in 'inv_mpu6050_fifo_rate_store'
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:893: warning: Function parameter or member 'attr' not described in 'inv_mpu6050_fifo_rate_store'
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:893: warning: Function parameter or member 'buf' not described in 'inv_mpu6050_fifo_rate_store'
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:893: warning: Function parameter or member 'count' not described in 'inv_mpu6050_fifo_rate_store'
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:954: warning: Function parameter or member 'dev' not described in 'inv_fifo_rate_show'
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:954: warning: Function parameter or member 'attr' not described in 'inv_fifo_rate_show'
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:954: warning: Function parameter or member 'buf' not described in 'inv_fifo_rate_show'
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:975: warning: Function parameter or member 'dev' not described in 'inv_attr_show'
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:975: warning: Function parameter or member 'attr' not described in 'inv_attr_show'
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:975: warning: Function parameter or member 'buf' not described in 'inv_attr_show'
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c:1282: warning: Function parameter or member 'st' not described in 'inv_check_and_setup_chip'

Cc: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 8f73a13f 03-Jun-2020 Alexandru Ardelean <alexandru.ardelean@analog.com>

iio: remove left-over parent assignments

These were found by doing some shell magic:
------------
for file in $(git grep -w devm_iio_device_alloc | cut -d: -f1 | sort | uniq) ; do
if grep 'parent =' $file | grep -v trig | grep -vq devm_; then
echo "$file -> $(grep "parent =" $file)"
fi
done
-----------

The output is bearable [after the semantic patch is applied].
There is a mix of trigger assignments with some iio device parent
assignments that are removed via this patch.

JC: A few more added via inspection of all parent =
statements in drivers/iio. Some of these may just have crossed with this
series, others were less obvious to scripting due to some cross
file / module boundary calls.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 0a2bf920 31-Mar-2020 Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>

iio: imu: inv_mpu6050: fix suspend/resume with runtime power

Suspend/resume were not working correctly with pm runtime.
Now suspend check if the chip is already suspended, and
resume put runtime pm in the correct state.

Issues seen prior to this were:

When entering suspend, there was an error in logs because we
were disabling vddio regulator although it was already disabled.
And when resuming, the chip was pull back to full power but the
pm_runtime state was not updated. So it was believing it was
still suspended.

Fixes: 4599cac84614 ("iio: imu: inv_mpu6050: use runtime pm with autosuspend")
Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# d7d3a132 05-Apr-2020 Jonathan Cameron <Jonathan.Cameron@huawei.com>

iio:imu:mpu6050: Tidy up parameters to regmap_bulk functions.

A mixture of:
* Casts to u8 * for the val parameter which is void * and so needs no cast.
* Explicit sizes when we can use sizeof on the destination / source variable.

Not broken in anyway, I'm just trying to tidy up the is in the subsystem to
avoid it getting cut and paste into new drivers.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>


# 4b7ef604 27-Mar-2020 Rohit Sarkar <rohitsarkar5398@gmail.com>

iio: imu: inv_mpu6050: add debugfs register r/w interface

The debugfs interface provides direct access to read and write device
registers if debugfs is enabled.

Signed-off-by: Rohit Sarkar <rohitsarkar5398@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


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

iio: imu: inv_mpu6050: temperature only work with accel/gyro

Temperature sensor works correctly only when accel and/or gyro
is turned on. Prevent polling value if they are not running.
Anyway it doesn't make sense to use it without sensor engines
on.

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


# 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>


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

iio: imu: inv_mpu6050: dynamic sampling rate change

Sampling rate can be changed while the chip is running. It can
be useful thus do not prevent it.

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


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

iio: imu: inv_mpu6050: fix data polling interface

When reading data with the polling interface, we need to wait
at 1 sampling period to have a sample.
For gyroscope and magnetometer, we need to wait for 2 periods
before having a correct sample.

Not suitable for stable or backporting.

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>


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

iio: imu: inv_mpu6050: reduce sleep time when turning regulators on

Turning vdd regulator on requires a consequent sleep for the
chip to power on correctly.
Turning vddio regulator is much faster.

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>


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

iio: imu: inv_mpu6050: set power on/off only once during all init

This way there is no need anymore to export the power function to
i2c and spi modules.
Bus setup is done inside init when power is on and the result is
now checked.

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>


# 84961af7 11-Jan-2020 Michał Mirosław <mirq-linux@rere.qmqm.pl>

iio: imu/mpu6050: support dual-edge IRQ

Make mpu6050 usable on platforms which provide only any-edge interrupts.
One example of this kind of platform is AT91SAM9G45

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Acked-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>


# a2587eb0 15-Nov-2019 Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>

iio: imu: inv_mpu6050: add support of MPU9150 magnetometer

Add support for driving MPU9150 magnetometer (AK8975) from mpu.

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>


# 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>


# d284feaf 08-Jul-2019 Fuqian Huang <huangfq.daxian@gmail.com>

iio: imu: mpu6050: Replace devm_add_action() followed by failure action with devm_add_action_or_reset()

devm_add_action_or_reset() is introduced as a helper function which
internally calls devm_add_action(). If devm_add_action() fails
then it will execute the action mentioned and return the error code.
This reduce source code size (avoid writing the action twice)
and reduce the likelyhood of bugs.

Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 1244a720 27-Jun-2019 Jean-Baptiste Maneyrol <JManeyrol@invensense.com>

iio: imu: mpu6050: add missing available scan masks

Driver only supports 3-axis gyro and/or 3-axis accel.
For icm20602, temp data is mandatory for all configurations.

Fix all single and double axis configurations (almost never used) and more
importantly fix 3-axis gyro and 6-axis accel+gyro buffer on icm20602 when
temp data is not enabled.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Fixes: 1615fe41a195 ("iio: imu: mpu6050: Fix FIFO layout for ICM20602")
Cc: <Stable@vger.kernel.org>
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>


# 28799cea 21-Feb-2019 H. Nikolaus Schaller <hns@goldelico.com>

iio: mpu6050: improve code readability

- use temporary variable in get_mount_matrix()
- remove , after { }

Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# fb158971 21-Feb-2019 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

iio: Allow to read mount matrix from ACPI

Currently mount matrix is allowed in Device Tree, though there is
no technical issue to extend it to support ACPI.

Convert the function to use device_property_read_string_array() and
thus allow to read mount matrix from ACPI if available.

Example of use in _DSD method:

Name (_DSD, Package ()
{
ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
Package ()
{
Package () { "mount-matrix", Package() {
"1", "0", "0",
"0", "0.866", "0.5",
"0", "-0.5", "0.866",
} },
}
})

At the same time drop the "of" prefix from its name and
convert current users.

No functional change intended.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
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>


# 2a221c04 18-Jun-2018 Hans de Goede <hdegoede@redhat.com>

iio: imu: inv_mpu6050: Fix probe() failure on older ACPI based machines

Commit 5ec6486daa98 ("iio:imu: inv_mpu6050: support more interrupt types")
causes inv_mpu_core_probe() to fail if the IRQ does not have a
trigger-type setup.

This happens on machines where the mpu6050 is enumerated through ACPI and
an older Interrupt type ACPI resource is used for the interrupt, rather
then a GpioInt type type, causing the mpu6050 driver to no longer work
there. This happens on e.g. the Asus T100TA.

This commits makes the mpu6050 fallback to the old IRQF_TRIGGER_RISING
default if the irq-type is not setup, fixing this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Fixes: 5ec6486daa98 ("iio:imu: inv_mpu6050: support more interrupt types")
Reviewed-by: Martin Kelly <mkelly@xevo.com>
Reviewed-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
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>


# 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>


# 96c92d42 21-May-2018 Martin Kelly <mkelly@xevo.com>

iio: imu: inv_mpu6050: add comment about frequencies

Although the driver allows frequencies between 4 and 1000 Hz, only the
frequencies advertised in the available frequencies file are backed
properly by a low-pass filter to prevent aliasing, so it's best to use
them. Since this is not obvious to the user, add a comment explaining
what's going on.

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>


# d8b40181 01-May-2018 Martin Kelly <mkelly@xevo.com>

iio: imu: inv_mpu6050: minor wording fixes

Just some minor grammar/spelling fixes of things I noticed while reading
the code.

Signed-off-by: Martin Kelly <mkelly@xevo.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>


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

iio: imu: inv_mpu6050: fix possible deadlock between mutex and iio

Detected by kernel circular locking dependency checker.

We are locking iio mutex (iio_device_claim_direct_mode) after
locking our internal mutex. But when the buffer starts, iio first
locks its mutex and then we lock our internal one.

To avoid possible deadlock, we need to use the same order
everwhere. So we change the ordering by locking first iio mutex,
then our internal mutex.

Fixes: 68cd6e5b206b ("iio: imu: inv_mpu6050: fix lock issues by using our own mutex")
Cc: stable@vger.kernel.org
Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 880b2d6c 22-Apr-2018 Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>

iio: imu: inv_mpu6050: clean read channel data error path

Delete the useless ored result and give a second chance to turn
the chip back off at the end.

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


# 6792b455 22-Apr-2018 Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>

iio: imu: inv_mpu6050: clean read raw by factorizing out raw data

Factorize reading channel data in its own function.

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>


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

iio: imu: inv_mpu6050: fix error path not turning chip back off

Some functions are turning the chip on and not back off in error
path. With set_power function using a reference counter that
would keep the chip on forever.

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>


# 7fc01685 17-Apr-2018 Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>

iio: imu: inv_mpu6050: clean set_power_itg and fix usage

Rewrite set_power_itg. Failing when turning power off is
no more decreasing the counter now and sleeping only happens
when effectively turning the chip on. Fix also usage in init
function (setting power on one time is sufficient to ensure
chip is effectively on).

Signed-off-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>


# 2711e642 29-Aug-2017 Colin Ian King <colin.king@canonical.com>

iio: imu: inv_mpu6050: make arrays hz and d static

Don't populate the arrays on the stack, instead make them static.
Makes the object code smaller by 135 bytes:

Before:
text data bss dec hex filename
15135 4240 128 19503 4c2f inv_mpu_core.o

After:
text data bss dec hex filename
14840 4400 128 19368 4ba8 inv_mpu_core.o

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 4e57562b 22-Aug-2017 Gustavo A. R. Silva <gustavo@embeddedor.com>

iio: imu: inv_mpu6050: fix missing break in switch

Add missing break statement to prevent the code for case
IIO_CHAN_INFO_CALIBBIAS falling through to the default case.

Also, add a break to the default case for the switch within
case IIO_CHAN_INFO_CALIBBIAS.

Addresses-Coverity-ID: 1357377
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


# 79978a9b 23-Jul-2017 Jonathan Cameron <jic23@kernel.org>

iio:imu: drop assign iio_info.driver_module and iio_trigger_ops.owner

The equivalent of both of these are now done via macro magic when
the relevant register calls are made. The actual structure
elements will shortly go away.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>


# 881b556f 06-Jun-2017 Jean-Baptiste Maneyrol <JManeyrol@invensense.com>

iio: imu: inv_mpu6050: test whoami first and against all known values

SPI bus is never generating error during transfer, so to check if
a chip is correctly connected on a SPI bus we enforce whoami check
to be correct. In this way we can assure SPI probe is failing if
there is no chip connected.

Note that this is really papering over boards that claim the device
is there when it isn't. Not a bad thing to cope with, but not
necessarily stable material.

Fixes: cec0154556f8 ("iio: inv_mpu6050: Check WHO_AM_I register on probe")
Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 8a12ed7d 07-Jun-2017 Jean-Baptiste Maneyrol <JManeyrol@invensense.com>

iio: imu: inv_mpu6050: replace sprintf with scnprintf

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


# 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>


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

iio: inv_mpu6050: Cleanup hw_info mapping

The hw_info array was indexed by enum inv_devices chip_type despite the
fact that the enumeration had more members than the array and was
ordered differently.

The patch cleans this up and adds explicit chip_types to i2c/spi/acpi
IDs. It also adds some stricter checks inside the driver core.

This happened to work so far because the differences between the
supported models are very minor.

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>


# 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>


# 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>


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

iio: imu: mpu6050: use inv_mpu6050_sensor_show return code

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


# 3afdf6cf 17-Feb-2016 Matt Ranostay <mranostay@gmail.com>

iio: imu: mpu6050: remove trailing whitespaces

removed several trailing whitespaces before assignment operations

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


# fc0dccdd 18-Feb-2016 Daniel Baluta <daniel.baluta@intel.com>

iio: imu: inv_mpu6050: Fix alignment with open parenthesis

This makes code consistent around inv_mpu6050 driver and
fixes the following checkpatch.pl warning:
CHECK: Alignment should match open parenthesis

Note that there were few cases were it was not possible to
fix this due to making the line too long, but we can live with that.

Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# aeeb18fc 18-Feb-2016 Daniel Baluta <daniel.baluta@intel.com>

iio: imu: inv_mpu6050: Delete space before comma

This fixes the following checkpatch.pl warning:

ERROR: space prohibited before that ',' (ctx:WxE)
.shift = 0 ,

Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# d92241a0 18-Feb-2016 Daniel Baluta <daniel.baluta@intel.com>

iio: imu: inv_mpu6050: Fix newlines to make code easier to read

This fixes the following checkpatch.pl warnings:
* WARNING: Missing a blank line after declarations
* CHECK: Blank lines aren't necessary before a close brace '}'

Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# acf7146e 18-Feb-2016 Daniel Baluta <daniel.baluta@intel.com>

iio: imu: inv_mpu6050: Fix Yoda conditions

This fixes the following checkpatch warning:
* WARNING: Comparisons should place the constant
on the right side of the test

Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
Acked-by: Crt Mori <cmo@melexis.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 23c5edcc 18-Feb-2016 Daniel Baluta <daniel.baluta@intel.com>

iio: imu: inv_mpu6050: Fix multiline comments style

The preffered style for long (multi-line) comments is:

/*
* this is a multiline
* comment
*/

This also fixes checkpatch.pl warning:
WARNING: Block comments use * on subsequent lines

Signed-off-by: Daniel Baluta <daniel.baluta@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>


# c2472d0b 30-Jan-2016 Adriana Reus <adi.reus@gmail.com>

iio: inv_mpu6050: Remove unused parameter

The inv_check_and_setup_chip function does not use the i2c_device_id
parameter. Therefore remove it.

Signed-off-by: Adriana Reus <adriana.reus@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 2acbe15f 12-Jun-2015 Adriana Reus <adi.reus@gmail.com>

iio: inv-mpu: Specify the expected format/precision for write channels

The gyroscope needs IIO_VAL_INT_PLUS_NANO for the scale channel and
unless specified write returns MICRO by default.
This needs to be properly specified so that write operations into scale
have the expected behaviour.

Signed-off-by: Adriana Reus <adriana.reus@intel.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 2155971a 09-Jul-2015 Krzysztof Kozlowski <krzk@kernel.org>

iio: Drop owner assignment from i2c_driver

i2c_driver does not need to set an owner because i2c_register_driver()
will set it.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# a858c7da 12-Jun-2015 Adriana Reus <adi.reus@gmail.com>

iio: inv-mpu: Export scale_available attributes

Export the available scales for accel and gyro in order
to hint the user-space as to what are the available valid values.

Signed-off-by: Adriana Reus <adriana.reus@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 6a3c45bb 12-Jun-2015 Adriana Reus <adi.reus@gmail.com>

iio: inv-mpu: Specify the expected format/precision for write channels

The gyroscope needs IIO_VAL_INT_PLUS_NANO for the scale channel and
unless specified write returns MICRO by default.
This needs to be properly specified so that write operations into scale
have the expected behaviour.

Signed-off-by: Adriana Reus <adriana.reus@intel.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# af5e1a68 23-Feb-2015 Adriana Reus <adi.reus@gmail.com>

iio:inv-mpu6050: Fix inconsistency for the scale channel

Fix inconsistency in the semantics of the scale attribute.
For scale the write_raw function was considering the scale table index
and writing the appropriate value into the range register, while
for read_raw it was outputting the actual scale.
Fix this behaviour and adhere to the iio ABI specification.

Signed-off-by: Adriana Reus <adriana.reus@intel.com>
Reviewed-by: Viorel Suman <viorel.suman@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>


# 4f33fbae 09-Jan-2015 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

iio: imu: inv_mpu6050: Prevent dereferencing NULL

When id is null, with ACPI enumeration, don't dereference it.

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


# 6ed5ac50 15-Dec-2014 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

iio: imu: inv_mpu6050: ACPI enumeration

Added changes so that the module can be enumerated via ACPI.

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>


# 63d1157d 28-Aug-2014 Jingoo Han <jg1.han@samsung.com>

iio: imu: inv_mpu6050: Remove casting the return value which is a void pointer

Casting the return value which is a void pointer is redundant.
The conversion from void pointer to any other pointer type is
guaranteed by the C programming language.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# b9b3a418 11-Apr-2014 Atilla Filiz <atilla.filiz@essensium.com>

iio:imu:mpu6050: Fixed segfault in Invensens MPU driver due to null dereference

The driver segfaults when the kernel boots with device tree as the
platform data is then not present and the pointer is deferenced without
checking it is not null. This patch introduces such a check avoiding the
crash.

Signed-off-by: Atilla Filiz <atilla.filiz@essensium.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Cc: Stable@vger.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>


# 36eb8cc2 01-Sep-2014 Paul Gortmaker <paul.gortmaker@windriver.com>

iio: delete non-required instances of include <linux/init.h>

None of these files are actually using any __init type directives
and hence don't need to include <linux/init.h>. Most are just a
left over from __devinit and __cpuinit removal, or simply due to
code getting copied from one driver to the next.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 452204ae 30-Jul-2013 Sachin Kamat <sachin.kamat@linaro.org>

iio: imu: inv_mpu6050: Use devm_iio_device_alloc

Using devm_iio_device_alloc makes code simpler. While at
it include missing iio.h header file and do some cleanup.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 2ffdcd3d 23-Jun-2013 Peter Meerwald <pmeerw@pmeerw.net>

iio: use I2C_FUNC_SMBUS_I2C_BLOCK macro

I do not see why the driver requires I2C_FUNC_SMBUS_I2C_BLOCK,
actually only single bytes or words are transferred

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Cc: Ge Gao <ggao@invensense.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>


# 0b1f8da3 27-Feb-2013 Jonathan Cameron <jic23@kernel.org>

iio:imu:mpu6050 move to info_mask_(shared_by_type/separate)

The original info_mask is going away in favour of the broken out versions.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
cc: Ge Gao <ggao@invensense.com>


# 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>