linux-2.6-microblaze.git
8 weeks agoiio: adc: ad4000: Add support for SPI offload
Marcelo Schmitt [Thu, 27 Mar 2025 21:24:35 +0000 (18:24 -0300)]
iio: adc: ad4000: Add support for SPI offload

FPGA HDL projects can include a PWM generator in addition to SPI-Engine.
The PWM IP is used to trigger SPI-Engine offload modules that in turn set
SPI-Engine to execute transfers to poll data from the ADC. That allows data
to be read at the maximum sample rates. Also, it is possible to set a
specific sample rate by setting the proper PWM duty cycle and related state
parameters, thus allowing an adjustable ADC sample rate when a PWM (offload
trigger) is used in combination with SPI-Engine.

Add support for SPI offload.

Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Link: https://patch.msgid.link/386ce043a0e3fc9e8ff71f17aef8de128ce5869e.1743110188.git.marcelo.schmitt@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: adc: ad7944: drop bits_per_word hack
David Lechner [Mon, 31 Mar 2025 19:29:54 +0000 (14:29 -0500)]
iio: adc: ad7944: drop bits_per_word hack

Remove setting bits_per_word in SPI xfers without data. The shortcoming
that this was working around was fixed in the SPI controller driver, so
it is no longer necessary. And we don't need this to be cargo-culted to
new drivers.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250331-iio-adc-ad7944-drop-bits_per_word-hack-v1-1-2b952e033340@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: dac: bd79703: Support ROHM BD79702
Matti Vaittinen [Wed, 2 Apr 2025 06:46:44 +0000 (09:46 +0300)]
iio: dac: bd79703: Support ROHM BD79702

The ROHM BD79702 is similar to the BD79703, except that it has only 4
channels whereas BD79703 has 6 channels. The channel 'addresses' of the
first two channels (used to identify the channel when data is read over
SPI) are same for both ICs. The next two channels of the BD79702 have
same addresses as the last two channels of the BD79703. This means the
BD79702 channel addresses do not follow the channel numbers with a
constant offset. Thus, we need to specify the addresses separately,
instead of directly deriving them from the channel number with a
constant offset.

It's worth noting that the data-sheet describes the BD79702 as a device
having channels 1,2,5 and 6. The driver however represents channels
0,1,2,3 to the users - with no gaps in the numbering - which may be more
familiar view for the application software.

Support ROHM BD79702 DAC.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/0ba243a63115dd4af03ebf9656c65b8c259a3e34.1743576022.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: dac: bd79703: Support BD79700 and BD79701
Matti Vaittinen [Wed, 2 Apr 2025 06:46:30 +0000 (09:46 +0300)]
iio: dac: bd79703: Support BD79700 and BD79701

The BD79700 and BD79701 look like almost exact subsets of the BD79703.
The BD79703 contains 6 channels (channels 0 to 5). The BD79700 provides
only 2 channels, matching the BD79703 channels 0 and 1. The BD79701
provides 3 channels (matching BD79703 channels 0, 1, and 2).

Furthermore, the BD79700 and BD79701 do not have separate VFS pin but
use VCC for the full-scale voltage.

Suopport these ICs using the BD79703 driver.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/845aa45974f6fb81c83046368a24a0674e9a8b0e.1743576022.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: dac: bd79703: Add chip data
Matti Vaittinen [Wed, 2 Apr 2025 06:46:13 +0000 (09:46 +0300)]
iio: dac: bd79703: Add chip data

Add a chip data structure which allows handling the different variants
(ROHM BD79700BD79701) with different number of channels.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/2cacb4bec5455fe1aa58a0b28d2d91b96a396d1a.1743576022.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: dac: bd79703 Store device address to 'address'
Matti Vaittinen [Wed, 2 Apr 2025 06:45:56 +0000 (09:45 +0300)]
iio: dac: bd79703 Store device address to 'address'

The ROHM BD79703 needs to identify a channel which we are reading from
in the SPI transfers. This can be seen as an address for the device.

For the bd79703 the address is nicely aligned with the channel number,
so the driver uses the channel ID for the SPI transfers. This, however,
does not need to be the case. The iio_chan_spec has a separate 'address'
field, which we can populate directly with this information.

This helps adding new ICs like the ROHM BD79702 where the channel ID is
different from this address to be handled by this driver, so we don't
need to have separate, IC specific mapping for channel numbers <=>
addresses.

Make the 'address' field in the iio_chan_spec to contain the SPI protocol
address for the channel, and use this value in the transfers.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/e53cb4120d16a3c678e1f391b600af630d6767ce.1743576022.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agodt-bindings: Add ROHM BD7970x variants
Matti Vaittinen [Wed, 2 Apr 2025 06:44:36 +0000 (09:44 +0300)]
dt-bindings: Add ROHM BD7970x variants

The ROHM BD79700BD79701 and BD79702 are subsets of the BD79703 DAC.
The main difference is the number of the channels. BD79703 has 6
channels.

The BD79702 has 4, BD79701 3 and BD79700 2 channels. Additionally, the
BD79700 and BD79701 do not have separate Vfs pin but use the Vcc also
for the full-scale voltage.

Add properties for the BD79700BD79701 and BD79702.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://patch.msgid.link/0a114565e4de52bf8f98c4f9d17943e5148b0112.1743576022.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: al3320a: Implement regmap support
David Heidelberg [Wed, 2 Apr 2025 19:33:28 +0000 (21:33 +0200)]
iio: light: al3320a: Implement regmap support

Modernize and clean up the driver using the regmap framework.

With the regmap implementation, the compiler produces
a significantly smaller module.

Size before: 72 kB
Size after:  58 kB

Signed-off-by: David Heidelberg <david@ixit.cz>
Link: https://patch.msgid.link/20250402-al3010-iio-regmap-v4-5-d189bea87261@ixit.cz
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: al3010: Implement regmap support
David Heidelberg [Wed, 2 Apr 2025 19:33:27 +0000 (21:33 +0200)]
iio: light: al3010: Implement regmap support

Modernize and clean up the driver using the regmap framework.

With the regmap implementation, the compiler produces
a significantly smaller module.

Size before: 72 kB
Size after:  58 kB

Signed-off-by: David Heidelberg <david@ixit.cz>
Link: https://patch.msgid.link/20250402-al3010-iio-regmap-v4-4-d189bea87261@ixit.cz
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: al3320a: Fix an error handling path in al3320a_probe()
David Heidelberg [Wed, 2 Apr 2025 19:33:26 +0000 (21:33 +0200)]
iio: light: al3320a: Fix an error handling path in al3320a_probe()

If regmap_write() fails in al3320a_init(), al3320a_set_pwr_off is
not called.

In order to avoid such a situation, move the devm_add_action_or_reset()
which calls al3320a_set_pwr_off right after a successful
al3320a_set_pwr_on.

Signed-off-by: David Heidelberg <david@ixit.cz>
Link: https://patch.msgid.link/20250402-al3010-iio-regmap-v4-3-d189bea87261@ixit.cz
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: al3000a: Fix an error handling path in al3000a_probe()
David Heidelberg [Wed, 2 Apr 2025 19:33:25 +0000 (21:33 +0200)]
iio: light: al3000a: Fix an error handling path in al3000a_probe()

If regmap_write() fails in al3000a_init(), al3000a_set_pwr_off is
not called.

In order to avoid such a situation, move the devm_add_action_or_reset()
which calls al3000a_set_pwr_off right after a successful
al3000a_set_pwr_on.

Signed-off-by: David Heidelberg <david@ixit.cz>
Link: https://patch.msgid.link/20250402-al3010-iio-regmap-v4-2-d189bea87261@ixit.cz
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: al3010: Improve al3010_init error handling with dev_err_probe()
David Heidelberg [Wed, 2 Apr 2025 19:33:24 +0000 (21:33 +0200)]
iio: light: al3010: Improve al3010_init error handling with dev_err_probe()

Minor code simplifications and improved error reporting.

Signed-off-by: David Heidelberg <david@ixit.cz>
Link: https://patch.msgid.link/20250402-al3010-iio-regmap-v4-1-d189bea87261@ixit.cz
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: vcnl4035: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Sun, 9 Mar 2025 17:06:33 +0000 (17:06 +0000)]
iio: light: vcnl4035: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

