From dbf20809d6e0072ad189c937761d58bf98a47b43 Mon Sep 17 00:00:00 2001 From: Nuno Sa Date: Tue, 27 Apr 2021 10:54:52 +0200 Subject: iio: adis: add burst_max_speed_hz variable Typically, in burst mode, the device cannot operate at it's full spi speed. Hence, the spi transfers for burst mode have to take this into account. With this change we avoid a potential race with the spi core as drivers were 'hacking' the device 'max_speed_hz' directly in the trigger handler. Reviewed-by: Alexandru Ardelean Signed-off-by: Nuno Sa Link: https://lore.kernel.org/r/20210427085454.30616-5-nuno.sa@analog.com Signed-off-by: Jonathan Cameron --- include/linux/iio/imu/adis.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/linux/iio/imu/adis.h b/include/linux/iio/imu/adis.h index f9b728d490b1..cf49997d5903 100644 --- a/include/linux/iio/imu/adis.h +++ b/include/linux/iio/imu/adis.h @@ -55,6 +55,7 @@ struct adis_timeout { * this should be the minimum size supported by the device. * @burst_max_len: Holds the maximum burst size when the device supports * more than one burst mode with different sizes + * @burst_max_speed_hz: Maximum spi speed that can be used in burst mode */ struct adis_data { unsigned int read_delay; @@ -83,6 +84,7 @@ struct adis_data { unsigned int burst_reg_cmd; unsigned int burst_len; unsigned int burst_max_len; + unsigned int burst_max_speed_hz; }; /** -- cgit v1.2.3 From 15ea2878bfb255099092634d28f31177f237ccd7 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Mon, 26 Apr 2021 18:49:03 +0100 Subject: iio: core: move @id from struct iio_dev to struct iio_dev_opaque Continuing from Alexandru Ardelean's introduction of the split between driver modifiable fields and those that should only be set by the core. This could have been done in two steps to make the actual move after introducing iio_device_id() but there seemed limited point to that given how mechanical the majority of the patch is. Includes fixup from Alex for missing mxs-lradc-adc conversion. Signed-off-by: Jonathan Cameron Reviewed-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20210426174911.397061-2-jic23@kernel.org --- include/linux/iio/iio-opaque.h | 2 ++ include/linux/iio/iio.h | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/linux/iio/iio-opaque.h b/include/linux/iio/iio-opaque.h index 32addd5e790e..e66b029d99de 100644 --- a/include/linux/iio/iio-opaque.h +++ b/include/linux/iio/iio-opaque.h @@ -6,6 +6,7 @@ /** * struct iio_dev_opaque - industrial I/O device opaque information * @indio_dev: public industrial I/O device information + * @id: used to identify device internally * @event_interface: event chrdevs associated with interrupt lines * @attached_buffers: array of buffers statically attached by the driver * @attached_buffers_cnt: number of buffers in the array of statically attached buffers @@ -26,6 +27,7 @@ */ struct iio_dev_opaque { struct iio_dev indio_dev; + int id; struct iio_event_interface *event_interface; struct iio_buffer **attached_buffers; unsigned int attached_buffers_cnt; diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index f2d65e2e88b6..569861d5887a 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -488,7 +488,6 @@ struct iio_buffer_setup_ops { /** * struct iio_dev - industrial I/O device - * @id: [INTERN] used to identify device internally * @driver_module: [INTERN] used to make it harder to undercut users * @modes: [DRIVER] operating modes supported by device * @currentmode: [DRIVER] current operating mode @@ -523,7 +522,6 @@ struct iio_buffer_setup_ops { * **MUST** be accessed **ONLY** via iio_priv() helper */ struct iio_dev { - int id; struct module *driver_module; int modes; @@ -559,6 +557,8 @@ struct iio_dev { void *priv; }; +int iio_device_id(struct iio_dev *indio_dev); + const struct iio_chan_spec *iio_find_channel_from_si(struct iio_dev *indio_dev, int si); /** -- cgit v1.2.3 From e5333ed09e0f8ece3cbb37912c17cf9880ee3fb0 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Mon, 26 Apr 2021 18:49:04 +0100 Subject: iio: avoid shadowing of variable name in to_iio_dev_opaque() indio_dev was both the macro input parameter and the field name in this macro. That causes trouble if the instance of struct iio_dev passed in is not called indio_dev. Whilst a fix of sorts, no need to backport as it seems we never hit this previously due to some very consistent naming in IIO. Signed-off-by: Jonathan Cameron Reviewed-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20210426174911.397061-3-jic23@kernel.org --- include/linux/iio/iio-opaque.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/linux/iio/iio-opaque.h b/include/linux/iio/iio-opaque.h index e66b029d99de..f876e3aede2c 100644 --- a/include/linux/iio/iio-opaque.h +++ b/include/linux/iio/iio-opaque.h @@ -48,7 +48,7 @@ struct iio_dev_opaque { #endif }; -#define to_iio_dev_opaque(indio_dev) \ - container_of(indio_dev, struct iio_dev_opaque, indio_dev) +#define to_iio_dev_opaque(_indio_dev) \ + container_of((_indio_dev), struct iio_dev_opaque, indio_dev) #endif -- cgit v1.2.3 From 6eaf9f6a2738789dedb1e962096f61aaddd81464 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Mon, 26 Apr 2021 18:49:05 +0100 Subject: iio: core: move @driver_module from struct iio_dev to struct iio_dev_opaque Continuing move to hide internal elements from drivers, move this structure element over. It's only accessed from iio core files so this one was straight forward and no accessor functions are needed. Signed-off-by: Jonathan Cameron Reviewed-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20210426174911.397061-4-jic23@kernel.org --- include/linux/iio/iio-opaque.h | 2 ++ include/linux/iio/iio.h | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/linux/iio/iio-opaque.h b/include/linux/iio/iio-opaque.h index f876e3aede2c..96dd265103d0 100644 --- a/include/linux/iio/iio-opaque.h +++ b/include/linux/iio/iio-opaque.h @@ -7,6 +7,7 @@ * struct iio_dev_opaque - industrial I/O device opaque information * @indio_dev: public industrial I/O device information * @id: used to identify device internally + * @driver_module: used to make it harder to undercut users * @event_interface: event chrdevs associated with interrupt lines * @attached_buffers: array of buffers statically attached by the driver * @attached_buffers_cnt: number of buffers in the array of statically attached buffers @@ -28,6 +29,7 @@ struct iio_dev_opaque { struct iio_dev indio_dev; int id; + struct module *driver_module; struct iio_event_interface *event_interface; struct iio_buffer **attached_buffers; unsigned int attached_buffers_cnt; diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 569861d5887a..9e8e1358a032 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -488,7 +488,6 @@ struct iio_buffer_setup_ops { /** * struct iio_dev - industrial I/O device - * @driver_module: [INTERN] used to make it harder to undercut users * @modes: [DRIVER] operating modes supported by device * @currentmode: [DRIVER] current operating mode * @dev: [DRIVER] device structure, should be assigned a parent @@ -522,8 +521,6 @@ struct iio_buffer_setup_ops { * **MUST** be accessed **ONLY** via iio_priv() helper */ struct iio_dev { - struct module *driver_module; - int modes; int currentmode; struct device dev; -- cgit v1.2.3 From 3028e0c2af95dd476ccd71f4fc025990385168c2 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Mon, 26 Apr 2021 18:49:06 +0100 Subject: iio: core: move @trig_readonly from struct iio_dev to struct iio_dev_opaque This is only set via the iio_trig_set_immutable() call and later used by the IIO core so there is no benefit in drivers being able to access it. Signed-off-by: Jonathan Cameron Reviewed-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20210426174911.397061-5-jic23@kernel.org --- include/linux/iio/iio-opaque.h | 2 ++ include/linux/iio/iio.h | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/linux/iio/iio-opaque.h b/include/linux/iio/iio-opaque.h index 96dd265103d0..10aa97239117 100644 --- a/include/linux/iio/iio-opaque.h +++ b/include/linux/iio/iio-opaque.h @@ -8,6 +8,7 @@ * @indio_dev: public industrial I/O device information * @id: used to identify device internally * @driver_module: used to make it harder to undercut users + * @trig_readonly: mark the current trigger immutable * @event_interface: event chrdevs associated with interrupt lines * @attached_buffers: array of buffers statically attached by the driver * @attached_buffers_cnt: number of buffers in the array of statically attached buffers @@ -30,6 +31,7 @@ struct iio_dev_opaque { struct iio_dev indio_dev; int id; struct module *driver_module; + bool trig_readonly; struct iio_event_interface *event_interface; struct iio_buffer **attached_buffers; unsigned int attached_buffers_cnt; diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 9e8e1358a032..672f141f74c5 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -503,7 +503,6 @@ struct iio_buffer_setup_ops { * @scan_timestamp: [INTERN] set if any buffers have requested timestamp * @scan_index_timestamp:[INTERN] cache of the index to the timestamp * @trig: [INTERN] current device trigger (buffer modes) - * @trig_readonly: [INTERN] mark the current trigger immutable * @pollfunc: [DRIVER] function run on trigger being received * @pollfunc_event: [DRIVER] function run on events trigger being received * @channels: [DRIVER] channel specification structure table @@ -535,7 +534,6 @@ struct iio_dev { bool scan_timestamp; unsigned scan_index_timestamp; struct iio_trigger *trig; - bool trig_readonly; struct iio_poll_func *pollfunc; struct iio_poll_func *pollfunc_event; -- cgit v1.2.3 From 62f4f36cdfcdbb961bbbeab15e6595dd391d2205 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Mon, 26 Apr 2021 18:49:07 +0100 Subject: iio: core: move @scan_index_timestamp to struct iio_dev_opaque No reason for this cached value to be exposed to drivers so move it to the opaque structure. Signed-off-by: Jonathan Cameron Reviewed-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20210426174911.397061-6-jic23@kernel.org --- include/linux/iio/iio-opaque.h | 4 ++++ include/linux/iio/iio.h | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/linux/iio/iio-opaque.h b/include/linux/iio/iio-opaque.h index 10aa97239117..02038fb2d291 100644 --- a/include/linux/iio/iio-opaque.h +++ b/include/linux/iio/iio-opaque.h @@ -22,6 +22,7 @@ * @groupcounter: index of next attribute group * @legacy_scan_el_group: attribute group for legacy scan elements attribute group * @legacy_buffer_group: attribute group for legacy buffer attributes group + * @scan_index_timestamp: cache of the index to the timestamp * @debugfs_dentry: device specific debugfs dentry * @cached_reg_addr: cached register address for debugfs reads * @read_buf: read buffer to be used for the initial reg read @@ -44,6 +45,9 @@ struct iio_dev_opaque { int groupcounter; struct attribute_group legacy_scan_el_group; struct attribute_group legacy_buffer_group; + + unsigned int scan_index_timestamp; + #if defined(CONFIG_DEBUG_FS) struct dentry *debugfs_dentry; unsigned cached_reg_addr; diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 672f141f74c5..cbc9e9ece0a6 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -501,7 +501,6 @@ struct iio_buffer_setup_ops { * channels * @active_scan_mask: [INTERN] union of all scan masks requested by buffers * @scan_timestamp: [INTERN] set if any buffers have requested timestamp - * @scan_index_timestamp:[INTERN] cache of the index to the timestamp * @trig: [INTERN] current device trigger (buffer modes) * @pollfunc: [DRIVER] function run on trigger being received * @pollfunc_event: [DRIVER] function run on events trigger being received @@ -532,7 +531,6 @@ struct iio_dev { unsigned masklength; const unsigned long *active_scan_mask; bool scan_timestamp; - unsigned scan_index_timestamp; struct iio_trigger *trig; struct iio_poll_func *pollfunc; struct iio_poll_func *pollfunc_event; -- cgit v1.2.3 From b804e2b76ac6d5559b99588e0190ac97b5597497 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Mon, 26 Apr 2021 18:49:08 +0100 Subject: iio: core: move @info_exist_lock to struct iio_dev_opaque This lock is only of interest to the IIO core, so make it only visible there. Signed-off-by: Jonathan Cameron Reviewed-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20210426174911.397061-7-jic23@kernel.org --- include/linux/iio/iio-opaque.h | 2 ++ include/linux/iio/iio.h | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/linux/iio/iio-opaque.h b/include/linux/iio/iio-opaque.h index 02038fb2d291..538b4b5ef1a9 100644 --- a/include/linux/iio/iio-opaque.h +++ b/include/linux/iio/iio-opaque.h @@ -8,6 +8,7 @@ * @indio_dev: public industrial I/O device information * @id: used to identify device internally * @driver_module: used to make it harder to undercut users + * @info_exist_lock: lock to prevent use during removal * @trig_readonly: mark the current trigger immutable * @event_interface: event chrdevs associated with interrupt lines * @attached_buffers: array of buffers statically attached by the driver @@ -32,6 +33,7 @@ struct iio_dev_opaque { struct iio_dev indio_dev; int id; struct module *driver_module; + struct mutex info_exist_lock; bool trig_readonly; struct iio_event_interface *event_interface; struct iio_buffer **attached_buffers; diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index cbc9e9ece0a6..a12bbd8b1e74 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -510,7 +510,6 @@ struct iio_buffer_setup_ops { * @label: [DRIVER] unique name to identify which device this is * @info: [DRIVER] callbacks and constant info from driver * @clock_id: [INTERN] timestamping clock posix identifier - * @info_exist_lock: [INTERN] lock to prevent use during removal * @setup_ops: [DRIVER] callbacks to call before and after buffer * enable/disable * @chrdev: [INTERN] associated character device @@ -542,7 +541,6 @@ struct iio_dev { const char *label; const struct iio_info *info; clockid_t clock_id; - struct mutex info_exist_lock; const struct iio_buffer_setup_ops *setup_ops; struct cdev chrdev; -- cgit v1.2.3 From 396f7234856956eb29f009da6e5d846f29f87ebd Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Mon, 26 Apr 2021 18:49:09 +0100 Subject: iio: core: move @chrdev from struct iio_dev to struct iio_dev_opaque No reason for this to be exposed to the drivers, so lets move it to the opaque structure. Signed-off-by: Jonathan Cameron Reviewed-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20210426174911.397061-8-jic23@kernel.org --- include/linux/iio/iio-opaque.h | 2 ++ include/linux/iio/iio.h | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/linux/iio/iio-opaque.h b/include/linux/iio/iio-opaque.h index 538b4b5ef1a9..2f8ef5d15a66 100644 --- a/include/linux/iio/iio-opaque.h +++ b/include/linux/iio/iio-opaque.h @@ -24,6 +24,7 @@ * @legacy_scan_el_group: attribute group for legacy scan elements attribute group * @legacy_buffer_group: attribute group for legacy buffer attributes group * @scan_index_timestamp: cache of the index to the timestamp + * @chrdev: associated character device * @debugfs_dentry: device specific debugfs dentry * @cached_reg_addr: cached register address for debugfs reads * @read_buf: read buffer to be used for the initial reg read @@ -49,6 +50,7 @@ struct iio_dev_opaque { struct attribute_group legacy_buffer_group; unsigned int scan_index_timestamp; + struct cdev chrdev; #if defined(CONFIG_DEBUG_FS) struct dentry *debugfs_dentry; diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index a12bbd8b1e74..586e2dc4fbf3 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -512,7 +512,6 @@ struct iio_buffer_setup_ops { * @clock_id: [INTERN] timestamping clock posix identifier * @setup_ops: [DRIVER] callbacks to call before and after buffer * enable/disable - * @chrdev: [INTERN] associated character device * @flags: [INTERN] file ops related flags including busy flag. * @priv: [DRIVER] reference to driver's private information * **MUST** be accessed **ONLY** via iio_priv() helper @@ -542,7 +541,6 @@ struct iio_dev { const struct iio_info *info; clockid_t clock_id; const struct iio_buffer_setup_ops *setup_ops; - struct cdev chrdev; unsigned long flags; void *priv; -- cgit v1.2.3 From 8b1c82cb849f8f7c758891099f2128b8fbc05744 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Mon, 26 Apr 2021 18:49:10 +0100 Subject: iio: core: move @flags from struct iio_dev to struct iio_dev_opaque No reason any driver should ever need access to this field, so hide it. Signed-off-by: Jonathan Cameron Reviewed-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20210426174911.397061-9-jic23@kernel.org --- include/linux/iio/iio-opaque.h | 2 ++ include/linux/iio/iio.h | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/linux/iio/iio-opaque.h b/include/linux/iio/iio-opaque.h index 2f8ef5d15a66..d7c3036861ac 100644 --- a/include/linux/iio/iio-opaque.h +++ b/include/linux/iio/iio-opaque.h @@ -25,6 +25,7 @@ * @legacy_buffer_group: attribute group for legacy buffer attributes group * @scan_index_timestamp: cache of the index to the timestamp * @chrdev: associated character device + * @flags: file ops related flags including busy flag. * @debugfs_dentry: device specific debugfs dentry * @cached_reg_addr: cached register address for debugfs reads * @read_buf: read buffer to be used for the initial reg read @@ -51,6 +52,7 @@ struct iio_dev_opaque { unsigned int scan_index_timestamp; struct cdev chrdev; + unsigned long flags; #if defined(CONFIG_DEBUG_FS) struct dentry *debugfs_dentry; diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 586e2dc4fbf3..ed0537015eee 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -512,7 +512,6 @@ struct iio_buffer_setup_ops { * @clock_id: [INTERN] timestamping clock posix identifier * @setup_ops: [DRIVER] callbacks to call before and after buffer * enable/disable - * @flags: [INTERN] file ops related flags including busy flag. * @priv: [DRIVER] reference to driver's private information * **MUST** be accessed **ONLY** via iio_priv() helper */ @@ -542,7 +541,6 @@ struct iio_dev { clockid_t clock_id; const struct iio_buffer_setup_ops *setup_ops; - unsigned long flags; void *priv; }; -- cgit v1.2.3 From 62a486c46d61bc684967fc3f83eed15dde49cf9b Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Mon, 26 Apr 2021 18:49:11 +0100 Subject: iio: core: move @clock_id from struct iio_dev to struct iio_dev_opaque There is already an acessor function used to access it, making this move straight forward. Signed-off-by: Jonathan Cameron Reviewed-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20210426174911.397061-10-jic23@kernel.org --- include/linux/iio/iio-opaque.h | 2 ++ include/linux/iio/iio.h | 12 +----------- 2 files changed, 3 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/linux/iio/iio-opaque.h b/include/linux/iio/iio-opaque.h index d7c3036861ac..c9504e9da571 100644 --- a/include/linux/iio/iio-opaque.h +++ b/include/linux/iio/iio-opaque.h @@ -24,6 +24,7 @@ * @legacy_scan_el_group: attribute group for legacy scan elements attribute group * @legacy_buffer_group: attribute group for legacy buffer attributes group * @scan_index_timestamp: cache of the index to the timestamp + * @clock_id: timestamping clock posix identifier * @chrdev: associated character device * @flags: file ops related flags including busy flag. * @debugfs_dentry: device specific debugfs dentry @@ -51,6 +52,7 @@ struct iio_dev_opaque { struct attribute_group legacy_buffer_group; unsigned int scan_index_timestamp; + clockid_t clock_id; struct cdev chrdev; unsigned long flags; diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index ed0537015eee..5606a3f4c4cb 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -509,7 +509,6 @@ struct iio_buffer_setup_ops { * @name: [DRIVER] name of the device. * @label: [DRIVER] unique name to identify which device this is * @info: [DRIVER] callbacks and constant info from driver - * @clock_id: [INTERN] timestamping clock posix identifier * @setup_ops: [DRIVER] callbacks to call before and after buffer * enable/disable * @priv: [DRIVER] reference to driver's private information @@ -538,7 +537,6 @@ struct iio_dev { const char *name; const char *label; const struct iio_info *info; - clockid_t clock_id; const struct iio_buffer_setup_ops *setup_ops; void *priv; @@ -589,15 +587,7 @@ static inline void iio_device_put(struct iio_dev *indio_dev) put_device(&indio_dev->dev); } -/** - * iio_device_get_clock() - Retrieve current timestamping clock for the device - * @indio_dev: IIO device structure containing the device - */ -static inline clockid_t iio_device_get_clock(const struct iio_dev *indio_dev) -{ - return indio_dev->clock_id; -} - +clockid_t iio_device_get_clock(const struct iio_dev *indio_dev); int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id); /** -- cgit v1.2.3 From 38934daf7b5c1b35a01748cb7d4272282cc3a890 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Wed, 14 Apr 2021 22:54:50 +0300 Subject: iio: magnetometer: st_magn: Provide default platform data Provide default platform data for magnetometer in case it supports DRDY. One case is LSM9DS0 IMU, on which it is the case. Since accelerometer is using INT1, default magnetometer to INT2. While at it, update description of the drdy_int_pin field. Signed-off-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210414195454.84183-3-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron --- include/linux/platform_data/st_sensors_pdata.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/linux/platform_data/st_sensors_pdata.h b/include/linux/platform_data/st_sensors_pdata.h index e40b28ca892e..897051e51b78 100644 --- a/include/linux/platform_data/st_sensors_pdata.h +++ b/include/linux/platform_data/st_sensors_pdata.h @@ -13,8 +13,9 @@ /** * struct st_sensors_platform_data - Platform data for the ST sensors * @drdy_int_pin: Redirect DRDY on pin 1 (1) or pin 2 (2). - * Available only for accelerometer and pressure sensors. + * Available only for accelerometer, magnetometer and pressure sensors. * Accelerometer DRDY on LSM330 available only on pin 1 (see datasheet). + * Magnetometer DRDY is supported only on LSM9DS0. * @open_drain: set the interrupt line to be open drain if possible. * @spi_3wire: enable spi-3wire mode. * @pullups: enable/disable i2c controller pullup resistors. -- cgit v1.2.3 From d61881ef7f08aef02d9bfc8c66f4c89c59cdf112 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Wed, 14 Apr 2021 22:54:52 +0300 Subject: iio: st_sensors: Make accel, gyro, magn and pressure probe shared Some IMUs may utilize existing library code for STMicro accelerometer, gyroscope, magnetometer and pressure. Let's share them via st_sensors.h. Signed-off-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210414195454.84183-5-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron --- include/linux/iio/common/st_sensors.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'include') diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h index 33e939977444..aa017b90fb06 100644 --- a/include/linux/iio/common/st_sensors.h +++ b/include/linux/iio/common/st_sensors.h @@ -317,4 +317,24 @@ ssize_t st_sensors_sysfs_scale_avail(struct device *dev, void st_sensors_dev_name_probe(struct device *dev, char *name, int len); +/* Accelerometer */ +const struct st_sensor_settings *st_accel_get_settings(const char *name); +int st_accel_common_probe(struct iio_dev *indio_dev); +void st_accel_common_remove(struct iio_dev *indio_dev); + +/* Gyroscope */ +const struct st_sensor_settings *st_gyro_get_settings(const char *name); +int st_gyro_common_probe(struct iio_dev *indio_dev); +void st_gyro_common_remove(struct iio_dev *indio_dev); + +/* Magnetometer */ +const struct st_sensor_settings *st_magn_get_settings(const char *name); +int st_magn_common_probe(struct iio_dev *indio_dev); +void st_magn_common_remove(struct iio_dev *indio_dev); + +/* Pressure */ +const struct st_sensor_settings *st_press_get_settings(const char *name); +int st_press_common_probe(struct iio_dev *indio_dev); +void st_press_common_remove(struct iio_dev *indio_dev); + #endif /* ST_SENSORS_H */ -- cgit v1.2.3 From 6731ca3999ffa4c878a661b980759300dfb0237e Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Wed, 14 Apr 2021 22:54:53 +0300 Subject: iio: st_sensors: Add lsm9ds0 IMU support We can utilize separate drivers for accelerometer and magnetometer, so here is the glue driver to enable LSM9DS0 IMU support. The idea was suggested by Crestez Dan Leonard in [1]. The proposed change was sent as RFC due to race condition concerns, which are indeed possible. In order to amend the initial change, I went further by providing a specific multi-instantiate probe driver that reuses existing accelerometer and magnetometer. [1]: https://lore.kernel.org/patchwork/patch/670353/ Suggested-by: Crestez Dan Leonard Cc: mr.lahorde@laposte.net Cc: Matija Podravec Cc: Sergey Borishchenko Signed-off-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210414195454.84183-6-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron --- include/linux/iio/common/st_sensors.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h index aa017b90fb06..0b9aeb479f48 100644 --- a/include/linux/iio/common/st_sensors.h +++ b/include/linux/iio/common/st_sensors.h @@ -20,6 +20,8 @@ #include +#define LSM9DS0_IMU_DEV_NAME "lsm9ds0" + /* * Buffer size max case: 2bytes per channel, 3 channels in total + * 8bytes timestamp channel (s64) -- cgit v1.2.3 From 8dea228b174ac9637b567e5ef54f4c40db4b3c41 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 1 May 2021 18:13:47 +0100 Subject: iio: cros_ec_sensors: Fix alignment of buffer in iio_push_to_buffers_with_timestamp() The samples buffer is passed to iio_push_to_buffers_with_timestamp() which requires a buffer aligned to 8 bytes as it is assumed that the timestamp will be naturally aligned if present. Fixes tag is inaccurate but prior to that likely manual backporting needed (for anything before 4.18) Earlier than that the include file to fix is drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.h: commit 974e6f02e27 ("iio: cros_ec_sensors_core: Add common functions for the ChromeOS EC Sensor Hub.") present since kernel stable 4.10. (Thanks to Gwendal for tracking this down) Fixes: 5a0b8cb46624c ("iio: cros_ec: Move cros_ec_sensors_core.h in /include") Signed-off-by: Jonathan Cameron Reviewed-by: Gwendal Grignou Date: Tue, 18 May 2021 14:25:46 +0300 Subject: iio: Drop Duplicated "mount-matrix" parameter All of the users of iio_read_mount_matrix() are using the very same property name. Moreover, the property name is hard coded in the API documentation. Make this clear and avoid duplication now and in the future. Signed-off-by: Andy Shevchenko Reviewed-by: Sean Nyekjaer Reviewed-by: Linus Walleij Link: https://lore.kernel.org/r/20210518112546.44592-1-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron --- include/linux/iio/iio.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include') diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 5606a3f4c4cb..324561b7a5e8 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -127,8 +127,7 @@ struct iio_mount_matrix { ssize_t iio_show_mount_matrix(struct iio_dev *indio_dev, uintptr_t priv, const struct iio_chan_spec *chan, char *buf); -int iio_read_mount_matrix(struct device *dev, const char *propname, - struct iio_mount_matrix *matrix); +int iio_read_mount_matrix(struct device *dev, struct iio_mount_matrix *matrix); typedef const struct iio_mount_matrix * (iio_get_mount_matrix_t)(const struct iio_dev *indio_dev, -- cgit v1.2.3 From 42ef8aa2263b19b06e69a318dbd8f1639013ded3 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Wed, 19 May 2021 01:07:18 +0200 Subject: iio: st_sensors: Create extended attr macro Extend ST_SENSORS_LSM_CHANNELS() to a version that will accept extended attributes named ST_SENSORS_LSM_CHANNELS_EXT() and wrap the former as a specialized version of the former. Cc: Hans de Goede Cc: Denis Ciocca Cc: Daniel Drake Reviewed-by: Andy Shevchenko Signed-off-by: Stephan Gerhold Signed-off-by: Linus Walleij Reviewed-by: Hans de Goede Link: https://lore.kernel.org/r/20210518230722.522446-1-linus.walleij@linaro.org Signed-off-by: Jonathan Cameron --- include/linux/iio/common/st_sensors.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h index 0b9aeb479f48..8e0d76b42db9 100644 --- a/include/linux/iio/common/st_sensors.h +++ b/include/linux/iio/common/st_sensors.h @@ -48,8 +48,8 @@ #define ST_SENSORS_MAX_NAME 17 #define ST_SENSORS_MAX_4WAI 8 -#define ST_SENSORS_LSM_CHANNELS(device_type, mask, index, mod, \ - ch2, s, endian, rbits, sbits, addr) \ +#define ST_SENSORS_LSM_CHANNELS_EXT(device_type, mask, index, mod, \ + ch2, s, endian, rbits, sbits, addr, ext) \ { \ .type = device_type, \ .modified = mod, \ @@ -65,8 +65,14 @@ .storagebits = sbits, \ .endianness = endian, \ }, \ + .ext_info = ext, \ } +#define ST_SENSORS_LSM_CHANNELS(device_type, mask, index, mod, \ + ch2, s, endian, rbits, sbits, addr) \ + ST_SENSORS_LSM_CHANNELS_EXT(device_type, mask, index, mod, \ + ch2, s, endian, rbits, sbits, addr, NULL) + #define ST_SENSORS_DEV_ATTR_SAMP_FREQ_AVAIL() \ IIO_DEV_ATTR_SAMP_FREQ_AVAIL( \ st_sensors_sysfs_sampling_frequency_avail) -- cgit v1.2.3 From 3d8ad94bb175c2de7200569bb706d67c45903838 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Wed, 19 May 2021 01:07:19 +0200 Subject: iio: accel: st_sensors: Support generic mounting matrix The ST accelerators support a special type of quirky mounting matrix found in ACPI systems, but not a generic mounting matrix such as from the device tree. Augment the ACPI hack to be a bit more generic and accept a mounting matrix from device properties. This makes it possible to fix orientation on the Ux500 HREF device. Cc: Hans de Goede Cc: Denis Ciocca Cc: Daniel Drake Reviewed-by: Andy Shevchenko Signed-off-by: Stephan Gerhold Signed-off-by: Linus Walleij Reviewed-by: Hans de Goede Link: https://lore.kernel.org/r/20210518230722.522446-2-linus.walleij@linaro.org Signed-off-by: Jonathan Cameron --- include/linux/iio/common/st_sensors.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h index 8e0d76b42db9..8bdbaf3f3796 100644 --- a/include/linux/iio/common/st_sensors.h +++ b/include/linux/iio/common/st_sensors.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -221,6 +222,7 @@ struct st_sensor_settings { * struct st_sensor_data - ST sensor device status * @dev: Pointer to instance of struct device (I2C or SPI). * @trig: The trigger in use by the core driver. + * @mount_matrix: The mounting matrix of the sensor. * @sensor_settings: Pointer to the specific sensor settings in use. * @current_fullscale: Maximum range of measure by the sensor. * @vdd: Pointer to sensor's Vdd power supply @@ -240,7 +242,7 @@ struct st_sensor_settings { struct st_sensor_data { struct device *dev; struct iio_trigger *trig; - struct iio_mount_matrix *mount_matrix; + struct iio_mount_matrix mount_matrix; struct st_sensor_settings *sensor_settings; struct st_sensor_fullscale_avl *current_fullscale; struct regulator *vdd; -- cgit v1.2.3 From aa5c8b25392800bbefa82dd19eeff8ebbf261ace Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Thu, 3 Jun 2021 17:58:35 +0100 Subject: i2c: core: Add stub for i2c_verify_client() if !CONFIG_I2C If I2C is not compiled, there is no way we should see a call to i2c_verify_client() on a device that is an i2c client. As such, provide a stub to return NULL to resolve an associated build failure. The build is failing with this link error ld: fxls8962af-core.o: in function `fxls8962af_fifo_transfer': fxls8962af-core.c: undefined reference to `i2c_verify_client' Reported-by: Tom Rix Signed-off-by: Jonathan Cameron Fixes: af959b7b96b8 ("iio: accel: fxls8962af: fix errata bug E3 - I2C burst reads") Reviewed-by: Sean Nyekjaer Acked-by: Wolfram Sang Link: https://lore.kernel.org/r/20210603165835.3594557-1-jic23@kernel.org --- include/linux/i2c.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/linux/i2c.h b/include/linux/i2c.h index e8f2ac8c9c3d..7d71131c394e 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -343,7 +343,6 @@ struct i2c_client { }; #define to_i2c_client(d) container_of(d, struct i2c_client, dev) -struct i2c_client *i2c_verify_client(struct device *dev); struct i2c_adapter *i2c_verify_adapter(struct device *dev); const struct i2c_device_id *i2c_match_id(const struct i2c_device_id *id, const struct i2c_client *client); @@ -477,6 +476,13 @@ i2c_new_ancillary_device(struct i2c_client *client, u16 default_addr); void i2c_unregister_device(struct i2c_client *client); + +struct i2c_client *i2c_verify_client(struct device *dev); +#else +static inline struct i2c_client *i2c_verify_client(struct device *dev) +{ + return NULL; +} #endif /* I2C */ /* Mainboard arch_initcall() code should register all its I2C devices. -- cgit v1.2.3