Commit graph

687 commits

Author SHA1 Message Date
Jonathan Albrieux
fb7749661a iio: imu: bmi160: fix typo
Fix a typo in MODULE_AUTHOR() argument.

Signed-off-by: Jonathan Albrieux <jonathan.albrieux@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-14 11:49:43 +01:00
Andy Shevchenko
ab4dd0128f iio: imu: inv_mpu6050: Drop double check for ACPI companion device
acpi_dev_get_resources() does perform the NULL pointer check against
ACPI companion device which is given as function parameter. Thus,
there is no need to duplicate this check in the caller.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-14 11:49:32 +01:00
Greg Kroah-Hartman
c2312ff575 Merge 5.7-rc7 into staging-next
We need the staging/iio fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-05-25 09:11:19 +02:00
Greg Kroah-Hartman
cef077e6aa Second set of new device support, cleanups and features for IIO in the 5.8 cycle
Usual mixed back but with a few subsystem wide or device type
 wide cleanups.
 
 New device support
 
 * adis16475
   - New driver supporting adis16470, adis16475, adis16477, adis16465,
     adis16467, adis16500, adis16505 and adis16507.
     Includes some rework of the adis library to simplify using it
     for this new driver.
 * ak8974
   - Add support for Alps hscdt008a. ID only. Related patches add support
     for scale.
 * atlas-sensor
   - Add support for RTD-SM OEM temperature sensor.
 * cm32181
   - Add support for CM3218 including support for SMBUS alert via
     ACPI resources.
 * ltc2632
   - Add support for ltc2634-12/10/8 DACS including handling per
     device type numbers of channels.
 
 Major Features
 
 * cm32181
   - ACPI bindings including parsing CPM0 and CPM1 custom ACPI tables.
     Includes minor tidy ups and fixes.
 * vcnl4000
   - Add event support
   - Add buffered data capture support
   - Add control of sampling frequency
 
 Cleanups and minor fixes.
 
 * core
   - Trivial rework of iio_device_alloc to use an early return and
     improve readability.
   - Precursors to addition of multiple buffer support. So far
     minor refactoring.
 * subsystem wide
   - Use get_unaligned_be24 slightly improve readability over open
     coding it.
 * adis drivers
   - Use iio_get_debugfs_dentry access function.
 * bh1780, cm32181, cm3232, gp2ap02a00f, opt3001, st_uvis25, vl6180,
   dmard06, kxsd9
   - Drop use of of_match_ptr to allow ACPI based probing via PRP0001.
     Part of clear out of this to avoid cut and paste into new drivers.
 * ad5592r, ad5593r
   - Fix typos
 * ad5933
   - Use managed interfaces to automate error handling and remove.
 * ak8974
   - Fix wrong number of 'real bits' for buffered data.
   - Refactor to pull measurement code out as separate function.
     bmp280
   - Fix lack of clamp on range during data capture.
 * at91-sama5d2_adc
   - Handle unfinished conversions correctly.
   - Allow use of triggers other than it's own.
   - Reorganize buffer setup and tear down as part of long running
     subsystem wide rework.
 * ccs811
   - Add DT binding docs and match table.
   - Support external reset and wakeup pins.
 * hid-sensors
   - Reorganize buffer setup and tear down as part of long running
     subsystem wide rework.
 * ltr501
   - Constify some structs.
 * vcnl4000
   - Fix an endian issue by using explicit byte swapped i2c accessors.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAl666PYRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FohMRQ//ZvDdYRB883lW11iRZJhnzpFhClNbzEp1
 2wxEqMOaLQmf6MntRX6LWmN15EGmQw1Eu2SBCt3G5XRMWKvtxaLnERKYxds67qtP
 uhTJDnfcDUYa6ACEHYs0FSfdmUL3S/7qmdKsABU+86o4LGzyb/jblWruB+6jOWyJ
 vRtMGUC8QP2RA2hq5UNJ3au1tlIS3IYqkmh1A1IXD8OtNW/EGpwFUMsmtRGd99gI
 lJb9VtlAF2bxqUBJuvludrRs8HMHafKRm9WM7+pJX7w2waSsiMMFojB7jDlJTAW/
 J2Zb5UGSUHMwJNLmhr+t1BjeAtO9AVzQsK80e+GXxjyb7rv1IKSt9eFUfev1jCuR
 lws3+QhwamGrxh7sFG4NFaWkZmmj5SSPTMqI+GCjm1VTL+vb3rh0MBjgn9/RNPux
 lEhscgEmq0w3BJPX08G8tZ4yipZbO4ZMmuQC3Gx2iPqO80xJqD+XpD5jz4MciGBC
 MDfWMamlnGk3n1sb4TIm0vPCtkz471DX5TyVLPLatcPnwWtu1zH380BD9HGVfnBN
 Fommp6YKvlpOCHOgl4vNg9pLKyUAukQbM8V0lPfk3NWQdswABmzDYJqh4HJWADxT
 uLiW8VgDfeq7CVPL+wwfWV3S9edu/REZa2f9y6qV/3eCyK0XId2CVHr8WpqbQIOR
 p6jjJHfzPNU=
 =mYqq
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-5.8b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

Second set of new device support, cleanups and features for IIO in the 5.8 cycle

Usual mixed back but with a few subsystem wide or device type
wide cleanups.

New device support

* adis16475
  - New driver supporting adis16470, adis16475, adis16477, adis16465,
    adis16467, adis16500, adis16505 and adis16507.
    Includes some rework of the adis library to simplify using it
    for this new driver.
* ak8974
  - Add support for Alps hscdt008a. ID only. Related patches add support
    for scale.
* atlas-sensor
  - Add support for RTD-SM OEM temperature sensor.
* cm32181
  - Add support for CM3218 including support for SMBUS alert via
    ACPI resources.
* ltc2632
  - Add support for ltc2634-12/10/8 DACS including handling per
    device type numbers of channels.

Major Features

* cm32181
  - ACPI bindings including parsing CPM0 and CPM1 custom ACPI tables.
    Includes minor tidy ups and fixes.
* vcnl4000
  - Add event support
  - Add buffered data capture support
  - Add control of sampling frequency

Cleanups and minor fixes.

* core
  - Trivial rework of iio_device_alloc to use an early return and
    improve readability.
  - Precursors to addition of multiple buffer support. So far
    minor refactoring.
* subsystem wide
  - Use get_unaligned_be24 slightly improve readability over open
    coding it.
* adis drivers
  - Use iio_get_debugfs_dentry access function.
* bh1780, cm32181, cm3232, gp2ap02a00f, opt3001, st_uvis25, vl6180,
  dmard06, kxsd9
  - Drop use of of_match_ptr to allow ACPI based probing via PRP0001.
    Part of clear out of this to avoid cut and paste into new drivers.
* ad5592r, ad5593r
  - Fix typos
* ad5933
  - Use managed interfaces to automate error handling and remove.
* ak8974
  - Fix wrong number of 'real bits' for buffered data.
  - Refactor to pull measurement code out as separate function.
    bmp280
  - Fix lack of clamp on range during data capture.
* at91-sama5d2_adc
  - Handle unfinished conversions correctly.
  - Allow use of triggers other than it's own.
  - Reorganize buffer setup and tear down as part of long running
    subsystem wide rework.
* ccs811
  - Add DT binding docs and match table.
  - Support external reset and wakeup pins.
* hid-sensors
  - Reorganize buffer setup and tear down as part of long running
    subsystem wide rework.
* ltr501
  - Constify some structs.
* vcnl4000
  - Fix an endian issue by using explicit byte swapped i2c accessors.

* tag 'iio-for-5.8b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (74 commits)
  iio: light: ltr501: Constify structs
  staging: iio: ad5933: attach life-cycle of kfifo buffer to parent device and use managed calls throughout
  iio: bmp280: fix compensation of humidity
  iio: light: cm32181: Fix integartion time typo
  iio: light: cm32181: Add support for parsing CPM0 and CPM1 ACPI tables
  iio: light: cm32181: Make lux_per_bit and lux_per_bit_base_it runtime settings
  iio: light: cm32181: Use units of 1/100000th for calibscale and lux_per_bit
  iio: light: cm32181: Change reg_init to use a bitmap of which registers to init
  iio: light: cm32181: Handle CM3218 ACPI devices with 2 I2C resources
  iio: light: cm32181: Clean up the probe function a bit
  iio: light: cm32181: Add support for the CM3218
  iio: light: cm32181: Add some extra register defines
  iio: light: cm32181: Add support for ACPI enumeration
  iio: light: cm32181: Switch to new style i2c-driver probe function
  iio: hid-sensors: move triggered buffer setup into hid_sensor_setup_trigger
  iio: vcnl4000: Add buffer support for VCNL4010/20.
  iio: vcnl4000: Add sampling frequency support for VCNL4010/20.
  iio: vcnl4000: Add event support for VCNL4010/20.
  iio: vcnl4000: Factorize data reading and writing.
  iio: vcnl4000: Fix i2c swapped word reading.
  ...
2020-05-15 16:03:28 +02:00
Alexandru Ardelean
b7190859ab iio: imu: adis16xxx: use helper to access iio core debugfs dir
The IIO core provides a iio_get_debugfs_dentry() helper.
It seems that the ADIS IMU drivers access that field directly.

This change converts them to use iio_get_debugfs_dentry() instead.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Acked-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-05-03 14:47:56 +01:00
Lorenzo Bianconi
8f9a5249e3 iio: imu: st_lsm6dsx: enable 833Hz sample frequency for tagged sensors
Enable 833Hz ODR for sensors that supports tagged hw FIFO:
- LSM6DSO/LSM6DSOX
- LSM6DSR/LSM6DSRX
- ASM330LHH

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-05-03 09:47:21 +01:00
Nuno Sá
fff7352bf7 iio: imu: Add support for adis16475
Support ADIS16475 and similar IMU devices. These devices are
a precision, miniature MEMS inertial measurement unit (IMU) that
includes a triaxial gyroscope and a triaxial accelerometer. Each
inertial sensor combines with signal conditioning that optimizes
dynamic performance.

The driver adds support for the following devices:
* adis16470, adis16475, adis16477, adis16465, adis16467, adis16500,
  adis16505, adis16507.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-05-03 09:47:18 +01:00
Greg Kroah-Hartman
e8014d83f6 Merge 5.7-rc3 into staging-next
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-27 12:20:40 +02:00
Dan Carpenter
115c215a7e iio: imu: st_lsm6dsx: unlock on error in st_lsm6dsx_shub_write_raw()
We need to release a lock if st_lsm6dsx_check_odr() fails, we can't
return directly.

Fixes: 76551a3c3d ("iio: imu: st_lsm6dsx: specify slave odr in slv_odr")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-25 18:33:54 +01:00
Nuno Sá
3e04cb60e8 iio: adis: Support different burst sizes
Add burst_max_len to `adis_burst`. This is useful for devices which
support different burst modes with different sizes. The buffer to be
used in the spi transfer is allocated with this variable making sure
that has space for all burst modes. The spi transfer length should hold
the "real" burst length depending on the current burst mode configured
in the device.

