Commit Graph

4314 Commits

Author SHA1 Message Date
Gwendal Grignou
9ef38afd25 iio: cros_ec_accel_legacy: Add Read Only frequency entries
Report to user space that 10Hz is the sampling frequency of
the accelerometers in legacy mode, and it can not be changed.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-07-12 14:45:35 +01:00
Alexandru Ardelean
3c53080588 iio: adc: ti_am335x_adc: alloc kfifo & IRQ via devm_ functions
This change attaches the life-cycle of the kfifo buffer & IRQ to the
parent-device. This in turn cleans up the exit & error paths, since we
don't need to explicitly cleanup these resources.

The main intent here is to remove the explicit cleanup of the
'indio_dev->buffer' via 'iio_kfifo_free(indio_dev->buffer);'.

As we want to add support for multiple buffers per IIO device, having it
exposed like this makes it tricky to consider a safe backwards compatible
approach for it.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-07-07 20:24:11 +01:00
Alexandru Ardelean
6ff0199a1d iio: adc: ti_am335x_adc: alloc channels via devm_kcalloc()
This change attaches the life-cycle of the channels array to the parent
device object that is attached to the IIO device.
This way we can remove from the cleanup code, the explicit
tiadc_channels_remove() which simply does a kfree() on the channels array.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-07-07 20:24:11 +01:00
Jonathan Cameron
a07a4fe5ff iio:adc:ingenic: drop of_match_ptr protection and include mod_devicetable.h
Whilst it's unlikely this device will ever be instantiated using
ACPI, there is little advantage not assigning the of_device_id table in all
cases and it avoids providing an example that might be coppied into new
drivers.

Also include mod_devicetable.h whilst here as of_device_id is defined
in there so including the header is best practice.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Artur Rojek <contact@artur-rojek.eu>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
2020-07-07 20:24:11 +01:00
Jonathan Cameron
4e53d47fd3 iio:adc:ti-tlc4541: Drop CONFIG_OF and of_match_ptr protections.
These stop us using ACPI PRP0001 to instantiate the device.
I am slowly clearly out use of these in IIO to avoid this being coppied
into new drivers.

Here I also included mod_devicetable.h as we are using of_match_id
which is defined in there and hence it is best practice to include
it directly.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Phil Reid <preid@electromag.com.au>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
2020-07-07 20:24:11 +01:00
Jonathan Cameron
a6b40706ff iio:adc:ti-adc161s626: Drop of_match_ptr protection.
Dropping this allows use of ACPI PRP0001.

I'm also looking to drop all of_match_ptr use in IIO in order to avoid
it getting cut and paste into new drivers in the future.

Also add a direct include of mod_devicetable.h to reflect the use
of struct of_device_id.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
2020-07-07 20:24:10 +01:00
Jonathan Cameron
f14bac473f iio:adc:ti-adc084s021: drop of_match_ptr protection
Allows ACPI PRP0001 to be used with this driver.
Also adds mod_devicetable.h header as the driver is directly using
struct of_device_id which is defined in that file.

I'm also trying to clear out of_match_ptr use in IIO to avoid it
being cut and paste into new drivers.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Mårten Lindahl <martenli@axis.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
2020-07-07 20:24:10 +01:00
Jonathan Cameron
0896ffdd83 iio:adc:ti-adc0832: drop CONFIG_OF and of_match_ptr protections
These just prevent the driver being used with ACPI PRP0001.

I am also trying to remove these from IIO in general to avoid
them being coppied into new drivers.

Also include the mod_devicetable.h header as we are using
of_device_id which is defined in there.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Akinobu Mita <akinobu.mita@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
2020-07-07 20:24:10 +01:00
Jonathan Cameron
b087374944 iio:adc:ti-adc081c: Drop of_match_ptr and change to mod_devicetable.h
Whilst this driver already supports explicit ACPI bindings we
might as well also allow for PRP0001 based binding.