This case triggered a false positive from sparse, resolved by
factoring out the code that includes the claim and release of
direct mode.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309170633.1347476-19-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: vcnl4000: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Sun, 9 Mar 2025 17:06:32 +0000 (17:06 +0000)]
iio: light: vcnl4000: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

To simplify the code whilst making the change (and avoid potential false
positives from sparse), split the enabling and disabling of thresholds
into separate functions.  This could have been done in two steps
by splitting the functions first, but would have meant rewriting
the enable function twice.

Cc: Astrid Rost <astrid.rost@axis.com>
Tested-by: Per-Daniel Olsson <perdaniel.olsson@axis.com>
Reviewed-by: Per-Daniel Olsson <perdaniel.olsson@axis.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309170633.1347476-18-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: tcs3472: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Sun, 9 Mar 2025 17:06:31 +0000 (17:06 +0000)]
iio: light: tcs3472: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309170633.1347476-17-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: tcs3414: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Sun, 9 Mar 2025 17:06:30 +0000 (17:06 +0000)]
iio: light: tcs3414: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309170633.1347476-16-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: st_uvis25: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Sun, 9 Mar 2025 17:06:29 +0000 (17:06 +0000)]
iio: light: st_uvis25: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309170633.1347476-15-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: si1145: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Sun, 9 Mar 2025 17:06:28 +0000 (17:06 +0000)]
iio: light: si1145: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309170633.1347476-14-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: rpr0521: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Sun, 9 Mar 2025 17:06:27 +0000 (17:06 +0000)]
iio: light: rpr0521: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309170633.1347476-13-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: rpr0521: Factor out handling of IIO_INFO_RAW and use guard()
Jonathan Cameron [Sun, 9 Mar 2025 17:06:26 +0000 (17:06 +0000)]
iio: light: rpr0521: Factor out handling of IIO_INFO_RAW and use guard()

Factor out the code which is only called with the direct mode claimed.
This and the use of guard(mutex) allows direct returns simplifying
code flow.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309170633.1347476-12-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: rohm-bu27034: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Sun, 9 Mar 2025 17:06:25 +0000 (17:06 +0000)]
iio: light: rohm-bu27034: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Acked-by: Matti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309170633.1347476-11-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: opt4060: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Sun, 9 Mar 2025 17:06:24 +0000 (17:06 +0000)]
iio: light: opt4060: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.  This is a case where the code
is pinning down the mode so also has a claim on buffered mode.
A follow up set may move those calls over to a sparse friendly
form as well.

Tested-by: Per-Daniel Olsson <perdaniel.olsson@axis.com>
Reviewed-by: Per-Daniel Olsson <perdaniel.olsson@axis.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309170633.1347476-10-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: ltr501: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Sun, 9 Mar 2025 17:06:23 +0000 (17:06 +0000)]
iio: light: ltr501: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309170633.1347476-9-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: ltr501: Factor out core of write_raw() where direct mode claim is held.
Jonathan Cameron [Sun, 9 Mar 2025 17:06:22 +0000 (17:06 +0000)]
iio: light: ltr501: Factor out core of write_raw() where direct mode claim is held.

Factoring this code out allows for direct returns on error simplifying code
flow.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309170633.1347476-8-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: ltr501: Factor out IIO_INFO_RAW leg of read_raw() callback.
Jonathan Cameron [Sun, 9 Mar 2025 17:06:21 +0000 (17:06 +0000)]
iio: light: ltr501: Factor out IIO_INFO_RAW leg of read_raw() callback.

Factoring this code out allows for direct returns, simplifying code flow.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309170633.1347476-7-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: as73211: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Sun, 9 Mar 2025 17:06:20 +0000 (17:06 +0000)]
iio: light: as73211: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated

Cc: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309170633.1347476-6-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: as73211: Use guard() and move mode switch into inner write_raw fucntion
Jonathan Cameron [Sun, 9 Mar 2025 17:06:19 +0000 (17:06 +0000)]
iio: light: as73211: Use guard() and move mode switch into inner write_raw fucntion

By using guard(mutex) and moving code that switches the device to config
mode into _as73211_write_raw() the error flow is simplified.

Cc: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309170633.1347476-5-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: isl29125: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Sun, 9 Mar 2025 17:06:18 +0000 (17:06 +0000)]
iio: light: isl29125: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309170633.1347476-4-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: gp2ap020a00f: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Sun, 9 Mar 2025 17:06:17 +0000 (17:06 +0000)]
iio: light: gp2ap020a00f: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309170633.1347476-3-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: apds9306: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Sun, 9 Mar 2025 17:06:16 +0000 (17:06 +0000)]
iio: light: apds9306: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Acked-by: Subhajit Ghosh <subhajit.ghosh@tweaklogic.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309170633.1347476-2-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: adc: rcar: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Sun, 9 Mar 2025 16:58:19 +0000 (16:58 +0000)]
iio: adc: rcar: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Cc: Marek Vasut <marek.vasut+renesas@gmail.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309165819.1346684-9-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: adc: mxs-lradc: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Sun, 9 Mar 2025 16:58:18 +0000 (16:58 +0000)]
iio: adc: mxs-lradc: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309165819.1346684-8-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: adc: ti-ads1015: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Sun, 9 Mar 2025 16:58:17 +0000 (16:58 +0000)]
iio: adc: ti-ads1015: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Cc: Marek Vasut <marex@denx.de>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309165819.1346684-7-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: adc: ti-ads1015: Use guard(mutex) and factor out code for INFO_RAW
Jonathan Cameron [Sun, 9 Mar 2025 16:58:16 +0000 (16:58 +0000)]
iio: adc: ti-ads1015: Use guard(mutex) and factor out code for INFO_RAW

By use of automatic lock release and introducing a new utility
function to handle the core activity of reading the ADC channel,
many more complex code flows can be replaced by direct returns.

Cc: Marek Vasut <marex@denx.de>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309165819.1346684-6-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: adc: ti-ads1100: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Sun, 9 Mar 2025 16:58:15 +0000 (16:58 +0000)]
iio: adc: ti-ads1100: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Cc: Mike Looijmans <mike.looijmans@topic.nl>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309165819.1346684-5-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: adc: ti-ads1100: Use guard(mutex) to allow direct returns
Jonathan Cameron [Sun, 9 Mar 2025 16:58:14 +0000 (16:58 +0000)]
iio: adc: ti-ads1100: Use guard(mutex) to allow direct returns

Use of automated lock release simplifies the code.

Cc: Mike Looijmans <mike.looijmans@topic.nl>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309165819.1346684-4-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: adc: vf610: Switch to sparse friendly iio_device_claim/release_direct()
Jonathan Cameron [Sun, 9 Mar 2025 16:58:13 +0000 (16:58 +0000)]
iio: adc: vf610: Switch to sparse friendly iio_device_claim/release_direct()

These new functions allow sparse to find failures to release
direct mode reducing chances of bugs over the claim_direct_mode()
functions that are deprecated.

Cc: Frank Li <Frank.Li@nxp.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309165819.1346684-3-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: adc: vf610: Move claim of direct mode to caller of vf610_read_sample and use...
Jonathan Cameron [Sun, 9 Mar 2025 16:58:12 +0000 (16:58 +0000)]
iio: adc: vf610: Move claim of direct mode to caller of vf610_read_sample and use guard(mutex)

These two changes allow direct returns in all paths, improving code
readablity.

Cc: Frank Li <Frank.Li@nxp.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250309165819.1346684-2-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: trigger: stm32-lptimer: add support for stm32mp25
Olivier Moysan [Fri, 14 Mar 2025 17:14:46 +0000 (18:14 +0100)]
iio: trigger: stm32-lptimer: add support for stm32mp25

Add support for STM32MP25 SoC. Use newly introduced compatible to handle
this new HW variant. Add new trigger definitions that can be used by the
stm32 analog-to-digital converter. Use compatible data to identify them.

Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Link: https://patch.msgid.link/20250314171451.3497789-4-fabrice.gasnier@foss.st.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: cros_ec: Avoid -Wflex-array-member-not-at-end warning
Gustavo A. R. Silva [Tue, 18 Mar 2025 10:03:20 +0000 (20:33 +1030)]
iio: cros_ec: Avoid -Wflex-array-member-not-at-end warning

