Junjie Cao [Wed, 20 Aug 2025 00:47:55 +0000 (08:47 +0800)]
iio: core: switch info_mask fields to unsigned long to match find_bit helpers
for_each_set_bit()/find_*_bit() expect arrays of unsigned long (see
include/linux/find.h), but industrialio-core passed const long * into
iio_device_add_info_mask_type{,_avail}().
These masks are used purely as bit arrays and are populated via BIT()
(1UL << n). Switch the info_mask_* fields and the corresponding function
parameters to unsigned long so the types match the helpers. This removes
sparse warnings about signedness mismatches (seen with 'make C=1'
CF='-Wsparse-all') without changing behavior or struct layout.
No functional change intended.
Suggested-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Junjie Cao <junjie.cao@intel.com> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://patch.msgid.link/20250820004755.69627-1-junjie.cao@intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Add #io-channel-cells property with a constant value of 1 because it is
multi-channel ADC.
Fix below CHECK_DTBS warnings:
arch/arm/boot/dts/nxp/ls/ls1021a-iot.dtb: adc@35 (maxim,max1239): '#io-channel-cells' does not match any of the regexes: '^pinctrl-[0-9]+$'
from schema $id: http://devicetree.org/schemas/iio/adc/maxim,max1238.yaml#
iio: imu: bmi270: Match PNP ID found on newer GPD firmware
GPD devices originally used BMI160 sensors with the "BMI0160" PNP ID.
When they switched to BMI260 sensors in newer hardware, they reused
the existing Windows driver which accepts both "BMI0160" and "BMI0260"
IDs. Consequently, they kept "BMI0160" in DSDT tables for new BMI260
devices, causing driver mismatches in Linux.
1. GPD updated BIOS v0.40+[1] for newer devices to report "BMI0260" for
BMI260 sensors to avoid loading the bmi160 driver on Linux. While this
isn't Bosch's VID;
2. Bosch's official Windows driver uses "BMI0260" as a compatible ID
3. We're seeing real devices shipping with "BMI0260" in DSDT
The DSDT excerpt of GPD G1619-04 with BIOS v0.40:
Scope (_SB.I2CC)
{
Device (BMA2)
{
Name (_ADR, Zero) // _ADR: Address
Name (_HID, "BMI0260") // _HID: Hardware ID
Name (_CID, "BMI0260") // _CID: Compatible ID
Name (_DDN, "Accelerometer") // _DDN: DOS Device Name
Name (_UID, One) // _UID: Unique ID
Method (_CRS, 0, NotSerialized) // _CRS: Current Resource Settings
{
Name (RBUF, ResourceTemplate ()
{
I2cSerialBusV2 (0x0069, ControllerInitiated, 0x00061A80,
AddressingMode7Bit, "\\_SB.I2CC",
0x00, ResourceConsumer, , Exclusive,
)
})
Return (RBUF) /* \_SB_.I2CC.BMA2._CRS.RBUF */
}
# omit some noise
}
}
Qianfeng Rong [Tue, 19 Aug 2025 12:50:17 +0000 (20:50 +0800)]
iio: common: scmi_iio: use kcalloc() instead of kzalloc()
Replace calls of devm_kzalloc() with devm_kcalloc() in scmi_alloc_iiodev()
and scmi_iio_set_sampling_freq_avail() for safer memory allocation with
built-in overflow protection.
Similarly, use array_size() instead of explicit multiplication for
'sensor->sensor_info->intervals.count * 2'.
Ben Collins [Fri, 22 Aug 2025 13:23:52 +0000 (09:23 -0400)]
iio: mcp9600: White space and fixed width cleanup
Make tabs consistent for register definitions and also fix width
to byte size.
Signed-off-by: Ben Collins <bcollins@watter.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Reviewed-by: Andy Shevchenko <abdy@kernel.org> Reviewed-by: David Lechner <dlechner@baylibrc.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Link: https://patch.msgid.link/20250822-upstream-changes-v8-3-40bb1739e3e2@watter.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Ben Collins [Fri, 22 Aug 2025 13:23:51 +0000 (09:23 -0400)]
dt-bindings: iio: mcp9600: Add microchip,mcp9601 and add constraints
Add microchip,mcp9601 compatible in addition to the original
microchip,mcp9600 to designate support between these two chips.
The current dt-binding has open-circuit and short-circuit as interrupt
names, but these are only supported in mcp9601.
The OC and SC detection requires that mcp9601 VSENSE be wired up, which
not only enables the OC SC interrupts, but also the OC and SC status
register bits.
Add a microchip,vsense boolean to show the chip is wired for this
support.
Add constraints so this feature only applies if the mcp9601 compatible
is selected.
Xichao Zhao [Thu, 21 Aug 2025 08:06:51 +0000 (16:06 +0800)]
iio: temperature: mlx90635: Remove dev_err_probe() if error is -ENOMEM
The dev_err_probe() doesn't do anything when the error is '-ENOMEM'.
Therefore, remove the useless call to dev_err_probe(), and just return the
value instead.
Xichao Zhao [Thu, 21 Aug 2025 08:06:50 +0000 (16:06 +0800)]
iio: proximity: Remove dev_err_probe() if error is -ENOMEM
The dev_err_probe() doesn't do anything when the error is '-ENOMEM'.
Therefore, remove the useless call to dev_err_probe(), and just return the
value instead.
Xichao Zhao [Thu, 21 Aug 2025 08:06:49 +0000 (16:06 +0800)]
iio: light: Remove dev_err_probe() if error is -ENOMEM
The dev_err_probe() doesn't do anything when the error is '-ENOMEM'.
Therefore, remove the useless call to dev_err_probe(), and just return the
value instead.
Xichao Zhao [Thu, 21 Aug 2025 08:06:48 +0000 (16:06 +0800)]
iio: imu: bmi323: Remove dev_err_probe() if error is -ENOMEM
The dev_err_probe() doesn't do anything when the error is '-ENOMEM'.
Therefore, remove the useless call to dev_err_probe(), and just return the
value instead.
Xichao Zhao [Thu, 21 Aug 2025 08:06:47 +0000 (16:06 +0800)]
iio: chemical: Remove dev_err_probe() if error is -ENOMEM
The dev_err_probe() doesn't do anything when the error is '-ENOMEM'.
Therefore, remove the useless call to dev_err_probe(), and just return the
value instead.
Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com> Reviewed-by: Gustavo Silva <gustavograzs@gmail.com> # for ens160 Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://patch.msgid.link/20250821080723.525379-4-zhao.xichao@vivo.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Xichao Zhao [Thu, 21 Aug 2025 08:06:46 +0000 (16:06 +0800)]
iio: adc: Remove dev_err_probe() if error is -ENOMEM
The dev_err_probe() doesn't do anything when the error is '-ENOMEM'.
Therefore, remove the useless call to dev_err_probe(), and just return the
value instead.
Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com> Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> # meson_saradc Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://patch.msgid.link/20250821080723.525379-3-zhao.xichao@vivo.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Xichao Zhao [Thu, 21 Aug 2025 08:06:45 +0000 (16:06 +0800)]
iio: accel: msa311: Remove dev_err_probe() if error is -ENOMEM
The dev_err_probe() doesn't do anything when the error is '-ENOMEM'.
Therefore, remove the useless call to dev_err_probe(), and just return the
value instead.
Salah Triki [Tue, 19 Aug 2025 15:00:53 +0000 (16:00 +0100)]
staging: iio: adc: ad7816: Drop unnecessary dev_set_drvdata() call
Remove the call to `dev_set_drvdata()` and the associated comment
since private data is never read.
Signed-off-by: Salah Triki <salah.triki@gmail.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Link: https://patch.msgid.link/aKSRpTuwA0P-ZaUS@pc Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Dan Carpenter [Tue, 19 Aug 2025 15:02:53 +0000 (18:02 +0300)]
iio: proximity: vl53l0x-i2c: Fix error code in probe()
Commit 65e8202f0322 ("iio: Remove error prints for
devm_add_action_or_reset()") accidentally introduced a bug where we
returned "ret" but the error code was stored in "error" if
devm_add_action_or_reset() failed. Using two variables to store error
codes is unnecessary and confusing. Delete the "error" variable and use
"ret" everywhere instead.
Fixes: 65e8202f0322 ("iio: Remove error prints for devm_add_action_or_reset()") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://patch.msgid.link/aKSSHTdJf5QoYiRx@stanley.mountain Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Matti Vaittinen [Mon, 18 Aug 2025 08:13:05 +0000 (11:13 +0300)]
iio: adc: adc128s052: Support ROHM BD7910[0,1,2,3]
The ROHM BD79100, BD79101, BD79102, BD79103 are very similar ADCs as the
ROHM BD79104. The BD79100 has only 1 channel. BD79101 has 2 channels and
the BD79102 has 4 channels. Both BD79103 and BD79104 have 4 channels,
and, based on the data sheets, they seem identical from the software
point-of-view.
Matti Vaittinen [Mon, 18 Aug 2025 08:12:52 +0000 (11:12 +0300)]
iio: adc: adc128s052: Rename channel structs
The adc128s052 can be used to drive a few other ADCs but the TI's ADCs
it was originally intended for. The TI's IC variants model numbers don't
(trivially) explain the channel configuration (for a reader working with
other than TI's ICs).
Rename the channel configuration structures to explicitly explain they
are used for simple ADCs, having 2, 4 or 8 channels.
Matti Vaittinen [Mon, 18 Aug 2025 08:12:39 +0000 (11:12 +0300)]
iio: adc: adc128s052: Simplify matching chip_data
The adc128s052 driver supports a few different ICs. IC specific
configuration data is stored in an array. IC data, residing in a
specific point of the array, is pointed from the SPI device match data.
There is no need to have the chip config data structures in an array
and splitting them out of an array has at least following benefits:
- Chip-specific structures can be named after the chips they support.
This makes referring them a tad cleaner, compared to using a generic
array name with a numerical index.
- Avoid all potential 'out of bounds' errors which can result if the
array is changed.
Split the chip configuration data array to individual structures.
Matti Vaittinen [Mon, 18 Aug 2025 08:12:22 +0000 (11:12 +0300)]
dt-bindings: iio: adc: Add BD7910[0,1,2,3]
The ROHM BD79100, BD79101, BD79102, BD79103 are very similar ADCs as the
ROHM BD79104. The BD79100 has only 1 channel. BD79101 has 2 channels and
the BD79102 has 4 channels. Both BD79103 and BD79104 have 4 channels,
and, based on the data sheets, they seem identical from the software
point-of-view.
The clamp macro returns a value within the specified range.
In ad7768_set_freq(), the value returned from clamp() is checked against
zero, which is not possible since the value would always be between
50 and 1024000.
Removed the 'if' check.
This issue was reported by static coverity analyser as logically
dead code.
iio: light: Simple conversions to iio_push_to_buffers_with_ts()
This new function allows for runtime checks on the provided source buffer
being of sufficient size to accommodate the enabled channel data layout and
the naturally aligned s64 timestamp (which is non obvious and a frequent
source of bugs in the past).
This patch includes the remaining simple cases for light sensor drivers.
Cc: Mudit Sharma <muditsharma.info@gmail.com> Cc: Jiri Kosina <jikos@kernel.org> Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Cc: Javier Carrasco <javier.carrasco.cruz@gmail.com> Cc: Matti Vaittinen <mazziesaccount@gmail.com> Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://patch.msgid.link/20250802164436.515988-17-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Akshay Bansod [Mon, 11 Aug 2025 16:56:40 +0000 (22:26 +0530)]
iio: st_lsm6dsx: Replace scnprintf() with sysfs_emit()
Update the sysfs interface for sampling frequency and scale attributes.
Replace `scnprintf()` with `sysfs_emit_at()` which is PAGE_SIZE-aware
and recommended for use in sysfs.
Haibo Chen [Tue, 12 Aug 2025 08:04:23 +0000 (16:04 +0800)]
iio: adc: imx93_adc: load calibrated values even calibration failed
ADC calibration might fail because of the noise on reference voltage.
To avoid calibration fail, need to meet the following requirement:
ADC reference voltage Noise < 1.8V * 1/2^ENOB
For the case which the ADC reference voltage on board do not meet
the requirement, still load the calibrated values, so ADC can also
work but maybe not that accurate.
Signed-off-by: Haibo Chen <haibo.chen@nxp.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Reviewed-by: Primoz Fiser <primoz.fiser@norik.com> Link: https://patch.msgid.link/20250812-adc-v2-2-0260833f13b8@nxp.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Haibo Chen [Tue, 12 Aug 2025 08:04:22 +0000 (16:04 +0800)]
iio: adc: imx93_adc: keep one style of the hex values
Use capital letters consistently for hex values.
Signed-off-by: Haibo Chen <haibo.chen@nxp.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://patch.msgid.link/20250812-adc-v2-1-0260833f13b8@nxp.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Ben Collins [Tue, 12 Aug 2025 11:12:58 +0000 (07:12 -0400)]
iio: iio_format_list() should set stride=1 for IIO_VAL_CHAR
iio_format_list() sets a stride across the val array of 1 for INT
type, and 2 for all others. Add IIO_VAL_CHAR so it also gets a
stride of 1 assuming val is an array of integers with char type
values.
No drivers currently use this, but I found this issue adding an
avail callback for IIO_INFO_THERMOCOUPLE_TYPE for a driver I'm
working on.
Xichao Zhao [Wed, 13 Aug 2025 07:55:56 +0000 (15:55 +0800)]
iio: adc: ti-tsc2046: use us_to_ktime() where appropriate
Given scan_interval_us and time_per_scan_us are both in usecs, it
makes more sense to use us_to_ktime() helper rather than converting
to nanosecs as needed for ns_to_ktime().
Andrew Davis [Wed, 13 Aug 2025 22:58:38 +0000 (17:58 -0500)]
iio: health: afe4404: Do not store dev pointer in device struct
The device *dev is only used in probe(), so no need to store it
in the device local data struct. In all the places in probe()
we did use that, just use a new local variable for the same.
Andrew Davis [Wed, 13 Aug 2025 22:58:35 +0000 (17:58 -0500)]
iio: health: afe4403: Do not store dev pointer in device struct
The device *dev is only used in probe(), so no need to store it
in the device local data struct. In all the places in probe()
we did use that, just use a new local variable for the same.
The ROHM BD79105 is a simple 16-bit ADC accessible via SPI*.
The BD79105 has a CONVSTART pin, which must be set high to start the ADC
conversion. Unlike with the ad7091 and ad7091r which also have a
CONVSTART pin, the BD79105 requires that the pin must remain high also
for the duration of the SPI access.
(*) Couple of words about the SPI. The BD79105 has pins named as
CONVSTART, SCLK, DIN and DOUT. For the curious reader, DIN is not SPI
ISO.
DIN is a signal which can be used as a chip-select. When DIN is pulled
low, the ADC will output the completed measurement via DOUT as SCLK is
clocked. According to the data-sheet, the DIN can also be used for
daisy-chaining multiple ADCs. Furthermore, DOUT can be used also for a
'data-ready' -IRQ. These modes aren't supported by this driver.
Support reading ADC scale and data from the BD79105 using SPI, when DIN
is used as a chip-select.
The ROHM BD79105 is a simple, 16-bit, 1-channel ADC with a 'CONVSTART'
pin used to start the ADC conversion. Other than the 'CONVSTART', there
are 3 supply pins (one used as a reference), analog inputs, ground and
communication pins. It's worth noting that the pin somewhat confusingly
labeled as 'DIN', is a pin which should be used as a chip-select. The IC
does not have any writable registers.
The device is designed so that the output pin can, in addition to
outputting the data, be used as a 'data-ready'-IRQ. There are cases
where the IRQ can't be used (because it is delivered via SPI data-line).
Hence, some systems may use a GPIO for polling the data readiness.
Add a compatible for the bd79105 and add the data-ready GPIO to the
binding.
Matti Vaittinen [Mon, 11 Aug 2025 08:51:50 +0000 (11:51 +0300)]
dt-bindings: iio: adc: ad7476: Drop redundant prop: true
The ad7476 supports a few variants with different power-supplies and
control GPIOs. The binding first unconditionally introduces all the
properties, and later sets them 'true' or 'false' based on the
combatible.
The 'true' seems to be implied by the initial property introduction so
the 'true' -branches in later conditional handling (based on the
compatible) can be omitted.
Matti Vaittinen [Mon, 11 Aug 2025 08:51:39 +0000 (11:51 +0300)]
iio: adc: ad7476: Conditionally call convstart
The ad7476 supports two IC variants which may have a 'convstart' -GPIO
for starting the conversion. Currently the driver calls a function which
tries to access the GPIO for all of the IC variants, whether they
support 'convstart' or not. This is not an error because this function
returns early if GPIO information is not populated.
We can do a tad better by calling this function only for the ICs which
have the 'convstart' by providing a function pointer to the convstart
function from the chip_info structure, and calling this function only
for the ICs which have the function pointer set.
This does also allow to support ICs which require different convstart
handling than the currently supported ICs.
Call convstart function only on the ICs which can support it and allow
IC-specific convstart functions for the ICs which require different
handling.
Matti Vaittinen [Mon, 11 Aug 2025 08:51:28 +0000 (11:51 +0300)]
iio: adc: ad7476: Drop convstart chan_spec
The ad7476 driver defines separate chan_spec structures for operation
with and without convstart GPIO. At quick glance this may seem as if the
driver did provide more than 1 data-channel to users - one for the
regular data, other for the data obtained with the convstart GPIO.
The only difference between the 'convstart' and 'non convstart'
-channels is presence / absence of the BIT(IIO_CHAN_INFO_RAW) in
channel's flags.
We can drop the convstart channel spec, and related convstart macro, by
allocating a mutable per driver instance channel spec and adding the flag
in probe if needed. This will simplify the driver with the cost of added
memory consumption.
Assuming there aren't systems with very many ADCs and very few
resources, this tradeoff seems worth making.
Simplify the driver by dropping the 'convstart' channel spec and
allocating the channel spec for each driver instance.
Matti Vaittinen [Mon, 11 Aug 2025 08:51:17 +0000 (11:51 +0300)]
iio: adc: ad7476: use *_cansleep GPIO APIs
The ad7476 driver supports ADCs which require a GPIO pin to be used to
start conversion. The GPIO line status seems to be always toggled from
a process context, either from the user-initiated "raw-read conversion",
or from a threaded IRQ handler. Furthermore, these ICs are connected via
SPI bus, which is usually implemented in a way that the access to the
device can sleep. The GPIO here is toggled from the same context which
is reading the results over SPI.
Thus it seems very likely these GPIOs are toggled from a context which
can sleep.
Swap the gpiod_set_value() to gpiod_set_value_cansleep() accordinlgy.
Matti Vaittinen [Mon, 11 Aug 2025 08:51:06 +0000 (11:51 +0300)]
iio: adc: ad7476: Use correct channel for bit info
The ad7476 supports ADCs which use separate GPIO for starting the
conversion. For such devices, the driver uses different channel
information if the GPIO is found. The bit information is still always
used from the original (non 'convstart') channels.
This has not been causing problems because the bit information for the
'convstart' -channel and the 'normal' -channel is identical. It,
however, will cause issues if an IC has different characteristics for an
'convstart' -channel and regular channel. Furthermore, this will cause
problems if a device always requires the convstart GPIO and thus only
defines the convstart channel.
Matti Vaittinen [Mon, 11 Aug 2025 08:50:55 +0000 (11:50 +0300)]
iio: adc: ad7476: Use mV for internal reference
The ad7476 supports some ICs with an internal reference voltage. For
those ICs the reference voltage has been hard-coded as micro volts, but
the value which is later used in code needs to be milli volts. This
results the need to divide hard coded voltage by 1000 before using it.
Simplify code by changing the hard-coded voltage to millivolts and by
dropping the division.
Matti Vaittinen [Mon, 11 Aug 2025 08:50:41 +0000 (11:50 +0300)]
iio: adc: ad7476: Simplify scale handling
The ad7476 driver supports variants with different amount of supply
regulators. On some variants there is only VCC, which is used as a
reference voltage. Others have separate VREF regulator, and some rely on
internal VREF. Some have both internal VREF and option to connect
external one.
The ad7476 driver reads the regulator voltage only when the user asks to
get the scale. This means the driver needs to do some dancing while
picking the correct reference regulator (or internal reference), and
store it for the later use.
According to the discussion [1] variable voltage references are rare,
making it hard to justify the added complexity for supporting those.
Drop the support for the variable voltage references and simplify things
by using the managed regulator get and enable interfaces.
Matti Vaittinen [Mon, 11 Aug 2025 08:50:27 +0000 (11:50 +0300)]
iio: adc: ad7476: Simplify chip type detection
The ad7476 driver uses a table of structures for defining the IC variant
specific data. Table is indexed using enum values, which are picked by
SPI ID.
Having the table and an enum adds extra complexity and may encourage
adding IC specific quircks in the code, instead of centralizing the IC
differences in one place, the chip-info.
Simplify this by dropping the table and using individual structures for
the IC specific data, and storing the IC specific structure's address
directly in the SPI ID data. Finally, switch to the
spi_get_device_match_data() and add a check for the return value.
Waqar Hameed [Tue, 5 Aug 2025 09:33:33 +0000 (11:33 +0200)]
iio: Remove error prints for devm_add_action_or_reset()
When `devm_add_action_or_reset()` fails, it is due to a failed memory
allocation and will thus return `-ENOMEM`. `dev_err_probe()` doesn't do
anything when error is `-ENOMEM`. Therefore, remove the useless call to
`dev_err_probe()` when `devm_add_action_or_reset()` fails, and just
return the value instead.
Signed-off-by: Waqar Hameed <waqar.hameed@axis.com> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Reviewed-by: Andy Shevchenko <andy@kernel.org> Link: https://patch.msgid.link/pndectqm7te.a.out@axis.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Stefano Manni [Thu, 7 Aug 2025 07:48:49 +0000 (09:48 +0200)]
iio: adc: ad799x: add reference voltage capability to chip_info
If the chip supports an external reference voltage
on REFIN pin then the "vref-supply" regulator may be used.
This commit partially refactors 6b104e7895ab16b9b7f466c5f2ca282b87f661e8
to add the capability of the chip to have an external
voltage reference and then remove the ugly conditional check
on chip id.
Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Stefano Manni <stefano.manni@gmail.com> Acked-by: Andy Shevchenko <andriy.shevchenko@intel.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Link: https://patch.msgid.link/20250807074850.130831-2-stefano.manni@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
docs: iio: describe inactivity and free-fall detection on the ADXL345
Describe the inactivity detection additionally using the free-fall
register. Due to the controversial discussions on the mailing list, this
section of the documentation will be committed separately to allow for a
more focused and detailed elaboration of the topic.
iio: accel: adxl345: extend inactivity time for less than 1s
Inactivity and free-fall events are essentially the same type of sensor
events. Therefore, inactivity detection (normally set for periods between 1
and 255 seconds) can be extended for shorter durations to support free-fall
detection.
For periods shorter than 1 second, the driver automatically configures the
threshold and duration using the free-fall register. For periods longer
than 1 second, it uses the inactivity threshold and duration using the
inactivity registers.
When using the free-fall register, the link bit is not set, which means
auto-sleep cannot be enabled if activity detection is also active.
iio: accel: adxl345: add coupling detection for activity/inactivity
Enable AC/DC coupling configuration for activity and inactivity detection
by setting the AC/DC bit. Extend existing magnitude-based detection with
adaptive AC-coupled mode.
Use DC-coupled mode to compare acceleration samples directly against
configured thresholds. Use AC-coupled mode to compare samples against a
reference taken at the start of activity detection. Implement DC-coupled
events using MAG, and AC-coupled events using MAG_ADAPTIVE.
Expose configuration of thresholds and periods via separate sysfs handles.
Note that both coupling modes share the same sensor registers, so activity
or inactivity detection cannot be configured for both AC and DC
simultaneously. Apply the most recently configured mode.
Simplify event handling and support adaptive AC-coupling.
Add support for the sensor’s inactivity feature in the driver. When both
activity and inactivity detection are enabled, the sensor sets a link bit
that ties the two functions together. This also enables auto-sleep mode,
allowing the sensor to automatically enter sleep state upon detecting
inactivity.
Inactivity detection relies on a configurable threshold and a specified
time period. If sensor measurements remain below the threshold for the
defined duration, the sensor transitions to the inactivity state.
When an Output Data Rate (ODR) is set, the inactivity time period is
automatically adjusted to a sensible default. Higher ODRs result in shorter
inactivity timeouts, while lower ODRs allow longer durations-within
reasonable upper and lower bounds. This is important because features like
auto-sleep operate effectively only between 12.5 Hz and 400 Hz. These
defaults are applied when the sample rate is modified, but users can
override them by explicitly setting a custom inactivity timeout.
Similarly, configuring the g-range provides default threshold values for
both activity and inactivity detection. These are implicit defaults meant
to simplify configuration, but they can also be manually overridden as
needed.
Enable the sensor to detect activity and trigger interrupts accordingly.
Activity events are determined based on a threshold, which is initialized
to a sensible default during probe. This default value is adopted from the
legacy ADXL345 input driver to maintain consistent behavior.
The combination of activity detection, ODR configuration, and range
settings lays the groundwork for the activity/inactivity hysteresis
mechanism, which will be implemented in a subsequent patch. As such,
portions of this patch prepare switch-case structures to support those
upcoming changes.
There is no txt file for it, add yaml for invensense,icp10100
which is already used in the driver. Also, document other compatibles
for ICP-101xx family and add invensense,icp10100 as a fallback.
Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com> Signed-off-by: Rodrigo Gobbi <rodrigo.gobbi.7@gmail.com> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://patch.msgid.link/20250801221424.132305-1-rodrigo.gobbi.7@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
iio: adc: ti-adc12138: Simplify with devm_clk_get_enabled()
Driver is getting clock and almost immediately enabling it, with the
devm_request_irq() as the only relevant code executed between, thus the
probe path and cleanups can be simplified with devm_clk_get_enabled().
Move devm_request_irq() earlier, so the interrupt handler will be
registered before clock is enabled. This might be important in case
regulator supplies are enabled by other device driver and this device
raises interrupt immediately after clock sarts ticking.
The change does not reverse cleanup paths - first regulator will be
disabled, then clock and finally interrupt handler freed.
dt-bindings: iio: light: Simplify interrupts property in the example
dynaimage,al3010 and dynaimage,al3320a are I2C devices, so their
interrupts are not routed to GIC and rarely first interrupt cell is <0>.
This looks like copy-paste from some SoC block, so drop it and also for
readability use known defines instead of hard-coding interrupt flag.
dt-bindings: iio: adc: samsung,exynos-adc: Use correct IRQ level in example
The interrupt line to GIC is IRQ_TYPE_LEVEL_HIGH, so use that instead of
"none". Also replace the hard-coded GIC_SPI flag.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com> Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org> Acked-by: Rob Herring (Arm) <robh@kernel.org> Link: https://patch.msgid.link/20250724111345.47889-7-krzysztof.kozlowski@linaro.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
dt-bindings: iio: adc: Replace hard-coded GPIO/IRQ flag with a define
For readability use known defines instead of hard-coding GPIO or
interrupt flag.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Acked-by: Rob Herring (Arm) <robh@kernel.org> Acked-by: Matti Vaittinen <mazziesaccount@gmail.com> Link: https://patch.msgid.link/20250724111345.47889-6-krzysztof.kozlowski@linaro.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
dt-bindings: iio: Drop unused header includes in examples
Drop includes of headers which example code does not use. No functional
impact.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Reviewed-by: David Heidelberg <david@ixit.cz> Acked-by: Matti Vaittinen <mazziesaccount@gmail.com> Acked-by: Rob Herring (Arm) <robh@kernel.org> Link: https://patch.msgid.link/20250724111345.47889-5-krzysztof.kozlowski@linaro.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
David Lechner [Mon, 21 Jul 2025 22:12:47 +0000 (17:12 -0500)]
iio: adc: ti-adc081c: use individual model structures instead of array
Change the ti-adc081c driver to use individual model structures instead
of an array. This reduces the verbosity of the code. Also, the data is
now const as it should have been in the first place. The ADCxx1C_MODEL()
macro is dropped to be consistent with similar model definitions in
other drivers.
David Lechner [Mon, 21 Jul 2025 23:16:34 +0000 (18:16 -0500)]
iio: accel: bma180: use stack allocated buffer for scan
Move the scan struct to the stack instead of being in the driver state
struct. The buffer is only used in a single function and does not need
to be DMA-safe so it does not need to exist outside of that function's
scope.
David Lechner [Mon, 21 Jul 2025 22:21:08 +0000 (17:21 -0500)]
iio: proximity: srf08: use stack allocated scan buffer
Use a stack allocated scan struct in srf08_trigger_handler(). Since the
scan buffer isn't used outside of this function and doesn't need to be
DMA-safe, it doesn't need to be in struct srf08_data. We can also
eliminate an extra local variable for the return value of
srf08_read_ranging() by using scan.chan directly.
David Lechner [Tue, 22 Jul 2025 19:35:02 +0000 (14:35 -0500)]
iio: proximity: sx9500: use stack allocated struct for scan data
Use a stack-allocated struct in sx9500_trigger_handler() to hold the
IIO buffer scan data. Since the scan buffer isn't used outside of this
function, it doesn't need to be in struct sx9500_data.
By always allocating enough space for the maximum number of channels,
we can avoid having to reallocate the buffer each time buffered reads
are enabled.
David Lechner [Tue, 22 Jul 2025 21:52:38 +0000 (16:52 -0500)]
iio: fix iio_push_to_buffers_with_ts() typo
Replace iio_push_to_buffer_with_ts() with iio_push_to_buffers_with_ts()
in some documentation comments in iio.h. The latter is the correct name
of the function, the former doesn't exist.