I'm also keen to remove of_match_ptr from IIO drivers to avoid
this (now) anti-pattern getting coppied into new drivers.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
2020-07-07 20:24:10 +01:00
Jonathan Cameron
34eb7366bc iio:adc:sd_adc_modulator: Drop of_match_ptr and tweak includes
Dropping of_match_ptr allows this driver to be used with ACPI.
The header includes are adjusted to include platform_device.h
and mod_devicetable.h instead of OF specific header as nothing
from that header itself is actually used.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
2020-07-07 20:24:09 +01:00
Jonathan Cameron
bf12d3fd11 iio:adc:mcp3422: remove CONFIG_OF and of_match_ptr protections
They stop the driver being used with ACPI PRP0001 and are something
I want to avoid being cut and paste into new drivers.
Also switch the include from of.h to mod_devicetable.h as we
struct of_device_id is defined in there and we don't use anything
actually in of.h.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Angelo Compagnucci <angelo.compagnucci@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
2020-07-07 20:24:09 +01:00
Jonathan Cameron
016d271e33 iio:adc:mcp320x: Drop CONFIG_OF and of_match_ptr protections
These just prevent the driver being used with ACPI PRP0001.
They also get cut and paste into new drivers and we want to discourage
this from happening by cleaning it out in general.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Oskar Andero <oskar.andero@gmail.com>
Cc: Søren Andersen <san@rosetechnology.dk>
Cc: Lukas Wunner <lukas@wunner.de>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
2020-07-07 20:24:09 +01:00
Jonathan Cameron
1fa8b34a62 iio:adc:max1118: Drop CONFIG_OF / of_match_ptr protections
These just stop the driver being used with ACPI PRP0001 and
we are trying to clear them out of IIO to avoid them getting copied
into new drivers.
Also add the mod_devicetable.h include as we are using
struct of_device_id which is defined in there.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Akinobu Mita <akinobu.mita@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
2020-07-07 20:24:09 +01:00
Jonathan Cameron
7a3e190f9c iio:adc:max11100: Drop of_match_ptr protection / add mod_devicetable.h include
Allows use of driver with ACPI PRP0001 base binding.
Mostly this is about trying to avoid cut and paste of this into new
drivers (it is a frequent review comment) rather than any
thought that this driver might get used on an ACPI platform.

The mod_devicetable.h include is to encourage best practice of including
any header directly used within the code (here for of_match_id)

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
2020-07-07 20:24:09 +01:00
Jonathan Cameron
0a9a500acd iio:adc:ltc2497 drop of_match_ptr protection
This prevents the driver being used with ACPI PRP0001 based
bindings. Also switch include to mod_devicetable.h which devices
the used id structure.

Note this is most about removing something I don't want want cut
and paste into new driver rather than any thought that this particular
driver will be used in an ACPI system (though it might!)

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Michael Hennerich <michael.hennerich@analog.com>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
2020-07-07 20:24:09 +01:00
Jonathan Cameron
29788fd607 iio:adc:cpcap-adc: Drop of_match_ptr protection and use device_get_match_data
Part of a slow effort to avoid OF specific code in IIO.

Whilst the main advantages of this are not likely to be seen in this
particular driver (ACPI support via PRP0001) the change proposed
does make things a bit more maintainable and also ensures that
this particular (now) anti-patern is less likely to be cut and
paste into new drivers.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
2020-07-07 20:24:08 +01:00
Jonathan Cameron
4b7dddb21a iio:adc:ltc2496: Drop of_match_ptr and use mod_devicetable.h
The macro prevents use of driver with ACPI PRP0001 and
the of_match_id structure is defined in mod_devicetable.h so include
that directly rather than of.h.

Note this is mostly about removing something I don't want cut and
paste into new drivers rather than expectation that this particular
driver will be used on an ACPI platform.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
2020-07-07 20:24:08 +01:00
Jonathan Cameron
53469fa5c5 iio:adc:max1027: drop of_match_ptr and CONFIG_OF protections
These just prevent the driver being used with ACPI PRP0001
and provide no major benefits.

Part of clearing these out in general in IIO to avoid cut and paste
repetition in new drivers.  Also include mod_devicetable.h as we
directly make use of of_device_id which is defined in there.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Philippe Reynes <tremyfr@yahoo.fr>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
2020-07-07 20:24:08 +01:00
Jonathan Cameron
f84ff467c0 iio:adc:max1363: Drop of_match_ptr and use generic device_get_match_data
Allows driver to use ACPI PRP0001 binding and there was no particular
advantage in having the protections in this driver.