-Wflex-array-member-not-at-end was introduced in GCC-14, and we are
getting ready to enable it, globally.

Use the `DEFINE_RAW_FLEX()` helper for an on-stack definition of
a flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

So, with these changes, fix the following warning:

drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c:39:40: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://patch.msgid.link/Z9lE6IVDeC5lnChN@kspp
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: proximity: cros_ec_mkbp_proximity: Avoid -Wflex-array-member-not-at-end warning
Gustavo A. R. Silva [Tue, 18 Mar 2025 10:01:05 +0000 (20:31 +1030)]
iio: proximity: cros_ec_mkbp_proximity: Avoid -Wflex-array-member-not-at-end warning

-Wflex-array-member-not-at-end was introduced in GCC-14, and we are
getting ready to enable it, globally.

Use the `DEFINE_RAW_FLEX()` helper for an on-stack definition of
a flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

So, with these changes, fix the following warning:

drivers/iio/proximity/cros_ec_mkbp_proximity.c:63:40: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://patch.msgid.link/Z9lEYdPPIyiRGm36@kspp
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: adc: ad7606_par: add ad7606c chips
David Lechner [Tue, 18 Mar 2025 22:52:18 +0000 (17:52 -0500)]
iio: adc: ad7606_par: add ad7606c chips

Add lookup table entries for ad7606c-16 and ad7606c-18 chips.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250318-iio-adc-ad7606-improvements-v2-10-4b605427774c@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: adc: ad7606: dynamically allocate channel info
David Lechner [Tue, 18 Mar 2025 22:52:17 +0000 (17:52 -0500)]
iio: adc: ad7606: dynamically allocate channel info

Refactor the ad7606 drivers to dynamically allocate the channel info.

The channel info was getting a bit unwieldy. In some cases, the
indio_dev->channels field was getting assigned up to 3 different times,
each in a different function, making it difficult to see where the info
was coming from. This problem stems from the number of permutations of
the channel array needed to support various modes of operation and data
buses. We already have 4 per chip (hardware mode, software mode, AXI ADC
backend and AXI ADC backend with software mode) and we intend to add two
more per chip when adding SPI offload support.

To make it easier to read and maintain, move all of the channel setup
to a single function that dynamically allocates and fills in the channel
info.

Additionally, this lets us remove some hacks where we had to compute an
offset due to the fact that sometimes there was a soft timestamp channel
at the start of the array. Now the timestamp channel is always at the
end of the array as is typical in other drivers.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250318-iio-adc-ad7606-improvements-v2-9-4b605427774c@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: adc: ad7606: drop ch param from ad7606_scale_setup_cb_t
David Lechner [Tue, 18 Mar 2025 22:52:16 +0000 (17:52 -0500)]
iio: adc: ad7606: drop ch param from ad7606_scale_setup_cb_t

Drop the ch parameter from the ad7606_scale_setup_cb_t functions. The
same info is already available from the chan param via chan->scan_type
and chan->channel, so the parameter is redundant.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250318-iio-adc-ad7606-improvements-v2-8-4b605427774c@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: adc: ad7606: don't use address field
David Lechner [Tue, 18 Mar 2025 22:52:15 +0000 (17:52 -0500)]
iio: adc: ad7606: don't use address field

Drop use of the address field in the ad7606 driver. This field was
duplicating the same info that was already in the channel and scan_index
fields. This is one less thing to have to hold in your mind when reading
the code.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250318-iio-adc-ad7606-improvements-v2-7-4b605427774c@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: adc: ad7606: use kernel identifier name style
David Lechner [Tue, 18 Mar 2025 22:52:14 +0000 (17:52 -0500)]
iio: adc: ad7606: use kernel identifier name style

Use lower_snake_case for the identifier names as that is the usual
kernel code style.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250318-iio-adc-ad7606-improvements-v2-6-4b605427774c@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: adc: ad7606: fix kernel-doc comments
David Lechner [Tue, 18 Mar 2025 22:52:13 +0000 (17:52 -0500)]
iio: adc: ad7606: fix kernel-doc comments

Fix several issues with kernel-doc comments in ad7606.h:
* Add missing ":" to @param names.
* Fix order of @param names.
* Add some missing parameters.
* Remove some non-existent parameters.
* Fix alignment and wrapping.
* Fix some spelling.

`./scripts/kernel-doc -v -none drivers/iio/adc/ad7606*` is happy now.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250318-iio-adc-ad7606-improvements-v2-5-4b605427774c@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: adc: ad7606: use devm_mutex_init()
David Lechner [Tue, 18 Mar 2025 22:52:12 +0000 (17:52 -0500)]
iio: adc: ad7606: use devm_mutex_init()

Use devm_mutex_init() in ad7606_probe(). Mutexes should be cleaned up
on driver removal.

Also add missing include while we are touching this.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250318-iio-adc-ad7606-improvements-v2-4-4b605427774c@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: adc: ad7606: add missing max sample rates
David Lechner [Tue, 18 Mar 2025 22:52:11 +0000 (17:52 -0500)]
iio: adc: ad7606: add missing max sample rates

Add max sample rates for all of the chips. Previously, only one chip had
this field populated. The fallback value for the initial sampling
frequency can be removed now that all chips have a max sample rate
defined.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250318-iio-adc-ad7606-improvements-v2-3-4b605427774c@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: adc: ad7606_spi: check error in ad7606B_sw_mode_config()
David Lechner [Tue, 18 Mar 2025 22:52:10 +0000 (17:52 -0500)]
iio: adc: ad7606_spi: check error in ad7606B_sw_mode_config()

Add missing error check in ad7606B_sw_mode_config().

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250318-iio-adc-ad7606-improvements-v2-2-4b605427774c@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: al3320a: Split set_pwr function into set_pwr_on and _off
David Heidelberg [Wed, 19 Mar 2025 20:59:47 +0000 (21:59 +0100)]
iio: light: al3320a: Split set_pwr function into set_pwr_on and _off

Simplifies later conversion to the regmap framework.

Signed-off-by: David Heidelberg <david@ixit.cz>
Link: https://patch.msgid.link/20250319-al3010-iio-regmap-v2-8-1310729d0543@ixit.cz
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: al3010: Split set_pwr function into set_pwr_on and _off
David Heidelberg [Wed, 19 Mar 2025 20:59:46 +0000 (21:59 +0100)]
iio: light: al3010: Split set_pwr function into set_pwr_on and _off

Simplifies later conversion to the regmap framework.

Signed-off-by: David Heidelberg <david@ixit.cz>
Link: https://patch.msgid.link/20250319-al3010-iio-regmap-v2-7-1310729d0543@ixit.cz
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: al3320a: Abstract device reference in the probe function
David Heidelberg [Wed, 19 Mar 2025 20:59:45 +0000 (21:59 +0100)]
iio: light: al3320a: Abstract device reference in the probe function

Introduce a local variable reducing redundancy and improving readability.

No functional changes.

Signed-off-by: David Heidelberg <david@ixit.cz>
Link: https://patch.msgid.link/20250319-al3010-iio-regmap-v2-6-1310729d0543@ixit.cz
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: al3010: Abstract device reference in the probe function
David Heidelberg [Wed, 19 Mar 2025 20:59:44 +0000 (21:59 +0100)]
iio: light: al3010: Abstract device reference in the probe function

Introduce a local variable reducing redundancy and improving readability.

No functional changes.

Signed-off-by: David Heidelberg <david@ixit.cz>
Link: https://patch.msgid.link/20250319-al3010-iio-regmap-v2-5-1310729d0543@ixit.cz
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: al3320a: Remove DRV_NAME definition
David Heidelberg [Wed, 19 Mar 2025 20:59:43 +0000 (21:59 +0100)]
iio: light: al3320a: Remove DRV_NAME definition

The driver name should be passed directly.

Signed-off-by: David Heidelberg <david@ixit.cz>
Link: https://patch.msgid.link/20250319-al3010-iio-regmap-v2-4-1310729d0543@ixit.cz
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: al3010: Remove DRV_NAME definition
David Heidelberg [Wed, 19 Mar 2025 20:59:42 +0000 (21:59 +0100)]
iio: light: al3010: Remove DRV_NAME definition