Moreover, `extra_len` in `adis_burst` is made const and it should
contain the smallest extra length necessary for a burst transfer. In
`struct adis` was added a new `burst_extra_len` that should hold the
extra bytes needed depending on the device instance being used.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-25 16:11:56 +01:00
Nuno Sá
b9c5eec725 iio: adis: Add adis_update_bits() APIs
This patch adds a `regmap_update_bits()` like API to the ADIS library.
It provides locked and unlocked variant.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-25 16:10:44 +01:00
Nuno Sá
698211065d iio: imu: adis: Add irq flag variable
There are some ADIS devices that can configure the data ready pin
polarity. Hence, we cannot hardcode our IRQ mask as IRQF_TRIGGER_RISING
since we might want to have it as IRQF_TRIGGER_FALLING.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-25 16:09:30 +01:00
Nuno Sá
fec86c6b83 iio: imu: adis: Add Managed device functions
This patch adds support for a managed device version of
adis_setup_buffer_and_trigger. It works exactly as the original
one but it calls all the devm_iio_* functions to setup an iio
buffer and trigger. Hence we do not need to care about cleaning those
and we do not need to support a remove() callback for every driver using
the adis library.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-25 16:08:06 +01:00
Jean-Baptiste Maneyrol
0a2bf9200a 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: 4599cac846 ("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-19 17:50:02 +01:00
Lorenzo Bianconi
3a63da26db iio: imu: st_lsm6dsx: flush hw FIFO before resetting the device
flush hw FIFO before device reset in order to avoid possible races
on interrupt line 1. If the first interrupt line is asserted during
hw reset the device will work in I3C-only mode (if it is supported)

Fixes: 801a6e0af0 ("iio: imu: st_lsm6dsx: add support to LSM6DSO")
Fixes: 43901008fd ("iio: imu: st_lsm6dsx: add support to LSM6DSR")
Reported-by: Mario Tesi <mario.tesi@st.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Vitor Soares <vitor.soares@synopsys.com>
Tested-by: Vitor Soares <vitor.soares@synopsys.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 17:50:01 +01:00
Jonathan Cameron
d7d3a1327b 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>
2020-04-19 16:56:39 +01:00
Lorenzo Bianconi
780f1c1761 iio: imu: st_lsm6dsx: drop huge include in sensor-hub driver
st_lsm6dsx is a standalone driver for STM IMU sensors and does not rely
on st_sensor common framework, so it does not include st_sensor common
definitions.
In st_lsm6dsx_shub driver st_sensors.h is used just to introduce the
default wai address for LIS3MDL sensor.
Drop this largely unconnected include file and introduce the default wai
address for LIS3MDL in st_lsm6dsx_ext_dev_settings register map

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:38 +01:00
Christophe JAILLET
97f1755ee2 iio: imu: adis: Add a missing '\n' in a log message
Message logged by 'dev_xxx()' or 'pr_xxx()' should end with a '\n'.

Fixes: 1fd4567026 ("iio: imu: adis: add support product ID check in adis_initial_startup")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:34 +01:00
Jimmy Assarsson
394dedec77 iio: imu: st_lsm6dsx: Add sensor hub device LIS3MDL
Add LIS3MDL register map to sensor hub device table.
Tested with LSM6DSM.

Signed-off-by: Jimmy Assarsson <jimmyassarsson@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:26 +01:00
Jimmy Assarsson
a0e35e2416 iio: imu: st_lsm6dsx: Increase ODR_LIST_SIZE
Support for sensor with up to 8 different ODR settings.
Required for supporting LIS3MDL as sensor hub slave device.

Signed-off-by: Jimmy Assarsson <jimmyassarsson@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:25 +01:00
Rohit Sarkar
2ca73823d0 iio: imu: adis16460: use DEFINE_DEBUGFS_ATTRIBUTE instead of DEFINE_SIMPLE_ATTRIBUTE
debugfs_create_file_unsafe does not protect the fops handed to it
against file removal. DEFINE_DEBUGFS_ATTRIBUTE makes the fops aware of
the file lifetime and thus protects it against removal.

Signed-off-by: Rohit Sarkar <rohitsarkar5398@gmail.com>
Tested-by Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:25 +01:00
Rohit Sarkar
ae1d37a9bb iio: imu: adis16400: use DEFINE_DEBUGFS_ATTRIBUTE instead of DEFINE_SIMPLE_ATTRIBUTE
debugfs_create_file_unsafe does not protect the fops handed to it
against file removal. DEFINE_DEBUGFS_ATTRIBUTE makes the fops aware of
the file lifetime and thus protects it against removal.

Signed-off-by: Rohit Sarkar <rohitsarkar5398@gmail.com>
Tested-by Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:25 +01:00
Lorenzo Bianconi
4ab717d9e8 iio: imu: st_lsm6dsx: configure full scale on slave device if supported
Introduce st_lsm6dsx_shub_set_full_scale routine in order to configure
the i2c slave device sensitivity

Tested-by: Jimmy Assarsson <jimmyassarsson@gmail.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:24 +01:00
Rohit Sarkar
4b7ef6040f 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>
2020-04-19 16:56:20 +01:00
Wolfram Sang
b5fbf0568c iio: imu: inv_mpu6050: convert to use i2c_new_client_device()
Move away from the deprecated API and return the shiny new ERRPTR where
useful.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Acked-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:18 +01:00
Nishant Malpani
02566b459f iio: imu: inv_mpu6050_spi: Use vsprintf extension %pe for symbolic error name
Utilize %pe format specifier from vsprintf while printing error logs
with dev_err(). Discards the use of unnecessary explicit casting and
prints symbolic error name which might prove to be convenient during
debugging.

Signed-off-by: Nishant Malpani <nish.malpani25@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:18 +01:00
Nishant Malpani
fb3f7ab773 iio: imu: inv_mpu6050_i2c: Use vsprintf extension %pe for symbolic error name
Utilize %pe format specifier from vsprintf while printing error logs
with dev_err(). Discards the use of unnecessary explicit casting and
prints symbolic error name which might prove to be convenient during
debugging.

Signed-off-by: Nishant Malpani <nish.malpani25@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:17 +01:00
Nishant Malpani
35c9c8d5ec iio: imu: bmi160_spi: Use vsprintf extension %pe for symbolic error name
Utilize %pe format specifier from vsprintf while printing error logs
with dev_err(). Discards the use of unnecessary explicit casting and
prints symbolic error name which might prove to be convenient during
debugging.

Signed-off-by: Nishant Malpani <nish.malpani25@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:17 +01:00
Nishant Malpani
6e924c526a iio: imu: bmi160_i2c: Use vsprintf extension %pe for symbolic error name
Utilize %pe format specifier from vsprintf while printing error logs
with dev_err(). Discards the use of unnecessary explicit casting and
prints symbolic error name which might prove to be convenient during
debugging.

Signed-off-by: Nishant Malpani <nish.malpani25@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:16 +01:00
Lorenzo Bianconi
76551a3c3d iio: imu: st_lsm6dsx: specify slave odr in slv_odr
Introduce slv_odr in ext_info data structure in order to distinguish
between sensor hub trigger (accel sensor) odr and i2c slave odr and
properly compute samples in FIFO pattern

Fixes: e485e2a2cf ("iio: imu: st_lsm6dsx: enable sensor-hub support for lsm6dsm")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-28 16:35:03 +00:00
Lorenzo Bianconi
7762902c89 iio: imu: st_lsm6dsx: fix read misalignment on untagged FIFO
st_lsm6dsx suffers of a read misalignment on untagged FIFO when
all 3 supported sensors (accel, gyro and ext device) are running
at different ODRs (the use-case is reported in the LSM6DSM Application
Note at pag 100).
Fix the issue taking into account decimation factor reading the FIFO
pattern.

Fixes: e485e2a2cf ("iio: imu: st_lsm6dsx: enable sensor-hub support for lsm6dsm")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-28 16:35:02 +00:00
Sergiu Cuciurean
61e618be6a iio: imu: adis_buffer: Use new structure for SPI transfer delays
In a recent change to the SPI subsystem [1], a new `delay` struct was added
to replace the `delay_usecs`. This change replaces the current
`delay_usecs` with `delay` for this driver.

The `spi_transfer_delay_exec()` function [in the SPI framework] makes sure
that both `delay_usecs` & `delay` are used (in this order to preserve
backwards compatibility).

[1] commit bebcfd272d ("spi: introduce `delay` field for
`spi_transfer` + spi_transfer_delay_exec()")

Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:45 +00:00
Jean-Baptiste Maneyrol
74a40e19f9 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>
2020-03-08 17:28:40 +00:00
Jean-Baptiste Maneyrol
4599cac846 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>
2020-03-08 17:28:39 +00:00
Jean-Baptiste Maneyrol
5e95ca3637 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>
2020-03-08 17:28:39 +00:00
Jean-Baptiste Maneyrol
4c1e014701 iio: imu: inv_mpu6050: factorize fifo enable/disable
Rework fifo enable/disable in a separate function.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:39 +00:00
Jean-Baptiste Maneyrol
ffc9648a52 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>
2020-03-08 17:28:38 +00:00
Jean-Baptiste Maneyrol
92e7407ab1 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>
2020-03-08 17:28:38 +00:00
Jean-Baptiste Maneyrol
398da99423 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>
2020-03-08 17:28:38 +00:00
Jean-Baptiste Maneyrol
c1bfe9c818 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>
2020-03-08 17:28:37 +00:00
Jean-Baptiste Maneyrol
5621a63a01 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>
2020-03-08 17:28:37 +00:00
Jean-Baptiste Maneyrol
3c1024aa99 iio: imu: inv_mpu6050: simplify polling magnetometer
Do not change the sampling rate value. Let userspace decide what
is the sampling rate to use.
Read only the requested axis.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:37 +00:00
Jean-Baptiste Maneyrol
a3aaf7770a 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>
2020-03-08 17:28:37 +00:00
Jean-Baptiste Maneyrol
14c046ed17 iio: imu: inv_mpu6050: delete useless check
If we are here it means we have fifo enabled for 1 sensor
at least. And interrupt is always required for using trigger.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:36 +00:00
Jean-Baptiste Maneyrol
ddfd781dc4 iio: imu: inv_mpu6050: enable i2c aux mux bypass only once
i2c auxiliary mux is done by analog switches. You do not need to
set them for every i2c transfer.
Just set i2c bypass bit at init and do noting in i2c de/select.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:36 +00:00
Nuno Sá
62504d1b44 iio: adis16460: Make use of __adis_initial_startup
All of the actions done in `adis16460_initial_setup()` are now done in
`__adis_initial_startup()` so, there's no need for code duplication.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:31 +00:00
Nuno Sá
366a543421 iio: adis16480: Make use of __adis_initial_startup
All actions done in `adis16480_initial_setup()` are now done in
`__adis_initial_startup()` so, there's no need for code duplication.
Furthermore, the call to `adis16480_initial_setup()` is done before any
device configuration since the device will be reset if not already (via
rst pin). This is actually fixing a potential bug since `adis_reset()` was
being called after configuring the device which is obviously a problem.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:31 +00:00
Alexandru Ardelean
1fd4567026 iio: imu: adis: add support product ID check in adis_initial_startup
Each driver/chip that wants to validate it's product id, can now
specify a 'prod_id_reg' and an expected 'prod_id' value.
The 'prod_id' value is intentionally left 0 (uninitialized). There aren't
(yet) any product IDs with value 0; this enforces that both 'prod_id_reg'
and 'prod_id' are specified.

At the very least, this routine validates that the SPI connection to the
ADIS chip[s] works well.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:31 +00:00
Nuno Sá
ecb010d441 iio: imu: adis: Refactor adis_initial_startup
All the ADIS devices perform, at the beginning, a self test to make sure
the device is in a sane state. Previously, the logic was that the self-test
was performed in adis_initial_startup() and if that failed a reset was done
and then a self-test was attempted again.

This change unifies the reset mechanism under the adis_initial_startup()
call. A HW reset will be done if  GPIO is configured, or a SW reset
otherwise. This should make sure that the chip is in a sane state for
self-test. Once the reset is done, the self-test operation will be
performed. If anything goes wrong with self-test, the driver should just
bail/error-out (i.e. no second attempt). The chip would likely not be a in
a sane state state if the self-test fails after a reset.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:30 +00:00
Nuno Sá
fdcf6bbb4e iio: imu: adis: Add self_test_reg variable
This patch adds a dedicated self_test_reg variable. This is also a step
to let new drivers make use of `adis_initial_startup()`. Some devices
use MSG_CTRL reg to request a self_test command while others use the
GLOB_CMD register.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:30 +00:00
Alexandru Ardelean
3f17ada8f3 iio: imu: adis: add unlocked __adis_initial_startup()
This change splits the __adis_initial_startup() away from
adis_initial_startup(). The unlocked version can be used in certain calls
during probe, where races won't happen since the ADIS driver may not be
registered yet with IIO.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:29 +00:00
Alexandru Ardelean
99460853a8 iio: imu: adis16400: initialize adis_data statically
This change overrides commit 380b107bbf ("iio: adis: Introduce timeouts
structure"). It removes the memory allocation and moves the 'adis_data'
information to be static on the chip_info struct.

This also adds a timeout structure to ADIS16334, since it was initially
omitted. This was omitted (by accident) when the change was done.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:29 +00:00
Alexandru Ardelean
97928677fe iio: imu: adis16480: initialize adis_data statically
This change overrides commit 380b107bbf ("iio: adis: Introduce timeouts
structure"). It removes the memory allocation and moves the 'adis_data'
information to be static on the chip_info struct.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:29 +00:00
Lorenzo Bianconi
f20dbe11e2 iio: imu: st_lsm6dsx: check return value from st_lsm6dsx_sensor_set_enable
Add missing return value check in st_lsm6dsx_shub_read_oneshot disabling
the slave device connected to the st_lsm6dsx i2c controller.
The issue is reported by coverity with the following error:

Unchecked return value:
If the function returns an error value, the error value may be mistaken
for a normal value.

Addresses-Coverity-ID: 1456767 ("Unchecked return value")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-03-08 17:28:28 +00:00
Jean-Baptiste Maneyrol
9fc89f7965 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>
2020-02-14 15:06:25 +00:00
Jean-Baptiste Maneyrol
8abce87d39 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>
2020-02-14 15:06:25 +00:00
Jean-Baptiste Maneyrol
d31f74e608 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>
2020-02-14 15:06:25 +00:00
Jean-Baptiste Maneyrol
23db8d6959 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>
2020-02-14 15:06:25 +00:00
Jean-Baptiste Maneyrol
4235cc30c9 iio: imu: inv_mpu6050: cleanup of/acpi support
Use device_get_match_data for using of and acpi tables.
In spi support add missing mpu6515 and of match table.
Reorganize Kconfig to display chips grouped by generations.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-02-14 15:06:24 +00:00
JieunKim
5de6570b8a iio: imu: st_lsm6dsx: Fix mismatched comments
odr to odr_table
gain to fs_table

'gain' is actually in 'st_lsm6dsx_fs' structure of 'fs_table'

Signed-off-by: JieunKim <jieun.kim4758@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-02-14 12:08:11 +00:00
Greg Kroah-Hartman
c318f074d9 Merge 5.5-rc7 into staging-next
We want the staging fixes in here as well

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-01-22 09:05:34 +01:00
Martin Kepplinger
04e6fedb18 iio: imu: st_lsm6dsx: add mount matrix support
Allow to read the mount-matrix device tree property and provide the
mount_matrix file for userspace to read.

Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-01-18 14:23:53 +00:00
Stefan Popa
80cbc848c4 iio: imu: adis16480: Add support for ADIS16490
The ADIS16490 is part of the same family with ADIS16495 and ADIS16497,
the main difference is the temperature, accelerometer and gyroscope
scales.

Datasheet:
Link: https://www.analog.com/media/en/technical-documentation/data-sheets/adis16490.pdf

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-01-18 13:35:18 +00:00
Michał Mirosław
84961af78c 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>
2020-01-18 13:31:35 +00:00
Jean-Baptiste Maneyrol
2e4c0a5e25 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>
2020-01-18 11:43:37 +00:00
Alexandru Ardelean
a4e6f40c77 iio: imu: adis: use new delay structure for SPI transfer delays
In a recent change to the SPI subsystem [1], a new `delay` struct was added
to replace the `delay_usecs`. This change replaces the current `delay_usecs`
with `delay` for this driver.

The `spi_transfer_delay_exec()` function [in the SPI framework] makes sure
that both `delay_usecs` & `delay` are used (in this order to preserve
backwards compatibility).

[1] commit bebcfd272d ("spi: introduce `delay` field for
`spi_transfer` + spi_transfer_delay_exec()")

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-01-13 22:03:36 +00:00
Lorenzo Bianconi
a2dd9bd933 iio: imu: st_lsm6dsx: check return value from st_lsm6dsx_sensor_set_enable
Add missing return value check in st_lsm6dsx_read_oneshot disabling the
sensor. The issue is reported by coverity with the following error:

Unchecked return value:
If the function returns an error value, the error value may be mistaken
for a normal value.

Addresses-Coverity-ID: 1446733 ("Unchecked return value")
Fixes: b5969abfa8 ("iio: imu: st_lsm6dsx: add motion events")
Fixes: 290a6ce11d ("iio: imu: add support to lsm6dsx driver")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-01-13 21:41:43 +00:00
Stephan Gerhold
fb4fbc8904 iio: imu: st_lsm6dsx: Fix selection of ST_LSM6DS3_ID
At the moment, attempting to probe a device with ST_LSM6DS3_ID
(e.g. using the st,lsm6ds3 compatible) fails with:

    st_lsm6dsx_i2c 1-006b: unsupported whoami [69]

... even though 0x69 is the whoami listed for ST_LSM6DS3_ID.

This happens because st_lsm6dsx_check_whoami() also attempts
to match unspecified (zero-initialized) entries in the "id" array.
ST_LSM6DS3_ID = 0 will therefore match any entry in
st_lsm6dsx_sensor_settings (here: the first), because none of them
actually have all 12 entries listed in the "id" array.

Avoid this by additionally checking if "name" is set,
which is only set for valid entries in the "id" array.

Note: Although the problem was introduced earlier it did not surface until
commit 52f4b1f196 ("iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9ds1")
because ST_LSM6DS3_ID was the first entry in st_lsm6dsx_sensor_settings.

Fixes: d068e4a0f9 ("iio: imu: st_lsm6dsx: add support to multiple devices with the same settings")
Cc: <stable@vger.kernel.org> # 5.4
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-01-13 12:08:28 +01:00
Nuno Sá
77038bd01c iio: adis: Remove startup_delay
All timeouts are now handled by a dedicated timeout struct. This
variable is no longer needed.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-01-12 11:34:13 +00:00
Nuno Sá
380b107bbf iio: adis: Introduce timeouts structure
The adis library only allows to define a `startup_delay` which for some
devices is enough. However, other devices define different timeouts with
significantly different timings which could lead to devices to not wait
enough time or to wait a lot more than necessary (which is not
efficient). This patch introduces a new timeout struct that must be
passed into `adis_init()`. There are mainly, for now, three timeouts
used. This is also an introductory patch with the goal of refactoring
`adis_initial_startup()`. New driver's (eg: adis16480, adis16460) are
replicating code for the device initial setup. With some changes (being
this the first one) we can pass this to `adis_initial_startup()`.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-01-12 11:34:12 +00:00
Greg Kroah-Hartman
821f7ce79f 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.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAl4R2mwRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0Fogfow//Rfsrd2oiAwy4ypm70ZWGnr84C3O/Vpic
 Agwdd2/lHiCA2Gjg+n7ZT6XkKQmKiojuBMT05PuskEm5onJVQuSAKMVppXwU6UDP
 uOUS5MAbo87GLogzXJnAR/eCrx/VkC4UqFRBSi7IUIj+lTpjiOhmoqm78VTMxkgT
 hvp5PVN/mLNxNV3eVrR9uILjZLpbBjKjWil00IS2zj0o78sGtd2QtMIdTbn3iBLp
 m0ngCDww1KDH+idwbOIn8YX8GSK8mTjNV5q4r9+xnjoAk8RPk+H317idyRHCKfCM
 wWFSFB6u/oqtHXRgQVi3ndRrZnPLTycA/R20f3ezzhVYZzf3RpH8Upcx0lqqCmrB
 +ZTbYW1L7KL6zCSR4ZYIEmw2TeQngfCGy0yDoEDXm9V8/B2nGWFc3Iknq+fK415V
 7OgJCWAw6ybF2LZfJHpcuJTb0EPxCKnInHbRsaxCsSAPRyERSdAz8RLn3lpH/k2D
 X32Q9hz/6sXKzIAD1Y0jv8ll28D5S7d2FgaWufy1tpB+CMb0Mp0RQn+Ho8lNMh70
 Zh9SF8RvknAiCT9iHeVIdbJxoYEtMuCaDwScliukVcg12gVViY5VzXMbSV/4jCnZ
 bAVZDpcM3LVLxCGbWqCNxjQ9wle99LsVHRld/KDpOfI6VIYDb8Y900Nf6efkQkAs
 a6z6rhpVdDg=
 =8FmM
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-5.6a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

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
  ...
2020-01-10 10:44:00 +01:00
Lorenzo Bianconi
e485e2a2cf iio: imu: st_lsm6dsx: enable sensor-hub support for lsm6dsm
Enabled i2c master controller support for LSM6DSM sensor. Enable
ext_sensor0 for lsm6dsm. This series has been tested using LIS2MDL as
slave device connected to the i2c controller of the LSM6DSM

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-29 15:20:07 +00:00
Lorenzo Bianconi
111b087577 iio: imu: st_lsm6dsx: rename st_lsm6dsx_shub_read_reg in st_lsm6dsx_shub_read_output
Rename st_lsm6dsx_shub_read_reg routine in st_lsm6dsx_shub_read_output
since it is used to read from sensorhub channel0 output register

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-29 15:20:07 +00:00
Lorenzo Bianconi
5b8343e067 iio: imu: st_lsm6dsx: check if shub_output reg is located in primary page
Check if the sensor hub output register is located in the primary or in the
secondary memory page. This is a preliminary patch to support i2c master
controller on lsm6dsm devices

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-29 15:20:07 +00:00
Lorenzo Bianconi
3a43195745 iio: imu: st_lsm6dsx: check if pull_up is located in primary page
Check if the pull up register is located in the primary or in the
secondary memory page. This is a preliminary patch to support i2c master
controller on lsm6dsm devices

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-29 15:20:06 +00:00
Lorenzo Bianconi
007f2ebbac iio: imu: st_lsm6dsx: check if master_enable is located in primary page
Check if the master enable register is located in the primary or in the
secondary memory page. This is a preliminary patch to support i2c master
controller on lsm6dsm devices

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-29 15:20:06 +00:00
Lorenzo Bianconi
ee978bb86d iio: imu: st_lsm6dsx: export max num of slave devices in st_lsm6dsx_shub_settings
Export max number of slave devices supported by the i2c master
controller in st_lsm6dsx_shub_settings data structure.
This is a preliminary patch to support i2c master controller
on lsm6dsm sensors

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-29 15:20:06 +00:00
Andy Shevchenko
03d4c566c5 iio: st_lsm6dsx: Make use of device properties
Device property API allows to gather device resources from different sources,
such as ACPI. Convert the drivers to unleash the power of device property API.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-29 15:20:04 +00:00
Andy Shevchenko
e3da430770 iio: st_lsm6dsx: Drop unneeded OF code
There is no need to have OF guard against ID table.
Drop it for good.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-29 15:20:04 +00:00
Andy Shevchenko
07bf07e2cc iio: st_lsm6dsx: Mark predefined constants with __maybe_unused
Since we put static variable to a header file it's copied to each module
that includes the header. But not all of them are actually used it.

Mark predefined constants with __maybe_unused to calm a compiler down:

In file included from drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c:17:
.../st_lsm6dsx/st_lsm6dsx.h:399:28: warning: ‘st_lsm6dsx_available_scan_masks’ defined but not used [-Wunused-const-variable=]
  399 | static const unsigned long st_lsm6dsx_available_scan_masks[] = {0x7, 0x0};
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../st_lsm6dsx/st_lsm6dsx.h:392:36: warning: ‘st_lsm6dsx_event’ defined but not used [-Wunused-const-variable=]
  392 | static const struct iio_event_spec st_lsm6dsx_event = {
      |                                    ^~~~~~~~~~~~~~~~
...

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-29 15:20:03 +00:00
Lorenzo Bianconi
757b4bcaa0 iio: imu: st_lsm6dsx: fix checkpatch warning
Fix following checkpatch warning:

CHECK: Alignment should match open parenthesis
+static int st_lsm6dsx_read_event(struct iio_dev *iio_dev,
+                                  const struct iio_chan_spec *chan,

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-15 11:42:15 +00:00
Linus Walleij
52241a082d iio: imu: inv_mpu6050: Select I2C_MUX again
commit f7072198f2 ("iio: imu: Fix inv_mpu6050 dependencies")
undid the explicit selection of I2C_MUX previously
done by the driver, because I2C_MUX implicitly depended
on HAS_IOMEM.

However commit 93d710a65e ("i2c: mux: fix up dependencies")
cleared up the situation properly and drivers that need
to select I2C_MUX can now do so again.

It makes a lot of sense for a driver to select the driver
infrastructure it needs so restore the natural order of
things.

Cc: Richard Weinberger <richard@nod.at>
Cc: Stephan Gerhold <stephan@gerhold.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-15 11:42:14 +00:00
Greg Kroah-Hartman
7347f09a19 First set of fixes for IIO in the 5.5 cycle.
Mixture of old things people have just hit, and a few late breaking
 issues with things that went in during the merge window.
 
 Being sent promptly to resolve potential DT breakage causing
 issues for binding test builds.
 
 * ad7606
   - Avoid reading extra data from the device over what was intended.
 * ad7124
   - Enable the internal reference when in use.
 * ad7292
   - Fix up license for newly added binding.  Better to not have this go
     out in a release with more limited header than intended.
   - Fix a constraint on number of channels.
 * ad7949
   - Fix an issue which can result in readouts being from the wrong channel.
 * hdc100x
   - Fix wrong ABI usage (units) for relative humidity channel.
 * intel mrfld
   - Allocate right amount of private data (currently allocating too much).
 * ltc2983
   - Avoid a potential issue with machine endianness and wrong length device
     tree read.
 * max1027
   - Clean up leak of an iio_trigger on probe failure.
 * max9611
   - Ensure we sleep long enough to successfully initialize the sensor.
 * mpu6050
   - Fix wrong ABI usage (units) for temperature channel.
 * st_accel
   - Fix an unused variable warning.
 * st_lsm6dsx
   - Fix decimation factor issue that can lead to missaligned datasets
     (and hence garbage)
   - Fix an issue with how we track enabled fifo channels.
   - Avoid powering off the device if wake up events are enabled.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAl3tPj0RHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FohHAA/5AYRHumbbF8AlbK7frPMqRKq7NqcOJOOB
 90WeSbr0rFyieKymrCHjOfW72BnHdNeIMh4IGf+D5nCtZd+HHs5Cs0G/dsTgVn//
 JjnmGXxil0ZyEKBrvlfKmOjkhfEcvnCR83gYR+P/cY7B9oukOJGn86x9vuzGDf/v
 ciDZcHYmbMyB3zuxqy9Xn0CLAdSok5ND1PPwIyQrKXhv8LihcyXOwCBxs5Yu61Iu
 kGmyZ8cru6PXt0aP7lZODyZQ4wexwWxtRRjEkDD3bYjqe+qltgHjmOgSwRr+fZLL
 JxtgaRoArnfIlkuUd2yy7Wbt/NXxiMXKwv6o5pESlKeqrxxCqTOonJi64ZDrPVO5
 ggnL3/HXGfKd+JLjKn4e1MzTSWFkbvNU9zw3IGEAWSX0kPVIJtx7yo8dx3bYszLZ
 1bADUEvL+gDnFsBJ3MhCzF5xUDDnus/3yz2GykNKMxVFhEhjxV4rvNZPWtxtWyIB
 liCwsczeDft+TaQqR0ke0Ki8zbOeG8jxrogHBIJWZvaBu1KHgDhkySLloT+gFthD
 +BDf4EGGsxuItK6rN4X0Q62SUa9gAGnQ/bfyQ8+1ZGaHc/I3rUzUN59WS/7NP9C9
 x9TwrQPYdJCQoJ6M6qzuyQaD2qMqt5B85hD0nK2e6q28C/T2P83xC/wMDEt5Bo88
 5WHDKxQwxhE=
 =vySY
 -----END PGP SIGNATURE-----

Merge tag 'iio-fixes-for-5.5a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus

Jonathan writes:

First set of fixes for IIO in the 5.5 cycle.

Mixture of old things people have just hit, and a few late breaking
issues with things that went in during the merge window.

Being sent promptly to resolve potential DT breakage causing
issues for binding test builds.

* ad7606
  - Avoid reading extra data from the device over what was intended.
* ad7124
  - Enable the internal reference when in use.
* ad7292
  - Fix up license for newly added binding.  Better to not have this go
    out in a release with more limited header than intended.
  - Fix a constraint on number of channels.
* ad7949
  - Fix an issue which can result in readouts being from the wrong channel.
* hdc100x
  - Fix wrong ABI usage (units) for relative humidity channel.
* intel mrfld
  - Allocate right amount of private data (currently allocating too much).
* ltc2983
  - Avoid a potential issue with machine endianness and wrong length device
    tree read.
* max1027
  - Clean up leak of an iio_trigger on probe failure.
* max9611
  - Ensure we sleep long enough to successfully initialize the sensor.
* mpu6050
  - Fix wrong ABI usage (units) for temperature channel.
* st_accel
  - Fix an unused variable warning.
* st_lsm6dsx
  - Fix decimation factor issue that can lead to missaligned datasets
    (and hence garbage)
  - Fix an issue with how we track enabled fifo channels.
  - Avoid powering off the device if wake up events are enabled.

* tag 'iio-fixes-for-5.5a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio:
  iio: adc: max9611: Fix too short conversion time delay
  iio: ad7949: fix channels mixups
  iio: imu: st_lsm6dsx: do not power-off accel if events are enabled
  iio: imu: st_lsm6dsx: track hw FIFO buffering with fifo_mask
  iio: imu: st_lsm6dsx: fix decimation factor estimation
  iio: imu: inv_mpu6050: fix temperature reporting using bad unit
  iio: humidity: hdc100x: fix IIO_HUMIDITYRELATIVE channel reporting
  iio: adc: max1027: fix not unregistered iio trigger
  iio: adc: intel_mrfld_adc: Allocating too much data in probe()
  iio: adc: ad7124: Enable internal reference
  dt-bindings: iio: adc: ad7292: fix constraint over channel quantity
  dt-bindings: iio: adc: ad7292: Update SPDX identifier
  iio: temperature: ltc2983: fix u32 read into a unsigned long long
  iio: st_accel: Fix unused variable warning
  iio: adc: ad7606: fix reading unnecessary data from device
2019-12-09 09:27:52 +01:00
Lorenzo Bianconi
bd41c445b7 iio: imu: st_lsm6dsx: do not power-off accel if events are enabled
Do not power-off accel unconditionally if wake-up events are enabled
powering off the hw FIFO. At the same time do not power-off the accel
sensor if it is 'batched' in the hw FIFO disabling sensor events

Fixes: b5969abfa8 ("iio: imu: st_lsm6dsx: add motion events")
Tested-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-08 18:10:30 +00:00
Lorenzo Bianconi
c2686eb2ae iio: imu: st_lsm6dsx: track hw FIFO buffering with fifo_mask
Track hw FIFO state introducing fifo_mask since now the accel sensor
can be enabled during suspend/resume in order to trigger the wake-up
enabling the FIFO in st_lsm6dsx_resume even if it was disabled before
the suspend.  Hence we must separately track the fifo state.

Fixes: 4c997dfa69 ("iio: imu: st_lsm6dsx: add wakeup-source option")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Tested-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-08 18:10:30 +00:00
Lorenzo Bianconi
5685b145c1 iio: imu: st_lsm6dsx: fix decimation factor estimation
Fix decimation factor and sip estimation for LSM6DSM series
(max value for decimation factor is 32).
If gyro and accel sensors are enabled at 12.5Hz and 416Hz
respectively, decimation factor lookup will fail, producing
unaligned data.
Remove unused decimator filed in st_lsm6dsx_sensor structure.

Fixes: f8710f0357 ("iio: imu: st_lsm6dsx: express odr in mHZ")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-08 18:10:30 +00:00
Jean-Baptiste Maneyrol
53eaa9c27f 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: 1615fe41a1 ("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-12-08 18:10:30 +00:00
Linus Torvalds
0dd09bc02c Staging / IIO patches for 5.5-rc1
Here is the big staging and iio set of patches for the 5.5-rc1 release.
 
 It's the usual huge collection of cleanup patches all over the
 drivers/staging/ area, along with a new staging driver, and a bunch of
 new IIO drivers as well.
 
 Full details are in the shortlog, but all of these have been in
 linux-next for a long time with no reported issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCXd6lVQ8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ylFnwCgyvZ62uUyQTRey0zvNTe3I4fY9L4AnAnrz3ZC
 U6ZA2+Uj3O6qhAr5frRu
 =uv8S
 -----END PGP SIGNATURE-----

Merge tag 'staging-5.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging / iio updates from Greg KH:
 "Here is the big staging and iio set of patches for the 5.5-rc1
  release.

  It's the usual huge collection of cleanup patches all over the
  drivers/staging/ area, along with a new staging driver, and a bunch of
  new IIO drivers as well.

  Full details are in the shortlog, but all of these have been in
  linux-next for a long time with no reported issues"

* tag 'staging-5.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (548 commits)
  staging: vchiq: Have vchiq_dump_* functions return an error code
  staging: vchiq: Refactor indentation in vchiq_dump_* functions
  staging: fwserial: Fix Kconfig indentation (seven spaces)
  staging: vchiq_dump: Replace min with min_t
  staging: vchiq: Fix block comment format in vchiq_dump()
  staging: octeon: indent with tabs instead of spaces
  staging: comedi: usbduxfast: usbduxfast_ai_cmdtest rounding error
  staging: most: core: remove sysfs attr remove_link
  staging: vc04: Fix Kconfig indentation
  staging: pi433: Fix Kconfig indentation
  staging: nvec: Fix Kconfig indentation
  staging: most: Fix Kconfig indentation
  staging: fwserial: Fix Kconfig indentation
  staging: fbtft: Fix Kconfig indentation
  fbtft: Drop OF dependency
  fbtft: Make use of device property API
  fbtft: Drop useless #ifdef CONFIG_OF and dead code
  fbtft: Describe function parameters in kernel-doc
  fbtft: Make sure string is NULL terminated
  staging: rtl8723bs: remove set but not used variable 'change', 'pos'
  ...
2019-11-27 10:57:52 -08:00
Alexandru Ardelean
d693845da3 iio: imu: adis16480: use state lock for filter freq set
It's the only operation that does 2 operations (a read & a write), so the
unlocked functions can be used under a single state lock.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-23 12:17:35 +00:00
Alexandru Ardelean
ce476cd18a iio: imu: adis16400: rework locks using ADIS library's state lock
This change removes the use of indio_dev's mlock in favor using the state
lock from the ADIS library.

The set_freq() & get_freq() hooks are unlocked, so they require specific
locking. That is because in some cases the get_freq() hook is used in
combination with adis16400_set_filter().

In cases where only one read/write is done, the functions that hold the
state lock are used.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-23 12:14:59 +00:00
Alexandru Ardelean
c5485a5d6a iio: imu: adis: group single conversion under a single state lock
The single conversion function does a series of reads + writes. This change
extends the use of the state_lock for the entire set of operations.
Previously, indio_dev's mlock was used. This change also removes the use of
this lock.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-23 12:13:35 +00:00
Alexandru Ardelean
cb5a07f1f1 iio: imu: adis: protect initial startup routine with state lock
The initial startup routine is called by some ADIS drivers during probe,
and before registering with IIO. Normally, userspace should not be able to
do any access to the device (as there shouldn't be any available).

This change extends the state lock to the entire initial-startup routine.
Behaviourally nothing should change, but this should make the library
function a bit more robust.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-23 12:09:54 +00:00
Alexandru Ardelean
762ab093cb iio: imu: adis: create an unlocked version of adis_reset()
The reset routine may also be important to be protected by the state-lock
and grouped with other operations, so create an unlocked version, so that
this can be done.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-23 12:05:17 +00:00
Alexandru Ardelean
6a4d6a7d65 iio: imu: adis: create an unlocked version of adis_check_status()
This one also gets re-used in certain operations, so it makes sense to
have an unlocked version of this to group it with other
reads/writes/operations to have a single lock for the whole state change.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-23 12:02:05 +00:00
Alexandru Ardelean
100bfa38c8 iio: imu: adis[16480]: group RW into a single lock in adis_enable_irq()
The adis_enable_irq() does a read & a write. This change keeps a lock for
the duration of both operations vs for each op.

The change is also needed in adis16480, since that has it's own
implementation for adis_enable_irq().

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-23 12:00:04 +00:00
Alexandru Ardelean
770d465619 iio: imu: adis: add unlocked read/write function versions
This will allow more flexible control to group reads & writes into a single
lock (particularly the state_lock).

The end-goal is to remove the indio_dev->mlock usage, and the simplest fix
would have been to just add another lock, which would not be a good idea on
the long-run.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-23 11:57:42 +00:00
Alexandru Ardelean
6a9afcb198 iio: imu: adis: rename txrx_lock -> state_lock
The lock can be extended a bit to protect other elements that are not
particular to just TX/RX. Another idea would have been to just add a new
`state_lock`, but that would mean 2 locks which would be redundant, and
probably cause more potential for dead-locks.

What will be done in the next patches, will be to add some unlocked
versions for read/write_reg functions.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-23 11:53:10 +00:00
Mark Brown
ca4196aa10
Merge branch 'spi-5.5' into spi-next 2019-11-22 19:56:35 +00:00
Jean-Baptiste Maneyrol
a2587eb032 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>
2019-11-16 17:19:01 +00:00
Jean-Baptiste Maneyrol
b95ed40627 iio: imu: inv_mpu6050: delete not existing MPU9150 spi support
MPU9150 is i2c only.
Update Kconfig to delete in description chips that are i2c or
spi only.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-16 17:15:57 +00:00
Greg Kroah-Hartman
8bde9f3d2a 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.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAl3JsAoRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0Foiw0w//Qpe9IxW4kdiMZB0vMr0mz74Aa6niS1Rm
 c/vMEv7x/0cHjNBJWZiI4VQqScadVMMk2nD/KHAMt+9ZgZg+/r9d7PkVsrEIydZw
 XBFf8qwFYoxL6jAgWinuCWuWAE3o9aKVqqGj/aosloUwzZDBXUpmCSnRpBFOhEyp
 hbNNYZJo4Sbrg/xOYqyIaGJFTes0u+n8OuiS53dLN71lGW6BbGyJQtPzb/7rkOV/
 z7zL0nbIfXszRrFQc17eBlblZvWl3QtHY08aiem8gcTkQbzTOTVWgLxyg+aZwBB2
 XkCeeI21gLjVh2rxAcqBTs7OWObyGUjVES0+fAGBqIGEslq9nruMPrVrlTqkUHxJ
 +vMPPA2VqvAqLI6cBz8oG9HsO/TUTQaRV3tHMF5WnoX9mDEzu9A8V4Cd7pg15lc1
 aEvDXq5UU+aocKOofvyZJ8LqBi0ZmxJpohMGHHyDPmdtlL/HuWWsn9FyzsSgdBuc
 EiGH+GKlUnG4mNOibr2L+TOBZwyelL+wGu40Xld3+KTyHyaysvQ2puP6wHTVf1da
 ME0e6sFDPk4k+JTmsT9vYljgEfW3IMuTzI0BePlsfsx3/SbMZqdYLkijIHM1mpyE
 yhaP/00u4aDFOlE1Ct0iwakUJ4Myxw0UeOz6deNKdTHcOExy28c8AIG6dqZhAJ9S
 ohWETBDIDzI=
 =ckQz
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-5.5c' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

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-13 19:24:42 +08:00
Nuno Sá
4c35b7a51e iio: adis16480: Add debugfs_reg_access entry
The driver is defining debugfs entries by calling
`adis16480_debugfs_init()`. However, those entries are attached to the
iio_dev debugfs entry which won't exist if no debugfs_reg_access
callback is provided.

Fixes: 2f3abe6cbb ("iio:imu: Add support for the ADIS16480 and similar IMUs")
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-11 18:38:13 +00:00
Nuno Sá
49549cb23a iio: adis16480: Fix scales factors
This patch fixes the scales for the gyroscope, accelerometer and
barometer. The pressure scale was just wrong. For the others, the scale
factors were not taking into account that a 32bit word is being read
from the device.

Fixes: 7abad1063d ("iio: adis16480: Fix scale factors")
Fixes: 82e7a1b250 ("iio: imu: adis16480: Add support for ADIS1649x family of devices")
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-11 18:38:03 +00:00
Greg Kroah-Hartman
f0cb9b5dfd Merge 5.4-rc7 into staging-next
We want the staging fixes in here, and it resolves some merge issues.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-11-11 06:23:37 +01:00
Stephan Gerhold
26a0ffeed9 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>
2019-11-10 16:00:34 +00:00
Lorenzo Bianconi
f8710f0357 iio: imu: st_lsm6dsx: express odr in mHZ
Express available frequencies in mHZ in order to support even
rational ODRs. This patch is need to fix an Android CTS failure

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-09 13:23:17 +00:00
Lorenzo Bianconi
fc3f6ad7f5 iio: imu: st_lsm6dsx: fix ODR check in st_lsm6dsx_write_raw
Since st_lsm6dsx i2c master controller relies on accel device as trigger
and slave devices can run at different ODRs we must select an accel_odr >=
slave_odr. Report real accel ODR in st_lsm6dsx_check_odr() in order to
properly set sensor frequency in st_lsm6dsx_write_raw and avoid to
report unsupported frequency

Fixes: 6ffb55e500 ("iio: imu: st_lsm6dsx: introduce ST_LSM6DSX_ID_EXT sensor ids")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-09 13:17:15 +00:00
Lorenzo Bianconi
59af4e2063 iio: imu: st_lsm6dsx: explicitly define odr table size
Introduce odr_len in st_lsm6dsx_odr_table_entry data structure in order
to explicitly define odr table size and support devices with different
odr table map

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-09 13:10:59 +00:00
Alexandru Ardelean
38262c01ea iio: imu: adis: assign read val in debugfs hook only if op successful
This was also caught by the `-Wmaybe-uninitialized` warning, which
(ironically as-is) it makes quite a lot of sense to do for this.

The code that actually calls this function will fail to copy on
the uninitialized value.   Hence, patch does not need to go into stable.

Fixes: 78026a6fde ("iio:imu:adis: Add debugfs register access support")
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-03 10:44:29 +00:00
Alexandru Ardelean
9b742763d9 iio: imu: adis16480: assign bias value only if operation succeeded
This was found only after the whole thing with the inline functions, but
the compiler actually found something. The value of the `bias` (in
adis16480_get_calibbias()) should only be set if the read operation was
successful.

No actual known problem occurs as users of this function all
ultimately check the return value.  Hence probably not stable material.

Fixes: 2f3abe6cbb ("iio:imu: Add support for the ADIS16480 and similar IMUs")
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-03 10:40:25 +00:00
Alexandru Ardelean
52c4c732b2 iio: imu: adis16480: prefer unsigned int over unsigned
This is a typical checkpatch warning. The change just renames the type of
the `freq` var to `unsigned int`.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-03 10:38:40 +00:00
Alexandru Ardelean
d9bbae304a iio: imu: adis16480: fix indentation of return statement
This is just a minor indentation/alignment fix for the default case of a
switch statement.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-03 10:35:21 +00:00
Alexandru Ardelean
6a39ab3b19 iio: imu: adis: check ret val for non-zero vs less-than-zero
The ADIS library functions return zero on success, and negative values for
error. Positive values aren't returned, but we only care about the success
value (which is zero).

This change is mostly needed so that the compiler won't make any inferences
about some about values being potentially un-initialized. This only
triggers after making some functions inline, because the compiler can
better follow return paths.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-03 10:29:25 +00:00
Alexandru Ardelean
92c7529fc1 iio: imu: adis16480: check ret val for non-zero vs less-than-zero
The ADIS library functions return zero on success, and negative values for
error. Positive values aren't returned, but we only care about the success
value (which is zero).

This change is mostly needed so that the compiler won't make any inferences
about some about values being potentially un-initialized. This only
triggers after making some functions inline, because the compiler can
better follow return paths.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-03 10:25:43 +00:00
Alexandru Ardelean
c754a45455 iio: imu: adis16460: check ret val for non-zero vs less-than-zero
The ADIS library functions return zero on success, and negative values for
error. Positive values aren't returned, but we only care about the success
value (which is zero).

This change is mostly needed so that the compiler won't make any inferences
about some about values being potentially un-initialized. This only
triggers after making some functions inline, because the compiler can
better follow return paths.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-03 10:22:39 +00:00
Alexandru Ardelean
fe4b7f917e iio: imu: adis16400: check ret val for non-zero vs less-than-zero
The ADIS library functions return zero on success, and negative values for
error. Positive values aren't returned, but we only care about the success
value (which is zero).

This change is mostly needed so that the compiler won't make any inferences
about some about values being potentially un-initialized. This only
triggers after making some functions inline, because the compiler can
better follow return paths.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-03 10:16:54 +00:00
Lorenzo Bianconi
cf9c71b38b iio: imu: st_lsm6dsx: add support to LSM6DSRX
Add support to STM LSM6DSRX 6-axis (acc + gyro) Mems sensor
https://www.st.com/resource/en/datasheet/lsm6dsrx.pdf

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-27 16:38:06 +00:00
Jean-Baptiste Maneyrol
6e82ae6b8d 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: f5057e7b2d ("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-22 12:42:54 +01:00
Robert Jones
84e5ddd5c4 iio: imu: Add support for the FXOS8700 IMU
FXOS8700CQ is a small, low-power, 3-axis linear accelerometer and 3-axis
magnetometer combined into a single package. The device features a
selectable I2C or point-to-point SPI serial interface with 14-bit
accelerometer and 16-bit magnetometer ADC resolution along with
smart-embedded functions.

FXOS8700CQ has dynamically selectable accelerationfull-scale ranges of
±2 g/±4 g/±8 g and a fixed magnetic measurement range of ±1200 μT.
Output data rates (ODR) from 1.563 Hz to 800 Hz are selectable by the user
for each sensor. Interleaved magnetic and acceleration data is available
at ODR rates of up to 400 Hz. FXOS8700CQ is available in a plastic QFN
package and it is guaranteed to operate over the extended temperature
range of –40 °C to +85 °C.

TODO: Trigger and IRQ configuration support

Datasheet:
  http://cache.freescale.com/files/sensors/doc/data_sheet/FXOS8700CQ.pdf

Signed-off-by: Robert Jones <rjones@gateworks.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-22 10:24:50 +01:00
Lorenzo Bianconi
fa060a3d9c iio: imu: st_lsm6dsx: add support to LSM6DS0
Add support to STM LSM6DS0 6-axis (acc + gyro) Mems sensor

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:07 +01:00
Lorenzo Bianconi
1b3751017e iio: imu: st_lsm6dsx: fix gyro gain definitions for LSM9DS1
Fix typos in gyro gain definitions for LSM9DS1 sensor

Fixes: 52f4b1f196 ("iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9ds1")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:07 +01:00
Mario Tesi
cb3b6b8e1b iio: imu: st_lsm6dsx: add odr calibration feature
On LSM6DSO/LSM6DSR/LSM6DSOX/ASM330LHH and ISH330DHCX
devices it is possible to trim the hardware timestamp
resolution through the FREQ_FINE[7:0] bits of the
INTERNAL_FREQ_FINE register, which contains the difference
in percentage of the effective ODR (and timestamp rate)
with respect to the typical value.

The formula for calculating the effective ODR reported
in the application notes has been linearized to the first
order to simplify the calculation (pls. see note on source
code).

This change may be useful in the outcome of CTS
tests regarding the SingleSensorTests and the
SensorTest#testSensorTimeStamps for high ODRs

Signed-off-by: Mario Tesi <mario.tesi@st.com>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:06 +01:00
Lorenzo Bianconi
960506ed2c iio: imu: st_lsm6dsx: enable drdy-mask if available
Enable drdy mask if available in order to mark invalid samples during
sensor bootstrap phase

Tested-by: Mario Tesi <mario.tesi@st.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:06 +01:00
Lorenzo Bianconi
3ea39d61ee iio: imu: st_lsm6dsx: enable wake-up event for LSM6DSO
Add missing wake-up register info for LSM6DSO/LSM6DSOX sensor

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:06 +01:00
Lorenzo Bianconi
3473b923b3 iio: imu: st_lsm6dsx: add missing kernel documenation
Add missing kernel doc for st_lsm6dsx_hw data structure

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:05 +01:00
Lorenzo Bianconi
b7a73b33bb iio: imu: st_lsm6dsx: add wakeup_source in st_sensors_platform_data
Add the possibility to enable/disable wakeup source through
st_sensors_platform_data and not only through device tree

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:05 +01:00
Lorenzo Bianconi
b307f49546 iio: imu: st_lsm6dsx: fix checkpatch warning
Fix following checkpatch warnings:

CHECK: Alignment should match open parenthesis
+static int st_lsm6dsx_read_event(struct iio_dev *iio_dev,
+				   const struct iio_chan_spec *chan,

CHECK: Alignment should match open parenthesis
+static int st_lsm6dsx_write_event(struct iio_dev *iio_dev,
+				    const struct iio_chan_spec *chan,

CHECK: Alignment should match open parenthesis
+static int st_lsm6dsx_read_event_config(struct iio_dev *iio_dev,
+					  const struct iio_chan_spec *chan,

CHECK: Alignment should match open parenthesis
+static int st_lsm6dsx_write_event_config(struct iio_dev *iio_dev,
+					   const struct iio_chan_spec *chan,

WARNING: line over 80 characters
+	if (dev->of_node && of_property_read_bool(dev->of_node, "wakeup-source"))

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:05 +01:00
Lorenzo Bianconi
d278d44794 iio: imu: st_lsm6dsx: grab conf mutex in st_lsm6dsx_write_event_config
Always grub conf mutex in st_lsm6dsx_write_event_config since it can run
concurrently with FIFO configuration

Fixes: b5969abfa8 ("iio: imu: st_lsm6dsx: add motion events")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:05 +01:00
Lorenzo Bianconi
04ca37d5ad iio: imu: st_lsm6dsx: rely on st_lsm6dsx_update_bits_locked configuring events
Rely on st_lsm6dsx_update_bits_locked in st_lsm6dsx_write_event and
st_lsm6dsx_event_setup routines since they can run concurrently with
sensor hub configuration

Fixes: b5969abfa8 ("iio: imu: st_lsm6dsx: add motion events")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:05 +01:00
Lorenzo Bianconi
84b2e7c319 iio: imu: st_lsm6dsx: always check enable_reg in st_lsm6dsx_event_setup
Check if enable_reg of event_settings data structure is defined before
writing on it

Fixes: b5969abfa8 ("iio: imu: st_lsm6dsx: add motion events")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Tested-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:05 +01:00
Lorenzo Bianconi
66b662a176 iio: imu: st_lsm6dsx: move bdu/boot and reset register info in hw_settings
Move bdu, boot and reset register definitions in hw_settings register
map since not all supported sensors (e.g lsm9ds1) rely on the same
definitions

Fixes: 52f4b1f196 ("iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9ds1")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:04 +01:00
Lorenzo Bianconi
31fe8d4e0f iio: imu: st_lsm6dsx: do not access active-low/open-drain regs if not supported
Move active low and open drain register definitions in hw_settings
register map since not all supported sensors (e.g lsm9ds1) rely on the
same definitions

Fixes: 52f4b1f196 ("iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9ds1")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:04 +01:00
Lorenzo Bianconi
7e9061030d iio: imu: st_lsm6dsx: move irq related definitions in irq_config
Group irq related definition in irq_config structure in
st_lsm6dsx_settings. This is a preliminary patch to move
OpenDrain/Active low registers in st_lsm6dsx_settings.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Tested-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:04 +01:00
Lorenzo Bianconi
a912ee4c91 iio: imu: st_lsm6dsx: add sanity check for read_fifo pointer
Check read_fifo pointer before using it since we can't assume it
is always set adding new sensors. This patch fixes the following crash:

irq 277: nobody cared (try booting with the "irqpoll" option)
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.3.0-rc5-00322-g792b824-dirty #7
Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
[<c0112750>] (unwind_backtrace) from [<c010d018>] (show_stack+0x10/0x14)
[<c010d018>] (show_stack) from [<c0c2bfc8>] (dump_stack+0xd8/0x10c)
[<c0c2bfc8>] (dump_stack) from [<c01923fc>] (__report_bad_irq+0x24/0xc0)
[<c01923fc>] (__report_bad_irq) from [<c0192820>] (note_interrupt+0x27c/0x2dc)
[<c0192820>] (note_interrupt) from [<c018f174>] (handle_irq_event_percpu+0x54/0x7c)
[<c018f174>] (handle_irq_event_percpu) from [<c018f1d4>] (handle_irq_event+0x38/0x5c)
[<c018f1d4>] (handle_irq_event) from [<c0193664>] (handle_level_irq+0xc8/0x154)
[<c0193664>] (handle_level_irq) from [<c018df58>] (generic_handle_irq+0x20/0x34)
[<c018df58>] (generic_handle_irq) from [<c053c348>] (mxc_gpio_irq_handler+0xc4/0xf8)
[<c053c348>] (mxc_gpio_irq_handler) from [<c053c3e0>] (mx3_gpio_irq_handler+0x64/0xb8)
[<c053c3e0>] (mx3_gpio_irq_handler) from [<c018df58>] (generic_handle_irq+0x20/0x34)
[<c018df58>] (generic_handle_irq) from [<c018e550>] (__handle_domain_irq+0x64/0xe0)
[<c018e550>] (__handle_domain_irq) from [<c0529610>] (gic_handle_irq+0x4c/0xa0)
[<c0529610>] (gic_handle_irq) from [<c0101a70>] (__irq_svc+0x70/0x98)
Exception stack(0xc1301f10 to 0xc1301f58
1f00: 00000001 00000006 00000000 c130c340
1f20: c1300000 c1308928 00000001 c1308960 00000000 c12b9db0 c1308908 00000000
1f40: 00000000 c1301f60 c0182010 c0109508 20000013 ffffffff
[<c0101a70>] (__irq_svc) from [<c0109508>] (arch_cpu_idle+0x20/0x3c)
[<c0109508>] (arch_cpu_idle) from [<c015ed70>] (do_idle+0x1bc/0x2bc)
[<c015ed70>] (do_idle) from [<c015f204>] (cpu_startup_entry+0x18/0x1c)
[<c015f204>] (cpu_startup_entry) from [<c1200e68>] (start_kernel+0x440/0x504)
[<c1200e68>] (start_kernel) from [<00000000>] (0x0)
handlers:
[<62052c0d>] st_lsm6dsx_handler_irq threaded
[<f2004b92>] st_lsm6dsx_handler_thread

Fixes: 52f4b1f196 ("iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9ds1")
Tested-by: Bobby Jones <rjones@gateworks.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:04 +01:00
Lorenzo Bianconi
615bd3785b iio: imu: st_lsm6dsx: use st_lsm6dsx_read_locked in st_lsm6dsx_report_motion_event
Rely on st_lsm6dsx_read_locked in st_lsm6dsx_report_motion_event since
it can run concurrently with sensor hub configuration. Move event
related code in st_lsm6dsx_report_motion_event

Fixes: 1aabad1fb5 ("iio: imu: st_lsm6dsx: add motion report function and call from interrupt")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Tested-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15 21:11:04 +01:00
Alexandru Ardelean
329f0dac4c
spi: make cs_change_delay the first user of the spi_delay logic
Since the logic for `spi_delay` struct + `spi_delay_exec()` has been copied
from the `cs_change_delay` logic, it's natural to make this delay, the
first user.

The `cs_change_delay` logic requires that the default remain 10 uS, in case
it is unspecified/unconfigured. So, there is some special handling needed
to do that.

The ADIS library is one of the few users of the new `cs_change_delay`
parameter for an spi_transfer.

The introduction of the `spi_delay` struct, requires that the users of of
`cs_change_delay` get an update. This change also updates the ADIS library.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20190926105147.7839-4-alexandru.ardelean@analog.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2019-10-15 11:41:47 +01:00
Greg Kroah-Hartman
27d6e47f8e Merge 5.4-rc3 into staging-next
We want the staging driver fixes in here as well to build on and test
with.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-10-14 07:07:36 +02:00
Alexandru Ardelean
24e1eb5c0d iio: imu: adis16480: make sure provided frequency is positive
It could happen that either `val` or `val2` [provided from userspace] is
negative. In that case the computed frequency could get a weird value.

Fix this by checking that neither of the 2 variables is negative, and check
that the computed result is not-zero.

Fixes: e4f9593901 ("iio: imu: adis16480 switch sampling frequency attr to core support")
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-12 14:14:45 +01:00
Lorenzo Bianconi
fdb828e2c7 iio: imu: st_lsm6dsx: fix waitime for st_lsm6dsx i2c controller
i2c controller available in st_lsm6dsx series performs i2c slave
configuration using accel clock as trigger.
st_lsm6dsx_shub_wait_complete routine is used to wait the controller has
carried out the requested configuration. However if the accel sensor is not
enabled we should not use its configured odr to estimate a proper timeout

Fixes: c91c1c844e ("iio: imu: st_lsm6dsx: add i2c embedded controller support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-09 19:11:28 +01:00
Navid Emamdoost
9c0530e898 iio: imu: adis16400: fix memory leak
In adis_update_scan_mode_burst, if adis->buffer allocation fails release
the adis->xfer.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-09 19:11:27 +01:00
Navid Emamdoost
ab612b1daf iio: imu: adis16400: release allocated memory on failure
In adis_update_scan_mode, if allocation for adis->buffer fails,
previously allocated adis->xfer needs to be released.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-09 19:11:27 +01:00
Sean Nyekjaer
1aabad1fb5 iio: imu: st_lsm6dsx: add motion report function and call from interrupt
Report iio motion events to iio subsystem and filter motion events.
Wakeup will still be on all channels as it's not possible to do the filtering
in hw.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-05 12:40:26 +01:00
Sean Nyekjaer
a3aa17d4ba iio: imu: st_lsm6dsx: always enter interrupt thread
The interrupt source can come from multiple sources,
fifo and wake interrupts.
Enter interrupt thread to check which interrupt that has fired.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-05 12:36:54 +01:00
Sean Nyekjaer
4c997dfa69 iio: imu: st_lsm6dsx: add wakeup-source option
This add ways for the SoC to wake from accelerometer wake events.

In the suspend function we skip disabling the sensor if wakeup-source
and events are activated.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-05 12:36:39 +01:00
Sean Nyekjaer
b5969abfa8 iio: imu: st_lsm6dsx: add motion events
Add event channels that controls the creation of motion events.
Tested on ISM330DLC

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-05 12:30:56 +01:00
Sean Nyekjaer
6ee6a368ac iio: imu: st_lsm6dsx: move interrupt thread to core
This prepares the interrupt to be used for other stuff than
fifo reading + event readings.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-05 12:23:58 +01:00
Jean-Baptiste Maneyrol
e764fb4e20 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>
2019-10-05 12:14:31 +01:00
Jean-Baptiste Maneyrol
b1392de061 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>
2019-10-05 12:14:20 +01:00
Jean-Baptiste Maneyrol
16ef433769 iio: imu: inv_mpu6050: helpers for using i2c master on auxiliary bus
Add helper functions to use the i2c auxiliary bus with the MPU i2c
master block.

Support only register based chip, reading and 1 byte writing. These
will be useful for initializing magnetometers inside MPU9x50 chips.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-05 12:06:16 +01:00
Jean-Baptiste Maneyrol
9d8261dbc4 iio: imu: inv_mpu6050: fix objects syntax in Makefile
Use the correct syntax *-y for declaring object files.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-05 11:59:59 +01:00
Jean-Baptiste Maneyrol
68fd019b89 iio: imu: inv_mpu6050: add defines for supporting 9-axis chips
Add registers defines required for driving chip i2c master ip.
Add MPU9xxx magnetometer scan elements and update data bytes size.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-05 11:58:18 +01:00
Jean-Baptiste Maneyrol
5ffd024838 iio: imu: inv_mpu6050: add header include protection macro
Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-05 11:55:52 +01:00
Jean-Baptiste Maneyrol
ca4a649694 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>
2019-10-05 11:05:03 +01:00
Lorenzo Bianconi
22ea565110 iio: imu: st_lsm6dsx: enable clear on read for latched interrupts
Enable clear on read feature for latched interrupts. This bit allows
immediately clearing the latched interrupts of an event detection upon
the read of the corresponding status register.
It must be set to 1 together with LIR.
This feature is available just on LSM6DS0/LSM6DSR/ASM330LHH

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Tested-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-09-15 12:02:28 +01:00
Lorenzo Bianconi
9db02d32b8 iio: imu: st_lsm6dsx: enable LIR for sensor events
Enable Latched interrupt by default for sensor events

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Tested-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-09-15 11:56:25 +01:00
Lorenzo Bianconi
85ae3aeede iio: imu: st_lsm6dsx: forbid 0 sensor sensitivity
Do not allow configuring null sensor gain since it will force to 0
device outputs

Fixes: c8d4066c7246 ("iio: imu: st_lsm6dsx: remove invalid gain value for LSM9DS1")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-09-08 12:35:08 +01:00
Lorenzo Bianconi
6fa029486b iio: imu: st_lsm6dsx: rely on IIO_G_TO_M_S_2 for gain definition for LSM9DS1
Rely on IIO_G_TO_M_S_2 macro for LSM9DS1 accelerometer gain definitions

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-09-03 21:11:28 +01:00
Lorenzo Bianconi
0f7e17286b iio: imu: st_lsm6dsx: remove invalid gain value for LSM9DS1
Get rid of invalid sensitivity value for LSM9DS1 gyro sensor

Fixes: 52f4b1f196 ("iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9ds1")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-09-03 21:10:51 +01:00
mario tesi
70575abeaa iio: imu: st_lsm6dsx: Fix FIFO diff mask for tagged fifo
According to the latest version of datasheet the mask
	for number of unread sensor data in FIFO_STATUS registers
	has been extended to 10 bits

	The devices involved are:
	 - LSM6DSO
	 - LSM6DSOX
	 - ASM330LHH
	 - LSM6DSR
	 - ISM330DHCX

Signed-off-by: mario tesi <mario.tesi@st.com>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-09-03 18:55:50 +01:00
Martin Kepplinger
52f4b1f196 iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9ds1
The LSM9DS1's accelerometer / gyroscope unit and it's magnetometer (separately
supported in iio/magnetometer/st_magn*) are located on a separate i2c addresses
on the bus.

For the datasheet, see https://www.st.com/resource/en/datasheet/lsm9ds1.pdf

Treat it just like the LSM6* devices and, despite it's name, hook it up
to the st_lsm6dsx driver, using it's basic functionality.

accelerometer and gyroscope are not independently clocked. It runs at the gyro
frequencies if both are enabled, see chapter 7.12 of the datasheet.
We could have handled this as a single IIO device but we have split
it up to be more consistent with the other more flexible devices.

Despite supporting and testing the LSM9DS1, we call the gyro channels
iio_chan_spec struct "st_lsm6ds0_gyro_channels" because the register
description is equal. This suggests that supporting LSM6DS0 should be
trivial to do.

Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-09-03 18:55:50 +01:00
Martin Kepplinger
5022c5a433 iio: imu: st_lsm6dsx: move register definitions to sensor_settings struct
Move some register definitions to the per-device array of struct
st_lsm6dsx_sensor_settings in order to simplify adding new sensor
devices to the driver.

Also, remove completely unused register definitions.

Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-08-27 20:58:34 +01:00
Lorenzo Bianconi
3b72950d5a iio: imu: st_lsm6dsx: introduce update_fifo function pointer
Introduce update_fifo routine pointer in st_lsm6dsx_fifo_ops data
structure since we will need a different update FIFO configuration
callback adding support for lsm6ds0/lsm9ds1 imu device

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-08-26 08:52:03 +01:00
Alexandru Ardelean
519808425e iio: imu: adis16460: fix variable signedness
Caught via static-analysis checker:
```
drivers/iio/imu/adis16460.c
   152  static int adis16460_set_freq(struct iio_dev *indio_dev, int val, int val2)
   153  {
   154          struct adis16460 *st = iio_priv(indio_dev);
   155          unsigned int t;
                ^^^^^^^^^^^^^^

   156
   157          t =  val * 1000 + val2 / 1000;
   158          if (t <= 0)
                    ^^^^^^
Unsigned is not less than zero.
```

The types of `val` && `val2` are obtained from the IIO `write_raw` hook, so
userspace can provide negative values, which can cause weird behavior after
conversion to unsigned.

This patch changes the sign of variable `t` so that -EINVAL will be
returned for negative values as well.

Fixes: db6ed4d23d ("iio: imu: Add support for the ADIS16460 IMU")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-08-18 18:53:15 +01:00
Greg Kroah-Hartman
6aed51d891 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.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAl1RxVQRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FohP8xAAjbWf431vsHQSt0Lmn4coh0XCBT26R9ys
 ybIga540Mcy1q91H+biBenShLVImCBtXEBJ57YdVjtLgkr1HJAJjvxCXdE79TJet
 Ak39CmTcTGrRyzYin2MOpWJJgCFc4Fg+E/kB8K7KIcperzQ48GDCzL5aJE/PksME
 Ay/rZDno+vPKGLmvxYCuSpmINq1YhVMQu/IPYO5sc6zRdDtEV29TAdZ/x8aaD2oM
 r1E22hm0h2wVLQRpbLUA5XUgoetQGmIYaUgbJPkpvxhuQYIlbLavODP7S0xDqAbT
 VCRzrzeR8eHxA+EeZDE8IWC5xbmFTUBdUHhHfCDETONOi5CjaPC/QnowNOi1IC0H
 k5XgBAO6Zju5QWpu+nHVdjwdJ1RftLVeCPatXorHLWWJv6UP8j/cNNKDAvBTlvhq
 yfG/zW1VMTr/Q2VkokHnr2D8JxcARf/+AcR1BOu+pVszJ/+kgnXVNu3QLMilCTnN
 +fzEfbErL7BfUBh19IqdB40XOojppuavyzAruiOjLGVrFRk3lwFP8FvVDy8MtPbO
 /roYxohwc1M/kK3+Sl+4LfY2mX7orStZ5NNAYcu9yzg/6vv3Oh5Pxw2UsDto4MCC
 ikDffzIGxXnJUzi3uIBthyvTHMX2y/EykikbjMkfsGOtCiFdcPGUl4iirsWkpebj
 zrpff+V1vXM=
 =aez5
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-5.4a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

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-08-12 22:52:44 +02:00
Jean-Baptiste Maneyrol
854da7511a iio: imu: inv_mpu6050: be more explicit on supported chips
Since every chip has a different whoami, we are not supporting all
existing variant of all chips. Add an explicit supported chips
list in Kconfig description.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-08-05 17:30:34 +01:00
Martin Kepplinger
48cceecfa7 iio: imu: st_lsm6dsx: make IIO_CHAN_INFO_SCALE shared by type
in_accel_x_scale, in_accel_y_scale and in_accel_z_scale are always
the same. The scale is still defined to be in "info_mask_separate".

Userspace (iio-sensor-proxy and others) is not used to that and only
looks for "in_accel_scale" for the scaling factor to apply.

Change IIO_CHAN_INFO_SCALE from being separate in all channel to be
shared by type.

This removes in_accel_x_scale, in_accel_y_scale and in_accel_z_scale and
makes available in_accel_scale.

This is an ABI change, but hopefully in the 'no one will notice'
category.  The cleanup in interface is worth the small risk that
there is a custom script out there somewhere that this will break.

Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-08-05 16:39:23 +01:00
Lorenzo Bianconi
db947a79fc iio: imu: st_lsm6dsx: add support to ISM330DHCX
Add support to STM ISM330DHCX 6-axis (acc + gyro) Mems sensor
https://www.st.com/resource/en/datasheet/ism330dhcx.pdf

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-08-05 15:22:43 +01:00
Lorenzo Bianconi
f48bc49b97 iio: imu: st_lsm6dsx: move iio chan definitions in st_lsm6dsx_sensor_settings
Move IIO channel definitions in st_lsm6dsx_sensor_settings in order to
support sensors with different channels maps.
This is a preliminary patch to add support for LSM9DS1 sensor to
st_lsm6dsx driver.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-08-05 15:16:45 +01:00
Lorenzo Bianconi
ec19a6f499 iio: imu: st_lsm6dsx: inline output acc/gyro output regs
Remove output register definition and inline register value since
they are used only for iio channel definition. This is a preliminary
patch to add support for LSM9DS1 sensor to st_lsm6dsx driver

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-08-05 15:02:43 +01:00
Lorenzo Bianconi
640aca3fb8 iio: imu: st_lsm6dsx: move fs_table in st_lsm6dsx_sensor_settings
Move fs_table in st_lsm6dsx_sensor_settings in order to support
sensors with different gain maps. This is a preliminary patch to add
support for LSM9DS1 sensor to st_lsm6dsx driver

Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-08-05 15:01:10 +01:00
Lorenzo Bianconi
40dd734389 iio: imu: st_lsm6dsx: move odr_table in st_lsm6dsx_sensor_settings
Move sensor odr table in st_lsm6dsx_sensor_settings in order to support
sensors with different odr maps. This is a preliminary patch to add
support for LSM9DS1 sensor to st_lsm6dsx driver

Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-08-05 14:58:07 +01:00
Sean Nyekjaer
ec76d918f2 iio: imu: st_lsm6dsx: flip irq return logic
No need for using reverse logic in the irq return,
fix this by flip things around.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-07-27 22:55:27 +01:00
Vitor Soares
2660b0080b iio: imu: st_lsm6dsx: add i3c basic support for LSM6DSO and LSM6DSR
For today the st_lsm6dsx driver support LSM6DSO and LSM6DSR sensor only in
spi and i2c mode.

The LSM6DSO and LSM6DSR are also i3c capable so let's give i3c support to
them.

Signed-off-by: Vitor Soares <vitor.soares@synopsys.com>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-07-27 22:55:27 +01:00
Alexandru Ardelean
db6ed4d23d iio: imu: Add support for the ADIS16460 IMU
The ADIS16460 device is a complete inertial system that includes a triaxial
gyroscope and a triaxial accelerometer. It's more simplified design than
that of the ADIS16480, and does not offer the triaxial magnetometers &
pressure sensors. It does also have a temperature sensor (like the
ADIS16480).
Since it is part of the ADIS16XXX family, it re-uses parts of the ADIS
library.

Naturally, the register map is different and much more simplified than the
ADIS16480 subfamily, so it cannot be integrated into that driver. A major
difference is that the registers are not paged.

One thing that is particularly special about it, is that it requires a
higher delay between CS changes (i.e. when CS goes up, the spec recommends
that it be brought down after a minimum of 16 uS).
Other ADIS chips require (via spec) a minimum of 2 uS between CS changes.
The kernel's 10 uS default should be fine for those other chips; they
haven't been tested with lower CS change delays yet.

Datasheet:
  https://www.analog.com/media/en/technical-documentation/data-sheets/adis16460.pdf

Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-07-27 22:52:06 +01:00
Alexandru Ardelean
dca39af883 iio: imu: adis: Add support for SPI transfer cs_change_delay
The ADIS16460 requires a higher delay before the next transfer. Since the
SPI framework supports configuring the delay before the next transfer, this
driver will become the first user of it.

The support for this functionality in ADIS16460 requires an addition to the
ADIS lib to support the `cs_change_delay` functionality from the SPI
subsystem.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-07-27 22:52:06 +01:00
Lorenzo Bianconi
dbcd2088a7 iio: imu: st_lsm6dsx: add support to LSM6DS3TR-C
Add support to STM LSM6DS3TR-C 6-axis (acc + gyro) Mems sensor
https://www.st.com/resource/en/datasheet/lsm6ds3tr-c.pdf

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-07-27 20:11:17 +01:00
Fuqian Huang
d284feaf98 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>
2019-07-27 20:11:14 +01:00
Jean-Baptiste Maneyrol
1244a72057 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: 1615fe41a1 ("iio: imu: mpu6050: Fix FIFO layout for ICM20602")
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-07-14 18:19:23 +01:00
Greg Kroah-Hartman
c55cc97a25 Second set of IIO device support, features, cleanups and minor fixes for 5.3.
A few bits for the counters subsystem mixed in here as well.
 There are some late breaking fixes as well, which aren't so urgent
 they can't wait for the merge window.
 
 New Device Support
 * adf4371
   - New driver + bindings.
   - Support the adf4372 PLL. Mostly ID and bindings.
 * ad8366 (note includes rework of driver needed to allow support for these).
   - Support the ADL5240 variable gain amplifier (VGA).
   - Support the ADA4961 digital gain amplifier (DGA).
 * dps310
   - New driver, in several parts from different authors for this temp
     and pressure sensor.
   - Includes errata workaround for a temperature reading issue.
 * stk3310
   - Support the stk3335, mostly ID.
 
 Features and cleanups
 * core
   - drop error handling on debugfs registration.
   - harden by making sure we don't overrun iio_chan_info_postfix.
 * docs
   - convert remaining docs to rst. At somepoint we'll fit these few
     into the main IIO docs.
   - improve sampling_frequency_available docs but explaining the
     range form.
 * ad_sigma_delta
   - Drop a pointless goto.
 * ad2s1210
   - Drop pointless platform data null check seeing as we don't actually
     use platform data anymore.
 * ad7124
   - Relax limitation on channel numbers to allow pseudo different channels.
   - Support control of whether the input is buffered via DT.
   - Use dynamic allocation for channel configuration to make it easier
     to support new devices.
   - YAML binding conversion.
 * ad7150
   - Comment tidy up.
   - Consistent and simple if (ret) handling of i2c errors.
   - FIELD_GET and GENMASK.
   - Ternary rather than !!(condition) for readability.
   - Use macros to avoid repetition of channel definitions.
 * ad7606
   - Add software channel config (rather that pin controlled)
   - Refactor to simplify addition of new part in future.
 * ad7746
   - of_deivce_id table.
 * ad7780
   - MAINTAINERS entry
   - YAML DT bindings.
 * ad8366
   - Stop using core mlock in favour of well scoped local lock.
   - SPDX + copyright date update.
 * ad9834
   - of_device_id table
 * adf4371
   - Add support for output stage muting before lock on has occured.
 * adis library
   - MAINTAINERS entry to reflect that this now Alexandru's problem ;)
 * adis162xx:
   - Fix a slightly incorrect set of comments and print statements on
     minimum supported voltage.
 * adis16203
   - of_device_id table.
 * adis16240
   - Add of_device_id table (in two parts as first patch only used it for
     MODULE_DEVICE_TABLE.)
 * adt7316-spi
   - of_device_id table
 * adxl372
   - YAML DT binding conversion.
   - Cleanup use of buffer callback functions (precursor to core rework).
 * bh1710
   - Simplify getting the i2c adapter from the client.
 * dht11
   - Mote to newer GPIO consumer interface.
 * kxcjk-1013.c
   - Add binding for sensor in display of some ultrabooks after userspace
     tools updated for it not be a problem to report two similar sensors.
 * imx7d
   - drop unused variables.
   - white space
   - define instead of variable for clock frequency that is fixed.
   - drop pointless error message.
 * messon_saradc
   - SPDX
 * sps30
   - MAINTAINERS entry
   - YAML binding conversion.
 * st_accel
   - Tidy up ordering in various buffer related callbacks. This is
     part of a long running effort to simplify the core code.
 * stm32-dfsdm:
   - Manage the resolution cleanly in triggerd modes.
   - Add fast mode support which allows more flexible filter choices.
   - Add a comment on the reason for a 16 bit record when technically
     not 'required'.
 * st_lsm6dsx
   - Embed device name in the sensor_settings struct as i3c doesn't
     have a convenient name field to use for this.
 * xilinx-adc
   - Relax constraints on supported platforms to reflect that this
     can used with FPGAs on PCIe cards and hence many architectures.
 * counters/ftm-quaddec
   - Fix some formatting io MODULE_AUTHOR
   - MAINTAINERS entry
 
 Fixes
 * tools
   - fix incorrect handling of 32 bit channels.
 * sca3000
   - Potential endian bug that is unlikely to bite anyone (be64 host
     seems unlikely for this old part).
 * stm32-adc
   - Add vdda-supply. On some boards it needs to be turned on to supply
     the ADC.  DT bindings included.
 * stm32-dfsdm
   - Fix output resolution to work with filter orders other than 3.
   - Fix output datatype as it's signed and previously claimed not to be.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAl0VHIkRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FojyxhAAgrLRy2wlHjQCAh0S6J22LKs02uPX1qvY
 nm1aI/av2DGcMCV2NF6J1sW2Mocvtt5a79/1f/wRqDzOHBrTpFr0Q0Ngwijv9bzc
 fv6NwfHlWolmXynKx8wK4b6Sa3KVCkltojEVpEVbhkuMkafSQ+pQzYF1Uf7enOrX
 j3Gq6NYaCks4YtFZsBphgzo3DC0mh7CfunlPiOdVcgcg4Pj/KZY9QCX86fJx972x
 YI3BRFHnDSMDOxOTjeqeKvMiqU2zLPlqLSEOCUw2XCrh6HI9qFiU+LVsYx6SP0tx
 aJ2q+qYc9raOTANHk7O2JZYWv/52JXvtKcFSLiuQdABjaAI20xEr1QAZYVYUiXmg
 dFH6lBsWvQyAy5F/SyZ5tavZvTfGsNDB5LhlpEggeO2W6cIIL4CLfHimB2EcxFSH
 utqEA72HQZosEUKut1jbmG6iYMiRnHS72pLOqkJ6HC/2/pZfoEWlEH9x/S3xbBsW
 918ISs9852VwjebQwck96+Dh0LwiKOl8Aii5ONzfNObJB6/JbULPoKKArsMdENQA
 mqDXLOMz6GspY3JgiVDCXAwg2x2Ht/ictR6svRJtOTLiBU2Iybpm/HRkPePhoePF
 HLw8fhwE+mOSWr22KhzjUJBHEAkoejo/14XOgKSTkO9V6amLlOWRDV3uK2PksmdI
 7DQyYhX9Tos=
 =a3vh
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-5.3b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

Second set of IIO device support, features, cleanups and minor fixes for 5.3.

A few bits for the counters subsystem mixed in here as well.
There are some late breaking fixes as well, which aren't so urgent
they can't wait for the merge window.

New Device Support
* adf4371
  - New driver + bindings.
  - Support the adf4372 PLL. Mostly ID and bindings.
* ad8366 (note includes rework of driver needed to allow support for these).
  - Support the ADL5240 variable gain amplifier (VGA).
  - Support the ADA4961 digital gain amplifier (DGA).
* dps310
  - New driver, in several parts from different authors for this temp
    and pressure sensor.
  - Includes errata workaround for a temperature reading issue.
* stk3310
  - Support the stk3335, mostly ID.

Features and cleanups
* core
  - drop error handling on debugfs registration.
  - harden by making sure we don't overrun iio_chan_info_postfix.
* docs
  - convert remaining docs to rst. At somepoint we'll fit these few
    into the main IIO docs.
  - improve sampling_frequency_available docs but explaining the
    range form.
* ad_sigma_delta
  - Drop a pointless goto.
* ad2s1210
  - Drop pointless platform data null check seeing as we don't actually
    use platform data anymore.
* ad7124
  - Relax limitation on channel numbers to allow pseudo different channels.
  - Support control of whether the input is buffered via DT.
  - Use dynamic allocation for channel configuration to make it easier
    to support new devices.
  - YAML binding conversion.
* ad7150
  - Comment tidy up.
  - Consistent and simple if (ret) handling of i2c errors.
  - FIELD_GET and GENMASK.
  - Ternary rather than !!(condition) for readability.
  - Use macros to avoid repetition of channel definitions.
* ad7606
  - Add software channel config (rather that pin controlled)
  - Refactor to simplify addition of new part in future.
* ad7746
  - of_deivce_id table.
* ad7780
  - MAINTAINERS entry
  - YAML DT bindings.
* ad8366
  - Stop using core mlock in favour of well scoped local lock.
  - SPDX + copyright date update.
* ad9834
  - of_device_id table
* adf4371
  - Add support for output stage muting before lock on has occured.
* adis library
  - MAINTAINERS entry to reflect that this now Alexandru's problem ;)
* adis162xx:
  - Fix a slightly incorrect set of comments and print statements on
    minimum supported voltage.
* adis16203
  - of_device_id table.
* adis16240
  - Add of_device_id table (in two parts as first patch only used it for
    MODULE_DEVICE_TABLE.)
* adt7316-spi
  - of_device_id table
* adxl372
  - YAML DT binding conversion.
  - Cleanup use of buffer callback functions (precursor to core rework).
* bh1710
  - Simplify getting the i2c adapter from the client.
* dht11
  - Mote to newer GPIO consumer interface.
* kxcjk-1013.c
  - Add binding for sensor in display of some ultrabooks after userspace
    tools updated for it not be a problem to report two similar sensors.
* imx7d
  - drop unused variables.
  - white space
  - define instead of variable for clock frequency that is fixed.
  - drop pointless error message.
* messon_saradc
  - SPDX
* sps30
  - MAINTAINERS entry
  - YAML binding conversion.
* st_accel
  - Tidy up ordering in various buffer related callbacks. This is
    part of a long running effort to simplify the core code.
* stm32-dfsdm:
  - Manage the resolution cleanly in triggerd modes.
  - Add fast mode support which allows more flexible filter choices.
  - Add a comment on the reason for a 16 bit record when technically
    not 'required'.
* st_lsm6dsx
  - Embed device name in the sensor_settings struct as i3c doesn't
    have a convenient name field to use for this.
* xilinx-adc
  - Relax constraints on supported platforms to reflect that this
    can used with FPGAs on PCIe cards and hence many architectures.
* counters/ftm-quaddec
  - Fix some formatting io MODULE_AUTHOR
  - MAINTAINERS entry

Fixes
* tools
  - fix incorrect handling of 32 bit channels.
* sca3000
  - Potential endian bug that is unlikely to bite anyone (be64 host
    seems unlikely for this old part).
* stm32-adc
  - Add vdda-supply. On some boards it needs to be turned on to supply
    the ADC.  DT bindings included.
* stm32-dfsdm
  - Fix output resolution to work with filter orders other than 3.
  - Fix output datatype as it's signed and previously claimed not to be.

* tag 'iio-for-5.3b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (68 commits)
  iio: iio-utils: Fix possible incorrect mask calculation
  iio: frequency: adf4371: Add support for output stage mute
  dt-bindings: iio: frequency: Add ADF4372 PLL documentation
  iio: frequency: adf4371: Add support for ADF4372 PLL
  dt-bindings: iio: adc: Add buffered input property
  Convert AD7124 bindings documentation to YAML format.
  iio: adc: ad7124: Shift to dynamic allocation for channel configuration
  iio: adc: ad7124: Add buffered input support
  iio: adc: ad7124: Remove input number limitation
  MAINTAINERS: add ADIS IMU driver library entry
  iio: adis162xx: fix low-power docs & reports
  counter/ftm-quaddec: Add missing '>' in MODULE_AUTHOR
  iio: core: no need to check return value of debugfs_create functions
  docs: iio: convert to ReST
  iio: adc: stm32-adc: add missing vdda-supply
  dt-bindings: iio: adc: stm32: add missing vdda supply
  iio: adc: stm32-dfsdm: add comment for 16 bits record
  iio: adc: stm32-dfsdm: add fast mode support
  iio: adc: stm32-dfsdm: manage data resolution in trigger mode
  iio: adc: stm32-dfsdm: fix data type
  ...
2019-07-01 10:58:13 +02:00
Linus Torvalds
db54615e21 Staging/IIO/Counter fixes for 5.2-rc6
Here are some small driver bugfixes for some staging/iio/counter
 drivers.
 
 Staging and IIO have been lumped together for a while, as those
 subsystems cross the areas a log, and counter is used by IIO, so that's
 why they are all in one pull request here.
 
 These are small fixes for reported issues in some iio drivers, the erofs
 filesystem, and a build issue for counter code.
 
 All have been in linux-next with no reported issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iGwEABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCXQyM7w8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ymBUwCYn7LKiishfnvx8PpGF1lGHNmtYACgrNoAWKRZ
 PUlOWXEbtD7NAPtqn3c=
 =tXAQ
 -----END PGP SIGNATURE-----

Merge tag 'staging-5.2-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging/IIO/counter fixes from Greg KH:
 "Here are some small driver bugfixes for some staging/iio/counter
  drivers.

  Staging and IIO have been lumped together for a while, as those
  subsystems cross the areas a log, and counter is used by IIO, so
  that's why they are all in one pull request here.

  These are small fixes for reported issues in some iio drivers, the
  erofs filesystem, and a build issue for counter code.

  All have been in linux-next with no reported issues"

* tag 'staging-5.2-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging:
  staging: erofs: add requirements field in superblock
  counter/ftm-quaddec: Add missing dependencies in Kconfig
  staging: iio: adt7316: Fix build errors when GPIOLIB is not set
  iio: temperature: mlx90632 Relax the compatibility check
  iio: imu: st_lsm6dsx: fix PM support for st_lsm6dsx i2c controller
  staging:iio:ad7150: fix threshold mode config bit
2019-06-21 10:20:19 -07:00
Thomas Gleixner
d2912cb15b treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500
Based on 2 normalized pattern(s):

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license version 2 as
  published by the free software foundation

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license version 2 as
  published by the free software foundation #

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Enrico Weigelt <info@metux.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-19 17:09:55 +02:00
Greg Kroah-Hartman
d7a5417b89 Second set of IIO fixes for the 5.2 cycle.
* ad7150
   - sense of bit for controlling adaptive vs fixed threshold was flipped.
 * adt7316
   - Fix a build issue due to wrong headers for gpio usage.
 * lsm6dsx
   - correctly suspend / resume i2c slaves when the host goes to sleep.
 * mlx90632
   - relax a compatability check to allow for newer devices.
 
 Also one counters fix
 
 * counter/ftm-quaddec
   - missing dependencies in Kconfig.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAl0H5PURHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0Foh7bhAAqF/VG9KhIioY4ov5U+Exh5OGzirhTLKC
 TyuK4fnSHO9avql1lTAc9b/tt2tBdE4f0vel6CSP+1GlbwfG01AYUu+ZW7j/GkgT
 D09o4IH1TspqH5nIc2JunZwYqPJG2v7Fis9IMtS13eTJ+csf9EhVCuIf8tnaPwyM
 /OH7t3JdSqxtsxHECEsZhl5IDrqZKyQI3+7MtlpcnuQpNjrrwxey4B54csZamUH8
 nhefM7CtI+roaT+Ydp5oNpvpVXhNH54rVKwEkJfeuhiuviHoO7SgUF59u4vp9JYa
 5dVo+T8+b2gsAt1w4jDCNDALTrFYL1d4XCyHuW+ZvpTGfb99E0g2QRStuBJp0Nyn
 9s9K05KTdcHi3HBUxx+pKh7MDUBzKSm5T5euq4ZHRUKF3vjfBhsoN4iVh31IHa53
 Nv28vnnxUd7RXHZonoi9wIT0zoDSY1IvpNGtwJaOjBJNcUjtDQivV2KqqvvvSfj0
 g7KswaUB5icRR/mtL4Jj2j0voD2e+mMXgknRmHJthXKBKzs4lQHFPqI1rZQy8DRg
 2YCi5zJNPBmf7hNbMqyt5YEkflZST3zzOUBRxdju4w3lwKZl6+bQd5B82ET6DZSr
 n99WXsGcdck/JEWomUhGb5uTbS2LAgsVLIXJTDzgzwQqE4Vp7FFYIHDNeTJx43Cm
 bEvNn0cT6a8=
 =2i3G
 -----END PGP SIGNATURE-----

Merge tag 'iio-fixes-for-5.2b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus

Jonathan writes:

Second set of IIO fixes for the 5.2 cycle.

* ad7150
  - sense of bit for controlling adaptive vs fixed threshold was flipped.
* adt7316
  - Fix a build issue due to wrong headers for gpio usage.
* lsm6dsx
  - correctly suspend / resume i2c slaves when the host goes to sleep.
* mlx90632
  - relax a compatability check to allow for newer devices.

Also one counters fix

* counter/ftm-quaddec
  - missing dependencies in Kconfig.

* tag 'iio-fixes-for-5.2b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio:
  counter/ftm-quaddec: Add missing dependencies in Kconfig
  staging: iio: adt7316: Fix build errors when GPIOLIB is not set
  iio: temperature: mlx90632 Relax the compatibility check
  iio: imu: st_lsm6dsx: fix PM support for st_lsm6dsx i2c controller
  staging:iio:ad7150: fix threshold mode config bit
2019-06-17 22:28:29 +02:00
Lorenzo Bianconi
81956a93b5 iio: imu: st_lsm6dsx: get device name from st_lsm6dsx_sensor_settings
Introduce sensor name in st_lsm6dsx_sensor_settings table. This is
a preliminary patch to add I3C support to st_lsm6dsx since i3c_device_id
data structure does not contain a name field

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-06-17 21:06:45 +01:00
Thomas Gleixner
36edc93958 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 330
Based on 1 normalized pattern(s):

  this file is subject to the terms and conditions of version 2 of the
  gnu general public license see the file copying in the main
  directory of this archive 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 55 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190530000436.108941081@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-05 17:37:06 +02:00
Thomas Gleixner
2025cf9e19 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 288
Based on 1 normalized pattern(s):

  this program is free software you can redistribute it and or modify
  it under the terms and conditions of the gnu general public license
  version 2 as published by the free software foundation this program
  is distributed in the hope 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 263 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190529141901.208660670@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-05 17:36:37 +02:00
Thomas Gleixner
9c92ab6191 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>
2019-06-05 17:36:37 +02:00
Linus Torvalds
2f4c533499 SPDX update for 5.2-rc3, round 1
Here is another set of reviewed patches that adds SPDX tags to different
 kernel files, based on a set of rules that are being used to parse the
 comments to try to determine that the license of the file is
 "GPL-2.0-or-later" or "GPL-2.0-only".  Only the "obvious" versions of
 these matches are included here, a number of "non-obvious" variants of
 text have been found but those have been postponed for later review and
 analysis.
 
 There is also a patch in here to add the proper SPDX header to a bunch
 of Kbuild files that we have missed in the past due to new files being
 added and forgetting that Kbuild uses two different file names for
 Makefiles.  This issue was reported by the Kbuild maintainer.
 
 These patches have been out for review on the linux-spdx@vger mailing
 list, and while they were created by automatic tools, they were
 hand-verified by a bunch of different people, all whom names are on the
 patches are reviewers.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCXPCHLg8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ykxyACgql6ktH+Tv8Ho1747kKPiFca1Jq0AoK5HORXI
 yB0DSTXYNjMtH41ypnsZ
 =x2f8
 -----END PGP SIGNATURE-----

Merge tag 'spdx-5.2-rc3-1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core

Pull yet more SPDX updates from Greg KH:
 "Here is another set of reviewed patches that adds SPDX tags to
  different kernel files, based on a set of rules that are being used to
  parse the comments to try to determine that the license of the file is
  "GPL-2.0-or-later" or "GPL-2.0-only". Only the "obvious" versions of
  these matches are included here, a number of "non-obvious" variants of
  text have been found but those have been postponed for later review
  and analysis.

  There is also a patch in here to add the proper SPDX header to a bunch
  of Kbuild files that we have missed in the past due to new files being
  added and forgetting that Kbuild uses two different file names for
  Makefiles. This issue was reported by the Kbuild maintainer.

  These patches have been out for review on the linux-spdx@vger mailing
  list, and while they were created by automatic tools, they were
  hand-verified by a bunch of different people, all whom names are on
  the patches are reviewers"

* tag 'spdx-5.2-rc3-1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (82 commits)
  treewide: Add SPDX license identifier - Kbuild
  treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 225
  treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 224
  treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 223
  treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 222
  treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 221
  treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 220
  treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 218
  treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 217
  treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 216
  treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 215
  treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 214
  treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 213
  treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 211
  treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 210
  treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 209
  treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 207
  treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 206
  treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 203
  treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 201
  ...
2019-05-31 08:34:32 -07:00
Linus Torvalds
2209a3055d Staging/IIO driver fixes for 5.2-rc3
Here are some Staging and IIO driver fixes to resolve some reported
 problems for 5.2-rc3.
 
 Nothing major here, just some tiny changes, full details are in the
 shortlog.
 
 All have been in linux-next for a while with no reported issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCXPCE/w8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ylLwQCdFRL6v7IHdGYQ6cAk/tjOcyYY0IEAoNRAdZU7
 n/JfHbtKvS7VpYzPzRvO
 =LjTj
 -----END PGP SIGNATURE-----

Merge tag 'staging-5.2-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging and IIO driver fixes from Greg KH:
 "Here are some Staging and IIO driver fixes to resolve some reported
  problems for 5.2-rc3.

  Nothing major here, just some tiny changes, full details are in the
  shortlog.

  All have been in linux-next for a while with no reported issues"

* tag 'staging-5.2-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging:
  staging: kpc2000: Add dependency on MFD_CORE to kconfig symbol 'KPC2000'
  staging: wilc1000: Fix some double unlock bugs in wilc_wlan_cleanup()
  staging: vc04_services: prevent integer overflow in create_pagelist()
  Staging: vc04_services: Fix a couple error codes
  staging: wlan-ng: fix adapter initialization failure
  staging: kpc2000: double unlock in error handling in kpc_dma_transfer()
  staging: kpc2000: Fix build error without CONFIG_UIO
  staging: kpc2000: fix build error on xtensa
  staging: erofs: set sb->s_root to NULL when failing from __getname()
  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-05-31 08:31:45 -07:00
Thomas Gleixner
fda8d26e61 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 177
Based on 1 normalized pattern(s):

  licensed under the gpl 2

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Richard Fontana <rfontana@redhat.com>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Reviewed-by: Steve Winslow <swinslow@gmail.com>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190528170026.071193225@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-30 11:29:19 -07:00
Thomas Gleixner
80503b23b2 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 149
Based on 1 normalized pattern(s):

  licensed under the gpl 2 or later

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-or-later

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Richard Fontana <rfontana@redhat.com>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190524100845.150836982@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-30 11:25:18 -07:00
Lorenzo Bianconi
bce0d57db3 iio: imu: st_lsm6dsx: fix PM support for st_lsm6dsx i2c controller
Properly suspend/resume i2c slaves connected to st_lsm6dsx master
controller if the CPU goes in suspended state

Fixes: c91c1c844e ("imu: st_lsm6dsx: add i2c embedded controller support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-05-27 10:52:30 +01:00
Thomas Gleixner
ec8f24b7fa treewide: Add SPDX license identifier - Makefile/Kconfig
Add SPDX license identifiers to all Make/Kconfig files which:

 - Have no license information of any form

These files fall under the project license, GPL v2 only. The resulting SPDX
license identifier is:

  GPL-2.0-only

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-21 10:50:46 +02:00
Greg Kroah-Hartman
083a685c2e 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.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAlzhFEARHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FojNMg//SCVSRt1KmsRDNdtCyUtgrs2BMISBQ5zP
 XpDvHajk9lPJvt/rbdKNJPC23N0qjV0fIfaMjsN1mTrbeL3JQE7r+17iCJ1EL+dj
 H2BFQlzMN9bPt9wx/VeQnTqPiTuwNpB5/eNb3mfGKGDkKmmfnL0+DDJEQycBgfK7
 gRgX4XGsMYLmKPAJvrQdSvMvu0V8UTAkZNBdcMydhl9Jba9elXPqI5kYFi7pNajD
 09fAGKhkeHd9whRNa2O6wKyRXh+c7regPAMtwjwlmv4dsmRHocYeLQOI05guuKf1
 /+0I+ptOf8RRHGOFX8j7rXua9Q2B+SzXsmoH4RlJLb23Jcqz7/ZDfcAGGVPndlME
 R3vGsYsoSLkmbRkVQ9ygDrzRsNnFKw/pR+u+zKdi/DH3C9EUI5JmRAkJSloElmrr
 VE1ZC7HXxUiKjfZaBLFeuugt65QGfxsGp+UsuFIgg0WQGk7yVWdC8RL9SZUy3wEq
 xFcfiWfbJp/LnVjs6aUBAV8cROswBv/ebcQZgOSPC/j8HyU6xRzmXVt4urBVwKVd
 gr3G+w7JhxCyByXJp7vqFtOmYeHB1X1UY8GNzgxsz9q2A1wtlEsXGpIh/arDY4r9
 toiSQAPAoVRBoLYfj+32EWgPR0iahjE81QZwWAqSzgBmompTQ1ByAyieOC4whgOe
 Lau/nLtAvGU=
 =nq1b
 -----END PGP SIGNATURE-----

Merge tag 'iio-fixes-for-5.2a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus:

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-05-20 09:15:14 +02:00
Lorenzo Bianconi
b9fedb0a17 iio: imu: st_lsm6dsx: inline per-sensor data
As it has been already done for other st sensors in 'commit 9049531c91
("iio: accel: st_accel: inline per-sensor data")', get rid of some
defines and just open code the values into the appropriate struct
elements since the semantic meaning is inherent in the name of the
C99-addressable fields and there is no reason to duplicate the code

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-22 11:34:14 +01:00
YueHaibing
631bd2f7ec iio: imu: st_lsm6dsx: remove set but not used variables 'acc_sensor' and 'gyro_sensor'
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c: In function 'st_lsm6dsx_read_tagged_fifo':
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c:520:41: warning:
 variable 'gyro_sensor' set but not used [-Wunused-but-set-variable]

drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c:520:28: warning:
 variable 'acc_sensor' set but not used [-Wunused-but-set-variable]

They are not used since commit 14c7c6e1a8 ("iio: imu: st_lsm6dsx: add
st_lsm6dsx_push_tagged_data routine")

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-14 13:39:30 +01:00
Steve Moskovchenko
1615fe41a1 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: 22904bdff9 ("iio: imu: mpu6050: Add support for the ICM 20602 IMU")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-14 11:45:01 +01:00
Lorenzo Bianconi
43901008fd iio: imu: st_lsm6dsx: add support to LSM6DSR
Add support to STM LSM6DSR 6-axis (acc + gyro) Mems sensor
https://www.st.com/resource/en/datasheet/lsm6dsr.pdf

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-07 11:29:43 +01:00
Alexandru Ardelean
3cb5161317 iio: imu: adis16400: move adis16400.h into adis16400.c
Final part of the re-organization. Move the `adis16400.h` into
`adis16400.c` since it no longer needs to be shared among other files.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04 20:20:28 +01:00
Alexandru Ardelean
5447e3f15c iio: imu: adis16400: rename adis16400_core.c -> adi16400.c
This change does a simple 1-to-1 rename of the adis16400_core.c file. Now
that the `adis16400_buffer.c` file was removed, everything can be moved
into a single driver file.
But first, this rename.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04 20:20:27 +01:00
Alexandru Ardelean
0e92e2d036 iio: imu: adis16400: move burst logic to ADIS lib
This change has been done separately, so that it's easier to visualize the
changed logic in the adis_scan_update() function.

Most of the function in this `adis16400_update_scan_mode()` that deals with
burst-mode will be re-used in the ADIS16480, but with different parameters.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04 20:20:26 +01:00
Alexandru Ardelean
5075e0720d iio: imu: adis: generalize burst mode support
Some variants in the ADIS16400 family support burst mode. This mechanism is
implemented in the `adis16400_buffer.c` file.

Some variants in ADIS16480 are also adding burst mode, which is
functionally similar to ADIS16400, but with different parameters. To get
there, a `adis_burst` struct is added to parametrize certain bits of the
SPI communication to setup: the register that triggers burst-mode, and the
extra-data-length that needs be accounted for when building the bust-length
buffer.

The trigger handler cannot be made generic, since it's very specific to
each ADIS164XX family.

A future enhancement of this `adis_burst` mode will be the possibility to
enable/disable burst-mode. For the ADIS16400 family it's hard-coded to on
by default. But for ADIS16480 there will be a need to disable this.

When that will be implemented, both ADIS16400 & ADIS16480 will have the
burst-mode enable-able/disable-able.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04 20:20:24 +01:00
Alexandru Ardelean
74878d4fa8 iio: imu: adis16400: move trigger handler into adis16400_core
The trigger handler for the ADIS16400 is very different from the generic
one in the ADIS library. Keeping it in a separate file won't make much
sense once the update_scan_mode function will be made more generic and
moved into the ADIS library.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04 20:20:23 +01:00
Lorenzo Bianconi
6af0e8a9a7 iio: imu: st_lsm6dsx: add support to LSM6DSOX
Add support to STM LSM6DSOX 6-axis (acc + gyro) Mems sensor
https://www.st.com/resource/en/datasheet/lsm6dsox.pdf

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04 20:20:00 +01:00
Stefan Popa
326e235755 iio: imu: adis16480: Add support for external clock
Inertial sensor data collection and processing can be controlled by
configuring one of the DIOx lines as an external clock input. This
option is available for all devices supported by this driver. However,
only adis1649x devices support different modes for the external clock.

Sync mode is supported by all devices. In this mode, the output data
rate is equal with the clock frequency divided by DEC_RATE + 1. This
mode of calculation is similar with the case when the internal clock is
used.

Pulse Per Second (PPS) Mode, is only supported by adis1649x devices. In
this mode, the output data rate is equal to the product of the external
clock frequency and the scale factor in the SYNC_SCALE register.

This patch uses the "clock-names" property to enable the external clock
in one of the two supported modes: "sync" or "pps". This property is
optional. If it is not specified, the internal clock is used.

This patch also offers the option to select the DIOx line to be used as
an external clock input via the custom "adi,ext-clk-pin" property. If this
field is left empty, DIO2 is assigned as default external clock input pin.
Each DIOx pin supports only one function at a time (data ready line
selection or external clock input).

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04 20:19:57 +01:00
Lorenzo Bianconi
3054c4ff28 iio: imu: st_lsm6dsx: add support to ASM330LHH
Add support to STM ASM330LHH 6-axis (acc + gyro) Mems sensor
https://www.st.com/resource/en/datasheet/asm330lhh.pdf

Tested-by: Mario Tesi <mario.tesi@st.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04 20:19:49 +01:00
H. Nikolaus Schaller
28799ceac0 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>
2019-04-04 20:19:48 +01:00
Andy Shevchenko
fb1589710e 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>
2019-04-04 20:19:46 +01:00
Stefan Popa
82e7a1b250 iio: imu: adis16480: Add support for ADIS1649x family of devices
The ADIS16495 and ADIS16497 are inertial systems that include a triaxis
gyroscope and a triaxis accelerometer. The serial peripheral interface
(SPI) provide a simple interface for data collection and configuration
control. The devices are similar to ADIS16475, ADIS16480, ADIS16485 and
ADIS16488, the main differences are highlighted below:

* The temperature data scale is 0.00565 C/LSB for ADIS16475 and ADIS1648x
  devices, while for ADIS1649x 0.0125 C/LSB.

* ADIS1649x devices support different gyroscope measurement ranges which
  are dependent on the dash number (-1, -2, -3), see Table 24 in the
  ADIS16495 datasheet. However, the ADIS16497 gyroscopes have the same
  scale as ADIS16495.

* ADIS16495 devices support the acceleration maximum range of 8g, while
  ADIS16497 devices go up to 40g.

* The internal clock for ADIS1649x devices is 4.25 kSPS. The sampling
  frequency is calculated by applying a decimation rate which can take a
  maximum value of 4250.

* ADIS1649x devices support different default filter frequencies.

Datasheets:
Link: https://www.analog.com/media/en/technical-documentation/data-sheets/adis16495.pdf
Link: https://www.analog.com/media/en/technical-documentation/data-sheets/adis16497.pdf

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04 20:19:43 +01:00
Stefan Popa
83ec2d5404 iio: imu: adis16480: Deal with filter freq in a generic way
When setting the filter frequency, the driver looks into the
adis16480_def_filter_freqs table for the best match. Pass this table to
the chip_info struct since future devices will need to use a different
table.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04 20:19:43 +01:00
Stefan Popa
e0e6398e1e iio: imu: adis16480: Calculate the sampling frequency in a generic way
The adis1648x devices have an internal clock of 2.46 kSPS. The sampling
frequency is calculated by applying a decimation rate which can take the
maximum value of 2047.

Although all adis1648x devices are similar in this regard, devices that
will use this feature will be added in the future.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04 20:19:43 +01:00
Stefan Popa
6cf7b866bd iio: imu: adis16480: Treat temperature scale in a generic way
All supported devices provide internal temperature measurement from -40 C
to +85 C, with +25 C representing value 0x00.

This patch treats the temperature scale in a generic way, similar to the
accelerometer and gyroscope scales. So far, there are no temperature max
scale differences between the supported devices. However, devices that
will make use of this feature will be added in the future.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04 20:19:42 +01:00
Stefan Popa
304840c476 iio: imu: adis16480: Add OF device ID table
The driver does not have a struct of_device_id table, but supported
devices are registered via Device Trees. This patch adds OF device ID
table.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04 20:19:42 +01:00
Stefan Popa
cede2f899d iio: imu: adis16480: Add support for configurable drdy indicator
The FNCTIO_CTRL register provides configuration control for each I/O pin
(DIO1, DIO2, DIO3 and DIO4).

This patch adds the option to configure each DIOx pin as data ready
indicator with positive or negative polarity by reading the 'interrupts'
and 'interrupt-names' properties from the devicetree. The
'interrupt-names' property is optional, if it is not specified, then the
DIO1 pin is used as default data ready signal.

Although the factory default assigns DIO2 as data ready signal, in the
versions previous this patch, DIO1 pin was used. We should leave this
configuration as is, since some devices might be expecting the interrupt
on the wrong physical pin.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04 20:19:42 +01:00
Martin Kelly
94edaac707 iio:bmi160: use if (ret) instead of if (ret < 0)
We are using "if (ret < 0)" in many places in which the function returns 0
on success. Use "if (ret)" instead for better clarity and correctness.

Signed-off-by: Martin Kelly <martin@martingkelly.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-09 15:25:25 +00:00
Martin Kelly
0a3f50e4d6 iio:bmi160: use iio_pollfunc_store_time
Currently, we snap the timestamp after reading from the buffer and
processing the event. When the IIO poll function is triggered by an
interrupt,  we can get a slightly more accurate timestamp by snapping it
prior to reading the data, since the data was already generated prior to
entering the trigger handler. This is not going to make a huge difference,
but we might as well improve slightly.

Do this by using iio_pollfunc_store_time as other drivers do.

Signed-off-by: Martin Kelly <martin@martingkelly.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-09 15:24:27 +00:00
Martin Kelly
895bf81e6b iio:bmi160: add drdy interrupt support
Add interrupt support for the data ready signal on the BMI160, which fires
an interrupt whenever new accelerometer/gyroscope data is ready to read.

Signed-off-by: Martin Kelly <martin@martingkelly.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-09 15:14:42 +00:00
Martin Kelly
3740232925 iio:bmi160: add SPDX identifiers
Add SPDX identifiers (GPL 2) for the BMI160 driver. bmi160.h had an
identifier, but the other files did not.

Signed-off-by: Martin Kelly <martin@martingkelly.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-09 14:48:33 +00:00
Greg Kroah-Hartman
1dcc3ed4a7 First set of new device support, features and cleanup for IIO in the 5.1 cycle
A number of interesting new devices supported plus a good set of staging
 cleanup including one graduation and one drop.
 
 New device support
 * ad56886
   - Add support for AD5674R/AD5679R with some minor driver changes to support
     more channels.
 * ad7768
   - New driver and dt bindings for this 24 bit ADC.
 * max44009
   - New driver and dt bindings for this ambient light sensor.
 * mpu6050
   - Support the ICM 20602 IMU. Minor tweaks due to slightly different
     register map.
 * NPCM adc
   - New driver and dt bindings for this BMC ADC.
 * Sensiron SGP30
   - Modifiers for ethanol and H2.
   - New driver and dt bindings.
   - Follow patch added self cleaning support.
 * Sensiron SPS30
   - New channel type for mass concentration.
   - New driver and bindings.
   - Minor tidy up patch followed (drop fmt specifier as unused)
 * st_pressure
   - lps22hh support. ID plus information structures and dt bindings.
 * ti-ads124s08
   - Add binding doc and driver.
 
 Staging graduations
 * ad7606 driver and bindings.
 
 Staging drops
 * ad7152 CDC driver dropped.  This part is near EoL and no one is known
   to be using it.  If anyone surfaces obviously we can bring the driver
   back.  If not, good to drop it to avoid wasting anyone's time cleaning
   it up.
 
 New features
 * bme680
   - DT support and bindings doc.
 * isl29018
   - Add regulator for VCC.
 * mag3110
   - Add regulators for supplies.
 * meson-saradc
   - Support the temperature sensors of more SoCs.
 * mma8452
   - Add regulators for power suplies and binding docs to reflect them.
 * st-accel
   - Support the undocumented but it seems fairly common _ONT ACPI method
     to specify orientation of the sensor.
 
 Cleanup, minor fixes and fixes for staging driver that have been broken a
 long time
 * ad5933
   - Drop platform data alternative to specifying the reference voltage
     using a regulator.
   - Use the clock framework to contorl the reference clock.
   - Add a DT binding doc to cover the defacto binding.
 * ad7280a
   - Split up some big functions to improve readability.
 * ad7606
   - Allow for timeout if interrupt never occurs.
   - Use devm functions to simplify probe and remove.
   - Use the find_closest macro to avoid need for precise values from
     userspace.
   - Add missing vendor prefixes for various DT properties. Note the
     driver is in staging still and there are no known devicetrees.
   - Add explict OF device ID table.
   - Simplify the Kconfig choices
   - Change to a threaded IRQ.
   - SPDX and simple stype fixes.
 * ad7816
   - Drop unnecessary variable init.
 * ad9523
   - Check a return value that was ignored.
 * ad9833
   - Drop platform data.  It was just setting most values to the hardware
     defaults.
   - Use the clock framework to provide the input clock.
 * adt7316 (lots of staging cleanup)
   - Fix some wrong register / bit definitions
   - Invert the logic of the check for an ldac pin so it actually makes sense.
   - Read the right register to get internal vref settings
   - Allow adt751x chips to use the internal vref for all DAC channels rather
     than a subset.
   - Remove dac vref bypass control from parts that don't have one.
   - Make the store DAC update mode function consistent with the show one.
   - Fix some spellings and other minor tidy up.
   - Avoid passing irq numbers around by putting all the irq logic in
     one place.
   - Fix an issue with the resolution of DAC control.
   - Fix support of the high resolution DAC mode (for temp proportional output)
     where supported.
   - Fix DAC read and write calculations.
 * st_lsm6dsx
   - Drop an unused variable (set but not read)
 * xilinx-xadc
   - Check an unhandled return value.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAlxXWXwRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FogtPhAAtGoXJl9gwBywQXjykFBiN5PxBxKypq58
 El7EQY7I0P/RkIVEBHgIc9p85lREVkIZQEcQZqsO5LI63cumCGtODyJg2CAF6+oz
 EIO0GCZFvb2zLiTyPg2NSuBhsYxiLtyHfu5MGPivbDyzVKZzf8LLjwQxkHYPaLzb
 Qa9D3wigoGHuvXpC9ULGQT36kMj6XPN9JGQsCRtbUQVgPu2XOPiuLv98vEpyaCPj
 1C7D72LAEq1Z5A3rA17KpT576Yy1JGv1LkSz48xEtHlDoB2IgCkoZfx6ThTr1ehX
 eWav1NsD1IpbWKiSY19rSmjSkkbYk1WHyV+tTeTguFb6nfIA/y22kl9td8Rqjk2P
 L/O1tRHdXO8G+gtCfBhUdVmT1SQq/vkow2UBH59CllN81bsWxFEudE4VHJCBlmjr
 sgMKdb3d0aYekRis/bNQJMvT0nY2x+g2k+ey+kEnrYOZVjCx+EeNNS249CnUnFId
 ZZNGqJ2j0xK9BULqffcupCoERLIhf/9nlx5JO3n5YA5X3pdns+yzVkS/9oXpN7EK
 9A41pU9zVWYN8B21MqfN0EPG41nkY36TOuTvL2/4/U2DfAD6VIf4vEYimrkTjsU0
 n7vKqQL8DRicWDsbxP8h6u/nG0u+ZgOgY4SVzth0aT3/plCAwhWmoQpnkjVFKMBD
 HBQB0HlEg2M=
 =M03w
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-5.1a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

First set of new device support, features and cleanup for IIO in the 5.1 cycle

A number of interesting new devices supported plus a good set of staging
cleanup including one graduation and one drop.

New device support
* ad56886
  - Add support for AD5674R/AD5679R with some minor driver changes to support
    more channels.
* ad7768
  - New driver and dt bindings for this 24 bit ADC.
* max44009
  - New driver and dt bindings for this ambient light sensor.
* mpu6050
  - Support the ICM 20602 IMU. Minor tweaks due to slightly different
    register map.
* NPCM adc
  - New driver and dt bindings for this BMC ADC.
* Sensiron SGP30
  - Modifiers for ethanol and H2.
  - New driver and dt bindings.
  - Follow patch added self cleaning support.
* Sensiron SPS30
  - New channel type for mass concentration.
  - New driver and bindings.
  - Minor tidy up patch followed (drop fmt specifier as unused)
* st_pressure
  - lps22hh support. ID plus information structures and dt bindings.
* ti-ads124s08
  - Add binding doc and driver.

Staging graduations
* ad7606 driver and bindings.

Staging drops
* ad7152 CDC driver dropped.  This part is near EoL and no one is known
  to be using it.  If anyone surfaces obviously we can bring the driver
  back.  If not, good to drop it to avoid wasting anyone's time cleaning
  it up.

New features
* bme680
  - DT support and bindings doc.
* isl29018
  - Add regulator for VCC.
* mag3110
  - Add regulators for supplies.
* meson-saradc
  - Support the temperature sensors of more SoCs.
* mma8452
  - Add regulators for power suplies and binding docs to reflect them.
* st-accel
  - Support the undocumented but it seems fairly common _ONT ACPI method
    to specify orientation of the sensor.

Cleanup, minor fixes and fixes for staging driver that have been broken a
long time
* ad5933
  - Drop platform data alternative to specifying the reference voltage
    using a regulator.
  - Use the clock framework to contorl the reference clock.
  - Add a DT binding doc to cover the defacto binding.
* ad7280a
  - Split up some big functions to improve readability.
* ad7606
  - Allow for timeout if interrupt never occurs.
  - Use devm functions to simplify probe and remove.
  - Use the find_closest macro to avoid need for precise values from
    userspace.
  - Add missing vendor prefixes for various DT properties. Note the
    driver is in staging still and there are no known devicetrees.
  - Add explict OF device ID table.
  - Simplify the Kconfig choices
  - Change to a threaded IRQ.
  - SPDX and simple stype fixes.
* ad7816
  - Drop unnecessary variable init.
* ad9523
  - Check a return value that was ignored.
* ad9833
  - Drop platform data.  It was just setting most values to the hardware
    defaults.
  - Use the clock framework to provide the input clock.
* adt7316 (lots of staging cleanup)
  - Fix some wrong register / bit definitions
  - Invert the logic of the check for an ldac pin so it actually makes sense.
  - Read the right register to get internal vref settings
  - Allow adt751x chips to use the internal vref for all DAC channels rather
    than a subset.
  - Remove dac vref bypass control from parts that don't have one.
  - Make the store DAC update mode function consistent with the show one.
  - Fix some spellings and other minor tidy up.
  - Avoid passing irq numbers around by putting all the irq logic in
    one place.
  - Fix an issue with the resolution of DAC control.
  - Fix support of the high resolution DAC mode (for temp proportional output)
    where supported.
  - Fix DAC read and write calculations.
* st_lsm6dsx
  - Drop an unused variable (set but not read)
* xilinx-xadc
  - Check an unhandled return value.

* tag 'iio-for-5.1a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (67 commits)
  iio: chemical: sps30: remove printk format specifier
  staging: iio: frequency: ad9833: Load clock using clock framework
  staging: iio: frequency: ad9833: Get frequency value statically
  dt-bindings: iio: light: Add max44009
  iio: light: add driver for MAX44009
  dt-bindings: iio: adc: Add docs for AD7768-1
  iio: adc: Add AD7768-1 ADC basic support
  staging: iio: cdc: ad7152: remove driver completely
  iio: imu: mpu6050: Add support for the ICM 20602 IMU
  dt-bindings: iio: imu: add icm20602 bindings to mpu6050
  dt-bindings: iio: pressure: add LPS22HH bindings
  iio: st_accel: use ACPI orientation data
  iio: adc: add NPCM ADC driver
  dt-binding: iio: add NPCM ADC documentation
  iio: chemical: sps30: allow changing self cleaning period
  dt-bindings: iio: chemical: Add bindings for bme680
  iio: chemical: bme680: Add device-tree support
  iio:st_pressure:initial lps22hh sensor support
  iio: accell: mma8452: add vdd/vddio regulator operation support
  dt-bindings: iio: accel: mma8452: add power supplies property
  ...
2019-02-04 07:06:36 +01:00
Randolph Maaßen
22904bdff9 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>
2019-02-02 09:52:21 +00:00
Linus Torvalds
02061181d3 Staging/IIO driver patches for 4.21-rc1
Here is the big staging and iio driver pull request for 4.21-rc1.
 
 Lots and lots of tiny patches here, nothing major at all.  Which is
 good, tiny cleanups is nice to see.  No new huge driver removal or
 addition, this release cycle, although there are lots of good IIO driver
 changes, addtions, and movement from staging into the "real" part of the
 kernel, which is always great.
 
 Full details are in the shortlog, and all of these have been in
 linux-next for a while with no reported issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCXCY93w8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ymJRwCfeV0x/+IMS0UGh9ltHnUfCfR9bcgAmgPWMPnY
 bauRCLkceTjzODOR4SzH
 =o6Fs
 -----END PGP SIGNATURE-----

Merge tag 'staging-4.21-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging/IIO driver updates from Greg KH:
 "Here is the big staging and iio driver pull request for 4.21-rc1.

  Lots and lots of tiny patches here, nothing major at all. Which is
  good, tiny cleanups is nice to see. No new huge driver removal or
  addition, this release cycle, although there are lots of good IIO
  driver changes, addtions, and movement from staging into the "real"
  part of the kernel, which is always great.

  Full details are in the shortlog, and all of these have been in
  linux-next for a while with no reported issues"

* tag 'staging-4.21-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (553 commits)
  staging: mt7621-mmc: Correct spelling mistakes in comments
  staging: wilc1000: fix missing read_write setting when reading data
  mt7621-mmc: char * array declaration might be better as static const
  mt7621-mmc: return statement in void function unnecessary
  mt7621-mmc: Alignment should match open parenthesis
  mt7621-mmc: Removed unnecessary blank lines
  mt7621-mmc: Fix some coding style issues
  staging: android: ashmem: doc: Fix spelling
  staging: rtl8188eu: cleanup brace coding style issues
  staging: rtl8188eu: add spaces around '&' in rtw_mlme_ext.c
  staging: rtl8188eu: change return type of is_basicrate() to bool
  staging: rtl8188eu: simplify null array initializations
  staging: rtl8188eu: change order of declarations to improve readability
  staging: rtl8188eu: make some arrays static in rtw_mlme_ext.c
  staging: rtl8188eu: constify some arrays
  staging: rtl8188eu: convert unsigned char arrays to u8
  staging: rtl8188eu: remove redundant declaration in rtw_mlme_ext.c
  staging: rtl8188eu: remove unused arrays WFD_OUI and WMM_INFO_OUI
  staging: rtl8188eu: remove unnecessary parentheses in rtw_mlme_ext.c
  staging: rtl8188eu: remove unnecessary comments in rtw_mlme_ext.c
  ...
2018-12-28 20:39:58 -08:00
YueHaibing
6a4b8937a3 iio: imu: st_lsm6dsx: remove set but not used variable ''
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c: In function 'st_lsm6dsx_shub_read_reg':
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c:108:41: warning:
 variable 'hub_settings' set but not used [-Wunused-but-set-variable]

It never used since introduction in commit c91c1c844e ("iio: imu: st_lsm6dsx:
add i2c embedded controller support")

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Acked-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-22 16:58:14 +00:00
Martin Kelly
6e9982918c iio: bmi160: use all devm functions in probe
Currently, we're using the devm version of some but not all functions.
Switch to the devm version of iio_triggered_buffer_setup and
iio_device_register to simplify the code a bit and decrease the chance of
bugs.

Signed-off-by: Martin Kelly <martin@martingkelly.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-10 21:15:41 +00:00
Andy Shevchenko
e278558a1f iio: inv_mpu6050: Use i2c_acpi_get_i2c_resource() helper
ACPI provides a generic helper to get I2C Serial Bus resources.
Use it instead of open coded variant.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-03 21:40:03 +02:00
Lorenzo Bianconi
3aed83caa2 iio: imu: st_lsm6dsx: do not use a fixed read len in read_oneshot
Generalize st_lsm6dsx_shub_read_oneshot in order to not use a fixed
read length and take into account iio channel realbits for single
read operations

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-25 14:06:30 +00:00
Lorenzo Bianconi
6d0205fd1e iio: imu: st_lsm6dsx: add hw FIFO support to i2c controller
Introduce hw FIFO support to lsm6dsx i2c controller.
st_lsm6dsx sensor-hub relies on SLV0 for slave configuration since SLV0
is the only channel that can be used to write into i2c slave devices.
SLV{1,2,3} channels are used to read external data and push them into
the hw FIFO

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-16 18:32:34 +00:00
Lorenzo Bianconi
14c7c6e1a8 iio: imu: st_lsm6dsx: add st_lsm6dsx_push_tagged_data routine
Introduce st_lsm6dsx_push_tagged_data routine to push samples
to iio buffers. st_lsm6dsx_push_tagged_data will be reused adding
hw fifo support to st_lsm6dsx i2c embedded controller in order to
improve code readability

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-16 18:32:34 +00:00
Lorenzo Bianconi
c91c1c844e iio: imu: st_lsm6dsx: add i2c embedded controller support
i2c controller embedded in lsm6dx series can connect up to four
slave devices using accelerometer sensor as trigger for i2c
read/write operations.
Introduce sensor hub support for lsm6dso sensor. Add register map
for lis2mdl magnetometer sensor.
In order to perform single read/write operations st_lsm6dsx driver
relies on SLV0 channel (hw FIFO is not supported yet)

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-16 18:32:33 +00:00
Lorenzo Bianconi
1775044356 iio: imu: st_lsm6dsx: introduce st_lsm6dsx_sensor_set_enable routine
Add st_lsm6dsx_sensor_set_enable routine and remove
st_lsm6dsx_sensor_{enable/disable} ones in order to make the code more
readable and remove unnecessary functions

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-16 18:32:33 +00:00
Lorenzo Bianconi
6ffb55e500 iio: imu: st_lsm6dsx: introduce ST_LSM6DSX_ID_EXT sensor ids
Add ST_LSM6DSX_ID_EXT{0,1,2} sensor ids as reference for slave devices
connected to st_lsm6dsx i2c controller. Moreover introduce odr dependency
between accel and ext devices since i2c embedded controller relies on the
accelerometer sensor as bus read/write trigger so we need to enable accel
device at odr = max(accel_odr, ext_odr) in order to properly communicate
with i2c slave devices

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-16 18:32:33 +00:00
Lorenzo Bianconi
d40464f30d iio: imu: st_lsm6dsx: remove static from st_lsm6dsx_set_watermark
Remove static qualifier from st_lsm6dsx_set_watermark routine in
order to be reused supporting st_lsm6dsx i2c controller

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-16 18:32:32 +00:00
Lorenzo Bianconi
19435425f2 iio: imu: st_lsm6dsx: reload trimming parameter at bootstrap
Perform a complete device reset at bootstrap reloading trimming parameter
after sw reset is completed. Device sw reset/boot is explained here:
https://www.st.com/resource/en/application_note/dm00517282.pdf,
section 5.7

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-16 18:32:32 +00:00
Lorenzo Bianconi
739aff87a8 iio: imu: st_lsm6dsx: introduce locked read/write utility routines
Add st_lsm6dsx_update_bits_locked, st_lsm6dsx_read_locked and
st_lsm6dsx_write_locked utility routines in order to guarantee
the bus access is atomic respect to reg page configuration.
This is a preliminary patch to add i2c sensor hub support since
i2c master registers are accessed through a reg page multiplexer

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-16 18:32:32 +00:00
Greg Kroah-Hartman
7dc074348e Merge 4.19-rc4 into staging-next
Handle the merge issues and take the iio and staging driver fixes.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-16 22:04:13 +02:00
Lorenzo Bianconi
801a6e0af0 iio: imu: st_lsm6dsx: add support to LSM6DSO
Add support to STM LSM6DSO 6-axis (acc + gyro) Mems sensor
https://www.st.com/resource/en/datasheet/lsm6dso.pdf

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-09-02 21:30:47 +01:00
Lorenzo Bianconi
5b3c87fd92 iio: imu: st_lsm6dsx: add addr/max_word_len to st_lsm6dsx_read_block()
Add reg addr and max_word_len parameters to st_lsm6dsx_read_block
since LSM6DSO will use a different register address to read samples
from the FIFO and a different sample len

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-09-02 21:29:24 +01:00
Lorenzo Bianconi
54a6d0c688 iio: imu: st_lsm6dsx: make st_lsm6dsx_check_odr() non-static
Remove static qualifier from st_lsm6dsx_check_odr() definition in order to
use it for the support of new devices

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-09-02 21:28:48 +01:00
Lorenzo Bianconi
50ff457d1b iio: imu: st_lsm6dsx: add read_fifo callback to fifo_ops
Remove static qualifier from st_lsm6dsx_read_fifo definition and
introduce read_fifo function pointer in fifo_ops data structure
in order to run the proper read_fifo routine since other compliant
devices will use a different FIFO queueing scheme.

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-09-02 21:26:38 +01:00
Lorenzo Bianconi
a13bf65f3f iio: imu: st_lsm6dsx: take into account ts samples in wm configuration
Take into account hw timer samples in pattern length computation done
in st_lsm6dsx_update_watermark routine for watermark configuration.
Moreover use samples in pattern (sip) already computed in
st_lsm6dsx_update_decimators routine

Fixes: 213451076b ("iio: imu: st_lsm6dsx: add hw timestamp support")
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-09-02 21:19:53 +01:00
Brian Masney
07c12b1c00 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>
2018-08-18 18:11:46 +01:00
Greg Kroah-Hartman
3ceefa3ffd Second set of IIO new device support, features and cleanups.
There are also a couple of fixes that can wait for the coming merge
 window.
 
 Core new features
 
 * Support for phase channels (used in time of flight sensors amongst
   other things)
 * Support for deep UV light channel modifier.
 
 New Device Support
 
 * AD4758 DAC
   - New driver and dt bindings.
 * adxl345
   - Support the adxl375 +-200g part which is register compatible.
 * isl29501 Time of flight sensor.
   - New driver
 * meson-saradc
   - Support the Meson8m2 Socs - right now this is just an ID, but there will
     be additional difference in future.
 * mpu6050
   - New ID for 6515 variant.
 * si1133 UV sensor.
   - New driver
 * Spreadtrum SC27xx PMIC ADC
   - New driver and dt bindings.
 
 Features
 
 * adxl345
   - Add calibration offset readback and writing.
   - Add sampling frequency control.
 
 Fixes and Cleanups
 
 * ad5933
   - Use a macro for the channel definition to reduce duplication.
 * ad9523
   - Replace use of core mlock with a local lock. Part of ongoing efforts
     to avoid confusing the purpose of mlock which is only about iio core
     state changes.
   - Fix displayed phase which was out by a factor of 10.
 * adxl345
   - Add a link to the datasheet.
   - Rework the use of the address field in the chan_spec structures to
     allow addition of more per channel information.
 * adis imu
   - Mark switch fall throughs.
 * at91-sama5d2
   - Fix some casting on big endian systems.
 * bmp280
   - Drop some DT elements that aren't used and should mostly be done from
     userspace rather than in DT.
 * hx711
   - add clock-frequency dt binding and resulting delay to deal with capacitance
     issue on some boards.
   - fix a spurious unit-address in the example.
 * ina2xx
   - Avoid a possible kthread_stop with a stale task_struct.
 * ltc2632
   - Remove some unused local variables (assigned but value never used).
 * max1363
   - Use device_get_match_data to remove some boilerplate.
 * mma8452
   - Mark switch fall throughs.
 * sca3000
   - Fix a missing return in a switch statement (a bad fallthrough
     previously!)
 * sigma-delta-modulator
   - Drop incorrect unit address from the DT example.
 * st_accel
   - Use device_get_match_data to drop some boiler plate.
   - Move to probe_new for i2c driver as second parameter not used.
 * st_sensors library
   - Use a strlcpy (safe in this case).
 * st_lsm6dsx
   - Add some error logging.
 * ti-ads7950
   - SPDX
   - Allow simultaneous buffered and polled reads. Needed on a Lego Mindstorms
     EV3 where some channels are used for power supply monitoring at a very low
     rate.
 * ti-dac5571
   - Remove an unused variable.
 * xadc
   - Drop some dead code.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAltXZAkRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FohYZQ//VAjpDBYjLzYTvTJy5bDt61fbh8KabhBf
 oxLIpwYrCeleLnpbrY7nU8shdIL7Vm755jtsHbTtQPCKSQ0RGnhLLDoqoWcmn70J
 rF9iVaSv+S2lZO+9+hv2eeqyX+kSM+74fkWRuLmDbaSZWYO4Jt9zFER1zizmPypY
 DnxLcViw1kwOLbiZKwmcaK0MqlWHRPhEEcNVKy7VGZHznbylujh8evkzzQNVWOol
 QrR2NG7V8BcLTflmsYCErQDvgciGjscnVZUAyY3yNLIpceGCSHZfUsE8ld6iPrS+
 aPeuiIxDhHAKyoOTQwsGi9ex7KEOUOkoDHhKdR3Jr74mtfcPF5B+TxgXU0p5UZ9g
 GummuvSX0izYjUZ9P4keVgu3W4bvmR9Kd8oJUHNByWI1iecoXP9bQf33tEyb26R6
 G1zvGSDXPNK1V7OEaGvzGkgxOY0ZAIWLRX/+wasErdJnt3lmOV9+cCSkJAFSNrk3
 jQ922q2ZWLfYAL6nNIAx2dIiJirxTQ2JIq/bys2BHiYvkuvqNcKoBIDAGlQ4xBKm
 /c5z9Dm/DxQpdlKFQugHmc5awLEZxpq2LCTBLlgM8z6+uRWXui+slPfIrfX5RWun
 BHaLmPNm6tKQLadjwWCoxXYjKqgK0wm35Yq5d5He7d45d3QWKvtUgZAj33pcIgTE
 wKmwF5oaLiU=
 =T+hS
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-4.19b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

Second set of IIO new device support, features and cleanups.

There are also a couple of fixes that can wait for the coming merge
window.

Core new features

* Support for phase channels (used in time of flight sensors amongst
  other things)
* Support for deep UV light channel modifier.

New Device Support

* AD4758 DAC
  - New driver and dt bindings.
* adxl345
  - Support the adxl375 +-200g part which is register compatible.
* isl29501 Time of flight sensor.
  - New driver
* meson-saradc
  - Support the Meson8m2 Socs - right now this is just an ID, but there will
    be additional difference in future.
* mpu6050
  - New ID for 6515 variant.
* si1133 UV sensor.
  - New driver
* Spreadtrum SC27xx PMIC ADC
  - New driver and dt bindings.

Features

* adxl345
  - Add calibration offset readback and writing.
  - Add sampling frequency control.

Fixes and Cleanups

* ad5933
  - Use a macro for the channel definition to reduce duplication.
* ad9523
  - Replace use of core mlock with a local lock. Part of ongoing efforts
    to avoid confusing the purpose of mlock which is only about iio core
    state changes.
  - Fix displayed phase which was out by a factor of 10.
* adxl345
  - Add a link to the datasheet.
  - Rework the use of the address field in the chan_spec structures to
    allow addition of more per channel information.
* adis imu
  - Mark switch fall throughs.
* at91-sama5d2
  - Fix some casting on big endian systems.
* bmp280
  - Drop some DT elements that aren't used and should mostly be done from
    userspace rather than in DT.
* hx711
  - add clock-frequency dt binding and resulting delay to deal with capacitance
    issue on some boards.
  - fix a spurious unit-address in the example.
* ina2xx
  - Avoid a possible kthread_stop with a stale task_struct.
* ltc2632
  - Remove some unused local variables (assigned but value never used).
* max1363
  - Use device_get_match_data to remove some boilerplate.
* mma8452
  - Mark switch fall throughs.
* sca3000
  - Fix a missing return in a switch statement (a bad fallthrough
    previously!)
* sigma-delta-modulator
  - Drop incorrect unit address from the DT example.
* st_accel
  - Use device_get_match_data to drop some boiler plate.
  - Move to probe_new for i2c driver as second parameter not used.
* st_sensors library
  - Use a strlcpy (safe in this case).
* st_lsm6dsx
  - Add some error logging.
* ti-ads7950
  - SPDX
  - Allow simultaneous buffered and polled reads. Needed on a Lego Mindstorms
    EV3 where some channels are used for power supply monitoring at a very low
    rate.
* ti-dac5571
  - Remove an unused variable.
* xadc
  - Drop some dead code.
2018-07-25 10:12:07 +02:00
Lorenzo Bianconi
a42174983c iio: imu: st_lsm6dsx: add error logs to st_lsm6dsx_read_fifo()
Add debug info to error conditions in st_lsm6dsx_read_fifo routine

Suggested-by: Jorge Ramirez-Ortiz <jramirez@baylibre.com>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-07-15 10:11:22 +01:00
Brian Masney
de8df0b9c3 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>
2018-07-15 09:40:54 +01:00
Gustavo A. R. Silva
82d65f9d55 iio:imu:adis: Mark expected switch fall-throughs
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-07-07 18:01:05 +01:00
Greg Kroah-Hartman
7f5d8f7116 Merge 4.18-rc3 into staging-next
We want the staging/iio fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-02 08:21:54 +02:00
Greg Kroah-Hartman
f62252bf39 First set of IIO new device support, features and cleanups in the 4.19 cycle
The usual mixed bunch.  Particular good to see is the generic
 touch screen driver.  Will be interesting to see if this works
 for other ADCs without major changes.
 
 Core features
 * Channel types
   - New position relative channel type primarily for touch screen
     sensors to feed the generic touchscreen driver.
 
 New device support
 * ad5586
   - Add support for the AD5311R DAC.
 
 * Generic touch screen driver as an IIO consumer.
   - Note this is in input, but due to dependencies is coming through
     the IIO tree.
   - Specific support for this added to the at91-sama5d2 ADC.
   - Various necessary DT bindings added.
 
 Staging Drops
 * ADIS16060 gyro
   - A device with a very odd interface that was never cleanly supported.
     It's now very difficult to get, so unlikely it'll ever be fixed up.
 
 Cleanups and minor features and fixes
 * core
   - Fix y2038 timestamp issues now the core support is in place.
 * 104-quad-8
   - Provide some defines for magic numbers to help readability.
   - Fix an off by one error in register selection
 * ad7606
   - Put in a missing function parameter name in a prototype.
 * adis16023
   - Use generic sign_extend function rather than local version.
 * adis16240
   - Use generic sign_extend funciton rather than local version.
 * at91-sama5d2
   - Drop dependency on HAS_DMA now this is handled elsewhere.  Will
     improve build test coverage.
   - Add oversampling ratio control.  Note there is a minor ABI change
     here to increase the apparent depth to 14 bits so as to allow
     for transparent provision of different oversampling ratios that
     drop the actual bit depth to 13 or 12 bits.
 * hx711
   - Add a MAINTAINERS entry for this device.
 * inv_mpu6050
   - Replace the timestamp fifo 'special' code with generic timestamp
     handling.
   - Switch to using local store of timestamp divider rather than rate
     as that is more helpful for accurate time measurement.
   - Fix an unaligned access that didn't seem to be causing any trouble.
   - Use the fifo overflow bit to track the overflow status rather than
     a software counter.
   - New timestamping mechanism to deal with missed sample interrupts.
 * stm32-adc
   - Drop HAS_DMA build dependency.
 * sun4i-gpadc
   - Select REGMAP_IRQ a very rarely hit build issue fix.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAlsxT24RHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FogOHRAAllFPJBoq+nVqGAqe6CjSmWhAFdyv/Ey0
 4iDBsdBHrzhxnDuatqzbFhvu9TgqQxMBSbcRfqrGnJrnCFDNcvo1eJcxq13YFPCy
 EitRhu5kUdZ6Ez+OQOjX77wGlPyh8idZnaUkWjowOjnXztkHQjy6IWTbDKFk9bPY
 9fGBpmPDn1xaVPPWh7lZVAdTwCt2i+efG4sGyZyMQODjtM0q2G1MoHm9ioqgg8lN
 hzO7YIrZmLlXRUhapQ2/61uwa/2WMrcGK5v8eCGphEZnPN5lUWrT//w91+BCQpBC
 A9gRFpWblz5qHaRpNhzNbQjUrGvTAeIhF+bdOV2W+oI8CJhTJ0AlNqtUXs2pbaJn
 FO6jGwkC+jOA3XdE4tbiqenuMSZNggXBCgyRMfIK5WuIeBF02w57KHxgefkGTnQe
 Iqc9QDLLfkGDsOoh1l/+TMWjAxfXJLd7d04wYcRIDy6wumTi6GJxUesiQAnyq5eo
 Rg+o8gbfZcnbgzphBRoQjjftFMPeYdr48bCGCmjFjNnIPnemmUZg988gTggl6NST
 mzbFBsAnejmYpT393FPL0K9dLVUq5cRngQMuLVDjR4VnlQEVMyV0O+CsW83iSM36
 3nqpaUOapqsKJT74n62k1YtzJgxr1uoyMS0LGjldAPLDiTgMf9YiPCCihCpiCY89
 K9gE6lzS70A=
 =SvKj
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-4.19a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

First set of IIO new device support, features and cleanups in the 4.19 cycle

The usual mixed bunch.  Particular good to see is the generic
touch screen driver.  Will be interesting to see if this works
for other ADCs without major changes.

Core features
* Channel types
  - New position relative channel type primarily for touch screen
    sensors to feed the generic touchscreen driver.

New device support
* ad5586
  - Add support for the AD5311R DAC.

* Generic touch screen driver as an IIO consumer.
  - Note this is in input, but due to dependencies is coming through
    the IIO tree.
  - Specific support for this added to the at91-sama5d2 ADC.
  - Various necessary DT bindings added.

Staging Drops
* ADIS16060 gyro
  - A device with a very odd interface that was never cleanly supported.
    It's now very difficult to get, so unlikely it'll ever be fixed up.

Cleanups and minor features and fixes
* core
  - Fix y2038 timestamp issues now the core support is in place.
* 104-quad-8
  - Provide some defines for magic numbers to help readability.
  - Fix an off by one error in register selection
* ad7606
  - Put in a missing function parameter name in a prototype.
* adis16023
  - Use generic sign_extend function rather than local version.
* adis16240
  - Use generic sign_extend funciton rather than local version.
* at91-sama5d2
  - Drop dependency on HAS_DMA now this is handled elsewhere.  Will
    improve build test coverage.
  - Add oversampling ratio control.  Note there is a minor ABI change
    here to increase the apparent depth to 14 bits so as to allow
    for transparent provision of different oversampling ratios that
    drop the actual bit depth to 13 or 12 bits.
* hx711
  - Add a MAINTAINERS entry for this device.
* inv_mpu6050
  - Replace the timestamp fifo 'special' code with generic timestamp
    handling.
  - Switch to using local store of timestamp divider rather than rate
    as that is more helpful for accurate time measurement.
  - Fix an unaligned access that didn't seem to be causing any trouble.
  - Use the fifo overflow bit to track the overflow status rather than
    a software counter.
  - New timestamping mechanism to deal with missed sample interrupts.
* stm32-adc
  - Drop HAS_DMA build dependency.
* sun4i-gpadc
  - Select REGMAP_IRQ a very rarely hit build issue fix.
2018-06-26 07:47:37 +08:00
Hans de Goede
2a221c0422 iio: imu: inv_mpu6050: Fix probe() failure on older ACPI based machines
Commit 5ec6486daa ("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: 5ec6486daa ("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>
2018-06-24 14:50:52 +01:00
Kees Cook
6396bb2215 treewide: kzalloc() -> kcalloc()
The kzalloc() function has a 2-factor argument form, kcalloc(). This
patch replaces cases of:

        kzalloc(a * b, gfp)

with:
        kcalloc(a * b, gfp)

as well as handling cases of:

        kzalloc(a * b * c, gfp)

with:

        kzalloc(array3_size(a, b, c), gfp)

as it's slightly less ugly than:

        kzalloc_array(array_size(a, b), c, gfp)

This does, however, attempt to ignore constant size factors like:

        kzalloc(4 * 1024, gfp)

though any constants defined via macros get caught up in the conversion.

Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.

The Coccinelle script used for this was:

// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@

(
  kzalloc(
-	(sizeof(TYPE)) * E
+	sizeof(TYPE) * E
  , ...)
|
  kzalloc(
-	(sizeof(THING)) * E
+	sizeof(THING) * E
  , ...)
)

// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@

(
  kzalloc(
-	sizeof(u8) * (COUNT)
+	COUNT
  , ...)
|
  kzalloc(
-	sizeof(__u8) * (COUNT)
+	COUNT
  , ...)
|
  kzalloc(
-	sizeof(char) * (COUNT)
+	COUNT
  , ...)
|
  kzalloc(
-	sizeof(unsigned char) * (COUNT)
+	COUNT
  , ...)
|
  kzalloc(
-	sizeof(u8) * COUNT
+	COUNT
  , ...)
|
  kzalloc(
-	sizeof(__u8) * COUNT
+	COUNT
  , ...)
|
  kzalloc(
-	sizeof(char) * COUNT
+	COUNT
  , ...)
|
  kzalloc(
-	sizeof(unsigned char) * COUNT
+	COUNT
  , ...)
)

// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@

(
- kzalloc
+ kcalloc
  (
-	sizeof(TYPE) * (COUNT_ID)
+	COUNT_ID, sizeof(TYPE)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(TYPE) * COUNT_ID
+	COUNT_ID, sizeof(TYPE)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(TYPE) * (COUNT_CONST)
+	COUNT_CONST, sizeof(TYPE)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(TYPE) * COUNT_CONST
+	COUNT_CONST, sizeof(TYPE)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(THING) * (COUNT_ID)
+	COUNT_ID, sizeof(THING)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(THING) * COUNT_ID
+	COUNT_ID, sizeof(THING)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(THING) * (COUNT_CONST)
+	COUNT_CONST, sizeof(THING)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(THING) * COUNT_CONST
+	COUNT_CONST, sizeof(THING)
  , ...)
)

// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@

- kzalloc
+ kcalloc
  (
-	SIZE * COUNT
+	COUNT, SIZE
  , ...)

// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@

(
  kzalloc(
-	sizeof(TYPE) * (COUNT) * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kzalloc(
-	sizeof(TYPE) * (COUNT) * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kzalloc(
-	sizeof(TYPE) * COUNT * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kzalloc(
-	sizeof(TYPE) * COUNT * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kzalloc(
-	sizeof(THING) * (COUNT) * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  kzalloc(
-	sizeof(THING) * (COUNT) * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  kzalloc(
-	sizeof(THING) * COUNT * (STRIDE)
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  kzalloc(
-	sizeof(THING) * COUNT * STRIDE
+	array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
)

// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@

(
  kzalloc(
-	sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
  , ...)
|
  kzalloc(
-	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
  , ...)
|
  kzalloc(
-	sizeof(THING1) * sizeof(THING2) * COUNT
+	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
  , ...)
|
  kzalloc(
-	sizeof(THING1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
  , ...)
|
  kzalloc(
-	sizeof(TYPE1) * sizeof(THING2) * COUNT
+	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
  , ...)
|
  kzalloc(
-	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
  , ...)
)

// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@

(
  kzalloc(
-	(COUNT) * STRIDE * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
-	COUNT * (STRIDE) * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
-	COUNT * STRIDE * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
-	(COUNT) * (STRIDE) * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
-	COUNT * (STRIDE) * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
-	(COUNT) * STRIDE * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
-	(COUNT) * (STRIDE) * (SIZE)
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
-	COUNT * STRIDE * SIZE
+	array3_size(COUNT, STRIDE, SIZE)
  , ...)
)

// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@

(
  kzalloc(C1 * C2 * C3, ...)
|
  kzalloc(
-	(E1) * E2 * E3
+	array3_size(E1, E2, E3)
  , ...)
|
  kzalloc(
-	(E1) * (E2) * E3
+	array3_size(E1, E2, E3)
  , ...)
|
  kzalloc(
-	(E1) * (E2) * (E3)
+	array3_size(E1, E2, E3)
  , ...)
|
  kzalloc(
-	E1 * E2 * E3
+	array3_size(E1, E2, E3)
  , ...)
)

// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@

(
  kzalloc(sizeof(THING) * C2, ...)
|
  kzalloc(sizeof(TYPE) * C2, ...)
|
  kzalloc(C1 * C2 * C3, ...)
|
  kzalloc(C1 * C2, ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(TYPE) * (E2)
+	E2, sizeof(TYPE)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(TYPE) * E2
+	E2, sizeof(TYPE)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(THING) * (E2)
+	E2, sizeof(THING)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	sizeof(THING) * E2
+	E2, sizeof(THING)
  , ...)
|
- kzalloc
+ kcalloc
  (
-	(E1) * E2
+	E1, E2
  , ...)
|
- kzalloc
+ kcalloc
  (
-	(E1) * (E2)
+	E1, E2
  , ...)
|
- kzalloc
+ kcalloc
  (
-	E1 * E2
+	E1, E2
  , ...)
)

Signed-off-by: Kees Cook <keescook@chromium.org>
2018-06-12 16:19:22 -07:00
Jean-Baptiste Maneyrol
4bcc19f1b2 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>
2018-06-10 11:52:30 +01:00
Jean-Baptiste Maneyrol
f5057e7b2d iio: imu: inv_mpu6050: better fifo overflow handling
Use fifo overflow bit from int status rather than using an
arbitrary threshold.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-06-10 11:52:30 +01:00
Jean-Baptiste Maneyrol
5cba7caaac iio: imu: inv_mpu6050: fix fifo count reading
Use unaligned access since buffer is a bytes table. Truncate fifo
count to read only complete datum.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-06-10 11:52:29 +01:00