Mostly this part of an effort to remove as many OF specific bits
of handling from IIO and use the generic forms where possible.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
2020-07-07 20:24:08 +01:00
Jonathan Cameron
f8e6ae5a33 iio:adc:hi8435: Drop of_match_ptr protection.
Allows use of ACPI with PRP0001 and is generally something we are
trying to avoid having people cut and paste into new drivers without
thinking about it.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Vladimir Barinov <vladimir.barinov@cogentembedded.com>
Cc: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
2020-07-07 20:24:08 +01:00
Jonathan Cameron
3745440f49 iio:adc:hi8435: Drop unused of_gpio.h header
I guess this is a left over from some earlier cleanup. Not used
currently.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Cc: Vladimir Barinov <vladimir.barinov@cogentembedded.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
2020-07-07 20:24:08 +01:00
Jonathan Cameron
7277a74a6c iio:adc:lpc32xx: Drop of_match_ptr protection
Whilst is unlikely anyone will be using this part with an ACPI PRP0001
based binding any time soon, we are getting a lot of cut and pasting
of this pattern so I am looking to remove it entirely from IIO.

In this case CONFIG_OF protections also removed and
mod_devicetable.h include added given direct use of struct of_device_id.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
2020-07-07 20:24:08 +01:00
Krzysztof Kozlowski
0954bc9787 iio: magnetometer: bmc150: Add proper compatible for BMM150
The compatible for BMM150 should not have "_magn" suffix because, unlike
two other Bosch devices, it is only a magnetometer.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-07-07 20:24:07 +01:00
Nuno Sá
471622c92d iio: adis16480: Use irq types instead of flags
The value retrieved by `irqd_get_trigger_type()` is not an irq flag.
While the values are the same, the meaning is different.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-07-07 20:24:07 +01:00
Alexandru Ardelean
fa83c3baa5 iio: core: move event interface on the opaque struct
Same as with other private fields, this moves the event interface reference
to the opaque IIO device object, to be invisible to drivers.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-07-07 20:24:07 +01:00
Alexandru Ardelean
6a8c6b26f7 iio: core: move iio_dev's buffer_list to the private iio device object
This change moves the 'buffer_list' away from the public IIO device object
into the private part.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-07-07 20:24:06 +01:00
Alexandru Ardelean
207c2d27a0 iio: core: move channel list & group to private iio device object
This change bit straightforward and simple, since the
'channel_attr_list' & 'chan_attr_group' fields are only used in
'industrialio-core.c'.

This change moves to the private IIO device object

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-07-07 20:24:06 +01:00
Alexandru Ardelean
96fb1b6742 iio: core: move debugfs data on the private iio dev info
This change moves all iio_dev debugfs fields to the iio_dev_priv object.
It's not the biggest advantage yet (to the whole thing of abstractization)
but it's a start.

The iio_get_debugfs_dentry() function (which is moved in
industrialio-core.c) needs to also be guarded against the CONFIG_DEBUG_FS
symbol, when it isn't defined. We do want to keep the inline definition in
the iio.h header, so that the compiler can better infer when to compile out
debugfs code that is related to the IIO debugfs directory.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-07-07 20:24:06 +01:00
Alexandru Ardelean
09673d5e1b iio: core: remove padding from private information
There was a recent discussion about this code:
  https://lore.kernel.org/linux-iio/20200322165317.0b1f0674@archlinux/

This looks like a good time to removed this, since any issues about it
should pop-up under testing, because the iio_dev is having a bit of an
overhaul and stuff being moved to iio_dev_opaque.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-07-07 20:24:06 +01:00
Alexandru Ardelean
6d4ebd565d iio: core: wrap IIO device into an iio_dev_opaque object
There are plenty of bad designs we want to discourage or not have to review
manually usually about accessing private (marked as [INTERN]) fields of
'struct iio_dev'.

Sometimes users copy drivers that are not always the best examples.

A better idea is to hide those fields into the framework.
For 'struct iio_dev' this is a 'struct iio_dev_opaque' which wraps a public
'struct iio_dev' object.

In the next series, some fields will be moved to this new struct, each with
it's own rework.

This rework will not be complete-able for a while, as many fields need some
drivers to be reworked in order to finalize them (e.g. 'indio_dev->mlock').

But some fields can already be moved, and in time, all of them may get
there (in the 'struct iio_dev_opaque' object).

Since a lot of drivers also call 'iio_priv()', in order to preserve
fast-paths (where this matters), the public iio_dev object will have a
'priv' field that will have the pointer to the private information already
computed. The reference returned by this field should be guaranteed to be
cacheline aligned.

The opaque parts will be moved into the 'include/linux/iio/iio-opaque.h'
header. Should the hidden information be required for some debugging or
some special needs, it can be made available via this header.
Otherwise, only the IIO core files should include this file.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-07-07 20:24:06 +01:00
Alexandru Ardelean
ebf35aad0b iio: at91-sama5d2_adc: remove usage of iio_priv_to_dev() helper
We may want to get rid of the iio_priv_to_dev() helper. The reason is that
we will hide some of the members of the iio_dev structure (to prevent
drivers from accessing them directly), and that will also mean hiding the
implementation of the iio_priv_to_dev() helper inside the IIO core.

