iio: remove unneeded assignment in __iio_format_value
Trivial cleanup in __iio_format_value() for the IIO_VAL_FRACTIONAL case
where tmp1 = vals[1] assignment is unneeded and irrelevant since tmp1 is
immediately overwritten by the subsequent div_s64_rem() call.
Dumitru Ceclan [Wed, 31 Jul 2024 12:37:25 +0000 (15:37 +0300)]
iio: adc: ad7124: set initial ADC mode to idle
During setup the st->adc_control is 0, which corresponds to a continuous
conversion mode. The reset value for channel 1 is to enable it. The
combined effect of these two is that the ADC will start conversions for
channel 1 without them being read.
This is not neccessarily a problem, but it is an unexpected behavior.
Set the ADC state to idle during setup to avoid this.
Dumitru Ceclan [Wed, 31 Jul 2024 12:37:24 +0000 (15:37 +0300)]
iio: adc: ad7124: reduce the number of SPI transfers
The ad7124_init_config_vref() function writes the AD7124_ADC_CONTROL
register for each channel that is configured to use the internal
reference.
The ad7124_write_config()function performs 7 SPI transfers for
configuring 2 registers: config_x and filter_x.
Reduce the number of SPI transfers:
-during the probe by only setting the st->adc_control value in
ad7124_init_config_vref() and writing to the device only at the end of
ad7124_setup().
-in ad7124_write_config() by grouping writes to the same register.
iio: light: ltr390: Add configurable gain and resolution
Add support for configuring and reading the gain and resolution
(integration time). Also provide the available values for gain and
resoltion respectively via `read_avail` callback.
Nuno Sa [Fri, 2 Aug 2024 14:27:06 +0000 (16:27 +0200)]
iio: adc: ad9467: add digital interface test to debugfs
One useful thing to do (in case of problems) in this high speed devices
with digital interfaces is to try different test patterns to see if the
interface is working properly (and properly calibrated). Hence add this
to debugfs.
On top of this, for some test patterns, the backend may have a matching
validator block which can be helpful in identifying possible issues. For
the other patterns some test equipment must be used so one can look into
the signal and see how it looks like.
Hence, we also add the backend debugfs interface with
iio_backend_debugfs_add().
Nuno Sa [Fri, 2 Aug 2024 14:27:05 +0000 (16:27 +0200)]
iio: adc: ad9467: add backend test mode helpers
Group the backend configurations to be done in preparing and stopping
calibration in two new helpers analogous to ad9467_testmode_set(). This
is in preparation for adding support for debugFS test_mode where
we need similar configurations as in the calibration process.
Nuno Sa [Fri, 2 Aug 2024 14:27:00 +0000 (16:27 +0200)]
iio: backend: add debugFs interface
This adds a basic debugfs interface for backends. Two new ops are being
added:
* debugfs_reg_access: Analogous to the core IIO one but for backend
devices.
* debugfs_print_chan_status: One useful usecase for this one is for
testing test tones in a digital interface and "ask" the backend to
dump more details on why a test tone might have errors.
Nuno Sa [Fri, 2 Aug 2024 14:26:59 +0000 (16:26 +0200)]
iio: backend: introduce struct iio_backend_info
Instead of only passing the backend ops when calling
devm_iio_backend_register(), pass an info like structure that will
contains the ops and additional information. Fow now, the backend name
is being added as that will be used by the debugFS interface introduced
in a later patch.
It also opens the door for further customizations passed by backends.
All users of devm_iio_backend_register() were updated accordingly.
Use of_property_present() to test for property presence rather than
of_find_property(). This is part of a larger effort to remove callers
of of_find_property() and similar functions. of_find_property() leaks
the DT struct property and data pointers which is a problem for
dynamically allocated nodes which may be freed.
Javier Carrasco [Thu, 1 Aug 2024 06:13:51 +0000 (08:13 +0200)]
iio: adc: ad7768-1: use device_* to iterate over device child nodes
Drop the manual access to the fwnode of the device to iterate over its
child nodes. `device_for_each_child_node` macro provides direct access
to the child nodes, and given that they are only required within the
loop, the scoped variant of the macro can be used.
Use the `device_for_each_child_node_scoped` macro to iterate over the
direct child nodes of the device.
Julien Stephan [Wed, 31 Jul 2024 07:05:48 +0000 (09:05 +0200)]
docs: iio: ad7380: add support for single-ended parts
The AD7380 family has some compatible single-ended chips: AD7386/7/8(-4).
These single-ended chips have a 2:1 multiplexer in front of each ADC.
They also include additional configuration registers that allow for either
manual selection or automatic switching (sequencer mode), of the
multiplexer inputs. Add a section to describe this.
Julien Stephan [Wed, 31 Jul 2024 07:05:47 +0000 (09:05 +0200)]
iio: adc: ad7380: enable sequencer for single-ended parts
ad7386/7/8(-4) single-ended parts have a 2:1 mux in front of each ADC.
>From an IIO point of view, all inputs are exported, i.e ad7386/7/8
export 4 channels and ad7386-4/7-4/8-4 export 8 channels. First inputs
of muxes correspond to the first half of IIO channels (i.e 0-1 or 0-3)
and second inputs correspond to second half (i.e 2-3 or 4-7)
Currently, the driver supports only sampling first half OR second half of
the IIO channels. To enable sampling all channels simultaneously, these
parts have an internal sequencer that automatically cycles through the
mux entries.
When enabled, the maximum throughput is divided by two. Moreover, the ADCs
need additional settling time, so we add an extra CS toggle to correctly
propagate setting, and an additional spi transfer to read the second
half.
Julien Stephan [Wed, 31 Jul 2024 07:05:46 +0000 (09:05 +0200)]
iio: adc: ad7380: add support for single-ended parts
Adding ad7386/7/8 (16/14/12 bits) unsigned, dual simultaneous sampling,
single-ended compatible parts, and the corresponding ad7386-4/7-4/8-4
4 channels.
These parts have a 2:1 multiplexer in front of each ADC. They also include
additional configuration registers that allow for either manual selection
or automatic switching (sequencer mode), of the multiplexer inputs.
This commit focus on integrating manual selection. Sequencer mode will
be implemented later.
>From an IIO point of view, all inputs are exported, i.e ad7386/7/8
export 4 channels and ad7386-4/7-4/8-4 export 8 channels.
Inputs AinX0 of multiplexers correspond to the first half of IIO channels
(i.e 0-1 or 0-3) and inputs AinX1 correspond to second half (i.e 2-3 or
4-7). Example for AD7386/7/8 (2 channels parts):
When switching channel, the ADC require an additional settling time.
According to the datasheet, data is valid on the third CS low. We already
have an extra toggle before each read (either direct reads or buffered
reads) to sample correct data, so we just add a single CS toggle at the
end of the register write.
Julien Stephan [Wed, 31 Jul 2024 07:05:45 +0000 (09:05 +0200)]
iio: adc: ad7380: prepare driver for single-ended parts support
ad738x family contains single-ended parts that have a 2:1 mux in front
of ADC, so the number of IIO channels is different from the number of
simultaneous channels that can be sampled.
To prepare the support for single-ended parts, introduce a new
num_simultaneous_channels variable. For currently supported parts,
num_simultaneous_channels is equal to num_channels minus 1 (the
timestamps channel)
Julien Stephan [Wed, 31 Jul 2024 07:05:43 +0000 (09:05 +0200)]
iio: core: add function to retrieve active_scan_mask index
Add a function to retrieve the index of the active scan mask inside the
available scan masks array.
As in iio_scan_mask_match and iio_sanity_check_avail_scan_masks,
this function does not handle multi-long masks correctly.
It only checks the first long to be zero, and will use such mask
as a terminator even if there was bits set after the first long.
This should be fine since the available_scan_mask has already been
sanity tested using iio_sanity_check_avail_scan_masks.
See iio_scan_mask_match and iio_sanity_check_avail_scan_masks for
more details
The adf4378 provides only one output channel. Therefore there is only
one gpio available to enable the output. Reflect that into the bindings
using property conditions.
dt-bindings: iio: light: stk33xx: add compatible for stk3013
STK3013 is a proximity sensor by Sensortek, bearing chipid of 0x31. Despite
being marketed as a proximity sensor, it also appears to have ambient
light sensing capabilities.
The part is fully compatible with the existing implementation of the
device driver. Add the compatible string of stk3013 to the existing
list, with a fallback of stk3310.
Add support for Sensortek's STK3013 in the driver. The part bears the
product ID 0x31.
As seen in [1], Sensortek lists STK3013 as a proximity sensor. But it
has been experimentally observed that they do have ambient light sensing
capabilities. Furthermore, [2] implements a proximity and ambient light
sensor driver for STK3x1x devices, which is also indicative of the fact
that these parts are also ambient light sensors.
In order to allow newer devices which are compatible with existing
sensors, issuing a warning for an unknown chipid indicates that
something has gone wrong with the init process, which isn't ideal.
Swap it with a friendlier info message to get things right.
Petar Stoykov [Thu, 25 Jul 2024 15:37:27 +0000 (17:37 +0200)]
dt-bindings: iio: pressure: Add Sensirion SDP500
Sensirion SDP500 is a digital differential pressure sensor. It provides
a digital I2C output. Add devicetree bindings requiring the compatible
string and I2C slave address (reg).
Add support for Microchip PAC1921 Power/Current monitor.
Implemented features:
* capture of bus voltage, sense voltage, current and power measurements
in free-run integration mode
* support for both raw and triggered buffer reading
* support for overflow events
* scale attributes to control voltage and current gains
* oversampling ratio attribute to control the number of integration
samples
* sampling rate attribute that reflects the integration period
* userspace attribute and DT parameter to control shunt resistor
* simple power management support
Limitations:
* operation mode fixed to free-run integration
* READ/INT pin and OUT pin not supported
* no controls for measurement resolutions and filters
David Lechner [Tue, 23 Jul 2024 18:59:50 +0000 (13:59 -0500)]
iio: adc: mcp3564: use devm_regulator_get_enable_read_voltage()
This makes use of the new devm_regulator_get_enable_read_voltage()
helper function to reduce boilerplate code in the MCP3564 ADC driver.
The error message is slightly changed since there are fewer error
return paths.
Setting adc->vref_mv is consolidated into a single place to make the
logic easier to follow.
A use_internal_vref_attr local variable is added to make it more
obvious what the difference between the two iio info structures is.
The return value of the "Unknown Vref" dev_err_probe() is hard-coded to
-ENODEV instead of ret since it was getting a bit far from where ret
was set and logically that is the only value it could have.
Nuno Sa [Fri, 26 Jul 2024 08:23:15 +0000 (10:23 +0200)]
iio: core: annotate masklength as __private
Now that all users are using the proper accessors, we can mark
masklength as __private so that no one tries to write. We also get help
from checkers in warning us in case someone does it.
To access the private field from IIO core code, we need to use the
ACCESS_PRIVATE() macro.
Nuno Sa [Fri, 26 Jul 2024 08:23:13 +0000 (10:23 +0200)]
iio: common: cros_ec_sensors_core: use new '.masklength' accessors
Make use of iio_get_masklength) and iio_for_each_active_channel() to
access '.masklength' so it can be annotated as __private when there
are no more direct users of it.
Nuno Sa [Fri, 26 Jul 2024 08:23:12 +0000 (10:23 +0200)]
iio: adc: xilinx-xadc-core: use new '.masklength' accessors
Make use of iio_get_masklength) and iio_for_each_active_channel() to
access '.masklength' so it can be annotated as __private when there
are no more direct users of it.
Nuno Sa [Fri, 26 Jul 2024 08:23:10 +0000 (10:23 +0200)]
iio: adc: ti-ads8688: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Fri, 26 Jul 2024 08:23:09 +0000 (10:23 +0200)]
iio: adc: ti-ads131e08: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Fri, 26 Jul 2024 08:23:08 +0000 (10:23 +0200)]
iio: adc: ti-ads124s08: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Fri, 26 Jul 2024 08:23:07 +0000 (10:23 +0200)]
iio: adc: ti-adc12138: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Fri, 26 Jul 2024 08:23:06 +0000 (10:23 +0200)]
iio: adc: ti-ads1298: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Fri, 26 Jul 2024 08:23:03 +0000 (10:23 +0200)]
iio: adc: ti-adc084s021: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Fri, 26 Jul 2024 08:23:02 +0000 (10:23 +0200)]
iio: adc: ti-adc0832: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Fri, 26 Jul 2024 08:22:59 +0000 (10:22 +0200)]
iio: adc: rtq6056: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Fri, 26 Jul 2024 08:22:58 +0000 (10:22 +0200)]
iio: adc: rockchip_saradc: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Fri, 26 Jul 2024 08:22:57 +0000 (10:22 +0200)]
iio: adc: mt6360-adc: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Fri, 26 Jul 2024 08:22:56 +0000 (10:22 +0200)]
iio: adc: mcp3911: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Fri, 26 Jul 2024 08:22:55 +0000 (10:22 +0200)]
iio: adc: max1118: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Fri, 26 Jul 2024 08:22:54 +0000 (10:22 +0200)]
iio: adc: max1118: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Move ABI documentation for custom shunt resistor attributes into the
generic iio documentation file. Exception for pac1934: leave it
untouched since it does not comply with common iio ABI generalization.
Add support for BH1745, which is an I2C colour sensor with red, green,
blue and clear channels. It has a programmable active low interrupt
pin. Interrupt occurs when the signal from the selected interrupt
source channel crosses set interrupt threshold high or low level.
Interrupt source for the device can be configured by enabling the
corresponding event. Interrupt latch is always enabled when setting
up interrupt.
Add myself as the maintainer for this driver in MAINTAINERS.
Signed-off-by: Mudit Sharma <muditsharma.info@gmail.com> Reviewed-by: Ivan Orlov <ivan.orlov0322@gmail.com> Reviewed-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Link: https://patch.msgid.link/20240718220208.331942-2-muditsharma.info@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Nuno Sa [Thu, 18 Jul 2024 13:38:08 +0000 (15:38 +0200)]
iio: proximity: sx_common: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Thu, 18 Jul 2024 13:38:07 +0000 (15:38 +0200)]
iio: proximity: sx9500: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Thu, 18 Jul 2024 13:38:06 +0000 (15:38 +0200)]
iio: proximity: hx9023s: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Thu, 18 Jul 2024 13:38:05 +0000 (15:38 +0200)]
iio: pressure: dlhl60d: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Thu, 18 Jul 2024 13:38:03 +0000 (15:38 +0200)]
iio: light: tcs3472: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Thu, 18 Jul 2024 13:38:02 +0000 (15:38 +0200)]
iio: light: tcs3414: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Thu, 18 Jul 2024 13:38:01 +0000 (15:38 +0200)]
iio: light: si1145: use new '.masklength' accessors
Make use of iio_get_masklength) and iio_for_each_active_channel() to
access '.masklength' so it can be annotated as __private when there
are no more direct users of it.
Nuno Sa [Thu, 18 Jul 2024 13:38:00 +0000 (15:38 +0200)]
iio: light: isl29125: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Thu, 18 Jul 2024 13:37:59 +0000 (15:37 +0200)]
iio: light: gp2ap020a00f: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Thu, 18 Jul 2024 13:37:58 +0000 (15:37 +0200)]
iio: light: adjd_s311: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Thu, 18 Jul 2024 13:37:57 +0000 (15:37 +0200)]
iio: imu: kmx61: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Thu, 18 Jul 2024 13:37:55 +0000 (15:37 +0200)]
iio: imu: bmi160_core: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Thu, 18 Jul 2024 13:37:54 +0000 (15:37 +0200)]
iio: humidity: am2315: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Thu, 18 Jul 2024 13:37:53 +0000 (15:37 +0200)]
iio: health: afe4404: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Thu, 18 Jul 2024 13:37:51 +0000 (15:37 +0200)]
iio: health: afe4403: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Thu, 18 Jul 2024 13:37:50 +0000 (15:37 +0200)]
iio: dummy: iio_simple_dummy_buffer: use iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Thu, 18 Jul 2024 13:37:49 +0000 (15:37 +0200)]
iio: adc: hx711: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Nuno Sa [Thu, 18 Jul 2024 13:37:48 +0000 (15:37 +0200)]
iio: adc: dln2-adc: use new '.masklength' accessors
Make use of iio_get_masklength) and iio_for_each_active_channel() to
access '.masklength' so it can be annotated as __private when there
are no more direct users of it.
Nuno Sa [Thu, 18 Jul 2024 13:37:47 +0000 (15:37 +0200)]
iio: adc: cc10001_adc: make use of iio_for_each_active_channel()
Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.
Internal clock of AD719X devices can be made available on MCLK2 pin. Add
clock provider to support this functionality when clock cells property
is present.
Internal clock of AD719X devices can be made available on MCLK2 pin. Add
clock provider to support this functionality when clock cells property
is present.
The clock source can be either provided externally or the internal clock
is used. Pair of clocks and clock-names property is mutally exclusive
with #clock-cells property.
Modify second example to showcase the mode where internal clock is used.
There are actually 4 configuration modes of clock source for AD719X
devices. Either a crystal can be attached externally between MCLK1 and
MCLK2 pins, or an external CMOS-compatible clock can drive the MCLK2
pin. The other 2 modes make use of the 4.92MHz internal clock.
Undocumented properties adi,int-clock-output-enable and adi,clock-xtal
still supported for backward compatibility, but their use is highly
discouraged. Use cleaner alternative of configuring external clock by
using clock names mclk and xtal.
Functionality of AD7192_CLK_INT_CO will be implemented in complementary
patch by adding clock provider.
There are actually 4 configuration modes of clock source for AD719X
devices. Either a crystal can be attached externally between MCLK1 and
MCLK2 pins, or an external CMOS-compatible clock can drive the MCLK2
pin. The other 2 modes make use of the 4.92MHz internal clock.
To configure external clock as either a crystal or a CMOS-compatible
clock, changing the register settings is necessary. Therefore, add clock
name xtal alongside mclk. By selecting one or the other, the register is
configured.
The presence of an external clock source is optional, not required. When
both clocks and clock-names properties are present, an external clock
source is used. If the intention is to use the internal clock, both
properties should be absent. Modify required properties accordingly.
Marek Vasut [Mon, 15 Jul 2024 18:28:59 +0000 (20:28 +0200)]
iio: light: noa1305: Make integration time configurable
Add another attribute which is the integration time. Report available
integration time settings, support read of integration time currently
configured in hardware, and support configuration of integration time
into hardware.
Marek Vasut [Mon, 15 Jul 2024 18:28:57 +0000 (20:28 +0200)]
iio: light: noa1305: Use static table lookup of scale values
Move scale values into a static table, perform look up of those
scale values in noa1305_scale() simply by using the integration
time register content as an index, because the integration time
register content directly maps to the table values.