aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2022-04-04iio: imu: inv_mpu6050: Add support for ICM-20608-DMichael Srba1-0/+9
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>
2021-07-19Add startup time for each chip using inv_mpu6050 driverBaptiste Mansuy1-4/+18
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>
2021-06-16iio: imu: mpu6050: Balance runtime pm + use pm_runtime_resume_and_get()Jonathan Cameron1-13/+6
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
2021-06-09iio: imu: inv_mpu6050: Drop use of %hhx format string.Jonathan Cameron1-3/+2
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
2021-06-03iio: Drop Duplicated "mount-matrix" parameterAndy Shevchenko1-2/+1
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>
2021-04-07iio: inv_mpu6050: Fully validate gyro and accel scale writesLars-Peter Clausen1-6/+14
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>
2021-04-07iio: inv_mpu6050: Make interrupt optionalLars-Peter Clausen1-19/+32
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>
2021-04-07iio: inv_mpu6050: Remove superfluous indio_dev->modes assignmentLars-Peter Clausen1-1/+0
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>
2021-01-09iio: imu: inv_mpu6050: Add support for MPU-6880Stephan Gerhold1-0/+9
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>
2020-09-03iio: imu: inv_mpu6050: Simplify with dev_err_probe()Krzysztof Kozlowski1-14/+6
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>
2020-07-20iio: imu: inv_mpu6050: inv_mpu_core: Demote obvious misuse of kerneldoc to standard comment blocksLee Jones1-7/+7
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>
2020-06-14iio: remove left-over parent assignmentsAlexandru Ardelean1-1/+0
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>
2020-04-27Merge 5.7-rc3 into staging-nextGreg Kroah-Hartman1-1/+10
We need the staging fixes in here too, and this resolves a merge issue with the vt6656 driver. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-04-19iio: imu: inv_mpu6050: fix suspend/resume with runtime powerJean-Baptiste Maneyrol1-1/+10
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>
2020-04-19iio:imu:mpu6050: Tidy up parameters to regmap_bulk functions.Jonathan Cameron1-2/+2
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>
2020-04-19iio: imu: inv_mpu6050: add debugfs register r/w interfaceRohit Sarkar1-0/+19
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>
2020-03-08iio: imu: inv_mpu6050: temperature only work with accel/gyroJean-Baptiste Maneyrol1-0/+5
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>
2020-03-08iio: imu: inv_mpu6050: use runtime pm with autosuspendJean-Baptiste Maneyrol1-95/+175
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>
2020-03-08iio: imu: inv_mpu6050: dynamic sampling rate changeJean-Baptiste Maneyrol1-5/+0
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>
2020-03-08iio: imu: inv_mpu6050: fix data polling interfaceJean-Baptiste Maneyrol1-2/+34
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>
2020-03-08iio: imu: inv_mpu6050: rewrite power and engine managementJean-Baptiste Maneyrol1-69/+195
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>
2020-03-08iio: imu: inv_mpu6050: reduce sleep time when turning regulators onJean-Baptiste Maneyrol1-1/+2
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>
2020-03-08iio: imu: inv_mpu6050: add all signal path resets at initJean-Baptiste Maneyrol1-0/+18
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>
2020-03-08iio: imu: inv_mpu6050: early init of chip_config for use at setupJean-Baptiste Maneyrol1-8/+7
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>
2020-03-08iio: imu: inv_mpu6050: set power on/off only once during all initJean-Baptiste Maneyrol1-19/+22
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>
2020-02-14iio: imu: inv_mpu6050: update LPF bandwidth settingsJean-Baptiste Maneyrol1-14/+16
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>
2020-02-14iio: imu: inv_mpu6050: add support of ICM20690Jean-Baptiste Maneyrol1-5/+31
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>
2020-02-14iio: imu: inv_mpu6050: add support of IAM20680Jean-Baptiste Maneyrol1-0/+8
Automotive certified IMU, similar to ICM20608. Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-02-14iio: imu: inv_mpu6050: add support of ICM20609 & ICM20689Jean-Baptiste Maneyrol1-4/+22
They are similar to ICM20608 chip. Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-01-18iio: imu/mpu6050: support dual-edge IRQMichał Mirosław1-1/+1
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>
2020-01-18iio: imu: inv_mpu6050: add fifo temperature data supportJean-Baptiste Maneyrol1-124/+76
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>
2020-01-10Merge tag 'iio-for-5.6a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-nextGreg Kroah-Hartman1-13/+44
Jonathan writes: First set of new device support, features and cleanups for IIO in the 5.6 cycle New device support * ad7091r5 ADC - New driver with follow up patch adding scale and vref support. - DT bindings * ad7923 - Support for ad7908, ad7918 and ad7928 added to driver. * bma180 - Support the BMA254 accelerometer. Required fairly substantial rework to allow for small differences between this an existing parts. * bma400 accelerometer - New driver with follow up patch for regulator support. - DT bindings. * asc dlhl60d - New driver support this range of pressure and temperature sensors. - DT bindings. * ltc2496 ADC - New driver to support this ADC. - Split the existing LTC2497 driver generic component out and reuse. - DT bindings. * parallax ping - New driver supporting ultrasonic and laser tof distance sensors. - Bindings for these sensors. New features * core - New char type for read_raw returns, used for thermocouple types. - Rename read_first_n callback to read. The reasons behind the original naming are lost to the mists of time. * ad799x - Allow pm_ops to disable device completely allowing regulator power down. * bma180 - Enable basic regulator support. * dmaengine buffer - Report platform data alignment requirements via new ABI. * max31856 - Add option to set mains filter rejection frequency and document new in_temp_filter_notch_center_frequency ABI. - Add support for configuring HW averaging (oversampling ratio) - Add runtime configuration of thermocouple type and document new ABI. * maxim-thermocouple - Add read only access to thermocouple type using new ABI, includes adding more specific compatibles to reflect which variant of the chip is being used. * mpu6050 - Provide option to support the PMU9150 in package magnetometer directly rather than via auxiliary bus. * stm32_adc - Add overrun interrupt checks to detect if this happens. * st_lsm6dsx - Enable the sensor-hub support for lsm6dsm. Includes various reworks to allow this. Cleanups and minor fixes * Subsystem wide - Tidy up indentation in Kconfig and fix alphabetical order of AD7091R5. - Drop linux/gpio.h and linux/of_gpio.h from drivers that don't use them. * ad7266 - Convert to GPIO descriptors. * ad7303 - Avoid a dance with checking if the regulator is supplied by just using the optional request interface. * ad7887 - Simplify channel specification assignment to enable adding more devices. * ad7923 - Drop some unused and largely pointless defines of BOB_N==N variety. - Tidy up checkpatch warnings. - Add missing of_device_id table. * adf4350 - Convert to GPIO descriptors. * ak8975 - Convert to GPIO descriptors. * ADIS library and drivers - Expand scope of txrx_lock to cover all state and rename as state_lock - Add unlocked read / write to allow grouping of consecutive calls under single lock / unlock. - Add unlocked check_status, reset to allow grouping under single lock / unlock. - Remove remaining uses of core mlock for local state protection. mlock should never be used directly as it protects tightly defined core IIO device management state. * adis16240 - Enforce only supported SPI mode on driver load + add DT binding doc. * atlas-ph-sensor - Rename to atlas-sensor given it now covers things beyond ph sensors. * bma180 - Use local dev variable to tidy up code. - Use c99 style explicity .member assignment to make driver more readable. * bmp280 - Drop ACPI support. No evidence this was used and appropriate ID is not registered. - Allow ACPI to bind device via PRP0001 * dmaengine buffer - Use dma_request_chan instead of dma_request_slave_channel_reason as that ABI is going away. - Add module info to avoid tainting the kernel. * hts221 - Avoid magic number defines when only used to fill structure elements that are self describing. * lm3533 - Drop a stray semicolon. * max9611 - Cleanup enum handling to be more resilient to future changes. * mpu6050 - Delete MPU9150 from supported SPI devices as doesn't provide SPI. - Select I2C_MUX again after kbuild issue fixed elsewhere. * stm32-timer - Drop an unnecessary register update. * ssp_sensors - Convert to GPIO descriptors. * st_sensors - drop !CONFIG_ACPI defines as ACPI_PTR() will stop them being used anyway. - Make default platform data structures __maybe_unsued. - Fill in some missing kernel-doc function parameters. * st_lsm6dsx - white space fixes. - Mark some constants that aren't always used as __maybe_unused. - Drop of ID table guards as they just pervent use under ACPI. - Switch to device properties to allow ACPI usage. * st_uvis25 - Drop acpi.h include as no ACPI APIs used. * ti-ads1015 - Drop legacy platform data as no one seems to be using it. - Use the device property API instead of OF specific. * ti-ads7950 - typo fix in error message. * tag 'iio-for-5.6a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (99 commits) iio: accel: bma180: BMA254 support iio: pressure: bmp280: Allow device to be enumerated from ACPI iio: pressure: bmp280: Drop ACPI support dt-bindings: iio: adc: convert sd modulator to json-schema iio: buffer: rename 'read_first_n' callback to 'read' iio: buffer-dmaengine: Report buffer length requirements bindings: iio: pressure: Add documentation for dlh driver dt-bindings: Add asc vendor iio: pressure: Add driver for DLH pressure sensors iio: buffer-dmaengine: Add module information iio: accel: bma180: Use explicit member assignment iio: accel: bma180: Basic regulator support iio: accel: bma180: Add dev helper variable iio: imu: st_lsm6dsx: enable sensor-hub support for lsm6dsm iio: imu: st_lsm6dsx: rename st_lsm6dsx_shub_read_reg in st_lsm6dsx_shub_read_output iio: imu: st_lsm6dsx: check if shub_output reg is located in primary page iio: imu: st_lsm6dsx: check if pull_up is located in primary page iio: imu: st_lsm6dsx: check if master_enable is located in primary page iio: imu: st_lsm6dsx: export max num of slave devices in st_lsm6dsx_shub_settings iio: light: remove unneeded semicolon ...
2019-12-08iio: imu: inv_mpu6050: fix temperature reporting using bad unitJean-Baptiste Maneyrol1-11/+12
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>
2019-11-16iio: imu: inv_mpu6050: add support of MPU9150 magnetometerJean-Baptiste Maneyrol1-13/+44
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>
2019-11-13Merge tag 'iio-for-5.5c' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-nextGreg Kroah-Hartman1-9/+34
Jonathan writes: Third set of IIO new device support cleanups and fixes for the 5.5 cycle. New device support * ad5446 - Support the ad5600 DAC (id only needed). * ad7292 ADC DAC etc - New driver plus dt-bindings. * veml6030 ambient light sensor - New driver plus dt-bindings and sysfs docs. Features * mpu6050 - Explicit VDD control. * stm32-adc - Allow limiting of max clock frequency from devicetree to ensure it's suitable for external circuitry. yaml binding conversions * ltc1660 * mcp3911 Fixes * adis16480 - Fix wrong scale factors. - Fix debugfs reg access by providing the callback. * cros_ec_baro - Fixing missing mask entry to make available sample frequencies visible in sysfs. * st_lsm6dsx - Explicitly handle different ODR table sizes. - Handle restrictions between slave ODR and accel ODR when both are enabled. - Allow ODR to be expressed more accurately by using miliHz. * tools - Fix an issue with parallel builds. Cleanups and warning fixes * adis16136, adis16400, adis16460, adis-lib - Change some checks on return values to be for 0 rather than strictly negative. Avoids some fiddly issues with the compiler concluding some variables are initialized due to a mixture of error checks. - Assign values only on success of 'read' operations - avoiding any chance the compiler will falsly suggest they might be used uninitialized. - Whitespace and simlar cleanups. * aspeed adc - devm_platfom_ioremap_resource to reduce boilerplate. * bcm-iproc-adc - Stray semicolon removal. * cc10001 - devm_platfom_ioremap_resource to reduce boilerplate. * dln2-adc - Reorganise the buffered mode setup and tear down. Part of moving towards being able to refactor this area of the IIO core. * hdc100x - Reorganise the buffered mode setup and tear down. * ingenic-adc - devm_platfom_ioremap_resource to reduce boilerplate. * lpc18xx-adc - devm_platfom_ioremap_resource to reduce boilerplate. * lpc18xx-dac - devm_platfom_ioremap_resource to reduce boilerplate. * mt6577 - devm_platfom_ioremap_resource to reduce boilerplate. * npcm - devm_platfom_ioremap_resource to reduce boilerplate. * rcar-gyroadc - devm_platfom_ioremap_resource to reduce boilerplate. * spear-adc - devm_platfom_ioremap_resource to reduce boilerplate. * vf610-adc - devm_platfom_ioremap_resource to reduce boilerplate. * vf610-dac - devm_platfom_ioremap_resource to reduce boilerplate. * tag 'iio-for-5.5c' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (43 commits) iio: adis16480: Add debugfs_reg_access entry iio: adis16480: Fix scales factors tools: iio: Correctly add make dependency for iio_utils iio: adc: Add driver support for AD7292 dt-bindings: iio: adc: Add dt-schema for AD7292 dt-bindings: iio: adc: Migrate MCP3911 documentation to yaml iio: imu: mpu6050: Add support for vdd-supply regulator dt-bindings: iio: imu: mpu6050: add vdd-supply iio: cros_ec_baro: set info_mask_shared_by_all_available field iio: dac: ad5446: Add support for new AD5600 DAC dt-bindings: iio: dac: Migrate LTC1660 documentation to yaml iio: documentation: light: Add veml6030 sysfs documentation dt-bindings: iio: light: add veml6030 ALS bindings iio: light: add driver for veml6030 ambient light sensor iio: imu: st_lsm6dsx: express odr in mHZ iio: imu: st_lsm6dsx: fix ODR check in st_lsm6dsx_write_raw iio: imu: st_lsm6dsx: explicitly define odr table size iio: adc: stm32: allow to tune analog clock dt-bindings: iio: stm32-adc: add max clock rate property iio: dac: vf610: Use devm_platform_ioremap_resource ...
2019-11-11Merge 5.4-rc7 into staging-nextGreg Kroah-Hartman1-0/+9
We want the staging fixes in here, and it resolves some merge issues. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-11-10iio: imu: mpu6050: Add support for vdd-supply regulatorStephan Gerhold1-9/+34
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>
2019-10-22iio: imu: inv_mpu6050: fix no data on MPU6050Jean-Baptiste Maneyrol1-0/+9
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>
2019-10-05iio: imu: inv_mpu6050: add fifo support for magnetometer dataJean-Baptiste Maneyrol1-0/+1
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>
2019-10-05iio: imu: inv_mpu6050: add MPU925x magnetometer supportJean-Baptiste Maneyrol1-3/+141
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>
2019-10-05iio: imu: inv_mpu6050: disable i2c mux for MPU925xJean-Baptiste Maneyrol1-3/+4
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>
2019-08-12Merge tag 'iio-for-5.4a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-nextGreg Kroah-Hartman1-2/+1
Jonathan writes: First set of new device support, features and cleanups for IIO in the 5.4 cycle Note includes a merge from i3c tree to get support needed for stm_lsm6dsx driver support for l3c devices. Done from immutable branch. A counter subsystem patche in here as well. Alongside the new device support (which is always good), Chuhong's work on using devres managed APIs has cleaned up a number of drivers. New device support * adis16460 - New driver based on ADIS framework which needed addition of support for cs_change_delay. Includes device tree binding. * cros_ec - Support fo the veyron-minnie which uses an older interface. * lsm6dsx - Support for LSM6DSTR-C gyro + magnetometer sensor (new IDs mainly) - Support for ISM330DHCX acc + gyro sensor (extensive rework needed!) * Maxim 5432 - New driver support MAX5432-MAX5435 family of potentiometers. * noa1305 - New driver for this ON Semiconductor Ambient light sensor. Features and cleanups * tree wide - Drop error prints after platform_get_irq as already prints errors internally if any occur. * docs - Document mounting matrix. - Fix a missing newline at end of file. * ad2s1210 - Switch to device managed APIs for all of probe and drop explicit remove. * ad7192 - Add of_device_id array to explicity handling DT bindings. * ad7606 - Lots of rework leading to support for software configure modes in ad7616 parts. - Debugfs register access support. * am2315 - Switch to device managed APIs for all of probe and drop explicit remove. * apds9960 - Typo in module description. * cm36651 - Convert to i2c_new_dummy_device. - Swithc to device managed APIs for all of probe adn drop explicit remove. * cros_ec - Calibscale support for accel, gyro and magnetometer. - Tidy up some error codes to return the error from the stack rather than -EIO. - Determine protocol version. - Add a sign vector to the core to fix sensor rotation if necessary. Cannot just be done with mount matrix as already in use in many devices. - Tidy up INFO_SCALE being in both the separate and shared lists. - Drop a lot of dplicate code from the cros-ec-accel-legacy driver and use the core provided code instead. - Make frequency range available to userspace. * counter / ftm-quaddec - Switch to device managed APIs for all of probe adn drop explicit remove. * hdc100x - Switch to device managed APIs for all of probe and drop explicit remove. * hi8435 - Use gpiod_set_value_cansleep as we don't care here and there is a board out there where it needs to sleep. - Switch to device managed APIs for all of probe and drop explict remove. * hp03 - Convert to i2c_new_dummy_device. * maxim thermocouple - Switch to device managed APIs for all of probe and drop explicit remove. * mmc35240 - Fix typo in constant naming. * mpu6050 - Use devm_add_action_or_reset in place of explicit error handling. - Make text in Kconfig more explicit about which parts are supported. * mxc4005 - Switch to device managed APIs for all of probe and drop explicit remove. * pms7003 - Convert device tree bindings to yaml. - Add a MAINTAINERS entry * sc27xx - Introduce a local struct device *dev pointer to avoid lots of deref. - Use devm_add_action_or_reset in place of explicit error handling. * sca3000 - Typo fix in naming. * si1145 - Switch to device managed APIs for all of probe and drop explicit remove. * st_sensors - Lots of rework to enable switch to regmap. - Regmap conversion at the end. - Tidy up some inconsistencies in buffer setup ops. - Tidy up an oddity by dropping get_irq_data_ready function in favour of direct access. - Stop allocating buffer in buffer enable in favour of just embedding a large enough constant size buffer in the iio_priv accessed structure. * st_lsm6dsx - l3c device support (LSM6DSO and LSM6DSR) - tidy up irq return logic which was strangely written. - fix up an ABI quirk where this driver used separate scale attributes, even though they were always shared by type. * stk33xx - Device tree bindings include manufacturer ID. * stm32-adc - Add control for supply to analog switches including DT bindings. * stm32 timer - Drop the quadrature mode support. Believed there were no users so take this opportunity to drop this unwanted ABI. * tsl2772 - Switch to device mangage APIs for all of probe and drop explicit remove. - Use regulator_bulk_* APIs to reduce repitition. * veml6070 - Convert to i2c_new_dummy_device. * tag 'iio-for-5.4a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (84 commits) iio: hi8435: Drop hi8435_remove() by using devres for remaining elements iio: hi8435: Use gpiod_set_value_cansleep() iio:st_sensors: remove buffer allocation at each buffer enable iio: imu: inv_mpu6050: be more explicit on supported chips iio: light: noa1305: Add support for NOA1305 dt-bindings: Add binding document for NOA1305 iio: remove get_irq_data_ready() function pointer and use IRQ number directly iio: imu: st_lsm6dsx: make IIO_CHAN_INFO_SCALE shared by type iio: tsl2772: Use regulator_bulk_() APIs iio: tsl2772: Use devm_iio_device_register iio: tsl2772: Use devm_add_action_or_reset for tsl2772_chip_off iio: tsl2772: Use devm_add_action_or_reset iio: Remove dev_err() usage after platform_get_irq() iio: light: si1145: Use device-managed APIs iio:pressure: preenable/postenable/predisable fixup for ST press buffer iio:magn: preenable/postenable/predisable fixup for ST magn buffer iio:gyro: preenable/postenable/predisable fixup for ST gyro buffer iio:accel: preenable/postenable/predisable fixup for ST accel buffer dt-bindings: iio: imu: st_lsm6dsx: add ism330dhcx device bindings iio: imu: st_lsm6dsx: add support to ISM330DHCX ...
2019-07-27iio: imu: mpu6050: Replace devm_add_action() followed by failure action with devm_add_action_or_reset()Fuqian Huang1-2/+1
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>
2019-07-14iio: imu: mpu6050: add missing available scan masksJean-Baptiste Maneyrol1-0/+43
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>
2019-06-05treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 282Thomas Gleixner1-9/+1
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>
2019-05-20Merge tag 'iio-fixes-for-5.2a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus:Greg Kroah-Hartman1-4/+42
Jonathan writes: First set of IIO fixes for the 5.2 cycle. * ads124 - Avoid a buffer overrun when setting an array to 0. * ads8688 - Don't use the pollfunc timestamp as it isn't set and would be wrong anyway for a device that does sampling on demand. * ds4422 - Fix masking on register used for chip verification. Wrong address was being read. * mpu6050 - Fix the fifo layout for ICM20602 to avoid underreading and hence failure to move on to the next record in the fifo. * NPCM ADC - Make sure there is actually a valid regulator before reading its voltage. * tag 'iio-fixes-for-5.2a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: iio: adc: ti-ads8688: fix timestamp is not updated in buffer iio: dac: ds4422/ds4424 fix chip verification iio: imu: mpu6050: Fix FIFO layout for ICM20602 iio: adc: ads124: avoid buffer overflow iio: adc: modify NPCM ADC read reference voltage
2019-04-14iio: imu: mpu6050: Fix FIFO layout for ICM20602Steve Moskovchenko1-4/+42
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>
2019-04-04iio: mpu6050: improve code readabilityH. Nikolaus Schaller1-2/+4
- 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>
2019-04-04iio: Allow to read mount matrix from ACPIAndy Shevchenko1-2/+2
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>
2019-02-02iio: imu: mpu6050: Add support for the ICM 20602 IMURandolph Maaßen1-0/+31
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>