David Lechner [Wed, 11 Jun 2025 22:39:13 +0000 (17:39 -0500)]
iio: light: veml6030: use = { } instead of memset()
Use { } instead of memset() to zero-initialize stack memory to simplify
the code.
Signed-off-by: David Lechner <dlechner@baylibre.com> Tested-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Reviewed-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20250611-iio-zero-init-stack-with-instead-of-memset-v1-21-ebb2d0a24302@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Lothar Rubusch [Tue, 10 Jun 2025 21:59:25 +0000 (21:59 +0000)]
iio: accel: adxl345: simplify measure enable
Simplify the function to enable or disable measurement. Replace the
separate decision logic and call to regmap_update_bits() by a single
call to regmap_assign_bits() taking a boolean argument directly.
This is a refactoring change and should not impact functionality.
David Lechner [Wed, 11 Jun 2025 21:33:02 +0000 (16:33 -0500)]
iio: amplifiers: ada4250: don't fail on bad chip ID
Only print an information message instead of error message and failing
to probe the device if the chip ID is not recognized. Experience shows
that this can be fragile and some devices may not return the expected
chip ID even though the driver is still able to work with them.
Nattan Ferreira [Wed, 11 Jun 2025 17:42:53 +0000 (14:42 -0300)]
iio: light: apds9306: Refactor threshold get/set functions to use helper
Refactor the apds9306_event_thresh_get() and apds9306_event_thresh_set()
functions to use a helper function (apds9306_get_thresh_reg()) for
obtaining the correct register based on the direction of the event. This
improves code readability and maintains consistency in accessing
threshold registers.
Signed-off-by: Nattan Ferreira <nattanferreira58@gmail.com> Co-developed-by: Lucas Antonio <lucasantonio.santos@usp.br> Signed-off-by: Lucas Antonio <lucasantonio.santos@usp.br> Acked-by: Subhajit Ghosh <subhajit.ghosh@tweaklogic.com> Link: https://patch.msgid.link/20250611174253.16578-1-nattanferreira58@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Jonathan Santos [Wed, 11 Jun 2025 11:51:50 +0000 (08:51 -0300)]
iio: adc: ad7768-1: add filter type and oversampling ratio attributes
Separate filter type and decimation rate from the sampling frequency
attribute. The new filter type attribute enables sinc3, sinc3+rej60
and wideband filters, which were previously unavailable.
Previously, combining decimation and MCLK divider in the sampling
frequency obscured performance trade-offs. Lower MCLK divider
settings increase power usage, while lower decimation rates reduce
precision by decreasing averaging. By creating an oversampling
attribute, which controls the decimation, users gain finer control
over performance.
The addition of those attributes allows a wider range of sampling
frequencies and more access to the device features. Sampling frequency
table is updated after every digital filter parameter change.
Changes in the sampling frequency are not allowed anymore while in
buffered mode.
Reviewed-by: David Lechner <dlechner@baylibre.com> Co-developed-by: Pop Paul <paul.pop@analog.com> Signed-off-by: Pop Paul <paul.pop@analog.com> Signed-off-by: Jonathan Santos <Jonathan.Santos@analog.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/cd3b60c44847d5c35cecc4385bbda6533be6825e.1749569957.git.Jonathan.Santos@analog.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Jonathan Santos [Wed, 11 Jun 2025 11:51:23 +0000 (08:51 -0300)]
iio: adc: ad7768-1: add support for Synchronization over SPI
The synchronization method using GPIO requires the generated pulse to be
truly synchronous with the base MCLK signal. When it is not possible to
do that in hardware, the datasheet recommends using synchronization over
SPI, where the generated pulse is already synchronous with MCLK. This
requires the SYNC_OUT pin to be connected to the SYNC_IN pin.
Use trigger-sources property to enable device synchronization over SPI
and multi-device synchronization while replacing sync-in-gpios property.
Jonathan Santos [Wed, 11 Jun 2025 11:51:11 +0000 (08:51 -0300)]
iio: adc: ad7768-1: add multiple scan types to support 16-bits mode
When the device is configured to decimation x8, only possible in the
sinc5 filter, output data is reduced to 16 bits in order to support
1 MHz of sampling frequency due to clock limitation.
Use multiple scan types feature to enable the driver to switch
scan type at runtime, making it possible to support both 24-bit and
16-bit resolution.
Sergiu Cuciurean [Wed, 11 Jun 2025 11:50:56 +0000 (08:50 -0300)]
iio: adc: ad7768-1: Add GPIO controller support
The AD7768-1 has the ability to control other local hardware (such as gain
stages),to power down other blocks in the signal chain, or read local
status signals over the SPI interface.
Add direct mode conditional locks in the GPIO callbacks to prevent register
access when the device is in buffered mode.
This change exports the AD7768-1's four GPIOs and makes them accessible
at an upper layer.
Reviewed-by: Marcelo Schmitt <marcelo.schmitt@analog.com> Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com> Co-developed-by: Jonathan Santos <Jonathan.Santos@analog.com> Signed-off-by: Jonathan Santos <Jonathan.Santos@analog.com> Link: https://patch.msgid.link/8abca580f43cb31d7088d07a7414b5f7efe91ead.1749569957.git.Jonathan.Santos@analog.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
In addition to GPIO synchronization, The AD7768-1 also supports
synchronization over SPI, which use is recommended when the GPIO
cannot provide a pulse synchronous with the base MCLK signal. It
consists of looping back the SYNC_OUT to the SYNC_IN pin and send
a command via SPI to trigger the synchronization.
Introduce the 'trigger-sources' property to enable SPI-based
synchronization via SYNC_OUT pin, along with additional optional
entries for GPIO3 and DRDY pins.
Also create #trigger-source-cells property to differentiate the trigger
sources provided by the ADC. To improve readability, create a
adi,ad7768-1.h header with the macros for the cell values.
While at it, add description to the interrupts property.
irq_domain_create_simple() takes fwnode as the first argument. It can be
extracted from the struct device using dev_fwnode() helper instead of
using of_node with of_fwnode_handle().
chuguangqing [Wed, 11 Jun 2025 08:58:38 +0000 (16:58 +0800)]
iio: light: opt4060: convert to use maple tree register cache
The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache.
chuguangqing [Wed, 11 Jun 2025 08:58:37 +0000 (16:58 +0800)]
iio: light: ltr501: convert to use maple tree register cache
The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache.
chuguangqing [Wed, 11 Jun 2025 08:58:36 +0000 (16:58 +0800)]
iio: light: isl29028: convert to use maple tree register cache
The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache.
chuguangqing [Wed, 11 Jun 2025 08:58:35 +0000 (16:58 +0800)]
iio: imu: bno055: convert to use maple tree register cache
The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache.
chuguangqing [Wed, 11 Jun 2025 08:58:34 +0000 (16:58 +0800)]
iio: imu: icm42600: convert to use maple tree register cache
The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache.
chuguangqing [Wed, 11 Jun 2025 08:58:33 +0000 (16:58 +0800)]
iio: health: afe4404: convert to use maple tree register cache
The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache.
chuguangqing [Wed, 11 Jun 2025 08:58:32 +0000 (16:58 +0800)]
iio: health: afe4403: convert to use maple tree register cache
The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache.
chuguangqing [Wed, 11 Jun 2025 08:58:31 +0000 (16:58 +0800)]
iio: dac: bd79703: convert to use maple tree register cache
The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache.
chuguangqing [Wed, 11 Jun 2025 08:58:30 +0000 (16:58 +0800)]
iio: dac: ad5380: convert to use maple tree register cache
The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache.
chuguangqing [Wed, 11 Jun 2025 08:58:29 +0000 (16:58 +0800)]
iio: chemical: bme680: convert to use maple tree register cache
The maple tree register cache is based on a much more modern data structure
than the rbtree cache and makes optimisation choices which are probably
more appropriate for modern systems than those made by the rbtree cache.
David Lechner [Wed, 11 Jun 2025 14:40:16 +0000 (09:40 -0500)]
iio: adc: ad7173: check return value of spi_setup()
Check the return value of spi_setup() and propagate the error in the
ad7173_probe() function. This is unlikely to happen since virtually
every SPI controller supports SPI_MODE_3, but still always a good idea
to check the return value.
Antonio Borneo [Tue, 10 Jun 2025 12:48:54 +0000 (14:48 +0200)]
iio: trigger: stm32-lptimer: Fix build warnings about export.h
After commit a934a57a42f6 ("scripts/misc-check: check missing #include
<linux/export.h> when W=1") and commit 7d95680d64ac ("scripts/misc-check:
check unnecessary #include <linux/export.h> when W=1") we get the build
warning with W=1:
drivers/iio/trigger/stm32-lptimer-trigger.c: warning: EXPORT_SYMBOL() is used, but #include <linux/export.h> is missing
Antonio Borneo [Tue, 10 Jun 2025 12:48:53 +0000 (14:48 +0200)]
iio: trigger: stm32-timer: Fix build warnings about export.h
After commit a934a57a42f6 ("scripts/misc-check: check missing #include
<linux/export.h> when W=1") and commit 7d95680d64ac ("scripts/misc-check:
check unnecessary #include <linux/export.h> when W=1") we get the build
warning with W=1:
drivers/iio/trigger/stm32-timer-trigger.c: warning: EXPORT_SYMBOL() is used, but #include <linux/export.h> is missing
Antonio Borneo [Tue, 10 Jun 2025 12:48:52 +0000 (14:48 +0200)]
iio: adc: stm32-dfsdm: Fix build warnings about export.h
After commit a934a57a42f6 ("scripts/misc-check: check missing #include
<linux/export.h> when W=1") and commit 7d95680d64ac ("scripts/misc-check:
check unnecessary #include <linux/export.h> when W=1") we get the build
warnings with W=1:
drivers/iio/adc/stm32-dfsdm-adc.c: warning: EXPORT_SYMBOL() is used, but #include <linux/export.h> is missing
drivers/iio/adc/stm32-dfsdm-core.c: warning: EXPORT_SYMBOL() is used, but #include <linux/export.h> is missing
Pop Ioan Daniel [Thu, 5 Jun 2025 15:09:43 +0000 (18:09 +0300)]
iio: adc: ad7405: add ad7405 driver
Add support for the AD7405/ADUM770x, a high performance isolated ADC,
1-channel, 16-bit with a second-order Σ-Δ modulator that converts an
analog input signal into a high speed, single-bit data stream.
Gwendal Grignou [Wed, 4 Jun 2025 05:39:03 +0000 (22:39 -0700)]
iio: cros_ec_sensors: add cros_ec_activity driver
ChromeOS EC can report activity information derived from the
accelerometer:
- Reports on-body/off-body as a proximity event.
- Reports significant motion as an activity event.
This new sensor is a virtual sensor, included only when the EC firmware
is compiled with the appropriate module.
Add gain calibration support, using resistor values set on devicetree,
values to be set accordingly with ADC external RFilter, as explained in
the ad7606c-16 datasheet, rev0, page 37.
The SYNC_IN pulse width must be at least 1.5 x Tmclk, corresponding to
~2.5 µs at the lowest supported MCLK frequency. Add a 3 µs delay to
ensure reliable synchronization timing even for the worst-case scenario.
iio: adc: ad7606: add enabling of optional Vrefin voltage
Add optional refin voltage enabling. The property "refin-supply" is
already available and optional in the current fdt dt_schema.
Note that the driver does not need to take any actions if the supply
is not present because a pin strap is used to change the behavior
of the device if an external reference is connected.
Matti Vaittinen [Fri, 30 May 2025 04:40:08 +0000 (07:40 +0300)]
iio: adc: ad7476: Support ROHM BU79100G
ROHM BU79100G is a 12-bit, single channel ADC. From the software point
of view it is identical to the TI's ADS7866. Support reading ADC
measurements using the ad7476.c
Waqar Hameed [Tue, 27 May 2025 14:45:42 +0000 (16:45 +0200)]
iio: Remove single use of macro definition for regmap name
There is really no reason for having the `regmap` name as a macro
definition if it is only used once directly in `struct regmap_config`.
It is also more readable this way. Remove these macro definitions and
instead use the string literal directly.
Waqar Hameed [Tue, 27 May 2025 14:45:42 +0000 (16:45 +0200)]
iio: Remove single use of macro definition for IRQ name
There is really no reason for having the IRQ name as a macro definition
if it is only used once (often in functions requesting the IRQ). It
is also more readable this way. Remove these macro definitions and
instead use the string literal directly.
Waqar Hameed [Tue, 27 May 2025 14:45:41 +0000 (16:45 +0200)]
iio: Remove single use of macro definition for driver name
There is really no reason for having the driver name as a macro
definition if it is only used once (often as `.name` in `struct
device_driver`). It is also more readable this way. Remove these macro
definitions and instead use the string literal directly.
iio: imu: inv_mpu6050: refactor aux read/write to use shared xfer logic
Refactors inv_mpu_aux_read() and inv_mpu_aux_write() to extract the common
I2C transfer sequence into inv_mpu_i2c_master_xfer(), which now handles
starting and stopping the I2C master, waiting for completion, disabling
SLV0, and checking for NACK errors.
This refactoring removes code duplication and improves maintainability.
No functional changes are intended.
David Lechner [Fri, 18 Apr 2025 18:16:13 +0000 (13:16 -0500)]
iio: amplifiers: ada4250: use DMA-safe memory for regmap_bulk_read()
Use DMA-safe memory instead of stack-allocated memory for the call to
regmap_bulk_read() in the ada4250_init() function as this could be used
directly by a SPI controller.
Also remove unnecessary use of get_unaligned_le16() and explicitly
include linux/types.h e.g. for __le16 while we are fixing this up.
Note this is DMA issue does not appear to be an actual bug due to
internals of the regmap SPI implementation. However, for IIO we are
following guidance that we should not make that assumption.
Lothar Rubusch [Sat, 10 May 2025 22:43:59 +0000 (22:43 +0000)]
iio: accel: adxl345: extend sample frequency adjustments
Introduce enums and functions to work with the sample frequency
adjustments. Let the sample frequency adjust via IIO and configure
a reasonable default.
Replace the old static sample frequency handling. During adjustment of
bw registers, measuring is disabled and afterwards enabled again.