Hiding the implementation of iio_priv_to_dev() implies that some fast-paths
may not be fast anymore, so a general idea is to try to get rid of the
iio_priv_to_dev() altogether.
The iio_priv() helper won't be affected by the rework, as the iio_dev
struct will keep a reference to the private information.

For this driver, not using iio_priv_to_dev(), means reworking some paths to
pass the iio device and using iio_priv() to access the private information,
and also keeping a reference to the iio device for some quirky paths.

One [quirky] path is the at91_adc_workq_handler() which requires the IIO
device & the state struct to push to buffers.
Since this requires the back-ref to the IIO device, the
at91_adc_touch_pos() also uses it. This simplifies the patch a bit. The
information required in this function is mostly for debugging purposes.
Replacing it with a reference to the IIO device would have been a slightly
bigger change, which may not be worth it (for just the debugging purpose
and given that we need the back-ref to the IIO device anyway).

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-07-07 20:24:05 +01:00
Tomasz Duszynski
d4553d6ec1 iio: chemical: scd30: add serial interface driver
Add serial interface driver for the SCD30 sensor.

Signed-off-by: Tomasz Duszynski <tomasz.duszynski@octakon.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 14:52:38 +01:00
Tomasz Duszynski
e510190e01 iio: chemical: scd30: add I2C interface driver
Add I2C interface driver for the SCD30 sensor.

Signed-off-by: Tomasz Duszynski <tomasz.duszynski@octakon.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 14:50:30 +01:00
Tomasz Duszynski
64b3d8b1b0 iio: chemical: scd30: add core driver
Add Sensirion SCD30 carbon dioxide core driver.

Signed-off-by: Tomasz Duszynski <tomasz.duszynski@octakon.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 14:46:44 +01:00
Jean-Baptiste Maneyrol
ec74ae9fd3 iio: imu: inv_icm42600: add accurate timestamping
Add a timestamping mechanism for buffer that provides accurate
event timestamps when using watermark. This mechanism estimates
device internal clock by comparing FIFO interrupts delta time and
device elapsed time computed by parsing FIFO data.

Take interrupt timestamp in hard irq handler and add IIO device
specific timestamp structures in device private allocation.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 14:24:42 +01:00
Jean-Baptiste Maneyrol
7f85e42a6c iio: imu: inv_icm42600: add buffer support in iio devices
Add all FIFO parsing and reading functions. Add accel and gyro
kfifo buffer and FIFO data parsing. Use device interrupt for
reading data FIFO and launching accel and gyro parsing.

Support hwfifo watermark by multiplexing gyro and accel settings.
Support hwfifo flush.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 14:23:18 +01:00
Jean-Baptiste Maneyrol
e5efa1049b iio: imu: inv_icm42600: add device interrupt
Add INT1 interrupt support. Support interrupt edge and level,
active high or low. Push-pull or open-drain configurations.

Interrupt will be used to read data from the FIFO.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 14:21:45 +01:00
Jean-Baptiste Maneyrol
8237945dbc iio: imu: add Kconfig and Makefile for inv_icm42600 driver
Add 3 modules: inv-icm42600, inv-icm42600-i2c, inv-icm42600-spi.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 14:20:25 +01:00
Jean-Baptiste Maneyrol
bc3eb0207f iio: imu: inv_icm42600: add temperature sensor support
Add temperature channel in gyroscope and accelerometer devices.

Temperature is available in full 16 bits resolution when reading
register and in low 8 bits resolution in the FIFO. Return full
precision raw temperature with corresponding scale and offset.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 14:20:16 +01:00
Jean-Baptiste Maneyrol
a47c1cdcb9 iio: imu: inv_icm42600: add accelerometer IIO device
Add IIO device for accelerometer sensor with data polling
interface.
Attributes: raw, scale, sampling_frequency, calibbias.

Accelerometer in low noise mode.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 14:20:13 +01:00
Jean-Baptiste Maneyrol
a095fadb44 iio: imu: inv_icm42600: add gyroscope IIO device
Add IIO device for gyroscope sensor with data polling interface.
Attributes: raw, scale, sampling_frequency, calibbias.

