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.
Marek Vasut [Mon, 15 Jul 2024 18:28:56 +0000 (20:28 +0200)]
iio: light: noa1305: Assign val in noa1305_measure()
Make noa1305_measure() behave similar to noa1305_scale(), make it
assign the 'val' output variable on success and return IIO_VAL_INT.
This further simplifies noa1305_read_raw() and allows removal of
ret variable altogether.
Marek Vasut [Mon, 15 Jul 2024 18:28:55 +0000 (20:28 +0200)]
iio: light: noa1305: Simplify noa1305_read_raw()
The only channel this hardware supports is IIO_LIGHT, if the channel
is anything else, exit right away. The 'ret' variable is now always
only assigned by noa1305_measure(), do not initialize it anymore.
Update function parameter indent. No functional change.
David Lechner [Fri, 12 Jul 2024 16:03:55 +0000 (11:03 -0500)]
iio: dac: mcp4922: drop remove() callback
By using devm_iio_device_register(), we can drop the remove() callback
in the mcp4922 driver. We can also remove spi_set_drvdata() since there
are no more callers of spi_get_drvdata(). Also use dev_err_probe()
while we are at it.
iio: pressure: bmp280: Fix waiting time for BMP3xx configuration
According to the datasheet, both pressure and temperature can go up to
oversampling x32. With this option, the maximum measurement time is not
80ms (this is for press x32 and temp x2), but it is 130ms nominal
(calculated from table 3.9.2) and since most of the maximum values
are around +15%, it is configured to 150ms.
Fixes: 8d329309184d ("iio: pressure: bmp280: Add support for BMP380 sensor family") Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com> Link: https://patch.msgid.link/20240711211558.106327-3-vassilisamir@gmail.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
David Lechner [Thu, 11 Jul 2024 19:15:42 +0000 (14:15 -0500)]
iio: adc: ad4695: Add driver for AD4695 and similar ADCs
This is a new driver for Analog Devices Inc. AD4695 and similar ADCs.
The initial driver supports initializing the chip including configuring
all possible LDO and reference voltage sources as well as any possible
voltage input channel wiring configuration.
Only the 4-wire SPI wiring mode where the CNV pin is tied to the CS pin
is supported at this time. And reading sample data from the ADC can only
be done in direct mode for now.
Co-developed-by: Ramona Gradinariu <ramona.gradinariu@analog.com> Signed-off-by: Ramona Gradinariu <ramona.gradinariu@analog.com> Signed-off-by: David Lechner <dlechner@baylibre.com> Reviewed-by: Nuno Sa <nuno.sa@analog.com> Link: https://patch.msgid.link/20240711-iio-adc-ad4695-v4-2-c31621113b57@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Introduces a more generalized ABI documentation for DAC. Instead of
having separate ABI files for each DAC, we now have a single ABI file
that covers the common sysfs interface for all DAC.
Signed-off-by: Kim Seer Paller <kimseer.paller@analog.com>
https://patch.msgid.link/20240718051834.32270-2-kimseer.paller@analog.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Nuno Sa [Tue, 9 Jul 2024 11:14:29 +0000 (13:14 +0200)]
iio: backend: print message in case op is not implemented
For APIs that have a return value, -EOPNOTSUPP is returned in case the
backend does not support the functionality. However, for APIs that do
not have a return value we are left in silence. Hence, at least print a
debug message in case the callback is not implemented by the backend.
Add documentation for adxl380 driver which describes the driver
device files and shows how the user may use the ABI for various
scenarios (configuration, measurement, etc.).
The ADXL380/ADXL382 is a low noise density, low power, 3-axis
accelerometer with selectable measurement ranges. The ADXL380 supports
the +/-4 g, +/-8 g, and +/-16 g ranges, and the ADXL382 supports
+/-15 g, +/-30 g and +/-60 g ranges.
The ADXL380/ADXL382 offers industry leading noise, enabling precision
applications with minimal calibration. The low noise, and low power
ADXL380/ADXL382 enables accurate measurement in an environment with
high vibration, heart sounds and audio.
In addition to its low power consumption, the ADXL380/ADXL382 has many
features to enable true system level performance. These include a
built-in micropower temperature sensor, single / double / triple tap
detection and a state machine to prevent a false triggering. In
addition, the ADXL380/ADXL382 has provisions for external control of
the sampling time and/or an external clock.
iio: pressure: bmp280: Add triggered buffer support
BMP2xx, BME280, BMP3xx, and BMP5xx use continuous buffers for their
temperature, pressure and humidity readings. This facilitates the
use of burst/bulk reads in order to acquire data faster. The
approach is different from the one used in oneshot captures.
BMP085 & BMP1xx devices use a completely different measurement
process that is well defined and is used in their buffer_handler().
iio: pressure: bmp280: Add SCALE, RAW values in channels and refactorize them
Add extra IIO_CHAN_INFO_SCALE and IIO_CHAN_INFO_RAW channels in order
to be able to calculate the processed value with standard userspace
IIO tools. Can be used for triggered buffers as well.
Even though it is not a good design choice to have SCALE, RAW and
PROCESSED together, the PROCESSED channel is kept for ABI compatibility.
While at it, separate BMPxxx and BMExxx device channels since BME
supports also humidity measurements.
Add the coefficients for the IIO standard units and the IIO value
inside the chip_info structure.
Move the calculations for the IIO unit compatibility from inside the
read_{temp,press,humid}() functions and move them to the general
read_raw() function.
In this way, all the data for the calculation of the value are
located in the chip_info structure of the respective sensor.
Marek Vasut [Mon, 8 Jul 2024 11:41:18 +0000 (13:41 +0200)]
iio: light: ltrf216a: Add LTR-308 support
Add LiteOn LTR-308 support into LTR-F216A kernel driver.
The two devices seem to have almost identical register map, except that
the LTR-308 does not have three CLEAR_DATA registers, which are unused
by this driver. Furthermore, LTR-308 and LTR-F216A use different lux
calculation constants, 0.6 and 0.45 respectively. Both differences are
handled using chip info data.
Marek Vasut [Mon, 8 Jul 2024 11:41:17 +0000 (13:41 +0200)]
dt-bindings: iio: light: ltrf216a: Document LTR-308 support
Document LiteOn LTR-308 support in LTR-F216A bindings.
The two devices seem to have almost identical register map, except that
the LTR-308 does not have three CLEAR_DATA registers, which are unused
by this driver. Furthermore, LTR-308 and LTR-F216A use different lux
calculation constants, 0.6 and 0.45 respectively.
Matti Vaittinen [Fri, 5 Jul 2024 10:55:49 +0000 (13:55 +0300)]
iio: bu27034: Add a read only HARDWAREGAIN
The ROHM BU27034 light sensor has two data channels for measuring
different frequencies of light. The result from these channels is
combined into Lux value while the raw channel values are reported via
intensity channels.
Both of the intensity channels have adjustable gain setting which
impacts the scale of the raw channels. Eg, doubling the gain will double
the values read from the raw channels, which halves the scale value. The
integration time can also be set for the sensor. This does also have an
impact to the scale of the intensity channels because increasing the
integration time will also increase the values reported via the raw
channels.
Impact of integration time to the scale and the fact that the scale value
does not start from '1', can make it hard for a human reader to compute the
gain values based on the scale.
Matti Vaittinen [Fri, 5 Jul 2024 10:55:34 +0000 (13:55 +0300)]
bu27034: ROHM BU27034ANUC correct lux calculation
The ROHM BU27034NUC was cancelled and BU27034ANUC is replacing this
sensor. The lux computation based on the data from a BU27034ANUC is
different from the computation for the data from an old BU27034NUC.
Matti Vaittinen [Fri, 5 Jul 2024 10:55:19 +0000 (13:55 +0300)]
bu27034: ROHM BU27034ANUC correct gains and times
The ROHM BU27034NUC was cancelled and BU27034ANUC is replacing this
sensor. The BU27034ANUC does not support all the gains or all the
integration times that were supported on BU27034NUC.
Matti Vaittinen [Fri, 5 Jul 2024 10:54:47 +0000 (13:54 +0300)]
bu27034: ROHM BU27034NUC to BU27034ANUC
The ROHM BU27034NUC was cancelled and BU27034ANUC is replacing this
sensor. These senors aren't compatible from the software point of view.
According to ROHM, the BU27034NUC was never mass-produced. Hence dropping
the BU27034NUC support and using this driver to support BU27034ANUC
should not be a problem to users. We however need to ensure than people
who use old kernel with the old BU27034NUC driver don't get the old
driver probed for the new sensor.
Prepare to use the BU27034NUC driver to support the new BU27034ANUC and
change the compatible to prevent probing the old driver with the new
sensor.
Matti Vaittinen [Fri, 5 Jul 2024 10:54:12 +0000 (13:54 +0300)]
dt-bindings: iio: BU27034 => BU27034ANUC
The BU27034NUC was cancelled before it entered mass production. It was
replaced by a new variant BU27034ANUC (note, added 'A'). The new
variant gained a few significant changes, like removal of the 3.rd data
channel and dropping some of the gain settings. This means that, from
software point of view these ICs are incompatible. Lux calculation based
on the data from the sensors needs to be done differently, and on the
BU27034ANUC the channel 3 data is missing. Also, the gain setting
differencies matter.
Unfortunately, the identification register was not changed so there is no
safe way for the software to distinguish the variants.
According to the ROHM HQ engineers, the old BU27034NUC should not be
encountered in the wild. Hence it makes sense to remove the support for
the old BU27034NUC and add support for the new BU27034ANUC. Change the
compatible in order to not load the incompatible old driver for new sensor
(or, if someone had the old sensor, the new driver for it).
Drop the compatible for old sensor which should not be in the wild and
add a new compatible for the new model with accurate model suffix
'anuc'. Rename the file to match the new compatible.
The reading of the pressure and humidity value, requires an update of the
t_fine variable which happens by reading the temperature value.
So the bme680_read_{press/humid}() functions of the above sensors are
internally calling the equivalent bme680_read_temp() function in order to
update the t_fine value. By just looking at the code this relation is a
bit hidden and is not easy to understand why those channels are not
independent.
This commit tries to clear these thing a bit by splitting the
bme680_{read/compensate}_{temp/press/humid}() to the following:
i. bme680_read_{temp/press/humid}_adc(): read the raw value from the
sensor.
ii. bme680_calc_t_fine(): calculate the t_fine variable.
iii. bme680_get_t_fine(): get the t_fine variable.
iv. bme680_compensate_{temp/press/humid}(): compensate the adc values and
return the calculated value.
v. bme680_read_{temp/press/humid}(): combine calls of the aforementioned
functions to return the requested value.
iio: chemical: bme680: Move forced mode setup in ->read_raw()
Whenever the sensor is set to forced mode, a TPHG cycle is triggered and
the values of temperature, pressure, humidity and gas become ready to be
read.
The setup of the forced mode to trigger measurements was located inside
the read_{temp/gas}() functions. This was not posing a functional problem
since read_{humid/press}() are internally calling read_temp() so the
forced mode is set through this call.
This is not very clear and it is kind of hidden that regardless of the
measurement, the setup of the forced mode needs to happen before any
measurement.
iio: chemical: bme680: Remove redundant gas configuration
There is no need to explicitly configure the gas measurement registers
every time a gas measurement takes place. These are initial configurations
which are written in the beginning and they are not changed throughout
the lifetime of the driver.
If in the future, the device starts to support multiple configuration
profiles with variable heater duration and heater temperature, then they
could become members of the ->read_avail().
Modify the startup procedure to reflect the procedure of the Bosch BME68x
Sensor API. The initial readings and configuration of the sensor need to
happen in the following order:
1) Read calibration data [1,2]
2) Chip general configuration [3]
3) Gas configuration [4]
After the chip configuration it is necessary to ensure that the sensor is
in sleeping mode, in order to apply the gas configuration settings [5].
Also, after the soft reset, it is advised to wait for 5ms [6].
iio: chemical: bme680: Add read buffers in read/write buffer union
Move the buffers that are used in order to read data from the device in
the union which handles all the device read/write buffers. Also create
defines for the number of bytes that are being read from the device and
don't use magic numbers.
iio: chemical: bme680: Allocate IIO device before chip initialization
Move the IIO device allocation before the actual initialization of the
chip to be more consistent with most IIO drivers and also to have the
ability to use any driver specific data for the chip initialization.
iio: chemical: bme680: Use bulk reads for calibration data
Calibration data are located in contiguous-ish registers inside the chip.
For that reason we can use bulk reads as is done as well in the BME68x
Sensor API [1].
The arrays that are used for reading the data out of the sensor
are located inside DMA safe buffer.
The LSB of the gas register was read first to check if the following
check was correct and then the MSB+LSB were read together. Simplify this
by reading together the MSB+LSB immediately.
The ACPI ID table was removed with the following 2 commits:
Commit b73d21dccf68 ("iio: bme680_i2c: Remove acpi_device_id table")
Commit f0e4057e97c1 ("iio: bme680_spi: Remove acpi_device_id table")
Remove the remaining ACPI related stuff to this driver since they are
not directly used.
iio: chemical: bme680: Fix read/write ops to device by adding mutexes
Add mutexes in the {read/write}_raw() functions of the device to guard the
read/write of data from/to the device. This is necessary because for any
operation other than temperature, multiple reads need to take place from
the device. Even though regmap has a locking by itself, it won't protect us
from multiple applications trying to read at the same time temperature and
pressure since the pressure reading includes an internal temperature
reading and there is nothing to ensure that this temperature+pressure
reading will happen sequentially without any other operation interfering
in the meantime.
Yasin Lee [Tue, 2 Jul 2024 14:12:34 +0000 (22:12 +0800)]
iio: proximity: Add driver support for TYHX's HX9023S capacitive proximity sensor
A SAR sensor from NanjingTianyihexin Electronics Ltd.
The device has the following entry points:
Usual frequency:
- sampling_frequency
Instant reading of current values for different sensors:
- in_proximity0_raw
- in_proximity1_raw
- in_proximity2_raw
- in_proximity3_raw
- in_proximity4_raw
and associated events in events/
iio: adc: ad7606: fix standby gpio state to match the documentation
The binding's documentation specifies that "As the line is active low, it
should be marked GPIO_ACTIVE_LOW". However, in the driver, it was handled
the opposite way. This commit sets the driver's behaviour in sync with the
documentation
Fixes: 722407a4e8c0 ("staging:iio:ad7606: Use GPIO descriptor API") Signed-off-by: Guillaume Stols <gstols@baylibre.com> Reviewed-by: Nuno Sa <nuno.sa@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
gpiod_set_array_value was misused here: the implementation relied on the
assumption that an unsigned long was required for each gpio, while the
function expects a bit array stored in "as much unsigned long as needed
for storing one bit per GPIO", i.e it is using a bit field.
This leaded to incorrect parameter passed to gpiod_set_array_value, that
would set 1 value instead of 3.
It also prevents to select the software mode correctly for the AD7606B.
Fixes: d2a415c86c6b ("iio: adc: ad7606: Add support for AD7606B ADC") Fixes: 41f71e5e7daf ("staging: iio: adc: ad7606: Use find_closest() macro") Signed-off-by: Guillaume Stols <gstols@baylibre.com> Reviewed-by: Nuno Sa <nuno.sa@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Since the driver supports several parts that present differences in
their layout and behaviour, it is necessary to describe the differences
from one chip to another.
Nuno Sa [Thu, 4 Jul 2024 09:25:25 +0000 (11:25 +0200)]
iio: adc: ad9467: support new parts
Add support for new devices:
* Analog Devices AD9652 16-bit 310 MSPS ADC;
* Analog Devices AD9643 14-Bit, 170/210/250 MSPS ADC;
* Analog Devices AD9649 14-bit 20/40/65/80 MSPS ADC.
Nuno Sa [Thu, 4 Jul 2024 09:25:24 +0000 (11:25 +0200)]
dt-bindings: adc: ad9467: support new parts
Add support for new devices:
* Analog Devices AD9652 16-bit 310 MSPS ADC;
* Analog Devices AD9643 14-Bit, 170/210/250 MSPS ADC;
* Analog Devices AD9649 14-bit 20/40/65/80 MSPS ADC.
Note all these parts have subtle differences in their programming model
(different scales, number of channels, etc..) so fallbacks are not
possible.
Nuno Sa [Thu, 4 Jul 2024 09:25:23 +0000 (11:25 +0200)]
iio: adc: ad9467: don't allow reading vref if not available
If there's only one possible scale, there's no way to change the Vref
select in the device so avoid reading the register in ad9467_get_scale().
In this case, it makes no sense to provide the .read_available()
callback nor allowing for writing the scale attribute.
Note this is in preparation for supporting a new device that only has
one possible scale.
Nuno Sa [Thu, 4 Jul 2024 09:25:22 +0000 (11:25 +0200)]
iio: adc: ad9467: add new chip_info variables
Add new variables to the per chip info structure:
* test_points: Number of valid test points for calibration;
* has_dco_invert: Supports inverting DCO (Data clock output) polarity;
* dco_en: Specicic mask to enable DCO delays.
This is in preparation for supporting new parts with subtle differences
in how to configure the hardware.
Note that with the new test_points variable, we also add a new
calib_map_size to 'struct ad9467_state' so we know our map size
depending on how many test points we have and if we can run the
calibration in the inverted state or not.
Nuno Sa [Thu, 4 Jul 2024 09:25:21 +0000 (11:25 +0200)]
iio: adc: ad9467: support multiple channels calibration
The calibration process mixes the support for calibrating multiple
channels with only having one channel. Some paths do have 'num_channels'
into account while others don't.
As of now, the driver only supports devices with one channel so the
above is not really a problem. That said, we'll add support for devices
with more than one channel, hence let's properly make the calibration
process to work with it.
Javier Carrasco [Wed, 3 Jul 2024 21:04:53 +0000 (23:04 +0200)]
iio: pressure: bmp280: Constify struct regmap_bus
`bmp280_regmap_bus` and `bmp380_regmap_bus` are conditionally assigned
to `bmp_regmap_bus`, which is only used to pass the struct as a
read-only member.
Add the const modifier to the structs and the pointer to move the data
to a read-only section.