This driver adds support to the family of magnetometric sensors
having the common whoami 0x3d. The following devices belong to
this family:
LIS3MDL - 3 axis Magnetometer
LSM9DS1 - 6 axis IMU + 3 axis Magnetometer
Tested on Kernel <= 5.4 and 5.10 where trigger ops structure
differs.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: If7d7b82333592fdb5a888bf53dfafc8382cce9a6
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/265990
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
The LSM6DSRx IMU sensor family also supports the following embedded
low power hw feature:
- tilt
- pedometer
so the following new IIO sensors were exported by the lsm6dsrx driver:
- tilt event detection (tilt)
- step detection (stepd)
- step counter (stepc)
- significant motion (sigmot)
all sensors are managed by interrupt pin and can be individually enabled.
The step counter is managed as a continuous data sensor and uses the
internal hw fifo to save the number of steps detected, it is also possible
to reset this counter via sysfs.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: I05ddf62effbd0831012b987d3e185bf209f0cee6
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/265866
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
Solve the issue that occurs when one of the devices that
only supports fsm is probed, in this case the support of
only fsm must be guaranteed even if there is no mlc.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: I7d15c3c6f94da731279a8aa92900a1de1d98223a
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/265326
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
During the loading of the MLC / FSM fw the register page can be
changed randomly and repeatedly by the firmware itself, for this
reason it is necessary to protect the access to allow the MLC
event handler to read the status register page and output register
value in an exclusive mode.
Same possible issue for mlc flush operation which in turn invoke
the main sensor enable function that is not protected by any register
page switch.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: I1146fbc3a58dfec1e241fd379e2d82d72f0d3861
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/265496
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
The event handler detection function reads the status register
without using the page lock which may have been modified by MLC/FSM
handler function.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: I05f7b7ad8d55ee93fc184c2d7ce0a9a27ac47263
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/265495
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
Some fields of the driver structures were partially or incorrectly documented,
also the initialization part was messy.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: I06b7c7db6dea9a10e47203a7a4ee3c3b92aadf2e
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/265494
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
The mlc verification function does not work correctly, the
modification rework the parsing procedure of the fw code that
is used to program the MLC / FSM block.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: Ic83d7c40dddea931bfa47e18f15d17a2c33b229d
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/265342
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
During flush operation the st_lsm6dsrx_mlc_flush_all function
loop on all iio_dev, also for the non MLC/FSM devices, this loop
could be very slow.
Furthermore, the return value of the st_lsm6dsrx_mlc_enable_sensor
function must be ignored for unallocated devices otherwise the
loop does not terminate and some devices may remain allocated.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: I05c3a05d539c364c6314ba343643adbe97907b60
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/265269
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
Permanently deletes the MLC defines left in the interface part and in
the default config of the driver.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: I168a8675ca8ecbadce6d1156cf9fd2e03697e2af
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/265267
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
LSM6DSRx family support tap and double tap detection embedded low-power
features. This patch configures the tap and double tap engine with a
basic configuration and enables the generation of interrupts in case of
acknowledgment of a tap or double tap event.
Each IIO event detection for tap and double tap can be individually enabled
as for the other basic embedded events.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: Id0b2a6c149e18b266e90b1cc37cfced01187ba99
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/265161
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
The names of the registers have been updated in accordance with the
data sheet.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: If558dcf85d5a40e42098342d063328b02ef40d04
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/265160
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
Removed the internal version of the driver no longer managed.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: I1371d23d9c71faf93605a51c37dae1f5f799399c
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/265159
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
Missing registration when enabling the trigger which in turn generates
a kernel oops caused by an undersizing and misalignment of the buffer
structure in the handler_threads of the triggers.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: I6183134a3366a102647d969cb26e7b293c42c3ce
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/265112
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
This patch is fixing a compilation error while building the driver as
built-in.
Compilation error:
compiler_types.h:315:38: error: call to '__compiletime_assert_307'
declared with attribute error: FIELD_PREP: mask is not constant
Signed-off-by: Denis Ciocca <denis.ciocca@st.com>
Change-Id: I062df2a0e31b288d4448cf8cd6ee3ba98904920a
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/264550
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
The number of iio devices supported by st_lsm6dsrx driver could
exceed 32 devices in the future, extends the enable mask to 64 bit.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: I92fe526c047b01709decd3905e679e8e5cfcf34b
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/264566
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
Move the preload mlc/fsm array to a separate file, include also
a free fall detection sample for lsm6dsr (FSM only).
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: I5cffc921590914f1d6c4bcbd2f83636fa2bf3395
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/264564
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
Extend support to lsm6dsr IMU of the same family group. This
device implements in HW only FSM and not support MLC.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: Ie541b2e17135e8683ba34670c0fb87a9ba6d28fd
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/264563
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
Added FSM and MLC flags in order to check device compatibility with
MLC/FSM configuration file.
This check has been added as not all devices of LSM6DSRx family
support the hw functions of FSM and MLC and therefore to avoid the
programming of an invalid configuration files a compatibility check
must be made in advance.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: I9acb30f677db516f294f730b3c12b904f6d73812
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/264562
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
Preparing the st_lsm6dsrx driver to extend support to devices of the
same family group.
The device ID managed through the compatible string has been introduced
in order to define which device to support through the device tree.
At the moment only lsm6dsrx which supports MLC is available.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: Ib290fc4ffafab0a89fc171b26c6bddb5cab8ce95
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/264561
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
Always leaves the MLC function support active in the driver to minimize
configuration parameters in Kconfig.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: I4db9e3cb22daf0598bc9ddae358731fdde875afc
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/264560
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
This patch is fixing a compilation error while building the driver as
built-in.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: I84f52c37629bf10da97d3b17624c2166c31073b7
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/264559
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
Removed all wrong references to devices not related to the
driver family in object.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: I6ff920537fc1493ae973137b025ea4e9b1c61407
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/264558
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
ASM330LHHX device include Finite State Machine (FSM) and Machine
Learning Core (MLC) HW block features which can be programmed through
binary ucf files generated by the "Unico" STmicroelectronics tool.
Through this patch the possibility to exploit the new features with
the following characteristics:
- Preload a test configuration for MLC / FSM during probe.
- Dynamically upload a new configuration via firmware upload.
- Individually enable and disable IIO devices generated by the ucf
configuration.
- Max number of contemporary MLC 8 and FSM 16 supported.
- Configurable MLC/FSM interrupt pin.
- Management of MLC and FSM events as IIO_ACTIVITY type including output
register data and timestamp.
- Possibility to dynamically flush a configuration.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: I17ff5a9133e93a75774f4b193d50cd23706d1237
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/262550
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
Complete documentation in sensor and hw structures and align
space and tab into sensor settings structure.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: I34b7b4b7247aa09de874db5afb10c8ee2727ee8b
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/261203
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
Pass device name to request threaded irq function instead the
generic driver name, in this way it will be possible to individuate
the device that requested the interrupt.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: I4a5c43452079b2174cec4128fddf0bf2283bb495
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/261202
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
ASM330LHHX embed a master I2C interface with sensor hub (SHUB) feature.
This patch add support to SHUB including the following features:
1) Maximum of 2 device supported to be chosen from the following part
numbers
- LIS2MDL 3-axis magnetometer
- LIS3MDL 3-axis magnetometer
- LPS22HB pressure
- LPS22HH pressure
2) Sensor hub leverage on HW FIFO to store samples
3) Possibility to configure pull up on I2C master interface through device
tree
4) Self scan on I2C master interface of supported device, including multi
address devices
5) ODR setting
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: Ia470e5798296d4517113c072f994b8518360cfa8
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/261198
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
Some device support also Low Power Mode setting for the primary
sensors (temperature is no a primary). This patch add support to read
and set power mode for acc and gyro sensors.
By default the Power Mode is set to High Performance.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: I3db25f2cc9e6004b18be24039ce6983f7fa8afab
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/261197
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
If the kernel is restarted while the driver was reading in the configuration
register page without turning off the power to the device, it could happen that
the bank regster 0 will be not accessible, so the first thing to do is to make
sure we are on the correct page before probe the whoami register.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: Ie732a5fa7a3230fd46ba044c7daa21d2e338a6dd
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/261196
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
Checkpatch report error when using Unix permission bits format.
Permission bits in the octal form are more readable and easier to
understand than their symbolic counterparts because many command-line
tools use this notation.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: Ifa44a53fa8ba46464097dcfc59f7200402102c05
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/261194
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
Since st_asm330lhhx driver supports more devices, the recognition
of the device name has been included in the probe phase so that
the sensor name is referred to the device name. Discrimination
of the device has the purpose of verifying the presence or absence
of the mlc and the sensor hub features.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: I0239d1b7d27be360f8918ec0db4b765fb543fb93
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/260651
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
Renamed st_asm330lhh driver to st_asm330lhhx, in order to include all
asm330lhh IMU device sensor family.
Signed-off-by: Mario Tesi <mario.tesi@st.com>
Change-Id: I98355a2050269eac4576d3e0a2d6243284c37387
Reviewed-on: https://gerrit.st.com/c/linuxandroidopen/stm-ldd-iio/+/260376
Tested-by: CITOOLS <MDG-smet-aci-reviews@list.st.com>
Reviewed-by: Denis CIOCCA <denis.ciocca@st.com>
This patch is fixing the calculation of the fifo watermark that was causing
wrong amount of fifo usage. In particular, highest 3 bits were always
reset to 0.
Signed-off-by: Denis Ciocca <denis.ciocca@st.com>
Change-Id: Id55eb114b9165a8a239fd5dff57a20c53e30714b