Gyroscope in low noise mode.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 14:20:11 +01:00
Jean-Baptiste Maneyrol
9f9ff91b77 iio: imu: inv_icm42600: add SPI driver for inv_icm42600 driver
Add SPI driver for InvenSense ICM-426xxx devices.

Configure bus signal slew rates as indicated in the datasheet.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 14:20:08 +01:00
Jean-Baptiste Maneyrol
7297ef1e26 iio: imu: inv_icm42600: add I2C driver for inv_icm42600 driver
Add I2C driver for InvenSense ICM-426xxx devices.

Configure bus signal slew rates as indicated in the datasheet.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 14:18:42 +01:00
Jean-Baptiste Maneyrol
31c24c1e93 iio: imu: inv_icm42600: add core of new inv_icm42600 driver
Core component of a new driver for InvenSense ICM-426xx devices.
It includes registers definition, main probe/setup, and device
utility functions.

ICM-426xx devices are latest generation of 6-axis IMU,
gyroscope+accelerometer and temperature sensor. This device
includes a 2K FIFO, supports I2C/I3C/SPI, and provides
intelligent motion features like pedometer, tilt detection,
and tap detection.

Signed-off-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 14:17:24 +01:00
Jishnu Prakash
8f52a15aca iio: adc: Combine read functions for PMIC5 and PMIC7
Add a common function used for read_raw callback for both PMIC5
and PMIC7 ADCs.

Signed-off-by: Jishnu Prakash <jprakash@codeaurora.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 14:10:52 +01:00
Simon Xue
4e130dc7b4 iio: adc: rockchip_saradc: Add support iio buffers
Add the ability to also support access via (triggered) buffers
next to the existing direct mode.

Device in question is the Odroid Go Advance that connects a joystick
to two of the saradc channels for X and Y axis and the new (and still
pending) adc joystick driver of course wants to use triggered buffers
from the iio subsystem.

Signed-off-by: Simon Xue <xxm@rock-chips.com>
[some simplifications and added commit description]
Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 13:09:15 +01:00
Heiko Stuebner
71eb7c855b iio: adc: rockchip_saradc: better prefix for channel constant
As suggested give the current ADC_CHANNEL constant a distinct
and consistent prefix.

Suggested-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 13:03:38 +01:00
Heiko Stuebner
d0389d4ed3 iio: adc: rockchip_saradc: move all of probe to devm-functions
Parts of the saradc probe rely on devm functions and later parts do not.
This makes it more difficult to for example enable triggers via their
devm-functions and would need more undo-work in remove.

So to make life easier for the driver, move the rest of probe calls
also to their devm-equivalents.

This includes moving the clk- and regulator-disabling to a devm_action
so that they gets disabled both during remove and in the error case
in probe, after the action is registered.

Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-27 13:00:26 +01:00
Lars-Peter Clausen
f11d59d87b iio: Move attach/detach of the poll func to the core
All devices using a triggered buffer need to attach and detach the trigger
to the device in order to properly work. Instead of doing this in each and
every driver by hand move this into the core.

At this point in time, all drivers should have been resolved to
attach/detach the poll-function in the same order.

This patch removes all explicit calls of iio_triggered_buffer_postenable()
& iio_triggered_buffer_predisable() in all drivers, since the core handles
now the pollfunc attach/detach.

The more peculiar change is for the 'at91-sama5d2_adc' driver, since it's
not immediately obvious that removing the hooks doesn't break anything.
Eugen was able to test on at91-sama5d2-adc driver, sama5d2-xplained board.
All seems to be fine.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Tested-by: Eugen Hristev <eugen.hristev@microchip.com> #for at91-sama5d2-adc
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-20 17:34:44 +01:00
Alexandru Ardelean
044d406a84 iio: at91_adc: remove usage of iio_priv_to_dev() helper
We may want to get rid of the iio_priv_to_dev() helper. The reason is that
we will hide some of the members of the iio_dev structure (to prevent
drivers from accessing them directly), and that will also mean hiding the
implementation of the iio_priv_to_dev() helper inside the IIO core.

Hiding the implementation of iio_priv_to_dev() implies that some fast-paths
may not be fast anymore, so a general idea is to try to get rid of the
iio_priv_to_dev() altogether.
The iio_priv() helper won't be affected by the rework, as the iio_dev
struct will keep a reference to the private information.

For this driver, not using iio_priv_to_dev(), means reworking some paths to
pass the iio device and using iio_priv() to access the private information.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Tested-by: Eugen Hristev <eugen.hristev@microchip.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-20 17:29:38 +01:00