The driver name should be passed directly.

Signed-off-by: David Heidelberg <david@ixit.cz>
Link: https://patch.msgid.link/20250319-al3010-iio-regmap-v2-3-1310729d0543@ixit.cz
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: al3320a: Use unsigned int for the indexing
David Heidelberg [Wed, 19 Mar 2025 20:59:41 +0000 (21:59 +0100)]
iio: light: al3320a: Use unsigned int for the indexing

The integer is used as array index which cannot be negative.

Signed-off-by: David Heidelberg <david@ixit.cz>
Link: https://patch.msgid.link/20250319-al3010-iio-regmap-v2-2-1310729d0543@ixit.cz
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: al3010: Use unsigned int for the indexing
David Heidelberg [Wed, 19 Mar 2025 20:59:40 +0000 (21:59 +0100)]
iio: light: al3010: Use unsigned int for the indexing

The integer is used as array index which cannot be negative.

Signed-off-by: David Heidelberg <david@ixit.cz>
Link: https://patch.msgid.link/20250319-al3010-iio-regmap-v2-1-1310729d0543@ixit.cz
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoDocumentation: ABI: add events sampling frequency in sysfs-bus-iio
Jorge Marques [Fri, 21 Mar 2025 14:50:01 +0000 (15:50 +0100)]
Documentation: ABI: add events sampling frequency in sysfs-bus-iio

