Adding support for IIO SCMI based sensors
Subsystems (3)
Jyoti Bhayana
maintainerv6 cover Adding support for IIO SCMI based sensors
Hi,
This series adds support for ARM SCMI Protocol based IIO Device.
This driver provides support for Accelerometer and Gyroscope sensor using SCMI Sensor Protocol extensions added in the SCMIv3.0 ARM specification, which is available at
https://developer.arm.com/documentation/den0056/c/
This version of the patch series has been tested using version 5.4.21 branch of Android common kernel.
Any feedback welcome,
Thanks,
Jyoti Bhayana
v5 --> v6
- Fixed the warning by kernel test robot
- Incorporated the feedback comments from v5
- Fixed the bug found in scmi_iio_set_odr_val
for calculating the multiplier
v4 --> v5
- Dropped the RFC tag
- Added channel ext_info for raw_available
- Incorporated the feedback comments from v4 review of the patch
v3 --> v4
- Incorporated the feedback comments from v3 review of the patch
v2 --> v3
- Incorporated the feedback comments from v2 review of the patch
v1 --> v2
- Incorporated the feedback comments from v1 review of the patch
- Regarding the new ABI for sensor_power,sensor_max_range, and sensor_resolution, these are some of the sensor attributes which Android passes to the apps. If there is any other way of getting those values, please let us know
Jyoti Bhayana (1):
iio/scmi: Adding support for IIO SCMI Based Sensors
MAINTAINERS | 6 + drivers/firmware/arm_scmi/driver.c | 2 +- drivers/iio/common/Kconfig | 1 + drivers/iio/common/Makefile | 1 + drivers/iio/common/scmi_sensors/Kconfig | 18 + drivers/iio/common/scmi_sensors/Makefile | 5 + drivers/iio/common/scmi_sensors/scmi_iio.c | 678 +++++++++++++++++++++ 7 files changed, 710 insertions(+), 1 deletion(-) create mode 100644 drivers/iio/common/scmi_sensors/Kconfig create mode 100644 drivers/iio/common/scmi_sensors/Makefile create mode 100644 drivers/iio/common/scmi_sensors/scmi_iio.c
Signature · 1 line
2.30.0.478.g8a0d178c01-goog
Jyoti Bhayana
maintainerPATCH v6 1/1 iio/scmi: Adding support for IIO SCMI Based Sensors
This change provides ARM SCMI Protocol based IIO device. This driver provides support for Accelerometer and Gyroscope using SCMI Sensor Protocol extensions added in the SCMIv3.0 ARM specification
--- MAINTAINERS | 6 + drivers/firmware/arm_scmi/driver.c | 2 +- drivers/iio/common/Kconfig | 1 + drivers/iio/common/Makefile | 1 + drivers/iio/common/scmi_sensors/Kconfig | 18 + drivers/iio/common/scmi_sensors/Makefile | 5 + drivers/iio/common/scmi_sensors/scmi_iio.c | 678 +++++++++++++++++++++ 7 files changed, 710 insertions(+), 1 deletion(-) create mode 100644 drivers/iio/common/scmi_sensors/Kconfig create mode 100644 drivers/iio/common/scmi_sensors/Makefile create mode 100644 drivers/iio/common/scmi_sensors/scmi_iio.c
MAINTAINERS +6 -0
@@ -8567,6 +8567,12 @@ S: Maintained F: Documentation/devicetree/bindings/iio/multiplexer/io-channel-mux.txt F: drivers/iio/multiplexer/iio-mux.c +IIO SCMI BASED DRIVER +M: Jyoti Bhayana <[email protected]> +L: [email protected] +S: Maintained +F: drivers/iio/common/scmi_sensors/scmi_iio.c + IIO SUBSYSTEM AND DRIVERS M: Jonathan Cameron <[email protected]> R: Lars-Peter Clausen <[email protected]>
drivers/firmware/arm_scmi/driver.c +1 -1
@@ -741,7 +741,7 @@ static struct scmi_prot_devnames devnames[] = { { SCMI_PROTOCOL_SYSTEM, { "syspower" },}, { SCMI_PROTOCOL_PERF, { "cpufreq" },}, { SCMI_PROTOCOL_CLOCK, { "clocks" },}, - { SCMI_PROTOCOL_SENSOR, { "hwmon" },}, + { SCMI_PROTOCOL_SENSOR, { "hwmon", "iiodev" },}, { SCMI_PROTOCOL_RESET, { "reset" },}, { SCMI_PROTOCOL_VOLTAGE, { "regulator" },}, };
drivers/iio/common/Kconfig +1 -0
@@ -6,5 +6,6 @@ source "drivers/iio/common/cros_ec_sensors/Kconfig" source "drivers/iio/common/hid-sensors/Kconfig" source "drivers/iio/common/ms_sensors/Kconfig" +source "drivers/iio/common/scmi_sensors/Kconfig" source "drivers/iio/common/ssp_sensors/Kconfig" source "drivers/iio/common/st_sensors/Kconfig"
drivers/iio/common/Makefile +1 -0
@@ -11,5 +11,6 @@ obj-y += cros_ec_sensors/ obj-y += hid-sensors/ obj-y += ms_sensors/ +obj-y += scmi_sensors/ obj-y += ssp_sensors/ obj-y += st_sensors/
drivers/iio/common/scmi_sensors/Kconfig new file +18 -0
@@ -0,0 +1,18 @@ +# +# IIO over SCMI +# +# When adding new entries keep the list in alphabetical order + +menu "IIO SCMI Sensors" + +config IIO_SCMI + tristate "IIO SCMI" + depends on ARM_SCMI_PROTOCOL + select IIO_BUFFER + select IIO_KFIFO_BUF + help + Say yes here to build support for IIO SCMI Driver. + This provides ARM SCMI Protocol based IIO device. + This driver provides support for accelerometer and gyroscope + sensors available on SCMI based platforms. +endmenu
drivers/iio/common/scmi_sensors/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX - License - Identifier : GPL - 2.0 - only +# +# Makefile for the IIO over SCMI +# +obj-$(CONFIG_IIO_SCMI) += scmi_iio.o
drivers/iio/common/scmi_sensors/scmi_iio.c new file +678 -0
678 lines not on this page · raw message
Signature · 1 line
2.30.0.478.g8a0d178c01-goog
Jonathan Cameron
maintainerRe: [PATCH v6 1/1] iio/scmi: Adding support for IIO SCMI Based Sensors
Quoted 3 lines · On Fri, 12 Feb 2021 17:22:35 +0000 Jyoti Bhayana <[email protected]> wrote:
This change provides ARM SCMI Protocol based IIO device. This driver provides support for Accelerometer and Gyroscope using SCMI Sensor Protocol extensions added in the SCMIv3.0 ARM specification
Hi Joyti
A few things inline but nothing to require a v7.
1) Use of long long to get s64 - I can tidy that up whilst applying.
2) Going to have a clash with Alex's multi buffer rework of the core I'll sort that out when I apply this as well.
Quoted 2 lines
Reported-by kernel test robot <[email protected]>
For fixes within a larger patch as a result of the various build robots, we should either only mention them in comments, or add a note after the Reported-by to say what was fixed. E.g something like
I can't remember what was actually reported for this one.
If you can reply with such a comment I'll add it on, if not I'll drop
the Reported-by as uninformative. Right now it looks like the whole
patch is a fix for an issue that 0-day reported :)
Quoted 28 lines
Signed-off-by Jyoti Bhayana <[email protected]>--- MAINTAINERS | 6 + drivers/firmware/arm_scmi/driver.c | 2 +- drivers/iio/common/Kconfig | 1 + drivers/iio/common/Makefile | 1 + drivers/iio/common/scmi_sensors/Kconfig | 18 + drivers/iio/common/scmi_sensors/Makefile | 5 + drivers/iio/common/scmi_sensors/scmi_iio.c | 678 +++++++++++++++++++++ 7 files changed, 710 insertions(+), 1 deletion(-) create mode 100644 drivers/iio/common/scmi_sensors/Kconfig create mode 100644 drivers/iio/common/scmi_sensors/Makefile create mode 100644 drivers/iio/common/scmi_sensors/scmi_iio.cMAINTAINERS +6
-0@@ -8567,6 +8567,12 @@ S: Maintained F: Documentation/devicetree/bindings/iio/multiplexer/io-channel-mux.txt F: drivers/iio/multiplexer/iio-mux.c +IIO SCMI BASED DRIVER +M: Jyoti Bhayana <[email protected]> +L: [email protected] +S: Maintained +F: drivers/iio/common/scmi_sensors/scmi_iio.c +
...
Quoted 36 lines
drivers/iio/common/scmi_sensors/Makefile new file +5
-0@@ -0,0 +1,5 @@ +# SPDX - License - Identifier : GPL - 2.0 - only +# +# Makefile for the IIO over SCMI +# +obj-$(CONFIG_IIO_SCMI) += scmi_iio.odrivers/iio/common/scmi_sensors/scmi_iio.c new file +19
-0@@ -0,0 +1,678 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* +* System Control and Management Interface(SCMI) based IIO sensor driver +* +* Copyright (C) 2021 Google LLC +*/ + +#include <linux/delay.h> +#include <linux/err.h> +#include <linux/iio/buffer.h> +#include <linux/iio/iio.h> +#include <linux/iio/kfifo_buf.h> +#include <linux/iio/sysfs.h> +#include <linux/kernel.h> +#include <linux/kthread.h> +#include <linux/module.h> +#include <linux/scmi_protocol.h> +#include <linux/time.h>
drivers/iio/common/scmi_sensors/scmi_iio.c line 29
Quoted 10 lines
drivers/iio/common/scmi_sensors/scmi_iio.c new file +10
-0+#include <linux/types.h> + +#define SCMI_IIO_NUM_OF_AXIS 3 + +struct scmi_iio_priv { +struct scmi_handle *handle; +const struct scmi_sensor_info *sensor_info; +struct iio_dev *indio_dev; +/* adding one additional channel for timestamp */ +long long iio_buf[SCMI_IIO_NUM_OF_AXIS +1 ];
Missed this previously but we should probably be careful to make this explicitly 64 bit rather than rely on long long being that length. s64 iio_buf[SCMI_IIO_NUM_OF_AXIS + 1];
I can tidy this up whilst applying if that is fine with you.
Quoted 4 lines
drivers/iio/common/scmi_sensors/scmi_iio.c new file +4
-0+struct notifier_block sensor_update_nb; +u32 *freq_avail; +}; +
...
drivers/iio/common/scmi_sensors/scmi_iio.c line 334
Quoted 5 lines
drivers/iio/common/scmi_sensors/scmi_iio.c new file +5
-0+ +static ssize_t scmi_iio_get_raw_available (struct iio_dev *iio_dev, +uintptr_t private, +const struct iio_chan_spec *chan, +char *buf)
Looks good. Thanks for persevering with this!
Quoted 40 lines
drivers/iio/common/scmi_sensors/scmi_iio.c new file +40
-0+{ +struct scmi_iio_priv *sensor =iio_priv (iio_dev); +unsigned long long resolution, rem; +long long min_range, max_range; +s8 exponent, scale; +int len =0 ; + +/* +* All the axes are supposed to have the same value for range and resolution. +* We are just using the values from the Axis 0 here. +*/ +if (sensor->sensor_info->axis[0 ].extended_attrs) { + min_range = sensor->sensor_info->axis[0 ].attrs.min_range; + max_range = sensor->sensor_info->axis[0 ].attrs.max_range; + resolution = sensor->sensor_info->axis[0 ].resolution; + exponent = sensor->sensor_info->axis[0 ].exponent; + scale = sensor->sensor_info->axis[0 ].scale; + +/* +* To provide the raw value for the resolution to the userspace, +* need to divide the resolution exponent by the sensor scale +*/ + exponent = exponent - scale; +if (exponent <0 ) { + resolution =div64_u64_rem (resolution, +int_pow (10 ,abs (exponent)), + &rem); + len =scnprintf (buf,PAGE_SIZE , +"[%lld %llu.%llu %lld]\n" , min_range, + resolution, rem, max_range); + }else { + resolution = resolution *int_pow (10 , exponent); + len =scnprintf (buf,PAGE_SIZE ,"[%lld %llu %lld]\n" , + min_range, resolution, max_range); + } + } +return len; +} + +static const struct iio_chan_spec_ext_info scmi_iio_ext_info[] = {
drivers/iio/common/scmi_sensors/scmi_iio.c line 384
Quoted 10 lines
drivers/iio/common/scmi_sensors/scmi_iio.c new file +10
-0+ { + .name = "raw_available", + .read = scmi_iio_get_raw_available, + .shared = IIO_SHARED_BY_TYPE, + }, + {}, +}; + +static void scmi_iio_set_timestamp_channel (struct iio_chan_spec *iio_chan, +int scan_index)
Not relevant to this patch!: I wonder how many times
we now have this replicated in various drivers. Feels like a good thing to just have as a library function in the IIO core.
(about 8 copies of this from a quick grep)
Quoted 9 lines
drivers/iio/common/scmi_sensors/scmi_iio.c new file +9
-0+{ + iio_chan->type =IIO_TIMESTAMP ; + iio_chan->channel =-1 ; + iio_chan->scan_index = scan_index; + iio_chan->scan_type.sign ='u' ; + iio_chan->scan_type.realbits =64 ; + iio_chan->scan_type.storagebits =64 ; +} +
...
drivers/iio/common/scmi_sensors/scmi_iio.c line 475
Quoted 2 lines
drivers/iio/common/scmi_sensors/scmi_iio.c new file +2
-0+ +static int scmi_iio_set_sampling_freq_avail (struct iio_dev *iio_dev)
Really trivial, but if you happen to be respinning for some reason, the naming of this function is a little confusing. My initial thought is it would somehow specify the sampling frequencies that the driver expects to be available, rather than the opposite where it is the driver establishing what is available.
If _get_ is also ambiguous, perhaps _query_ or _format_ or _convert_ (to reflect you are converting values to expected form).
Quoted 3 lines
drivers/iio/common/scmi_sensors/scmi_iio.c new file +3
-0+{ +u64 cur_interval_ns, low_interval_ns, high_interval_ns, step_size_ns, + hz, uhz;
...
drivers/iio/common/scmi_sensors/scmi_iio.c line 536
Quoted 13 lines
drivers/iio/common/scmi_sensors/scmi_iio.c new file +13
-0+} + +static int scmi_iio_buffers_setup (struct iio_dev *scmi_iiodev) +{ +struct iio_buffer *buffer; + + buffer =devm_iio_kfifo_allocate (&scmi_iiodev->dev); +if (!buffer) +return -ENOMEM ; + +iio_device_attach_buffer (scmi_iiodev, buffer); + scmi_iiodev->modes |=INDIO_BUFFER_SOFTWARE ; + scmi_iiodev->setup_ops = &scmi_iio_buffer_ops;
Ah. This has now crossed with Alex's large rework of the buffer registration in the core (to support multiple buffers).
Specifically it needs to flip over to using the function introduced
in https://lore.kernel.org/linux-iio/[email protected]/T/#u
This is going to make taking this via an immutable branch more fiddly. Don't worry about it though; I'll figure it out once rc1 is out. (either the merge of this tree will have to before Alex's series, or I'll need to do a non trivial merge resolution).
The one thing we can't do is rebase this series as that would then delay Cristian's work for a whole cycle (or require some usual tree management.) What fun :)
Quoted 123 lines
drivers/iio/common/scmi_sensors/scmi_iio.c new file +123
-0+return 0 ; +} + +static struct iio_dev *scmi_alloc_iiodev (struct device *dev, +struct scmi_handle *handle, +const struct scmi_sensor_info *sensor_info) +{ +struct iio_chan_spec *iio_channels; +struct scmi_iio_priv *sensor; +enum iio_modifier modifier; +enum iio_chan_type type; +struct iio_dev *iiodev; +int i, ret; + + iiodev =devm_iio_device_alloc (dev,sizeof (*sensor)); +if (!iiodev) +return ERR_PTR (-ENOMEM ); + + iiodev->modes =INDIO_DIRECT_MODE ; + iiodev->dev.parent = dev; + sensor =iio_priv (iiodev); + sensor->handle = handle; + sensor->sensor_info = sensor_info; + sensor->sensor_update_nb.notifier_call = scmi_iio_sensor_update_cb; + sensor->indio_dev = iiodev; + +/* adding one additional channel for timestamp */ + iiodev->num_channels = sensor_info->num_axis +1 ; + iiodev->name = sensor_info->name; + iiodev->info = &scmi_iio_info; + + iio_channels = +devm_kzalloc (dev, +sizeof (*iio_channels) * (iiodev->num_channels), +GFP_KERNEL ); +if (!iio_channels) +return ERR_PTR (-ENOMEM ); + + ret =scmi_iio_set_sampling_freq_avail (iiodev); +if (ret <0 ) +return ERR_PTR (ret); + +for (i =0 ; i < sensor_info->num_axis; i++) { + ret =scmi_iio_get_chan_type (sensor_info->axis[i].type, &type); +if (ret <0 ) +return ERR_PTR (ret); + + ret =scmi_iio_get_chan_modifier (sensor_info->axis[i].name, + &modifier); +if (ret <0 ) +return ERR_PTR (ret); + +scmi_iio_set_data_channel (&iio_channels[i], type, modifier, + sensor_info->axis[i].id); + } + +scmi_iio_set_timestamp_channel (&iio_channels[i], i); + iiodev->channels = iio_channels; +return iiodev; +} + +static int scmi_iio_dev_probe (struct scmi_device *sdev) +{ +const struct scmi_sensor_info *sensor_info; +struct scmi_handle *handle = sdev->handle; +struct device *dev = &sdev->dev; +struct iio_dev *scmi_iio_dev; +u16 nr_sensors; +int err = -ENODEV , i; + +if (!handle || !handle->sensor_ops) { +dev_err (dev,"SCMI device has no sensor interface\n" ); +return -EINVAL ; + } + + nr_sensors = handle->sensor_ops->count_get (handle); +if (!nr_sensors) { +dev_dbg (dev,"0 sensors found via SCMI bus\n" ); +return -ENODEV ; + } + +for (i =0 ; i < nr_sensors; i++) { + sensor_info = handle->sensor_ops->info_get (handle, i); +if (!sensor_info) { +dev_err (dev,"SCMI sensor %d has missing info\n" , i); +return -EINVAL ; + } + +/* This driver only supports 3-axis accel and gyro, skipping other sensors */ +if (sensor_info->num_axis !=SCMI_IIO_NUM_OF_AXIS ) +continue ; + +/* This driver only supports 3-axis accel and gyro, skipping other sensors */ +if (sensor_info->axis[0 ].type !=METERS_SEC_SQUARED && + sensor_info->axis[0 ].type !=RADIANS_SEC ) +continue ; + + scmi_iio_dev =scmi_alloc_iiodev (dev, handle, sensor_info); +if (IS_ERR (scmi_iio_dev)) { +dev_err (dev, +"failed to allocate IIO device for sensor %s: %ld\n" , + sensor_info->name,PTR_ERR (scmi_iio_dev)); +return PTR_ERR (scmi_iio_dev); + } + + err =scmi_iio_buffers_setup (scmi_iio_dev); +if (err <0 ) { +dev_err (dev, +"IIO buffer setup error at sensor %s: %d\n" , + sensor_info->name, err); +return err; + } + + err =devm_iio_device_register (dev, scmi_iio_dev); +if (err) { +dev_err (dev, +"IIO device registration failed at sensor %s: %d\n" , + sensor_info->name, err); +return err; + } + } +return err; +}
Jyoti Bhayana
maintainerRe: [PATCH v6 1/1] iio/scmi: Adding support for IIO SCMI Based Sensors
Hi Jonathan,
Thanks for the detailed and careful review of this patch. Good to hear
that v7 is not required. Please find below answers to your
questions. Looking forward to seeing this patch merged in the next cycle. Thanks for your help in making this happen.
1)
Quoted 1 line
1) Use of long long to get s64
Please feel free to change this
2)
Quoted 1 line
Reported-by kernel test robot <[email protected]>
The test robot gave the following warning which I fixed in this v6 of the patch. I added static to the below function to fix the warning
Quoted 1 line
drivers/iio/common/scmi_sensors/scmi_iio.c:537:17: warning: no previous prototype for 'scmi_alloc_iiodev' [-Wmissing-prototypes]
>537 | struct iio_dev *scmi_alloc_iiodev(struct device *dev,
3) Please feel free to change the name to _query if you like
Quoted 2 lines
+static int
scmi_iio_set_sampling_freq_avail(struct iio_dev *iio_dev)if _get_ is also ambiguous, perhaps _query_ or _format_ or _convert_
(to reflect you are converting values to expected form).
Thanks,
Jyoti
Quoted 368 lines · Jonathan Cameron
Quoted 3 lines · On Fri, 12 Feb 2021 17:22:35 +0000 Jyoti Bhayana <[email protected]> wrote:
This change provides ARM SCMI Protocol based IIO device. This driver provides support for Accelerometer and Gyroscope using SCMI Sensor Protocol extensions added in the SCMIv3.0 ARM specification
Hi Joyti
A few things inline but nothing to require a v7.
1) Use of long long to get s64 - I can tidy that up whilst applying.
2) Going to have a clash with Alex's multi buffer rework of the core I'll sort that out when I apply this as well.Quoted 2 lines
Reported-by kernel test robot <[email protected]>For fixes within a larger patch as a result of the various build robots, we should either only mention them in comments, or add a note after the Reported-by to say what was fixed. E.g something like
I can't remember what was actually reported for this one.
If you can reply with such a comment I'll add it on, if not I'll drop
the Reported-by as uninformative. Right now it looks like the whole
patch is a fix for an issue that 0-day reported :)Quoted 28 lines
Signed-off-by Jyoti Bhayana <[email protected]>--- MAINTAINERS | 6 + drivers/firmware/arm_scmi/driver.c | 2 +- drivers/iio/common/Kconfig | 1 + drivers/iio/common/Makefile | 1 + drivers/iio/common/scmi_sensors/Kconfig | 18 + drivers/iio/common/scmi_sensors/Makefile | 5 + drivers/iio/common/scmi_sensors/scmi_iio.c | 678 +++++++++++++++++++++ 7 files changed, 710 insertions(+), 1 deletion(-) create mode 100644 drivers/iio/common/scmi_sensors/Kconfig create mode 100644 drivers/iio/common/scmi_sensors/Makefile create mode 100644 drivers/iio/common/scmi_sensors/scmi_iio.cMAINTAINERS +6
-0@@ -8567,6 +8567,12 @@ S: Maintained F: Documentation/devicetree/bindings/iio/multiplexer/io-channel-mux.txt F: drivers/iio/multiplexer/iio-mux.c +IIO SCMI BASED DRIVER +M: Jyoti Bhayana <[email protected]> +L: [email protected] +S: Maintained +F: drivers/iio/common/scmi_sensors/scmi_iio.c +...
Quoted 36 lines
drivers/iio/common/scmi_sensors/Makefile new file +5
-0@@ -0,0 +1,5 @@ +# SPDX - License - Identifier : GPL - 2.0 - only +# +# Makefile for the IIO over SCMI +# +obj-$(CONFIG_IIO_SCMI) += scmi_iio.odrivers/iio/common/scmi_sensors/scmi_iio.c new file +19
-0@@ -0,0 +1,678 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* +* System Control and Management Interface(SCMI) based IIO sensor driver +* +* Copyright (C) 2021 Google LLC +*/ + +#include <linux/delay.h> +#include <linux/err.h> +#include <linux/iio/buffer.h> +#include <linux/iio/iio.h> +#include <linux/iio/kfifo_buf.h> +#include <linux/iio/sysfs.h> +#include <linux/kernel.h> +#include <linux/kthread.h> +#include <linux/module.h> +#include <linux/scmi_protocol.h> +#include <linux/time.h> drivers/iio/common/scmi_sensors/scmi_iio.c line 29
Quoted 10 lines
drivers/iio/common/scmi_sensors/scmi_iio.c new file +10
-0+#include <linux/types.h> + +#define SCMI_IIO_NUM_OF_AXIS 3 + +struct scmi_iio_priv { +struct scmi_handle *handle; +const struct scmi_sensor_info *sensor_info; +struct iio_dev *indio_dev; +/* adding one additional channel for timestamp */ +long long iio_buf[SCMI_IIO_NUM_OF_AXIS +1 ];Missed this previously but we should probably be careful to make this explicitly 64 bit rather than rely on long long being that length. s64 iio_buf[SCMI_IIO_NUM_OF_AXIS + 1];
I can tidy this up whilst applying if that is fine with you.
Quoted 4 lines
drivers/iio/common/scmi_sensors/scmi_iio.c new file +4
-0+struct notifier_block sensor_update_nb; +u32 *freq_avail; +}; +...
drivers/iio/common/scmi_sensors/scmi_iio.c line 334
Quoted 5 lines
drivers/iio/common/scmi_sensors/scmi_iio.c new file +5
-0+ +static ssize_t scmi_iio_get_raw_available (struct iio_dev *iio_dev, +uintptr_t private, +const struct iio_chan_spec *chan, +char *buf)Looks good. Thanks for persevering with this!
Quoted 40 lines
drivers/iio/common/scmi_sensors/scmi_iio.c new file +40
-0+{ +struct scmi_iio_priv *sensor =iio_priv (iio_dev); +unsigned long long resolution, rem; +long long min_range, max_range; +s8 exponent, scale; +int len =0 ; + +/* +* All the axes are supposed to have the same value for range and resolution. +* We are just using the values from the Axis 0 here. +*/ +if (sensor->sensor_info->axis[0 ].extended_attrs) { + min_range = sensor->sensor_info->axis[0 ].attrs.min_range; + max_range = sensor->sensor_info->axis[0 ].attrs.max_range; + resolution = sensor->sensor_info->axis[0 ].resolution; + exponent = sensor->sensor_info->axis[0 ].exponent; + scale = sensor->sensor_info->axis[0 ].scale; + +/* +* To provide the raw value for the resolution to the userspace, +* need to divide the resolution exponent by the sensor scale +*/ + exponent = exponent - scale; +if (exponent <0 ) { + resolution =div64_u64_rem (resolution, +int_pow (10 ,abs (exponent)), + &rem); + len =scnprintf (buf,PAGE_SIZE , +"[%lld %llu.%llu %lld]\n" , min_range, + resolution, rem, max_range); + }else { + resolution = resolution *int_pow (10 , exponent); + len =scnprintf (buf,PAGE_SIZE ,"[%lld %llu %lld]\n" , + min_range, resolution, max_range); + } + } +return len; +} + +static const struct iio_chan_spec_ext_info scmi_iio_ext_info[] = {drivers/iio/common/scmi_sensors/scmi_iio.c line 384
Quoted 10 lines
drivers/iio/common/scmi_sensors/scmi_iio.c new file +10
-0+ { + .name = "raw_available", + .read = scmi_iio_get_raw_available, + .shared = IIO_SHARED_BY_TYPE, + }, + {}, +}; + +static void scmi_iio_set_timestamp_channel (struct iio_chan_spec *iio_chan, +int scan_index)Not relevant to this patch!: I wonder how many times
we now have this replicated in various drivers. Feels like a good thing to just have as a library function in the IIO core.
(about 8 copies of this from a quick grep)Quoted 9 lines
drivers/iio/common/scmi_sensors/scmi_iio.c new file +9
-0+{ + iio_chan->type =IIO_TIMESTAMP ; + iio_chan->channel =-1 ; + iio_chan->scan_index = scan_index; + iio_chan->scan_type.sign ='u' ; + iio_chan->scan_type.realbits =64 ; + iio_chan->scan_type.storagebits =64 ; +} +...
drivers/iio/common/scmi_sensors/scmi_iio.c line 475
Quoted 2 lines
drivers/iio/common/scmi_sensors/scmi_iio.c new file +2
-0+ +static int scmi_iio_set_sampling_freq_avail (struct iio_dev *iio_dev)Really trivial, but if you happen to be respinning for some reason, the naming of this function is a little confusing. My initial thought is it would somehow specify the sampling frequencies that the driver expects to be available, rather than the opposite where it is the driver establishing what is available.
If _get_ is also ambiguous, perhaps _query_ or _format_ or _convert_ (to reflect you are converting values to expected form).
Quoted 3 lines
drivers/iio/common/scmi_sensors/scmi_iio.c new file +3
-0+{ +u64 cur_interval_ns, low_interval_ns, high_interval_ns, step_size_ns, + hz, uhz;...
drivers/iio/common/scmi_sensors/scmi_iio.c line 536
Quoted 13 lines
drivers/iio/common/scmi_sensors/scmi_iio.c new file +13
-0+} + +static int scmi_iio_buffers_setup (struct iio_dev *scmi_iiodev) +{ +struct iio_buffer *buffer; + + buffer =devm_iio_kfifo_allocate (&scmi_iiodev->dev); +if (!buffer) +return -ENOMEM ; + +iio_device_attach_buffer (scmi_iiodev, buffer); + scmi_iiodev->modes |=INDIO_BUFFER_SOFTWARE ; + scmi_iiodev->setup_ops = &scmi_iio_buffer_ops;Ah. This has now crossed with Alex's large rework of the buffer registration in the core (to support multiple buffers).
Specifically it needs to flip over to using the function introduced
in https://lore.kernel.org/linux-iio/[email protected]/T/#uThis is going to make taking this via an immutable branch more fiddly. Don't worry about it though; I'll figure it out once rc1 is out. (either the merge of this tree will have to before Alex's series, or I'll need to do a non trivial merge resolution).
The one thing we can't do is rebase this series as that would then delay Cristian's work for a whole cycle (or require some usual tree management.) What fun :)
Quoted 123 lines
drivers/iio/common/scmi_sensors/scmi_iio.c new file +123
-0+return 0 ; +} + +static struct iio_dev *scmi_alloc_iiodev (struct device *dev, +struct scmi_handle *handle, +const struct scmi_sensor_info *sensor_info) +{ +struct iio_chan_spec *iio_channels; +struct scmi_iio_priv *sensor; +enum iio_modifier modifier; +enum iio_chan_type type; +struct iio_dev *iiodev; +int i, ret; + + iiodev =devm_iio_device_alloc (dev,sizeof (*sensor)); +if (!iiodev) +return ERR_PTR (-ENOMEM ); + + iiodev->modes =INDIO_DIRECT_MODE ; + iiodev->dev.parent = dev; + sensor =iio_priv (iiodev); + sensor->handle = handle; + sensor->sensor_info = sensor_info; + sensor->sensor_update_nb.notifier_call = scmi_iio_sensor_update_cb; + sensor->indio_dev = iiodev; + +/* adding one additional channel for timestamp */ + iiodev->num_channels = sensor_info->num_axis +1 ; + iiodev->name = sensor_info->name; + iiodev->info = &scmi_iio_info; + + iio_channels = +devm_kzalloc (dev, +sizeof (*iio_channels) * (iiodev->num_channels), +GFP_KERNEL ); +if (!iio_channels) +return ERR_PTR (-ENOMEM ); + + ret =scmi_iio_set_sampling_freq_avail (iiodev); +if (ret <0 ) +return ERR_PTR (ret); + +for (i =0 ; i < sensor_info->num_axis; i++) { + ret =scmi_iio_get_chan_type (sensor_info->axis[i].type, &type); +if (ret <0 ) +return ERR_PTR (ret); + + ret =scmi_iio_get_chan_modifier (sensor_info->axis[i].name, + &modifier); +if (ret <0 ) +return ERR_PTR (ret); + +scmi_iio_set_data_channel (&iio_channels[i], type, modifier, + sensor_info->axis[i].id); + } + +scmi_iio_set_timestamp_channel (&iio_channels[i], i); + iiodev->channels = iio_channels; +return iiodev; +} + +static int scmi_iio_dev_probe (struct scmi_device *sdev) +{ +const struct scmi_sensor_info *sensor_info; +struct scmi_handle *handle = sdev->handle; +struct device *dev = &sdev->dev; +struct iio_dev *scmi_iio_dev; +u16 nr_sensors; +int err = -ENODEV , i; + +if (!handle || !handle->sensor_ops) { +dev_err (dev,"SCMI device has no sensor interface\n" ); +return -EINVAL ; + } + + nr_sensors = handle->sensor_ops->count_get (handle); +if (!nr_sensors) { +dev_dbg (dev,"0 sensors found via SCMI bus\n" ); +return -ENODEV ; + } + +for (i =0 ; i < nr_sensors; i++) { + sensor_info = handle->sensor_ops->info_get (handle, i); +if (!sensor_info) { +dev_err (dev,"SCMI sensor %d has missing info\n" , i); +return -EINVAL ; + } + +/* This driver only supports 3-axis accel and gyro, skipping other sensors */ +if (sensor_info->num_axis !=SCMI_IIO_NUM_OF_AXIS ) +continue ; + +/* This driver only supports 3-axis accel and gyro, skipping other sensors */ +if (sensor_info->axis[0 ].type !=METERS_SEC_SQUARED && + sensor_info->axis[0 ].type !=RADIANS_SEC ) +continue ; + + scmi_iio_dev =scmi_alloc_iiodev (dev, handle, sensor_info); +if (IS_ERR (scmi_iio_dev)) { +dev_err (dev, +"failed to allocate IIO device for sensor %s: %ld\n" , + sensor_info->name,PTR_ERR (scmi_iio_dev)); +return PTR_ERR (scmi_iio_dev); + } + + err =scmi_iio_buffers_setup (scmi_iio_dev); +if (err <0 ) { +dev_err (dev, +"IIO buffer setup error at sensor %s: %d\n" , + sensor_info->name, err); +return err; + } + + err =devm_iio_device_register (dev, scmi_iio_dev); +if (err) { +dev_err (dev, +"IIO device registration failed at sensor %s: %d\n" , + sensor_info->name, err); +return err; + } + } +return err; +}
Re: [PATCH v6 1/1] iio/scmi: Adding support for IIO SCMI Based Sensors
Hi Jonathan,
Quoted 7 lines · Jyoti Bhayana
Hi Jonathan,
Thanks for the detailed and careful review of this patch. Good to hear
that v7 is not required. Please find below answers to your
questions. Looking forward to seeing this patch merged in the next cycle. Thanks for your help in making this happen.
Any update on this ? Please share the branch with is patch so that I can pull and ask Cristian to make his changes on top.
--
Regards,
Sudeep
Jonathan Cameron
maintainerRe: [PATCH v6 1/1] iio/scmi: Adding support for IIO SCMI Based Sensors
Quoted 5 lines · On Mon, 8 Mar 2021 04:28:42 +0000 Sudeep Holla <[email protected]> wrote:
Hi Jonathan,
Quoted 2 lines · Jyoti Bhayana
Hi Jonathan,
Quoted 8 lines
Quoted 5 lines
Thanks for the detailed and careful review of this patch. Good to hear
that v7 is not required. Please find below answers to your
questions. Looking forward to seeing this patch merged in the next cycle. Thanks for your help in making this happen.Any update on this ? Please share the branch with is patch so that I can pull and ask Cristian to make his changes on top.
Running a bit behind at the moment.
Anyhow, there should now be an ib-iio-scmi-5.12-rc1 branch on https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git
Includes making the various long long local variables explicitly s64 and u64 as relevant.
Based on the rc1 that eats babies so handle with care :)
I've also merge this into the togreg branch of iio.git. As explained above that wasn't entirely trivial so Jyoti please take a quick look and check that changes are fine. Pushed out as testing to let the autobuilders poke at it. Assuming they don't find anything, it should be fine for Sudeep to merge that ib and everything will unwind nicely in Linus' tree next cycle.
There is a bit of an ongoing discussion of an earlier patch in the IIO tree, so I might end up redoing this merge if I need to rebase to sort that out, but I'll make sure the diff is the same (git ID might change).
Thanks,
Jonathan
Quoted 4 lines
--
Regards,
Sudeep
Jyoti Bhayana
maintainerRe: [PATCH v6 1/1] iio/scmi: Adding support for IIO SCMI Based Sensors
Hi Jonathan,
I looked at ib-iio-scmi-5.12-rc1 branch and the changes look good to me. Once again, thanks for all your help.
Thanks,
Jyoti
Quoted 49 lines · Jonathan Cameron
Quoted 5 lines · On Mon, 8 Mar 2021 04:28:42 +0000 Sudeep Holla <[email protected]> wrote:
Hi Jonathan,
Quoted 2 lines · Jyoti Bhayana
Hi Jonathan,
Quoted 8 lines
Quoted 5 lines
Thanks for the detailed and careful review of this patch. Good to hear
that v7 is not required. Please find below answers to your
questions. Looking forward to seeing this patch merged in the next cycle. Thanks for your help in making this happen.Any update on this ? Please share the branch with is patch so that I can pull and ask Cristian to make his changes on top.
Running a bit behind at the moment.
Anyhow, there should now be an ib-iio-scmi-5.12-rc1 branch on https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git
Includes making the various long long local variables explicitly s64 and u64 as relevant.
Based on the rc1 that eats babies so handle with care :)
I've also merge this into the togreg branch of iio.git. As explained above that wasn't entirely trivial so Jyoti please take a quick look and check that changes are fine. Pushed out as testing to let the autobuilders poke at it. Assuming they don't find anything, it should be fine for Sudeep to merge that ib and everything will unwind nicely in Linus' tree next cycle.
There is a bit of an ongoing discussion of an earlier patch in the IIO tree, so I might end up redoing this merge if I need to rebase to sort that out, but I'll make sure the diff is the same (git ID might change).
Thanks,
Jonathan
Quoted 4 lines
--
Regards,
Sudeep
Re: [PATCH v6 1/1] iio/scmi: Adding support for IIO SCMI Based Sensors
In reply to Jonathan CameronQuoted 14 lines · Jonathan Cameron
Quoted 11 lines · On Mon, 8 Mar 2021 04:28:42 +0000 Sudeep Holla <[email protected]> wrote:
Hi Jonathan,
Quoted 7 lines · Jyoti Bhayana
Hi Jonathan,
Thanks for the detailed and careful review of this patch. Good to hear
that v7 is not required. Please find below answers to your
questions. Looking forward to seeing this patch merged in the next cycle. Thanks for your help in making this happen.
Quoted 4 lines
Quoted 2 lines
Any update on this ? Please share the branch with is patch so that I can pull and ask Cristian to make his changes on top.
Running a bit behind at the moment.
No worries.
Quoted 3 lines
Anyhow, there should now be an ib-iio-scmi-5.12-rc1 branch on https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git
Thanks
Quoted 5 lines
Includes making the various long long local variables explicitly s64 and u64 as relevant.
Based on the rc1 that eats babies so handle with care :)
😁
Quoted 8 lines
I've also merge this into the togreg branch of iio.git. As explained above that wasn't entirely trivial so Jyoti please take a quick look and check that changes are fine. Pushed out as testing to let the autobuilders poke at it. Assuming they don't find anything, it should be fine for Sudeep to merge that ib and everything will unwind nicely in Linus' tree next cycle.
Hope so.
Quoted 5 lines
There is a bit of an ongoing discussion of an earlier patch in the IIO tree, so I might end up redoing this merge if I need to rebase to sort that out, but I'll make sure the diff is the same (git ID might change).
I can wait for a week or 2 if you think things will settle down by then. We can avoid 2 different git IDs if possible. The main intention was to give some reference to Cristian to rebase/post his series. I am all fine to wait for a week or 2 for final branch.
--
Regards,
Sudeep
Cristian Marussi
reviewerRe: [PATCH v6 1/1] iio/scmi: Adding support for IIO SCMI Based Sensors
Hi
Quoted 53 lines · Sudeep Holla
Quoted 14 lines · Jonathan Cameron
Quoted 11 lines · On Mon, 8 Mar 2021 04:28:42 +0000 Sudeep Holla <[email protected]> wrote:
Hi Jonathan,
Quoted 7 lines · Jyoti Bhayana
Hi Jonathan,
Thanks for the detailed and careful review of this patch. Good to hear
that v7 is not required. Please find below answers to your
questions. Looking forward to seeing this patch merged in the next cycle. Thanks for your help in making this happen.Quoted 4 lines
Quoted 2 lines
Any update on this ? Please share the branch with is patch so that I can pull and ask Cristian to make his changes on top.
Running a bit behind at the moment.
No worries.
Quoted 3 lines
Anyhow, there should now be an ib-iio-scmi-5.12-rc1 branch on https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git
Thanks
Quoted 5 lines
Includes making the various long long local variables explicitly s64 and u64 as relevant.
Based on the rc1 that eats babies so handle with care :)
😁
Quoted 8 lines
I've also merge this into the togreg branch of iio.git. As explained above that wasn't entirely trivial so Jyoti please take a quick look and check that changes are fine. Pushed out as testing to let the autobuilders poke at it. Assuming they don't find anything, it should be fine for Sudeep to merge that ib and everything will unwind nicely in Linus' tree next cycle.
Hope so.
Quoted 5 lines
There is a bit of an ongoing discussion of an earlier patch in the IIO tree, so I might end up redoing this merge if I need to rebase to sort that out, but I'll make sure the diff is the same (git ID might change).
Quoted 5 lines
I can wait for a week or 2 if you think things will settle down by then. We can avoid 2 different git IDs if possible. The main intention was to give some reference to Cristian to rebase/post his series. I am all fine to wait for a week or 2 for final branch.
In the meantime, I've anyway started reworking just based on -rc2 and barely cherry-picked Jyoti v6 on top of it just to able to start porting early the iiodev to the new SCMI API and be able to fully test it out (no problems so far); I will finally rebase on whatever final base branch Sudeep will pick but as Sudeep said I can wait, since I'm not expecting so much work still to do in that final rebase to -rc1-smh-final (...last famous words o_O)
Side question for Jyoti/Jonathan, for basic testing of this IIO SCMI driver (given that I'm not really familiar with IIO and I have not a full Android CTS/VTS suite to use it for testing), I'm doing something like:
(debian-arm64)root@debarm64:~# cd /sys/bus/iio/devices/iio\:device0 (debian-arm64)root@debarm64:/sys/bus/iio/devices/iio:device0# echo 1 > scan_elements/in_accel_x_en (debian-arm64)root@debarm64:/sys/bus/iio/devices/iio:device0# echo 1 > scan_elements/in_accel_y_en (debian-arm64)root@debarm64:/sys/bus/iio/devices/iio:device0# echo 1 > scan_elements/in_accel_z_en (debian-arm64)root@debarm64:/sys/bus/iio/devices/iio:device0# echo 1 > scan_elements/in_timestamp_en (debian-arm64)root@debarm64:/sys/bus/iio/devices/iio:device0# echo 1 > buffer/enable && cat /dev/iio\:device0 | xxd 00000000: 08da ffff ffff ffff 10da ffff ffff ffff ................ 00000010: 18da ffff ffff ffff 00b8 d3a0 c09b 6a16 ..............j. 00000020: 08da ffff ffff ffff 10da ffff ffff ffff ................ 00000030: 18da ffff ffff ffff 0082 6edc c09b 6a16 ..........n...j. 00000040: 08da ffff ffff ffff 10da ffff ffff ffff ................ 00000050: 18da ffff ffff ffff 004c 0918 c19b 6a16 .........L....j. 00000060: 08da ffff ffff ffff 10da ffff ffff ffff ................ 00000070: 18da ffff ffff ffff 0016 a453 c19b 6a16 ...........S..j. 00000080: 08da ffff ffff ffff 10da ffff ffff ffff ................ 00000090: 18da ffff ffff ffff 00aa d9ca c19b 6a16 ..............j. 000000a0: 08da ffff ffff ffff 10da ffff ffff ffff ................ 000000b0: 18da ffff ffff ffff 0074 7406 c29b 6a16 .........tt...j. ^C (debian-arm64)root@debarm64:/sys/bus/iio/devices/iio:device0# echo 0 > buffer/enable
(plus a bunch of DEBUG in my series to track notifs flows...)
Is this any good ?
Thanks
Cristian
Quoted 3 lines
--
Regards,
Sudeep
Re: [PATCH v6 1/1] iio/scmi: Adding support for IIO SCMI Based Sensors
Quoted 62 lines · On Tue, 9 Mar 2021 07:38:13 +0000 Cristian Marussi <[email protected]>…
Hi
Quoted 53 lines · Sudeep Holla
Quoted 14 lines · Jonathan Cameron
Quoted 11 lines · On Mon, 8 Mar 2021 04:28:42 +0000 Sudeep Holla <[email protected]> wrote:
Hi Jonathan,
Quoted 7 lines · Jyoti Bhayana
Hi Jonathan,
Thanks for the detailed and careful review of this patch. Good to hear
that v7 is not required. Please find below answers to your
questions. Looking forward to seeing this patch merged in the next cycle. Thanks for your help in making this happen.Quoted 4 lines
Quoted 2 lines
Any update on this ? Please share the branch with is patch so that I can pull and ask Cristian to make his changes on top.
Running a bit behind at the moment.
No worries.
Quoted 3 lines
Anyhow, there should now be an ib-iio-scmi-5.12-rc1 branch on https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git
Thanks
Quoted 5 lines
Includes making the various long long local variables explicitly s64 and u64 as relevant.
Based on the rc1 that eats babies so handle with care :)
😁
Quoted 8 lines
I've also merge this into the togreg branch of iio.git. As explained above that wasn't entirely trivial so Jyoti please take a quick look and check that changes are fine. Pushed out as testing to let the autobuilders poke at it. Assuming they don't find anything, it should be fine for Sudeep to merge that ib and everything will unwind nicely in Linus' tree next cycle.
Hope so.
Quoted 5 lines
There is a bit of an ongoing discussion of an earlier patch in the IIO tree, so I might end up redoing this merge if I need to rebase to sort that out, but I'll make sure the diff is the same (git ID might change).
Quoted 5 lines
I can wait for a week or 2 if you think things will settle down by then. We can avoid 2 different git IDs if possible. The main intention was to give some reference to Cristian to rebase/post his series. I am all fine to wait for a week or 2 for final branch.
Quoted 6 lines
In the meantime, I've anyway started reworking just based on -rc2 and barely cherry-picked Jyoti v6 on top of it just to able to start porting early the iiodev to the new SCMI API and be able to fully test it out (no problems so far); I will finally rebase on whatever final base branch Sudeep will pick but as Sudeep said I can wait, since I'm not expecting so much work still to do in that final rebase to -rc1-smh-final (...last famous words
o_O)
Side note, there was a build bug on 32 bit that needs fixing so we'll be tweaking the original patch.
Quoted 17 lines
Side question for Jyoti/Jonathan, for basic testing of this IIO SCMI driver (given that I'm not really familiar with IIO and I have not a full Android CTS/VTS suite to use it for testing), I'm doing something like:
(debian-arm64)root@debarm64:~# cd /sys/bus/iio/devices/iio\:device0 (debian-arm64)root@debarm64:/sys/bus/iio/devices/iio:device0# echo 1 > scan_elements/in_accel_x_en (debian-arm64)root@debarm64:/sys/bus/iio/devices/iio:device0# echo 1 > scan_elements/in_accel_y_en (debian-arm64)root@debarm64:/sys/bus/iio/devices/iio:device0# echo 1 > scan_elements/in_accel_z_en (debian-arm64)root@debarm64:/sys/bus/iio/devices/iio:device0# echo 1 > scan_elements/in_timestamp_en (debian-arm64)root@debarm64:/sys/bus/iio/devices/iio:device0# echo 1 > buffer/enable && cat /dev/iio\:device0 | xxd 00000000: 08da ffff ffff ffff 10da ffff ffff ffff ................ 00000010: 18da ffff ffff ffff 00b8 d3a0 c09b 6a16 ..............j. 00000020: 08da ffff ffff ffff 10da ffff ffff ffff ................ 00000030: 18da ffff ffff ffff 0082 6edc c09b 6a16 ..........n...j. 00000040: 08da ffff ffff ffff 10da ffff ffff ffff ................ 00000050: 18da ffff ffff ffff 004c 0918 c19b 6a16 .........L....j.
Quoted 8 lines
00000060: 08da ffff ffff ffff 10da ffff ffff ffff ................ 00000070: 18da ffff ffff ffff 0016 a453 c19b 6a16 ...........S..j. 00000080: 08da ffff ffff ffff 10da ffff ffff ffff ................ 00000090: 18da ffff ffff ffff 00aa d9ca c19b 6a16 ..............j. 000000a0: 08da ffff ffff ffff 10da ffff ffff ffff ................ 000000b0: 18da ffff ffff ffff 0074 7406 c29b 6a16 .........tt...j. ^C (debian-arm64)root@debarm64:/sys/bus/iio/devices/iio:device0# echo 0 > buffer/enable
That looks superficially plausible.
There is a test tool intools/iio/iio_generic_buffer.c which is fairly simple to use and will pretty print values for you. That'll sanity check all the type descriptions etc are correct as well.
Jonathan
Quoted 12 lines
(plus a bunch of DEBUG in my series to track notifs flows...)
Is this any good ?
Thanks
Cristian
Quoted 3 lines
--
Regards,
Sudeep
Cristian Marussi
reviewerRe: [PATCH v6 1/1] iio/scmi: Adding support for IIO SCMI Based Sensors
Hi Jonathan,
Quoted 72 lines · Jonathan Cameron
Quoted 62 lines · On Tue, 9 Mar 2021 07:38:13 +0000 Cristian Marussi <[email protected]>…
Hi
Quoted 53 lines · Sudeep Holla
Quoted 14 lines · Jonathan Cameron
Quoted 11 lines · On Mon, 8 Mar 2021 04:28:42 +0000 Sudeep Holla <[email protected]> wrote:
Hi Jonathan,
Quoted 7 lines · Jyoti Bhayana
Hi Jonathan,
Thanks for the detailed and careful review of this patch. Good to hear
that v7 is not required. Please find below answers to your
questions. Looking forward to seeing this patch merged in the next cycle. Thanks for your help in making this happen.Quoted 4 lines
Quoted 2 lines
Any update on this ? Please share the branch with is patch so that I can pull and ask Cristian to make his changes on top.
Running a bit behind at the moment.
No worries.
Quoted 3 lines
Anyhow, there should now be an ib-iio-scmi-5.12-rc1 branch on https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git
Thanks
Quoted 5 lines
Includes making the various long long local variables explicitly s64 and u64 as relevant.
Based on the rc1 that eats babies so handle with care :)
😁
Quoted 8 lines
I've also merge this into the togreg branch of iio.git. As explained above that wasn't entirely trivial so Jyoti please take a quick look and check that changes are fine. Pushed out as testing to let the autobuilders poke at it. Assuming they don't find anything, it should be fine for Sudeep to merge that ib and everything will unwind nicely in Linus' tree next cycle.
Hope so.
Quoted 5 lines
There is a bit of an ongoing discussion of an earlier patch in the IIO tree, so I might end up redoing this merge if I need to rebase to sort that out, but I'll make sure the diff is the same (git ID might change).
Quoted 5 lines
I can wait for a week or 2 if you think things will settle down by then. We can avoid 2 different git IDs if possible. The main intention was to give some reference to Cristian to rebase/post his series. I am all fine to wait for a week or 2 for final branch.
Quoted 6 lines
In the meantime, I've anyway started reworking just based on -rc2 and barely cherry-picked Jyoti v6 on top of it just to able to start porting early the iiodev to the new SCMI API and be able to fully test it out (no problems so far); I will finally rebase on whatever final base branch Sudeep will pick but as Sudeep said I can wait, since I'm not expecting so much work still to do in that final rebase to -rc1-smh-final (...last famous words
o_O)
Quoted 3 lines
Side note, there was a build bug on 32 bit that needs fixing so we'll be tweaking the original patch.
Sure, thanks, I'll rework it anyway, it was just preliminary work.
Quoted 25 lines
Quoted 17 lines
Side question for Jyoti/Jonathan, for basic testing of this IIO SCMI driver (given that I'm not really familiar with IIO and I have not a full Android CTS/VTS suite to use it for testing), I'm doing something like:
(debian-arm64)root@debarm64:~# cd /sys/bus/iio/devices/iio\:device0 (debian-arm64)root@debarm64:/sys/bus/iio/devices/iio:device0# echo 1 > scan_elements/in_accel_x_en (debian-arm64)root@debarm64:/sys/bus/iio/devices/iio:device0# echo 1 > scan_elements/in_accel_y_en (debian-arm64)root@debarm64:/sys/bus/iio/devices/iio:device0# echo 1 > scan_elements/in_accel_z_en (debian-arm64)root@debarm64:/sys/bus/iio/devices/iio:device0# echo 1 > scan_elements/in_timestamp_en (debian-arm64)root@debarm64:/sys/bus/iio/devices/iio:device0# echo 1 > buffer/enable && cat /dev/iio\:device0 | xxd 00000000: 08da ffff ffff ffff 10da ffff ffff ffff ................ 00000010: 18da ffff ffff ffff 00b8 d3a0 c09b 6a16 ..............j. 00000020: 08da ffff ffff ffff 10da ffff ffff ffff ................ 00000030: 18da ffff ffff ffff 0082 6edc c09b 6a16 ..........n...j. 00000040: 08da ffff ffff ffff 10da ffff ffff ffff ................ 00000050: 18da ffff ffff ffff 004c 0918 c19b 6a16 .........L....j.Quoted 8 lines
00000060: 08da ffff ffff ffff 10da ffff ffff ffff ................ 00000070: 18da ffff ffff ffff 0016 a453 c19b 6a16 ...........S..j. 00000080: 08da ffff ffff ffff 10da ffff ffff ffff ................ 00000090: 18da ffff ffff ffff 00aa d9ca c19b 6a16 ..............j. 000000a0: 08da ffff ffff ffff 10da ffff ffff ffff ................ 000000b0: 18da ffff ffff ffff 0074 7406 c29b 6a16 .........tt...j. ^C (debian-arm64)root@debarm64:/sys/bus/iio/devices/iio:device0# echo 0 > buffer/enable
Quoted 2 lines
That looks superficially plausible.
Yes, definitely not an in depth testing, I was just trying to double check not to break the general mechanism when porting to the new API.
Quoted 4 lines
There is a test tool in
tools/iio/iio_generic_buffer.cwhich is fairly simple to use and will pretty print values for you. That'll sanity check all the type descriptions etc are correct as well.
Cool, thanks a lot I'll give it a go.
Thanks
Cristian
Quoted 15 lines
Jonathan
Quoted 12 lines
(plus a bunch of DEBUG in my series to track notifs flows...)
Is this any good ?
Thanks
Cristian
Quoted 3 lines
--
Regards,
Sudeep