Some devices have an internal clock used by the events to space the
conversions.
The max1363 introduced the option in
commit 168c9d95a940 ("iio:adc:max1363 move from staging.")
and ad799x in
commit ba1d79613df3 ("staging:iio:ad799x: Use event spec for threshold
hysteresis")

Signed-off-by: Jorge Marques <jorge.marques@analog.com>
Link: https://patch.msgid.link/20250321-abi-oversampling-events-frequency-v1-1-794c1ab2f079@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: dac: ad3552r-hs: add debugfs reg access
Angelo Dureghello [Wed, 19 Mar 2025 15:45:31 +0000 (16:45 +0100)]
iio: dac: ad3552r-hs: add debugfs reg access

Add debugfs register access.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250319-wip-bl-ad3552r-fixes-v3-1-9975b38c0082@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoMAINTAINERS: Add ROHM BD79124 ADC/GPO
Matti Vaittinen [Mon, 24 Mar 2025 07:14:09 +0000 (09:14 +0200)]
MAINTAINERS: Add ROHM BD79124 ADC/GPO

Add undersigned as a maintainer for the ROHM BD79124 ADC/GPO driver.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/fa3b65599592c1685230a5fa95aea6ed12b0b504.1742560649.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoMAINTAINERS: Add IIO ADC helpers
Matti Vaittinen [Mon, 24 Mar 2025 07:13:56 +0000 (09:13 +0200)]
MAINTAINERS: Add IIO ADC helpers

Add undersigned as a maintainer for the IIO ADC helpers.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/1263c954cfb74223f322a9c31bd57f13d5516680.1742560649.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: adc: Support ROHM BD79124 ADC
Matti Vaittinen [Mon, 24 Mar 2025 07:13:42 +0000 (09:13 +0200)]
iio: adc: Support ROHM BD79124 ADC

The ROHM BD79124 is a 12-bit, 8-channel, SAR ADC. The ADC supports
an automatic measurement mode, with an alarm interrupt for out-of-window
measurements. The window is configurable for each channel.

The I2C protocol for manual start of the measurement and data reading is
somewhat peculiar. It requires the master to do clock stretching after
sending the I2C slave-address until the slave has captured the data.
Needless to say this is not well suopported by the I2C controllers.

Thus do not support the BD79124's manual measurement mode but implement
the measurements using automatic measurement mode, relying on the
BD79124's ability of storing latest measurements into register.

Support also configuring the threshold events for detecting the
out-of-window events.

The BD79124 keeps asserting IRQ for as long as the measured voltage is
out of the configured window. Thus, prevent the user-space from choking
on the events and mask the received event for a fixed duration (1 second)
when an event is handled.

The ADC input pins can be also configured as general purpose outputs.
Make those pins which don't have corresponding ADC channel node in the
device-tree controllable as GPO.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/ca3886c9abcb268ca976e62cd7da28bf5d6e6382.1742560649.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: adc: sun20i-gpadc: Use adc-helpers
Matti Vaittinen [Mon, 24 Mar 2025 07:13:28 +0000 (09:13 +0200)]
iio: adc: sun20i-gpadc: Use adc-helpers

The new devm_iio_adc_device_alloc_chaninfo_se() -helper is intended to
help drivers avoid open-coding the for_each_node -loop for getting the
channel IDs. The helper provides standard way to detect the ADC channel
nodes (by the node name), and a standard way to convert the "reg"
-properties to channel identification numbers, used in the struct
iio_chan_spec. Furthermore, the helper can optionally check the found
channel IDs are smaller than given maximum. This is useful for callers
which later use the IDs for example for indexing a channel data array.

The original driver treated all found child nodes as channel nodes. The
new helper requires channel nodes to be named channel[@N]. This should
help avoid problems with devices which may contain also other but ADC
child nodes. Quick grep from arch/* with the sun20i-gpadc's compatible
string didn't reveal any in-tree .dts with channel nodes named
otherwise. Also, same grep shows all the in-tree .dts seem to have
channel IDs between 0..num of channels.

Use the new helper.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/e367a803c0d625e60c9fca16c55a25eee06b5a89.1742560649.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: adc: rzg2l_adc: Use adc-helpers
Matti Vaittinen [Mon, 24 Mar 2025 07:13:16 +0000 (09:13 +0200)]
iio: adc: rzg2l_adc: Use adc-helpers

The new devm_iio_adc_device_alloc_chaninfo_se() -helper is intended to
help drivers avoid open-coding the for_each_node -loop for getting the
channel IDs. The helper provides standard way to detect the ADC channel
nodes (by the node name), and a standard way to convert the "reg"
-properties to channel identification numbers, used in the struct
iio_chan_spec. Furthermore, the helper can optionally check the found
channel IDs are smaller than given maximum. This is useful for callers
which later use the IDs for example for indexing a channel data array.

The original driver treated all found child nodes as channel nodes. The
new helper requires channel nodes to be named channel[@N]. This should
help avoid problems with devices which may contain also other but ADC
child nodes. Quick grep from arch/* with the rzg2l_adc's compatible
string didn't reveal any in-tree .dts with channel nodes named
otherwise. Also, same grep shows all the .dts seem to have channel IDs
between 0..num of channels.

Use the new helper.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Link: https://patch.msgid.link/e84ccff01070eaee3dd1ae2d7e109f963168f586.1742560649.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: adc: add helpers for parsing ADC nodes
Matti Vaittinen [Mon, 24 Mar 2025 07:13:03 +0000 (09:13 +0200)]
iio: adc: add helpers for parsing ADC nodes

There are ADC ICs which may have some of the AIN pins usable for other
functions. These ICs may have some of the AIN pins wired so that they
should not be used for ADC.

A common way of marking pins that can be used as ADC inputs is to add
corresponding channel@N nodes in the device tree as described in the ADC
      binding yaml.

Add couple of helper functions which can be used to retrieve the channel
information from the device node.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Link: https://patch.msgid.link/f1d8b3e15237947738912c0d297b3e1e21d8b03e.1742560649.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoproperty: Add functions to iterate named child
Matti Vaittinen [Mon, 24 Mar 2025 07:12:50 +0000 (09:12 +0200)]
property: Add functions to iterate named child

There are a few use-cases where child nodes with a specific name need to
be parsed. Code like:

fwnode_for_each_child_node()
if (fwnode_name_eq())
...

can be found from a various drivers/subsystems. Adding a macro for this
can simplify things a bit.

In a few cases the data from the found nodes is later added to an array,
which is allocated based on the number of found nodes. One example of
such use is the IIO subsystem's ADC channel nodes, where the relevant
nodes are named as channel[@N].

Add helpers for iterating and counting device's sub-nodes with certain
name instead of open-coding this in every user.

Suggested-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Link: https://patch.msgid.link/2767173b7b18e974c0bac244688214bd3863ff06.1742560649.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agodt-bindings: ROHM BD79124 ADC/GPO
Matti Vaittinen [Mon, 24 Mar 2025 07:12:36 +0000 (09:12 +0200)]
dt-bindings: ROHM BD79124 ADC/GPO

Add binding document for the ROHM BD79124 ADC / GPO.

ROHM BD79124 is a 8-channel, 12-bit ADC. The input pins can also be used
as general purpose outputs.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://patch.msgid.link/e16f54b6214b0d796216729a7e29b8f7be9ae19e.1742560649.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: filter: admv8818: Support frequencies >= 2^32
Brian Pellegrino [Fri, 28 Mar 2025 17:48:31 +0000 (13:48 -0400)]
iio: filter: admv8818: Support frequencies >= 2^32

This patch allows writing u64 values to the ADMV8818's high and low-pass
filter frequencies. It includes the following changes:

- Rejects negative frequencies in admv8818_write_raw.
- Adds a write_raw_get_fmt function to admv8818's iio_info, returning
  IIO_VAL_INT_64 for the high and low-pass filter 3dB frequency channels.

Fixes: f34fe888ad05 ("iio:filter:admv8818: add support for ADMV8818")
Signed-off-by: Brian Pellegrino <bpellegrino@arka.org>
Signed-off-by: Sam Winchenbach <swinchenbach@arka.org>
Link: https://patch.msgid.link/20250328174831.227202-7-sam.winchenbach@framepointer.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: core: Add support for writing 64 bit attrs
Sam Winchenbach [Fri, 28 Mar 2025 17:48:30 +0000 (13:48 -0400)]
iio: core: Add support for writing 64 bit attrs

Prior to this patch it was only possible to read 64 bit integers.

Signed-off-by: Sam Winchenbach <swinchenbach@arka.org>
Link: https://patch.msgid.link/20250328174831.227202-6-sam.winchenbach@framepointer.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: filter: admv8818: fix range calculation
Sam Winchenbach [Fri, 28 Mar 2025 17:48:29 +0000 (13:48 -0400)]
iio: filter: admv8818: fix range calculation

Search for the minimum error while ensuring that the LPF corner
frequency is greater than the target, and the HPF corner frequency
is lower than the target

This fixes issues where the range calculations were suboptimal.

Add two new DTS properties to set the margin between the input frequency
and the calculated corner frequency

Below is a generated table of the differences between the old algorithm
and the new. This is a sweep from 0 to 20 GHz in 10 MHz steps.
=== HPF ===
freq = 1750 MHz, 3db: bypass => 1750 MHz
freq = 3400 MHz, 3db: 3310 => 3400 MHz
freq = 3410 MHz, 3db: 3310 => 3400 MHz
freq = 3420 MHz, 3db: 3310 => 3400 MHz
freq = 3660 MHz, 3db: 3550 => 3656 MHz
freq = 6600 MHz, 3db: 6479 => 6600 MHz
freq = 6610 MHz, 3db: 6479 => 6600 MHz
freq = 6620 MHz, 3db: 6479 => 6600 MHz
freq = 6630 MHz, 3db: 6479 => 6600 MHz
freq = 6640 MHz, 3db: 6479 => 6600 MHz
freq = 6650 MHz, 3db: 6479 => 6600 MHz
freq = 6660 MHz, 3db: 6479 => 6600 MHz
freq = 6670 MHz, 3db: 6479 => 6600 MHz
freq = 6680 MHz, 3db: 6479 => 6600 MHz
freq = 6690 MHz, 3db: 6479 => 6600 MHz
freq = 6700 MHz, 3db: 6479 => 6600 MHz
freq = 6710 MHz, 3db: 6479 => 6600 MHz
freq = 6720 MHz, 3db: 6479 => 6600 MHz
freq = 6730 MHz, 3db: 6479 => 6600 MHz
freq = 6960 MHz, 3db: 6736 => 6960 MHz
freq = 6970 MHz, 3db: 6736 => 6960 MHz
freq = 6980 MHz, 3db: 6736 => 6960 MHz
freq = 6990 MHz, 3db: 6736 => 6960 MHz
freq = 7320 MHz, 3db: 7249 => 7320 MHz
freq = 7330 MHz, 3db: 7249 => 7320 MHz
freq = 7340 MHz, 3db: 7249 => 7320 MHz
freq = 7350 MHz, 3db: 7249 => 7320 MHz
freq = 7360 MHz, 3db: 7249 => 7320 MHz
freq = 7370 MHz, 3db: 7249 => 7320 MHz
freq = 7380 MHz, 3db: 7249 => 7320 MHz
freq = 7390 MHz, 3db: 7249 => 7320 MHz
freq = 7400 MHz, 3db: 7249 => 7320 MHz
freq = 7410 MHz, 3db: 7249 => 7320 MHz
freq = 7420 MHz, 3db: 7249 => 7320 MHz
freq = 7430 MHz, 3db: 7249 => 7320 MHz
freq = 7440 MHz, 3db: 7249 => 7320 MHz
freq = 7450 MHz, 3db: 7249 => 7320 MHz
freq = 7460 MHz, 3db: 7249 => 7320 MHz
freq = 7470 MHz, 3db: 7249 => 7320 MHz
freq = 7480 MHz, 3db: 7249 => 7320 MHz
freq = 7490 MHz, 3db: 7249 => 7320 MHz
freq = 7500 MHz, 3db: 7249 => 7320 MHz
freq = 12500 MHz, 3db: 12000 => 12500 MHz

=== LPF ===
freq = 2050 MHz, 3db: bypass => 2050 MHz
freq = 2170 MHz, 3db: 2290 => 2170 MHz
freq = 2290 MHz, 3db: 2410 => 2290 MHz
freq = 2410 MHz, 3db: 2530 => 2410 MHz
freq = 2530 MHz, 3db: 2650 => 2530 MHz
freq = 2650 MHz, 3db: 2770 => 2650 MHz
freq = 2770 MHz, 3db: 2890 => 2770 MHz
freq = 2890 MHz, 3db: 3010 => 2890 MHz
freq = 3010 MHz, 3db: 3130 => 3010 MHz
freq = 3130 MHz, 3db: 3250 => 3130 MHz
freq = 3250 MHz, 3db: 3370 => 3250 MHz
freq = 3260 MHz, 3db: 3370 => 3350 MHz
freq = 3270 MHz, 3db: 3370 => 3350 MHz
freq = 3280 MHz, 3db: 3370 => 3350 MHz
freq = 3290 MHz, 3db: 3370 => 3350 MHz
freq = 3300 MHz, 3db: 3370 => 3350 MHz
freq = 3310 MHz, 3db: 3370 => 3350 MHz
freq = 3320 MHz, 3db: 3370 => 3350 MHz
freq = 3330 MHz, 3db: 3370 => 3350 MHz
freq = 3340 MHz, 3db: 3370 => 3350 MHz
freq = 3350 MHz, 3db: 3370 => 3350 MHz
freq = 3370 MHz, 3db: 3490 => 3370 MHz
freq = 3490 MHz, 3db: 3610 => 3490 MHz
freq = 3610 MHz, 3db: 3730 => 3610 MHz
freq = 3730 MHz, 3db: 3850 => 3730 MHz
freq = 3850 MHz, 3db: 3870 => 3850 MHz
freq = 3870 MHz, 3db: 4130 => 3870 MHz
freq = 4130 MHz, 3db: 4390 => 4130 MHz
freq = 4390 MHz, 3db: 4650 => 4390 MHz
freq = 4650 MHz, 3db: 4910 => 4650 MHz
freq = 4910 MHz, 3db: 5170 => 4910 MHz
freq = 5170 MHz, 3db: 5430 => 5170 MHz
freq = 5430 MHz, 3db: 5690 => 5430 MHz
freq = 5690 MHz, 3db: 5950 => 5690 MHz
freq = 5950 MHz, 3db: 6210 => 5950 MHz
freq = 6210 MHz, 3db: 6470 => 6210 MHz
freq = 6470 MHz, 3db: 6730 => 6470 MHz
freq = 6730 MHz, 3db: 6990 => 6730 MHz
freq = 6990 MHz, 3db: 7250 => 6990 MHz
freq = 7000 MHz, 3db: 7250 => 7000 MHz
freq = 7250 MHz, 3db: 7400 => 7250 MHz
freq = 7400 MHz, 3db: 7800 => 7400 MHz
freq = 7800 MHz, 3db: 8200 => 7800 MHz
freq = 8200 MHz, 3db: 8600 => 8200 MHz
freq = 8600 MHz, 3db: 9000 => 8600 MHz
freq = 9000 MHz, 3db: 9400 => 9000 MHz
freq = 9400 MHz, 3db: 9800 => 9400 MHz
freq = 9800 MHz, 3db: 10200 => 9800 MHz
freq = 10200 MHz, 3db: 10600 => 10200 MHz
freq = 10600 MHz, 3db: 11000 => 10600 MHz
freq = 11000 MHz, 3db: 11400 => 11000 MHz
freq = 11400 MHz, 3db: 11800 => 11400 MHz
freq = 11800 MHz, 3db: 12200 => 11800 MHz
freq = 12200 MHz, 3db: 12600 => 12200 MHz
freq = 12210 MHz, 3db: 12600 => 12550 MHz
freq = 12220 MHz, 3db: 12600 => 12550 MHz
freq = 12230 MHz, 3db: 12600 => 12550 MHz
freq = 12240 MHz, 3db: 12600 => 12550 MHz
freq = 12250 MHz, 3db: 12600 => 12550 MHz
freq = 12260 MHz, 3db: 12600 => 12550 MHz
freq = 12270 MHz, 3db: 12600 => 12550 MHz
freq = 12280 MHz, 3db: 12600 => 12550 MHz
freq = 12290 MHz, 3db: 12600 => 12550 MHz
freq = 12300 MHz, 3db: 12600 => 12550 MHz
freq = 12310 MHz, 3db: 12600 => 12550 MHz
freq = 12320 MHz, 3db: 12600 => 12550 MHz
freq = 12330 MHz, 3db: 12600 => 12550 MHz
freq = 12340 MHz, 3db: 12600 => 12550 MHz
freq = 12350 MHz, 3db: 12600 => 12550 MHz
freq = 12360 MHz, 3db: 12600 => 12550 MHz
freq = 12370 MHz, 3db: 12600 => 12550 MHz
freq = 12380 MHz, 3db: 12600 => 12550 MHz
freq = 12390 MHz, 3db: 12600 => 12550 MHz
freq = 12400 MHz, 3db: 12600 => 12550 MHz
freq = 12410 MHz, 3db: 12600 => 12550 MHz
freq = 12420 MHz, 3db: 12600 => 12550 MHz
freq = 12430 MHz, 3db: 12600 => 12550 MHz
freq = 12440 MHz, 3db: 12600 => 12550 MHz
freq = 12450 MHz, 3db: 12600 => 12550 MHz
freq = 12460 MHz, 3db: 12600 => 12550 MHz
freq = 12470 MHz, 3db: 12600 => 12550 MHz
freq = 12480 MHz, 3db: 12600 => 12550 MHz
freq = 12490 MHz, 3db: 12600 => 12550 MHz
freq = 12500 MHz, 3db: 12600 => 12550 MHz
freq = 12510 MHz, 3db: 12600 => 12550 MHz
freq = 12520 MHz, 3db: 12600 => 12550 MHz
freq = 12530 MHz, 3db: 12600 => 12550 MHz
freq = 12540 MHz, 3db: 12600 => 12550 MHz
freq = 12550 MHz, 3db: 12600 => 12550 MHz
freq = 12600 MHz, 3db: 13000 => 12600 MHz
freq = 12610 MHz, 3db: 13000 => 12970 MHz
freq = 12620 MHz, 3db: 13000 => 12970 MHz
freq = 12630 MHz, 3db: 13000 => 12970 MHz
freq = 12640 MHz, 3db: 13000 => 12970 MHz
freq = 12650 MHz, 3db: 13000 => 12970 MHz
freq = 12660 MHz, 3db: 13000 => 12970 MHz
freq = 12670 MHz, 3db: 13000 => 12970 MHz
freq = 12680 MHz, 3db: 13000 => 12970 MHz
freq = 12690 MHz, 3db: 13000 => 12970 MHz
freq = 12700 MHz, 3db: 13000 => 12970 MHz
freq = 12710 MHz, 3db: 13000 => 12970 MHz
freq = 12720 MHz, 3db: 13000 => 12970 MHz
freq = 12730 MHz, 3db: 13000 => 12970 MHz
freq = 12740 MHz, 3db: 13000 => 12970 MHz
freq = 12750 MHz, 3db: 13000 => 12970 MHz
freq = 12760 MHz, 3db: 13000 => 12970 MHz
freq = 12770 MHz, 3db: 13000 => 12970 MHz
freq = 12780 MHz, 3db: 13000 => 12970 MHz
freq = 12790 MHz, 3db: 13000 => 12970 MHz
freq = 12800 MHz, 3db: 13000 => 12970 MHz
freq = 12810 MHz, 3db: 13000 => 12970 MHz
freq = 12820 MHz, 3db: 13000 => 12970 MHz
freq = 12830 MHz, 3db: 13000 => 12970 MHz
freq = 12840 MHz, 3db: 13000 => 12970 MHz
freq = 12850 MHz, 3db: 13000 => 12970 MHz
freq = 12860 MHz, 3db: 13000 => 12970 MHz
freq = 12870 MHz, 3db: 13000 => 12970 MHz
freq = 12880 MHz, 3db: 13000 => 12970 MHz
freq = 12890 MHz, 3db: 13000 => 12970 MHz
freq = 12900 MHz, 3db: 13000 => 12970 MHz
freq = 12910 MHz, 3db: 13000 => 12970 MHz
freq = 12920 MHz, 3db: 13000 => 12970 MHz
freq = 12930 MHz, 3db: 13000 => 12970 MHz
freq = 12940 MHz, 3db: 13000 => 12970 MHz
freq = 12950 MHz, 3db: 13000 => 12970 MHz
freq = 12960 MHz, 3db: 13000 => 12970 MHz
freq = 12970 MHz, 3db: 13000 => 12970 MHz
freq = 13000 MHz, 3db: 13390 => 13000 MHz
freq = 13390 MHz, 3db: 13810 => 13390 MHz
freq = 13810 MHz, 3db: 14230 => 13810 MHz
freq = 14230 MHz, 3db: 14650 => 14230 MHz
freq = 14650 MHz, 3db: 15070 => 14650 MHz
freq = 15070 MHz, 3db: 15490 => 15070 MHz
freq = 15490 MHz, 3db: 15910 => 15490 MHz
freq = 15910 MHz, 3db: 16330 => 15910 MHz
freq = 16330 MHz, 3db: 16750 => 16330 MHz
freq = 16750 MHz, 3db: 17170 => 16750 MHz
freq = 17170 MHz, 3db: 17590 => 17170 MHz
freq = 17590 MHz, 3db: 18010 => 17590 MHz
freq = 18010 MHz, 3db: 18430 => 18010 MHz
freq = 18430 MHz, 3db: 18850 => 18430 MHz
freq = 18850 MHz, 3db: bypass => 18850 MHz

Fixes: f34fe888ad05 ("iio:filter:admv8818: add support for ADMV8818")
Signed-off-by: Sam Winchenbach <swinchenbach@arka.org>
Link: https://patch.msgid.link/20250328174831.227202-5-sam.winchenbach@framepointer.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: filter: admv8818: fix integer overflow
Sam Winchenbach [Fri, 28 Mar 2025 17:48:28 +0000 (13:48 -0400)]
iio: filter: admv8818: fix integer overflow

HZ_PER_MHZ is only unsigned long. This math overflows, leading to
incorrect results.

Fixes: f34fe888ad05 ("iio:filter:admv8818: add support for ADMV8818")
Signed-off-by: Sam Winchenbach <swinchenbach@arka.org>
Link: https://patch.msgid.link/20250328174831.227202-4-sam.winchenbach@framepointer.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: filter: admv8818: fix band 4, state 15
Sam Winchenbach [Fri, 28 Mar 2025 17:48:27 +0000 (13:48 -0400)]
iio: filter: admv8818: fix band 4, state 15

Corrects the upper range of LPF Band 4 from 18.5 GHz to 18.85 GHz per
the ADMV8818 datasheet

Fixes: f34fe888ad05 ("iio:filter:admv8818: add support for ADMV8818")
Signed-off-by: Sam Winchenbach <swinchenbach@arka.org>
Link: https://patch.msgid.link/20250328174831.227202-3-sam.winchenbach@framepointer.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agodt-bindings: iio: filter: Add lpf/hpf freq margins
Sam Winchenbach [Fri, 28 Mar 2025 17:48:26 +0000 (13:48 -0400)]
dt-bindings: iio: filter: Add lpf/hpf freq margins

Adds two properties to add a margin when automatically finding the
corner frequencies.

Signed-off-by: Sam Winchenbach <swinchenbach@arka.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20250328174831.227202-2-sam.winchenbach@framepointer.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: adc: meson: add support for the GXLX SoC
Martin Blumenstingl [Sun, 30 Mar 2025 10:19:22 +0000 (12:19 +0200)]
iio: adc: meson: add support for the GXLX SoC

The SARADC IP on the GXLX SoC itself is identical to the one found on
GXL SoCs. However, GXLX SoCs require poking the first three bits in the
MESON_SAR_ADC_REG12 register to get the three MPLL clocks (used as clock
generators for the audio frequencies) to work.

The reason why there are MPLL clock bits in the ADC register space is
entirely unknown and it seems that nobody is able to comment on this.
So clearly mark this as a workaround and add a warning so users are
notified that this workaround can change (once we know what these bits
actually do).

Tested-by: Christian Hewitt <christianshewitt@gmail.com>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Link: https://patch.msgid.link/20250330101922.1942169-3-martin.blumenstingl@googlemail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agodt-bindings: iio: adc: amlogic,meson-saradc: Add GXLX SoC compatible
Martin Blumenstingl [Sun, 30 Mar 2025 10:19:21 +0000 (12:19 +0200)]
dt-bindings: iio: adc: amlogic,meson-saradc: Add GXLX SoC compatible

Add a compatible string for the GXLX SoC. It's very similar to GXL but
has three additional bits in MESON_SAR_ADC_REG12 for the three MPLL
clocks.

Acked-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Link: https://patch.msgid.link/20250330101922.1942169-2-martin.blumenstingl@googlemail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: light: bh1750: Add hardware reset support via GPIO
Sergio Perez [Mon, 24 Mar 2025 13:59:20 +0000 (14:59 +0100)]
iio: light: bh1750: Add hardware reset support via GPIO

Some BH1750 sensors require a hardware reset before they can be
detected on the I2C bus. This implementation adds support for an
optional reset GPIO that can be specified in the device tree.

The reset sequence pulls the GPIO low and then high before initializing
the sensor, which enables proper detection with tools like i2cdetect.
This is particularly important for sensors that power on in an
undefined state.

Signed-off-by: Sergio Perez <sergio@pereznus.es>
Link: https://patch.msgid.link/20250324135920.6802-2-sergio@pereznus.es
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agodt-bindings: iio: light: bh1750: Add reset-gpios property
Sergio Perez [Mon, 24 Mar 2025 13:59:19 +0000 (14:59 +0100)]
dt-bindings: iio: light: bh1750: Add reset-gpios property

Some BH1750 sensors require a hardware reset via GPIO before they can
be properly detected on the I2C bus. Add a new reset-gpios property
to the binding to support this functionality.

The reset-gpios property allows specifying a GPIO that will be toggled
during driver initialization to reset the sensor.

Signed-off-by: Sergio Perez <sergio@pereznus.es>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20250324135920.6802-1-sergio@pereznus.es
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agodt-bindings: iio: Use unevaluatedProperties for SPI devices
Krzysztof Kozlowski [Mon, 24 Mar 2025 12:53:13 +0000 (13:53 +0100)]
dt-bindings: iio: Use unevaluatedProperties for SPI devices

SPI devices should use unevaluatedProperties:false instead of
additionalProperties:false, to allow any SPI device properties listed in
spi-peripheral-props.yaml.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/20250324125313.82226-2-krzysztof.kozlowski@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agodt-bindings: iio: Correct indentation and style in DTS example
Krzysztof Kozlowski [Mon, 24 Mar 2025 12:53:12 +0000 (13:53 +0100)]
dt-bindings: iio: Correct indentation and style in DTS example

DTS example in the bindings should be indented with 2- or 4-spaces and
aligned with opening '- |', so correct any differences like 3-spaces or
mixtures 2- and 4-spaces in one binding.

No functional changes here, but saves some comments during reviews of
new patches built on existing code.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20250324125313.82226-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agostaging: iio: adt7316: replace irqd_get_trigger_type with irq_get_trigger_type
Feng Wei [Thu, 27 Mar 2025 01:57:04 +0000 (09:57 +0800)]
staging: iio: adt7316: replace irqd_get_trigger_type with irq_get_trigger_type

Convert irqd_get_trigger_type(irq_get_irq_data(irq)) cases to the more
simple irq_get_trigger_type(irq).

Signed-off-by: Feng Wei <feng.wei8@zte.com.cn>
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Link: https://patch.msgid.link/202503270957044481PK0Xb23i08BgwkodLtEC@zte.com.cn
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: frequency: ad9832: devicetree probing support
Siddharth Menon [Sat, 22 Mar 2025 16:28:11 +0000 (21:58 +0530)]
iio: frequency: ad9832: devicetree probing support

Introduce struct for device match of_device_id to avoid relying on fallback
mechanisms, which could lead to false matches against other AD9832 variants
in the future.

Suggested-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Signed-off-by: Siddharth Menon <simeddon@gmail.com>
Link: https://patch.msgid.link/20250322163211.253009-1-simeddon@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: hid-sensor-prox: Add support for 16-bit report size
Zhang Lixu [Mon, 17 Mar 2025 01:36:34 +0000 (09:36 +0800)]
iio: hid-sensor-prox: Add support for 16-bit report size

On Intel platforms, the HID_USAGE_SENSOR_HUMAN_PROXIMITY report size is 16
bits. This patch adds support for handling 16-bit report sizes for the
HID_USAGE_SENSOR_HUMAN_PROXIMITY usage in the HID sensor proximity driver.

Previously, the driver only supported 8-bit and 32-bit report sizes. With
this change, the driver can now correctly process 16-bit proximity data,
ensuring accurate human presence detection on platforms where this report
size is used.

Signed-off-by: Zhang Lixu <lixu.zhang@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://patch.msgid.link/20250317013634.4117399-1-lixu.zhang@intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: accel: adxl345: cleanup regmap return values
Lothar Rubusch [Thu, 13 Mar 2025 16:50:38 +0000 (16:50 +0000)]
iio: accel: adxl345: cleanup regmap return values

Regmap return values sometimes are checked being less than zero
to trigger error handling. Sometimes this is checked for being not
zero. Unify the situation and check for not being zero.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Link: https://patch.msgid.link/20250313165049.48305-4-l.rubusch@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: accel: adxl345: move INT enable to regmap cache
Lothar Rubusch [Thu, 13 Mar 2025 16:50:37 +0000 (16:50 +0000)]
iio: accel: adxl345: move INT enable to regmap cache

Replace the interrupt enable member variable to the regmap cache. This
makes the function set_interrupts() obsolete. The interrupt enable
register is written when the driver is probed. Thus it is perfectly
cacheable.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Link: https://patch.msgid.link/20250313165049.48305-3-l.rubusch@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: accel: adxl345: use regmap cache for INT mapping
Lothar Rubusch [Thu, 13 Mar 2025 16:50:36 +0000 (16:50 +0000)]
iio: accel: adxl345: use regmap cache for INT mapping

Use regmap cache to replace the maintenance of the interrupt mapping
state by a member variable intio. The interrupt mapping is initialized
when the driver is probed, and it is perfectly cacheable.

The patch will still leave the function set_interrupts(). A follow up
patch takes care of it, when cleaning up the INT enable register
variable.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Link: https://patch.msgid.link/20250313165049.48305-2-l.rubusch@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 weeks agoiio: adc: sort TI drivers alphanumerical
Tobias Sperling [Wed, 12 Mar 2025 15:29:40 +0000 (16:29 +0100)]
iio: adc: sort TI drivers alphanumerical

Sort TI drivers again in an alphanumerical manner.

Signed-off-by: Tobias Sperling <tobias.sperling@softing.com>
Link: https://patch.msgid.link/20250312-sort_ti_drivers-v1-1-4e8813e662d2@softing.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 months agoiio: adc: ad4030: explain rearranging raw sample data
David Lechner [Mon, 10 Mar 2025 20:43:08 +0000 (15:43 -0500)]
iio: adc: ad4030: explain rearranging raw sample data

Add a comment explaining why the raw sample data is rearranged in the
in the ad4030_conversion() function. It is not so obvious from the code
why this is done.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250310-iio-adc-ad4030-check-scan-type-err-v1-5-589e4ebd9711@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 months agoiio: adc: ad4030: don't store scan_type in state
David Lechner [Mon, 10 Mar 2025 20:43:07 +0000 (15:43 -0500)]
iio: adc: ad4030: don't store scan_type in state

Move getting the scan_type to ad4030_conversion(). Previously, we were
getting the scan_type in two other places, then storing it in the
state struct before using it in ad4030_conversion(). This was a bit
fragile against potential future changes since it isn't obvious that
anything that could potentially change the scan_type would need to
also update the state struct. Also, the non-obviousness of this led to
a redundant call to iio_get_current_scan_type() in
ad4030_single_conversion() since it also calls ad4030_set_mode() which
in turn calls ad4030_conversion().

To simplify things, just call iio_get_current_scan_type() in
ad4030_conversion() where the returned struct is actually used and
don't bother storing it in the state struct.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250310-iio-adc-ad4030-check-scan-type-err-v1-4-589e4ebd9711@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 months agoiio: adc: ad4030: move setting mode to update_scan_mode
David Lechner [Mon, 10 Mar 2025 20:43:06 +0000 (15:43 -0500)]
iio: adc: ad4030: move setting mode to update_scan_mode

Move calling ad4030_set_mode() from the buffer preenable callback to
the update_scan_mode callback. This doesn't change any functionality
but is more logical since setting the mode is a function of the scan
mask and doesn't require an "undo" operation when the buffer is
disabled.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250310-iio-adc-ad4030-check-scan-type-err-v1-3-589e4ebd9711@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 months agoiio: adc: ad4030: remove some duplicate code
David Lechner [Mon, 10 Mar 2025 20:43:05 +0000 (15:43 -0500)]
iio: adc: ad4030: remove some duplicate code

Remove some duplicate code in the ad4030_get_chan_scale() function by
simplifying the if statement.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250310-iio-adc-ad4030-check-scan-type-err-v1-2-589e4ebd9711@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 months agoiio: adc: ad4030: check scan_type for error
David Lechner [Mon, 10 Mar 2025 20:43:04 +0000 (15:43 -0500)]
iio: adc: ad4030: check scan_type for error

Check scan_type for error ad4030_get_chan_scale(). Currently, this
should never fail, but it is good practice to always check for errors
in case of future changes.

Calling iio_get_current_scan_type() is moved out of the if statement
also to avoid potential issues with future changes instead of assuming
that the non-differential case does not use extended scan_type.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202503040954.n6MhjSsV-lkp@intel.com/
Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250310-iio-adc-ad4030-check-scan-type-err-v1-1-589e4ebd9711@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 months agoiio: amplifiers: hmc425a: Remove not fully correct comment
Andy Shevchenko [Thu, 13 Mar 2025 16:22:53 +0000 (18:22 +0200)]
iio: amplifiers: hmc425a: Remove not fully correct comment

The OF match table can be used outside of OF-based platforms.
Remove the (misleading) comment.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://patch.msgid.link/20250313162254.416422-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2 months agoLinux 6.15-rc1
Linus Torvalds [Sun, 6 Apr 2025 20:11:33 +0000 (13:11 -0700)]
Linux 6.15-rc1

2 months agotools/include: make uapi/linux/types.h usable from assembly
Thomas Weißschuh [Wed, 2 Apr 2025 20:21:57 +0000 (21:21 +0100)]
tools/include: make uapi/linux/types.h usable from assembly

The "real" linux/types.h UAPI header gracefully degrades to a NOOP when
included from assembly code.

Mirror this behaviour in the tools/ variant.

Test for __ASSEMBLER__ over __ASSEMBLY__ as the former is provided by the
toolchain automatically.

Reported-by: Mark Brown <broonie@kernel.org>
Closes: https://lore.kernel.org/lkml/af553c62-ca2f-4956-932c-dd6e3a126f58@sirena.org.uk/
Fixes: c9fbaa879508 ("selftests: vDSO: parse_vdso: Use UAPI headers instead of libc headers")
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Link: https://patch.msgid.link/20250321-uapi-consistency-v1-1-439070118dc0@linutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2 months agoMerge tag 'turbostat-2025.05.06' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 6 Apr 2025 19:32:43 +0000 (12:32 -0700)]
Merge tag 'turbostat-2025.05.06' of git://git./linux/kernel/git/lenb/linux

Pull turbostat updates from Len Brown:

 - support up to 8192 processors

 - add cpuidle governor debug telemetry, disabled by default

 - update default output to exclude cpuidle invocation counts

 - bug fixes

* tag 'turbostat-2025.05.06' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux:
  tools/power turbostat: v2025.05.06
  tools/power turbostat: disable "cpuidle" invocation counters, by default
  tools/power turbostat: re-factor sysfs code
  tools/power turbostat: Restore GFX sysfs fflush() call
  tools/power turbostat: Document GNR UncMHz domain convention
  tools/power turbostat: report CoreThr per measurement interval
  tools/power turbostat: Increase CPU_SUBSET_MAXCPUS to 8192
  tools/power turbostat: Add idle governor statistics reporting
  tools/power turbostat: Fix names matching
  tools/power turbostat: Allow Zero return value for some RAPL registers
  tools/power turbostat: Clustered Uncore MHz counters should honor show/hide options

2 months agoMerge tag 'soundwire-6.15-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 6 Apr 2025 19:04:53 +0000 (12:04 -0700)]
Merge tag 'soundwire-6.15-rc1-fixes' of git://git./linux/kernel/git/vkoul/soundwire

Pull soundwire fix from Vinod Koul:

 - add missing config symbol CONFIG_SND_HDA_EXT_CORE required for asoc
   driver CONFIG_SND_SOF_SOF_HDA_SDW_BPT

* tag 'soundwire-6.15-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire:
  ASoC: SOF: Intel: Let SND_SOF_SOF_HDA_SDW_BPT select SND_HDA_EXT_CORE

2 months agotools/power turbostat: v2025.05.06
Len Brown [Sun, 6 Apr 2025 18:49:20 +0000 (14:49 -0400)]
tools/power turbostat: v2025.05.06

Support up to 8192 processors
Add cpuidle governor debug telemetry, disabled by default
Update default output to exclude cpuidle invocation counts
Bug fixes

Signed-off-by: Len Brown <len.brown@intel.com>
2 months agotools/power turbostat: disable "cpuidle" invocation counters, by default
Len Brown [Sun, 6 Apr 2025 18:29:57 +0000 (14:29 -0400)]
tools/power turbostat: disable "cpuidle" invocation counters, by default

Create "pct_idle" counter group, the sofware notion of residency
so it can now be singled out, independent of other counter groups.

Create "cpuidle" group, the cpuidle invocation counts.
Disable "cpuidle", by default.

Create "swidle" = "cpuidle" + "pct_idle".
Undocument "sysfs", the old name for "swidle", but keep it working
for backwards compatibilty.

Create "hwidle", all the HW idle counters

Modify "idle", enabled by default
"idle" = "hwidle" + "pct_idle" (and now excludes "cpuidle")

Signed-off-by: Len Brown <len.brown@intel.com>
2 months agoMerge tag 'perf-urgent-2025-04-06' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 6 Apr 2025 17:48:12 +0000 (10:48 -0700)]
Merge tag 'perf-urgent-2025-04-06' of git://git./linux/kernel/git/tip/tip

Pull perf event fix from Ingo Molnar:
 "Fix a perf events time accounting bug"

* tag 'perf-urgent-2025-04-06' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  perf/core: Fix child_total_time_enabled accounting bug at task exit