summaryrefslogtreecommitdiffstats
path: root/meta-egvirt
diff options
context:
space:
mode:
authorVasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>2022-05-10 16:13:12 +0200
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>2022-06-08 14:23:35 +0000
commit9893e9e1a0ae33a2ea2971081dbfbfd486c4214c (patch)
tree9da3946570fd05d975f2d5faef0518ea110aafe4 /meta-egvirt
parentdb4be1a90d3f84c8255c8a3b51ae71f2eae54980 (diff)
egvirt: linux-yocto: Adapt for kernel v5.15.
* Remove changes already present in v5.15. * Refresh other patches. * Document how to recreate kernel configs for future reference. Bug-AGL: SPEC-4365 Change-Id: If8f900c9de7d8536364d71288902fd842d3ddc5f Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
Diffstat (limited to 'meta-egvirt')
-rw-r--r--meta-egvirt/recipes-kernel/linux/linux-yocto/iio-scmi/0001-iio-scmi-Adding-support-for-IIO-SCMI-Based-Sensors.patch797
-rw-r--r--meta-egvirt/recipes-kernel/linux/linux-yocto/iio-scmi/0002-iio-core-Introduce-IIO_VAL_INT_64.patch20
-rw-r--r--meta-egvirt/recipes-kernel/linux/linux-yocto/iio-scmi/0003-iio-scmi-Add-reading-raw-attribute.patch27
-rw-r--r--meta-egvirt/recipes-kernel/linux/linux-yocto/scmi/0001-firmware-arm_scmi-rework-scmi_sensors_protocol_init.patch69
-rw-r--r--meta-egvirt/recipes-kernel/linux/linux-yocto/scmi/0002-firmware-arm_scmi-add-SCMIv3.0-Sensors-descriptors-e.patch733
-rw-r--r--meta-egvirt/recipes-kernel/linux/linux-yocto/scmi/0003-hwmon-scmi-update-hwmon-internal-scale-data-type.patch30
-rw-r--r--meta-egvirt/recipes-kernel/linux/linux-yocto/scmi/0004-firmware-arm_scmi-add-SCMIv3.0-Sensors-timestamped-r.patch236
-rw-r--r--meta-egvirt/recipes-kernel/linux/linux-yocto/scmi/0005-firmware-arm_scmi-add-SCMIv3.0-Sensor-configuration-.patch172
-rw-r--r--meta-egvirt/recipes-kernel/linux/linux-yocto/scmi/0006-firmware-arm_scmi-add-SCMIv3.0-Sensor-notifications.patch234
-rw-r--r--meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0001-firmware-arm_scmi-smccc-mailbox-Make-shmem-based-tra.patch119
-rw-r--r--meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0002-firmware-arm_scmi-Document-that-max_msg-is-a-per-cha.patch34
-rw-r--r--meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0003-firmware-arm_scmi-Add-op-to-override-max-message.patch165
-rw-r--r--meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0004-firmware-arm_scmi-Add-per-message-transport-data.patch42
-rw-r--r--meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0005-firmware-arm_scmi-Add-xfer_init_buffers-transport-op.patch79
-rw-r--r--meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0006-firmware-arm_scmi-Add-optional-link_supplier-transpo.patch54
-rw-r--r--meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0007-firmware-arm_scmi-Add-per-device-transport-private-i.patch92
-rw-r--r--meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0008-firmware-arm_scmi-Add-is_scmi_protocol_device.patch46
-rw-r--r--meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0009-dt-bindings-arm-Add-virtio-transport-for-SCMI.patch89
-rw-r--r--meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0010-firmware-arm_scmi-Add-virtio-transport.patch756
-rw-r--r--meta-egvirt/recipes-kernel/linux/linux-yocto/virtio_scmi.cfg22
-rw-r--r--meta-egvirt/recipes-kernel/linux/linux-yocto/virtio_video.cfg24
-rw-r--r--meta-egvirt/recipes-kernel/linux/linux-yocto_%.bbappend21
22 files changed, 70 insertions, 3791 deletions
diff --git a/meta-egvirt/recipes-kernel/linux/linux-yocto/iio-scmi/0001-iio-scmi-Adding-support-for-IIO-SCMI-Based-Sensors.patch b/meta-egvirt/recipes-kernel/linux/linux-yocto/iio-scmi/0001-iio-scmi-Adding-support-for-IIO-SCMI-Based-Sensors.patch
deleted file mode 100644
index 15f6b6a3..00000000
--- a/meta-egvirt/recipes-kernel/linux/linux-yocto/iio-scmi/0001-iio-scmi-Adding-support-for-IIO-SCMI-Based-Sensors.patch
+++ /dev/null
@@ -1,797 +0,0 @@
-From df55878d8bb123266d301939a3ff90762fd466e1 Mon Sep 17 00:00:00 2001
-From: Jyoti Bhayana <jbhayana@google.com>
-Date: Fri, 12 Feb 2021 17:22:35 +0000
-Subject: [PATCH] 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
-
-Signed-off-by: Jyoti Bhayana <jbhayana@google.com>
-Link: https://lore.kernel.org/r/20210212172235.507028-2-jbhayana@google.com
-Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
-Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
----
- 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
-
-diff --git a/MAINTAINERS b/MAINTAINERS
-index d223a5c3f465..c3a0245a51d0 100644
---- a/MAINTAINERS
-+++ b/MAINTAINERS
-@@ -8593,6 +8593,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 <jbhayana@google.com>
-+L: linux-iio@vger.kernel.org
-+S: Maintained
-+F: drivers/iio/common/scmi_sensors/scmi_iio.c
-+
- IIO SUBSYSTEM AND DRIVERS
- M: Jonathan Cameron <jic23@kernel.org>
- R: Lars-Peter Clausen <lars@metafoo.de>
-diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
-index 540a55285349..fa7279839397 100644
---- a/drivers/firmware/arm_scmi/driver.c
-+++ b/drivers/firmware/arm_scmi/driver.c
-@@ -808,7 +808,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" },},
- };
-
-diff --git a/drivers/iio/common/Kconfig b/drivers/iio/common/Kconfig
-index 2b9ee9161abd..0334b4954773 100644
---- a/drivers/iio/common/Kconfig
-+++ b/drivers/iio/common/Kconfig
-@@ -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"
-diff --git a/drivers/iio/common/Makefile b/drivers/iio/common/Makefile
-index 4bc30bb548e2..fad40e1e1718 100644
---- a/drivers/iio/common/Makefile
-+++ b/drivers/iio/common/Makefile
-@@ -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/
-diff --git a/drivers/iio/common/scmi_sensors/Kconfig b/drivers/iio/common/scmi_sensors/Kconfig
-new file mode 100644
-index 000000000000..67e084cbb1ab
---- /dev/null
-+++ b/drivers/iio/common/scmi_sensors/Kconfig
-@@ -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
-diff --git a/drivers/iio/common/scmi_sensors/Makefile b/drivers/iio/common/scmi_sensors/Makefile
-new file mode 100644
-index 000000000000..f13140a2575a
---- /dev/null
-+++ b/drivers/iio/common/scmi_sensors/Makefile
-@@ -0,0 +1,5 @@
-+# SPDX - License - Identifier : GPL - 2.0 - only
-+#
-+# Makefile for the IIO over SCMI
-+#
-+obj-$(CONFIG_IIO_SCMI) += scmi_iio.o
-diff --git a/drivers/iio/common/scmi_sensors/scmi_iio.c b/drivers/iio/common/scmi_sensors/scmi_iio.c
-new file mode 100644
-index 000000000000..31977c3bc600
---- /dev/null
-+++ b/drivers/iio/common/scmi_sensors/scmi_iio.c
-@@ -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>
-+#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];
-+ struct notifier_block sensor_update_nb;
-+ u32 *freq_avail;
-+};
-+
-+static int scmi_iio_sensor_update_cb(struct notifier_block *nb,
-+ unsigned long event, void *data)
-+{
-+ struct scmi_sensor_update_report *sensor_update = data;
-+ struct iio_dev *scmi_iio_dev;
-+ struct scmi_iio_priv *sensor;
-+ s8 tstamp_scale;
-+ u64 time, time_ns;
-+ int i;
-+
-+ if (sensor_update->readings_count == 0)
-+ return NOTIFY_DONE;
-+
-+ sensor = container_of(nb, struct scmi_iio_priv, sensor_update_nb);
-+
-+ for (i = 0; i < sensor_update->readings_count; i++)
-+ sensor->iio_buf[i] = sensor_update->readings[i].value;
-+
-+ if (!sensor->sensor_info->timestamped) {
-+ time_ns = ktime_to_ns(sensor_update->timestamp);
-+ } else {
-+ /*
-+ * All the axes are supposed to have the same value for timestamp.
-+ * We are just using the values from the Axis 0 here.
-+ */
-+ time = sensor_update->readings[0].timestamp;
-+
-+ /*
-+ * Timestamp returned by SCMI is in seconds and is equal to
-+ * time * power-of-10 multiplier(tstamp_scale) seconds.
-+ * Converting the timestamp to nanoseconds below.
-+ */
-+ tstamp_scale = sensor->sensor_info->tstamp_scale +
-+ const_ilog2(NSEC_PER_SEC) / const_ilog2(10);
-+ if (tstamp_scale < 0)
-+ time_ns =
-+ div64_u64(time, int_pow(10, abs(tstamp_scale)));
-+ else
-+ time_ns = time * int_pow(10, tstamp_scale);
-+ }
-+
-+ scmi_iio_dev = sensor->indio_dev;
-+ iio_push_to_buffers_with_timestamp(scmi_iio_dev, sensor->iio_buf,
-+ time_ns);
-+ return NOTIFY_OK;
-+}
-+
-+static int scmi_iio_buffer_preenable(struct iio_dev *iio_dev)
-+{
-+ struct scmi_iio_priv *sensor = iio_priv(iio_dev);
-+ u32 sensor_id = sensor->sensor_info->id;
-+ u32 sensor_config = 0;
-+ int err;
-+
-+ if (sensor->sensor_info->timestamped)
-+ sensor_config |= FIELD_PREP(SCMI_SENS_CFG_TSTAMP_ENABLED_MASK,
-+ SCMI_SENS_CFG_TSTAMP_ENABLE);
-+
-+ sensor_config |= FIELD_PREP(SCMI_SENS_CFG_SENSOR_ENABLED_MASK,
-+ SCMI_SENS_CFG_SENSOR_ENABLE);
-+
-+ err = sensor->handle->notify_ops->register_event_notifier(sensor->handle,
-+ SCMI_PROTOCOL_SENSOR, SCMI_EVENT_SENSOR_UPDATE,
-+ &sensor_id, &sensor->sensor_update_nb);
-+ if (err) {
-+ dev_err(&iio_dev->dev,
-+ "Error in registering sensor update notifier for sensor %s err %d",
-+ sensor->sensor_info->name, err);
-+ return err;
-+ }
-+
-+ err = sensor->handle->sensor_ops->config_set(sensor->handle,
-+ sensor->sensor_info->id, sensor_config);
-+ if (err) {
-+ sensor->handle->notify_ops->unregister_event_notifier(sensor->handle,
-+ SCMI_PROTOCOL_SENSOR,
-+ SCMI_EVENT_SENSOR_UPDATE, &sensor_id,
-+ &sensor->sensor_update_nb);
-+ dev_err(&iio_dev->dev, "Error in enabling sensor %s err %d",
-+ sensor->sensor_info->name, err);
-+ }
-+
-+ return err;
-+}
-+
-+static int scmi_iio_buffer_postdisable(struct iio_dev *iio_dev)
-+{
-+ struct scmi_iio_priv *sensor = iio_priv(iio_dev);
-+ u32 sensor_id = sensor->sensor_info->id;
-+ u32 sensor_config = 0;
-+ int err;
-+
-+ sensor_config |= FIELD_PREP(SCMI_SENS_CFG_SENSOR_ENABLED_MASK,
-+ SCMI_SENS_CFG_SENSOR_DISABLE);
-+
-+ err = sensor->handle->notify_ops->unregister_event_notifier(sensor->handle,
-+ SCMI_PROTOCOL_SENSOR, SCMI_EVENT_SENSOR_UPDATE,
-+ &sensor_id, &sensor->sensor_update_nb);
-+ if (err) {
-+ dev_err(&iio_dev->dev,
-+ "Error in unregistering sensor update notifier for sensor %s err %d",
-+ sensor->sensor_info->name, err);
-+ return err;
-+ }
-+
-+ err = sensor->handle->sensor_ops->config_set(sensor->handle, sensor_id,
-+ sensor_config);
-+ if (err) {
-+ dev_err(&iio_dev->dev,
-+ "Error in disabling sensor %s with err %d",
-+ sensor->sensor_info->name, err);
-+ }
-+
-+ return err;
-+}
-+
-+static const struct iio_buffer_setup_ops scmi_iio_buffer_ops = {
-+ .preenable = scmi_iio_buffer_preenable,
-+ .postdisable = scmi_iio_buffer_postdisable,
-+};
-+
-+static int scmi_iio_set_odr_val(struct iio_dev *iio_dev, int val, int val2)
-+{
-+ struct scmi_iio_priv *sensor = iio_priv(iio_dev);
-+ const unsigned long UHZ_PER_HZ = 1000000UL;
-+ u64 sec, mult, uHz;
-+ u32 sensor_config;
-+ char buf[32];
-+
-+ int err = sensor->handle->sensor_ops->config_get(sensor->handle,
-+ sensor->sensor_info->id, &sensor_config);
-+ if (err) {
-+ dev_err(&iio_dev->dev,
-+ "Error in getting sensor config for sensor %s err %d",
-+ sensor->sensor_info->name, err);
-+ return err;
-+ }
-+
-+ uHz = val * UHZ_PER_HZ + val2;
-+
-+ /*
-+ * The seconds field in the sensor interval in SCMI is 16 bits long
-+ * Therefore seconds = 1/Hz <= 0xFFFF. As floating point calculations are
-+ * discouraged in the kernel driver code, to calculate the scale factor (sf)
-+ * (1* 1000000 * sf)/uHz <= 0xFFFF. Therefore, sf <= (uHz * 0xFFFF)/1000000
-+ * To calculate the multiplier,we convert the sf into char string and
-+ * count the number of characters
-+ */
-+ mult = scnprintf(buf, sizeof(buf), "%llu", ((u64)uHz * 0xFFFF) / UHZ_PER_HZ) - 1;
-+
-+ sec = div64_u64(int_pow(10, mult) * UHZ_PER_HZ, uHz);
-+ if (sec == 0) {
-+ dev_err(&iio_dev->dev,
-+ "Trying to set invalid sensor update value for sensor %s",
-+ sensor->sensor_info->name);
-+ return -EINVAL;
-+ }
-+
-+ sensor_config &= ~SCMI_SENS_CFG_UPDATE_SECS_MASK;
-+ sensor_config |= FIELD_PREP(SCMI_SENS_CFG_UPDATE_SECS_MASK, sec);
-+ sensor_config &= ~SCMI_SENS_CFG_UPDATE_EXP_MASK;
-+ sensor_config |= FIELD_PREP(SCMI_SENS_CFG_UPDATE_EXP_MASK, -mult);
-+
-+ if (sensor->sensor_info->timestamped) {
-+ sensor_config &= ~SCMI_SENS_CFG_TSTAMP_ENABLED_MASK;
-+ sensor_config |= FIELD_PREP(SCMI_SENS_CFG_TSTAMP_ENABLED_MASK,
-+ SCMI_SENS_CFG_TSTAMP_ENABLE);
-+ }
-+
-+ sensor_config &= ~SCMI_SENS_CFG_ROUND_MASK;
-+ sensor_config |=
-+ FIELD_PREP(SCMI_SENS_CFG_ROUND_MASK, SCMI_SENS_CFG_ROUND_AUTO);
-+
-+ err = sensor->handle->sensor_ops->config_set(sensor->handle,
-+ sensor->sensor_info->id, sensor_config);
-+ if (err)
-+ dev_err(&iio_dev->dev,
-+ "Error in setting sensor update interval for sensor %s value %u err %d",
-+ sensor->sensor_info->name, sensor_config, err);
-+
-+ return err;
-+}
-+
-+static int scmi_iio_write_raw(struct iio_dev *iio_dev,
-+ struct iio_chan_spec const *chan, int val,
-+ int val2, long mask)
-+{
-+ int err;
-+
-+ switch (mask) {
-+ case IIO_CHAN_INFO_SAMP_FREQ:
-+ mutex_lock(&iio_dev->mlock);
-+ err = scmi_iio_set_odr_val(iio_dev, val, val2);
-+ mutex_unlock(&iio_dev->mlock);
-+ return err;
-+ default:
-+ return -EINVAL;
-+ }
-+}
-+
-+static int scmi_iio_read_avail(struct iio_dev *iio_dev,
-+ struct iio_chan_spec const *chan,
-+ const int **vals, int *type, int *length,
-+ long mask)
-+{
-+ struct scmi_iio_priv *sensor = iio_priv(iio_dev);
-+
-+ switch (mask) {
-+ case IIO_CHAN_INFO_SAMP_FREQ:
-+ *vals = sensor->freq_avail;
-+ *type = IIO_VAL_INT_PLUS_MICRO;
-+ *length = sensor->sensor_info->intervals.count * 2;
-+ if (sensor->sensor_info->intervals.segmented)
-+ return IIO_AVAIL_RANGE;
-+ else
-+ return IIO_AVAIL_LIST;
-+ default:
-+ return -EINVAL;
-+ }
-+}
-+
-+static void convert_ns_to_freq(u64 interval_ns, u64 *hz, u64 *uhz)
-+{
-+ u64 rem;
-+
-+ *hz = div64_u64_rem(NSEC_PER_SEC, interval_ns, &rem);
-+ *uhz = (rem * 1000000UL) / interval_ns;
-+}
-+
-+static int scmi_iio_get_odr_val(struct iio_dev *iio_dev, int *val, int *val2)
-+{
-+ u64 sensor_update_interval, sensor_interval_mult, hz, uhz;
-+ struct scmi_iio_priv *sensor = iio_priv(iio_dev);
-+ u32 sensor_config;
-+ int mult;
-+
-+ int err = sensor->handle->sensor_ops->config_get(sensor->handle,
-+ sensor->sensor_info->id, &sensor_config);
-+ if (err) {
-+ dev_err(&iio_dev->dev,
-+ "Error in getting sensor config for sensor %s err %d",
-+ sensor->sensor_info->name, err);
-+ return err;
-+ }
-+
-+ sensor_update_interval =
-+ SCMI_SENS_CFG_GET_UPDATE_SECS(sensor_config) * NSEC_PER_SEC;
-+
-+ mult = SCMI_SENS_CFG_GET_UPDATE_EXP(sensor_config);
-+ if (mult < 0) {
-+ sensor_interval_mult = int_pow(10, abs(mult));
-+ sensor_update_interval =
-+ sensor_update_interval / sensor_interval_mult;
-+ } else {
-+ sensor_interval_mult = int_pow(10, mult);
-+ sensor_update_interval =
-+ sensor_update_interval * sensor_interval_mult;
-+ }
-+
-+ convert_ns_to_freq(sensor_update_interval, &hz, &uhz);
-+ *val = hz;
-+ *val2 = uhz;
-+ return 0;
-+}
-+
-+static int scmi_iio_read_raw(struct iio_dev *iio_dev,
-+ struct iio_chan_spec const *ch, int *val,
-+ int *val2, long mask)
-+{
-+ struct scmi_iio_priv *sensor = iio_priv(iio_dev);
-+ s8 scale;
-+ int ret;
-+
-+ switch (mask) {
-+ case IIO_CHAN_INFO_SCALE:
-+ scale = sensor->sensor_info->axis[ch->scan_index].scale;
-+ if (scale < 0) {
-+ *val = 1;
-+ *val2 = int_pow(10, abs(scale));
-+ return IIO_VAL_FRACTIONAL;
-+ }
-+ *val = int_pow(10, scale);
-+ return IIO_VAL_INT;
-+ case IIO_CHAN_INFO_SAMP_FREQ:
-+ ret = scmi_iio_get_odr_val(iio_dev, val, val2);
-+ return ret ? ret : IIO_VAL_INT_PLUS_MICRO;
-+ default:
-+ return -EINVAL;
-+ }
-+}
-+
-+static const struct iio_info scmi_iio_info = {
-+ .read_raw = scmi_iio_read_raw,
-+ .read_avail = scmi_iio_read_avail,
-+ .write_raw = scmi_iio_write_raw,
-+};
-+
-+static ssize_t scmi_iio_get_raw_available(struct iio_dev *iio_dev,
-+ uintptr_t private,
-+ const struct iio_chan_spec *chan,
-+ char *buf)
-+{
-+ 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[] = {
-+ {
-+ .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)
-+{
-+ 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;
-+}
-+
-+static void scmi_iio_set_data_channel(struct iio_chan_spec *iio_chan,
-+ enum iio_chan_type type,
-+ enum iio_modifier mod, int scan_index)
-+{
-+ iio_chan->type = type;
-+ iio_chan->modified = 1;
-+ iio_chan->channel2 = mod;
-+ iio_chan->info_mask_separate = BIT(IIO_CHAN_INFO_SCALE);
-+ iio_chan->info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ);
-+ iio_chan->info_mask_shared_by_type_available =
-+ BIT(IIO_CHAN_INFO_SAMP_FREQ);
-+ iio_chan->scan_index = scan_index;
-+ iio_chan->scan_type.sign = 's';
-+ iio_chan->scan_type.realbits = 64;
-+ iio_chan->scan_type.storagebits = 64;
-+ iio_chan->scan_type.endianness = IIO_LE;
-+ iio_chan->ext_info = scmi_iio_ext_info;
-+}
-+
-+static int scmi_iio_get_chan_modifier(const char *name,
-+ enum iio_modifier *modifier)
-+{
-+ char *pch, mod;
-+
-+ if (!name)
-+ return -EINVAL;
-+
-+ pch = strrchr(name, '_');
-+ if (!pch)
-+ return -EINVAL;
-+
-+ mod = *(pch + 1);
-+ switch (mod) {
-+ case 'X':
-+ *modifier = IIO_MOD_X;
-+ return 0;
-+ case 'Y':
-+ *modifier = IIO_MOD_Y;
-+ return 0;
-+ case 'Z':
-+ *modifier = IIO_MOD_Z;
-+ return 0;
-+ default:
-+ return -EINVAL;
-+ }
-+}
-+
-+static int scmi_iio_get_chan_type(u8 scmi_type, enum iio_chan_type *iio_type)
-+{
-+ switch (scmi_type) {
-+ case METERS_SEC_SQUARED:
-+ *iio_type = IIO_ACCEL;
-+ return 0;
-+ case RADIANS_SEC:
-+ *iio_type = IIO_ANGL_VEL;
-+ return 0;
-+ default:
-+ return -EINVAL;
-+ }
-+}
-+
-+static u64 scmi_iio_convert_interval_to_ns(u32 val)
-+{
-+ u64 sensor_update_interval =
-+ SCMI_SENS_INTVL_GET_SECS(val) * NSEC_PER_SEC;
-+ u64 sensor_interval_mult;
-+ int mult;
-+
-+ mult = SCMI_SENS_INTVL_GET_EXP(val);
-+ if (mult < 0) {
-+ sensor_interval_mult = int_pow(10, abs(mult));
-+ sensor_update_interval =
-+ sensor_update_interval / sensor_interval_mult;
-+ } else {
-+ sensor_interval_mult = int_pow(10, mult);
-+ sensor_update_interval =
-+ sensor_update_interval * sensor_interval_mult;
-+ }
-+ return sensor_update_interval;
-+}
-+
-+static int scmi_iio_set_sampling_freq_avail(struct iio_dev *iio_dev)
-+{
-+ u64 cur_interval_ns, low_interval_ns, high_interval_ns, step_size_ns,
-+ hz, uhz;
-+ unsigned int cur_interval, low_interval, high_interval, step_size;
-+ struct scmi_iio_priv *sensor = iio_priv(iio_dev);
-+ int i;
-+
-+ sensor->freq_avail =
-+ devm_kzalloc(&iio_dev->dev,
-+ sizeof(*sensor->freq_avail) *
-+ (sensor->sensor_info->intervals.count * 2),
-+ GFP_KERNEL);
-+ if (!sensor->freq_avail)
-+ return -ENOMEM;
-+
-+ if (sensor->sensor_info->intervals.segmented) {
-+ low_interval = sensor->sensor_info->intervals
-+ .desc[SCMI_SENS_INTVL_SEGMENT_LOW];
-+ low_interval_ns = scmi_iio_convert_interval_to_ns(low_interval);
-+ convert_ns_to_freq(low_interval_ns, &hz, &uhz);
-+ sensor->freq_avail[0] = hz;
-+ sensor->freq_avail[1] = uhz;
-+
-+ step_size = sensor->sensor_info->intervals
-+ .desc[SCMI_SENS_INTVL_SEGMENT_STEP];
-+ step_size_ns = scmi_iio_convert_interval_to_ns(step_size);
-+ convert_ns_to_freq(step_size_ns, &hz, &uhz);
-+ sensor->freq_avail[2] = hz;
-+ sensor->freq_avail[3] = uhz;
-+
-+ high_interval = sensor->sensor_info->intervals
-+ .desc[SCMI_SENS_INTVL_SEGMENT_HIGH];
-+ high_interval_ns =
-+ scmi_iio_convert_interval_to_ns(high_interval);
-+ convert_ns_to_freq(high_interval_ns, &hz, &uhz);
-+ sensor->freq_avail[4] = hz;
-+ sensor->freq_avail[5] = uhz;
-+ } else {
-+ for (i = 0; i < sensor->sensor_info->intervals.count; i++) {
-+ cur_interval = sensor->sensor_info->intervals.desc[i];
-+ cur_interval_ns =
-+ scmi_iio_convert_interval_to_ns(cur_interval);
-+ convert_ns_to_freq(cur_interval_ns, &hz, &uhz);
-+ sensor->freq_avail[i * 2] = hz;
-+ sensor->freq_avail[i * 2 + 1] = uhz;
-+ }
-+ }
-+ return 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;
-+ 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;
-+}
-+
-+static const struct scmi_device_id scmi_id_table[] = {
-+ { SCMI_PROTOCOL_SENSOR, "iiodev" },
-+ {},
-+};
-+
-+MODULE_DEVICE_TABLE(scmi, scmi_id_table);
-+
-+static struct scmi_driver scmi_iiodev_driver = {
-+ .name = "scmi-sensor-iiodev",
-+ .probe = scmi_iio_dev_probe,
-+ .id_table = scmi_id_table,
-+};
-+
-+module_scmi_driver(scmi_iiodev_driver);
-+
-+MODULE_AUTHOR("Jyoti Bhayana <jbhayana@google.com>");
-+MODULE_DESCRIPTION("SCMI IIO Driver");
-+MODULE_LICENSE("GPL v2");
diff --git a/meta-egvirt/recipes-kernel/linux/linux-yocto/iio-scmi/0002-iio-core-Introduce-IIO_VAL_INT_64.patch b/meta-egvirt/recipes-kernel/linux/linux-yocto/iio-scmi/0002-iio-core-Introduce-IIO_VAL_INT_64.patch
index 3245a806..2a18a04d 100644
--- a/meta-egvirt/recipes-kernel/linux/linux-yocto/iio-scmi/0002-iio-core-Introduce-IIO_VAL_INT_64.patch
+++ b/meta-egvirt/recipes-kernel/linux/linux-yocto/iio-scmi/0002-iio-core-Introduce-IIO_VAL_INT_64.patch
@@ -1,36 +1,38 @@
-From 41b693ffea78e5e754ba7c1b7b85a20deff8ba9f Mon Sep 17 00:00:00 2001
+From 3698bab1b1856a8146c8f8a83c888bd9cefcdde0 Mon Sep 17 00:00:00 2001
From: Andriy Tryshnivskyy <andriy.tryshnivskyy@opensynergy.com>
-Date: Mon, 25 Oct 2021 13:30:19 +0300
+Date: Sun, 24 Oct 2021 12:16:26 +0300
Subject: [PATCH] iio: core: Introduce IIO_VAL_INT_64.
Introduce IIO_VAL_INT_64 to read 64-bit value for
channel attribute. Val is used as lower 32 bits.
Signed-off-by: Andriy Tryshnivskyy <andriy.tryshnivskyy@opensynergy.com>
+Link: https://lore.kernel.org/r/20211024091627.28031-2-andriy.tryshnivskyy@opensynergy.com
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
drivers/iio/industrialio-core.c | 3 +++
include/linux/iio/types.h | 1 +
2 files changed, 4 insertions(+)
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
-index 261d3b17edc9..71ecb2e66714 100644
+index 3e1e86d987cc..3f21e6b49a4a 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
-@@ -638,6 +638,9 @@ static ssize_t __iio_format_value(char *buf, size_t len, unsigned int type,
+@@ -702,6 +702,9 @@ static ssize_t __iio_format_value(char *buf, size_t offset, unsigned int type,
}
case IIO_VAL_CHAR:
- return scnprintf(buf, len, "%c", (char)vals[0]);
+ return sysfs_emit_at(buf, offset, "%c", (char)vals[0]);
+ case IIO_VAL_INT_64:
-+ tmp = (s64)((((u64)vals[1]) << 32) | (u32)vals[0]);
-+ return scnprintf(buf, len, "%lld", tmp);
++ tmp2 = (s64)((((u64)vals[1]) << 32) | (u32)vals[0]);
++ return sysfs_emit_at(buf, offset, "%lld", tmp2);
default:
return 0;
}
diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h
-index 1e3ed6f55bca..8d37cc5a3883 100644
+index 84b3f8175cc6..a7aa91f3a8dc 100644
--- a/include/linux/iio/types.h
+++ b/include/linux/iio/types.h
-@@ -23,6 +23,7 @@ enum iio_event_info {
+@@ -24,6 +24,7 @@ enum iio_event_info {
#define IIO_VAL_INT_PLUS_NANO 3
#define IIO_VAL_INT_PLUS_MICRO_DB 4
#define IIO_VAL_INT_MULTIPLE 5
diff --git a/meta-egvirt/recipes-kernel/linux/linux-yocto/iio-scmi/0003-iio-scmi-Add-reading-raw-attribute.patch b/meta-egvirt/recipes-kernel/linux/linux-yocto/iio-scmi/0003-iio-scmi-Add-reading-raw-attribute.patch
index 678aa89b..a11e5e2f 100644
--- a/meta-egvirt/recipes-kernel/linux/linux-yocto/iio-scmi/0003-iio-scmi-Add-reading-raw-attribute.patch
+++ b/meta-egvirt/recipes-kernel/linux/linux-yocto/iio-scmi/0003-iio-scmi-Add-reading-raw-attribute.patch
@@ -1,21 +1,24 @@
-From 642e7a22d9f9e7c02869e1689d513dd84d118388 Mon Sep 17 00:00:00 2001
+From a58a59fa0d626990f32e84bd35e1326cf0532c4a Mon Sep 17 00:00:00 2001
From: Andriy Tryshnivskyy <andriy.tryshnivskyy@opensynergy.com>
-Date: Mon, 25 Oct 2021 13:41:18 +0300
+Date: Sun, 24 Oct 2021 12:16:27 +0300
Subject: [PATCH] iio/scmi: Add reading "raw" attribute.
Add IIO_CHAN_INFO_RAW to the mask and implement corresponding
reading "raw" attribute in scmi_iio_read_raw.
Signed-off-by: Andriy Tryshnivskyy <andriy.tryshnivskyy@opensynergy.com>
+Acked-by: Jyoti Bhayana <jbhayana@google.com>
+Link: https://lore.kernel.org/r/20211024091627.28031-3-andriy.tryshnivskyy@opensynergy.com
+Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
drivers/iio/common/scmi_sensors/scmi_iio.c | 57 +++++++++++++++++++++-
1 file changed, 56 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/common/scmi_sensors/scmi_iio.c b/drivers/iio/common/scmi_sensors/scmi_iio.c
-index 31977c3bc600..53b3242f0f19 100644
+index 7cf2bf282cef..d538bf3ab1ef 100644
--- a/drivers/iio/common/scmi_sensors/scmi_iio.c
+++ b/drivers/iio/common/scmi_sensors/scmi_iio.c
-@@ -296,6 +296,52 @@ static int scmi_iio_get_odr_val(struct iio_dev *iio_dev, int *val, int *val2)
+@@ -279,6 +279,52 @@ static int scmi_iio_get_odr_val(struct iio_dev *iio_dev, int *val, int *val2)
return 0;
}
@@ -29,8 +32,8 @@ index 31977c3bc600..53b3242f0f19 100644
+
+ sensor_config = FIELD_PREP(SCMI_SENS_CFG_SENSOR_ENABLED_MASK,
+ SCMI_SENS_CFG_SENSOR_ENABLE);
-+ err = sensor->handle->sensor_ops->config_set(
-+ sensor->handle, sensor->sensor_info->id, sensor_config);
++ err = sensor->sensor_ops->config_set(
++ sensor->ph, sensor->sensor_info->id, sensor_config);
+ if (err) {
+ dev_err(&iio_dev->dev,
+ "Error in enabling sensor %s err %d",
@@ -38,8 +41,8 @@ index 31977c3bc600..53b3242f0f19 100644
+ return err;
+ }
+
-+ err = sensor->handle->sensor_ops->reading_get_timestamped(
-+ sensor->handle, sensor->sensor_info->id,
++ err = sensor->sensor_ops->reading_get_timestamped(
++ sensor->ph, sensor->sensor_info->id,
+ sensor->sensor_info->num_axis, readings);
+ if (err) {
+ dev_err(&iio_dev->dev,
@@ -50,8 +53,8 @@ index 31977c3bc600..53b3242f0f19 100644
+
+ sensor_config = FIELD_PREP(SCMI_SENS_CFG_SENSOR_ENABLED_MASK,
+ SCMI_SENS_CFG_SENSOR_DISABLE);
-+ err = sensor->handle->sensor_ops->config_set(
-+ sensor->handle, sensor->sensor_info->id, sensor_config);
++ err = sensor->sensor_ops->config_set(
++ sensor->ph, sensor->sensor_info->id, sensor_config);
+ if (err) {
+ dev_err(&iio_dev->dev,
+ "Error in disabling sensor %s err %d",
@@ -68,7 +71,7 @@ index 31977c3bc600..53b3242f0f19 100644
static int scmi_iio_read_raw(struct iio_dev *iio_dev,
struct iio_chan_spec const *ch, int *val,
int *val2, long mask)
-@@ -317,6 +363,14 @@ static int scmi_iio_read_raw(struct iio_dev *iio_dev,
+@@ -300,6 +346,14 @@ static int scmi_iio_read_raw(struct iio_dev *iio_dev,
case IIO_CHAN_INFO_SAMP_FREQ:
ret = scmi_iio_get_odr_val(iio_dev, val, val2);
return ret ? ret : IIO_VAL_INT_PLUS_MICRO;
@@ -83,7 +86,7 @@ index 31977c3bc600..53b3242f0f19 100644
default:
return -EINVAL;
}
-@@ -398,7 +452,8 @@ static void scmi_iio_set_data_channel(struct iio_chan_spec *iio_chan,
+@@ -381,7 +435,8 @@ static void scmi_iio_set_data_channel(struct iio_chan_spec *iio_chan,
iio_chan->type = type;
iio_chan->modified = 1;
iio_chan->channel2 = mod;
diff --git a/meta-egvirt/recipes-kernel/linux/linux-yocto/scmi/0001-firmware-arm_scmi-rework-scmi_sensors_protocol_init.patch b/meta-egvirt/recipes-kernel/linux/linux-yocto/scmi/0001-firmware-arm_scmi-rework-scmi_sensors_protocol_init.patch
deleted file mode 100644
index 02024d11..00000000
--- a/meta-egvirt/recipes-kernel/linux/linux-yocto/scmi/0001-firmware-arm_scmi-rework-scmi_sensors_protocol_init.patch
+++ /dev/null
@@ -1,69 +0,0 @@
-From d9d8732bdf07755780f37cf083ead8b61ee3c95d Mon Sep 17 00:00:00 2001
-From: Cristian Marussi <cristian.marussi@arm.com>
-Date: Thu, 19 Nov 2020 17:49:01 +0000
-Subject: [PATCH] firmware: arm_scmi: rework scmi_sensors_protocol_init
-
-Properly handle return values from initialization helpers and avoid
-setting sensor_ops before sensor_priv.
-
-Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
-Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
----
- drivers/firmware/arm_scmi/sensors.c | 16 ++++++++++------
- 1 file changed, 10 insertions(+), 6 deletions(-)
-
-diff --git a/drivers/firmware/arm_scmi/sensors.c b/drivers/firmware/arm_scmi/sensors.c
-index b4232d611033..6aaff478d032 100644
---- a/drivers/firmware/arm_scmi/sensors.c
-+++ b/drivers/firmware/arm_scmi/sensors.c
-@@ -2,7 +2,7 @@
- /*
- * System Control and Management Interface (SCMI) Sensor Protocol
- *
-- * Copyright (C) 2018 ARM Ltd.
-+ * Copyright (C) 2018-2020 ARM Ltd.
- */
-
- #define pr_fmt(fmt) "SCMI Notifications SENSOR - " fmt
-@@ -334,6 +334,7 @@ static const struct scmi_event_ops sensor_event_ops = {
- static int scmi_sensors_protocol_init(struct scmi_handle *handle)
- {
- u32 version;
-+ int ret;
- struct sensors_info *sinfo;
-
- scmi_version_get(handle, SCMI_PROTOCOL_SENSOR, &version);
-@@ -344,15 +345,19 @@ static int scmi_sensors_protocol_init(struct scmi_handle *handle)
- sinfo = devm_kzalloc(handle->dev, sizeof(*sinfo), GFP_KERNEL);
- if (!sinfo)
- return -ENOMEM;
-+ sinfo->version = version;
-
-- scmi_sensor_attributes_get(handle, sinfo);
--
-+ ret = scmi_sensor_attributes_get(handle, sinfo);
-+ if (ret)
-+ return ret;
- sinfo->sensors = devm_kcalloc(handle->dev, sinfo->num_sensors,
- sizeof(*sinfo->sensors), GFP_KERNEL);
- if (!sinfo->sensors)
- return -ENOMEM;
-
-- scmi_sensor_description_get(handle, sinfo);
-+ ret = scmi_sensor_description_get(handle, sinfo);
-+ if (ret)
-+ return ret;
-
- scmi_register_protocol_events(handle,
- SCMI_PROTOCOL_SENSOR, SCMI_PROTO_QUEUE_SZ,
-@@ -360,9 +365,8 @@ static int scmi_sensors_protocol_init(struct scmi_handle *handle)
- ARRAY_SIZE(sensor_events),
- sinfo->num_sensors);
-
-- sinfo->version = version;
-- handle->sensor_ops = &sensor_ops;
- handle->sensor_priv = sinfo;
-+ handle->sensor_ops = &sensor_ops;
-
- return 0;
- }
diff --git a/meta-egvirt/recipes-kernel/linux/linux-yocto/scmi/0002-firmware-arm_scmi-add-SCMIv3.0-Sensors-descriptors-e.patch b/meta-egvirt/recipes-kernel/linux/linux-yocto/scmi/0002-firmware-arm_scmi-add-SCMIv3.0-Sensors-descriptors-e.patch
deleted file mode 100644
index 8a4e3ded..00000000
--- a/meta-egvirt/recipes-kernel/linux/linux-yocto/scmi/0002-firmware-arm_scmi-add-SCMIv3.0-Sensors-descriptors-e.patch
+++ /dev/null
@@ -1,733 +0,0 @@
-From 994102ee967232e7565887d2a5fb83384b550bd8 Mon Sep 17 00:00:00 2001
-From: Cristian Marussi <cristian.marussi@arm.com>
-Date: Thu, 19 Nov 2020 17:49:02 +0000
-Subject: [PATCH] firmware: arm_scmi: add SCMIv3.0 Sensors descriptors
- extensions
-
-Add support for new SCMIv3.0 Sensors extensions related to new sensors'
-features, like multiple axis and update intervals, while keeping
-compatibility with SCMIv2.0 features.
-While at that, refactor and simplify all the internal helpers macros and
-move struct scmi_sensor_info to use only non-fixed-size typing.
-
-Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
-Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
----
- drivers/firmware/arm_scmi/sensors.c | 390 ++++++++++++++++++++++++++--
- include/linux/scmi_protocol.h | 220 +++++++++++++++-
- 2 files changed, 585 insertions(+), 25 deletions(-)
-
-diff --git a/drivers/firmware/arm_scmi/sensors.c b/drivers/firmware/arm_scmi/sensors.c
-index 6aaff478d032..a85827f60a02 100644
---- a/drivers/firmware/arm_scmi/sensors.c
-+++ b/drivers/firmware/arm_scmi/sensors.c
-@@ -7,16 +7,22 @@
-
- #define pr_fmt(fmt) "SCMI Notifications SENSOR - " fmt
-
-+#include <linux/bitfield.h>
- #include <linux/scmi_protocol.h>
-
- #include "common.h"
- #include "notify.h"
-
-+#define SCMI_MAX_NUM_SENSOR_AXIS 63
-+#define SCMIv2_SENSOR_PROTOCOL 0x10000
-+
- enum scmi_sensor_protocol_cmd {
- SENSOR_DESCRIPTION_GET = 0x3,
- SENSOR_TRIP_POINT_NOTIFY = 0x4,
- SENSOR_TRIP_POINT_CONFIG = 0x5,
- SENSOR_READING_GET = 0x6,
-+ SENSOR_AXIS_DESCRIPTION_GET = 0x7,
-+ SENSOR_LIST_UPDATE_INTERVALS = 0x8,
- };
-
- struct scmi_msg_resp_sensor_attributes {
-@@ -28,23 +34,100 @@ struct scmi_msg_resp_sensor_attributes {
- __le32 reg_size;
- };
-
-+/* v3 attributes_low macros */
-+#define SUPPORTS_UPDATE_NOTIFY(x) FIELD_GET(BIT(30), (x))
-+#define SENSOR_TSTAMP_EXP(x) FIELD_GET(GENMASK(14, 10), (x))
-+#define SUPPORTS_TIMESTAMP(x) FIELD_GET(BIT(9), (x))
-+#define SUPPORTS_EXTEND_ATTRS(x) FIELD_GET(BIT(8), (x))
-+
-+/* v2 attributes_high macros */
-+#define SENSOR_UPDATE_BASE(x) FIELD_GET(GENMASK(31, 27), (x))
-+#define SENSOR_UPDATE_SCALE(x) FIELD_GET(GENMASK(26, 22), (x))
-+
-+/* v3 attributes_high macros */
-+#define SENSOR_AXIS_NUMBER(x) FIELD_GET(GENMASK(21, 16), (x))
-+#define SUPPORTS_AXIS(x) FIELD_GET(BIT(8), (x))
-+
-+/* v3 resolution macros */
-+#define SENSOR_RES(x) FIELD_GET(GENMASK(26, 0), (x))
-+#define SENSOR_RES_EXP(x) FIELD_GET(GENMASK(31, 27), (x))
-+
-+struct scmi_msg_resp_attrs {
-+ __le32 min_range_low;
-+ __le32 min_range_high;
-+ __le32 max_range_low;
-+ __le32 max_range_high;
-+};
-+
- struct scmi_msg_resp_sensor_description {
- __le16 num_returned;
- __le16 num_remaining;
-- struct {
-+ struct scmi_sensor_descriptor {
-+ __le32 id;
-+ __le32 attributes_low;
-+/* Common attributes_low macros */
-+#define SUPPORTS_ASYNC_READ(x) FIELD_GET(BIT(31), (x))
-+#define NUM_TRIP_POINTS(x) FIELD_GET(GENMASK(7, 0), (x))
-+ __le32 attributes_high;
-+/* Common attributes_high macros */
-+#define SENSOR_SCALE(x) FIELD_GET(GENMASK(15, 11), (x))
-+#define SENSOR_SCALE_SIGN BIT(4)
-+#define SENSOR_SCALE_EXTEND GENMASK(31, 5)
-+#define SENSOR_TYPE(x) FIELD_GET(GENMASK(7, 0), (x))
-+ u8 name[SCMI_MAX_STR_SIZE];
-+ /* only for version > 2.0 */
-+ __le32 power;
-+ __le32 resolution;
-+ struct scmi_msg_resp_attrs scalar_attrs;
-+ } desc[];
-+};
-+
-+/* Base scmi_sensor_descriptor size excluding extended attrs after name */
-+#define SCMI_MSG_RESP_SENS_DESCR_BASE_SZ 28
-+
-+/* Sign extend to a full s32 */
-+#define S32_EXT(v) \
-+ ({ \
-+ int __v = (v); \
-+ \
-+ if (__v & SENSOR_SCALE_SIGN) \
-+ __v |= SENSOR_SCALE_EXTEND; \
-+ __v; \
-+ })
-+
-+struct scmi_msg_sensor_axis_description_get {
-+ __le32 id;
-+ __le32 axis_desc_index;
-+};
-+
-+struct scmi_msg_resp_sensor_axis_description {
-+ __le32 num_axis_flags;
-+#define NUM_AXIS_RETURNED(x) FIELD_GET(GENMASK(5, 0), (x))
-+#define NUM_AXIS_REMAINING(x) FIELD_GET(GENMASK(31, 26), (x))
-+ struct scmi_axis_descriptor {
- __le32 id;
- __le32 attributes_low;
--#define SUPPORTS_ASYNC_READ(x) ((x) & BIT(31))
--#define NUM_TRIP_POINTS(x) ((x) & 0xff)
- __le32 attributes_high;
--#define SENSOR_TYPE(x) ((x) & 0xff)
--#define SENSOR_SCALE(x) (((x) >> 11) & 0x1f)
--#define SENSOR_SCALE_SIGN BIT(4)
--#define SENSOR_SCALE_EXTEND GENMASK(7, 5)
--#define SENSOR_UPDATE_SCALE(x) (((x) >> 22) & 0x1f)
--#define SENSOR_UPDATE_BASE(x) (((x) >> 27) & 0x1f)
-- u8 name[SCMI_MAX_STR_SIZE];
-- } desc[0];
-+ u8 name[SCMI_MAX_STR_SIZE];
-+ __le32 resolution;
-+ struct scmi_msg_resp_attrs attrs;
-+ } desc[];
-+};
-+
-+/* Base scmi_axis_descriptor size excluding extended attrs after name */
-+#define SCMI_MSG_RESP_AXIS_DESCR_BASE_SZ 28
-+
-+struct scmi_msg_sensor_list_update_intervals {
-+ __le32 id;
-+ __le32 index;
-+};
-+
-+struct scmi_msg_resp_sensor_list_update_intervals {
-+ __le32 num_intervals_flags;
-+#define NUM_INTERVALS_RETURNED(x) FIELD_GET(GENMASK(11, 0), (x))
-+#define SEGMENTED_INTVL_FORMAT(x) FIELD_GET(BIT(12), (x))
-+#define NUM_INTERVALS_REMAINING(x) FIELD_GET(GENMASK(31, 16), (x))
-+ __le32 intervals[];
- };
-
- struct scmi_msg_sensor_trip_point_notify {
-@@ -114,6 +197,194 @@ static int scmi_sensor_attributes_get(const struct scmi_handle *handle,
- return ret;
- }
-
-+static inline void scmi_parse_range_attrs(struct scmi_range_attrs *out,
-+ struct scmi_msg_resp_attrs *in)
-+{
-+ out->min_range = get_unaligned_le64((void *)&in->min_range_low);
-+ out->max_range = get_unaligned_le64((void *)&in->max_range_low);
-+}
-+
-+static int scmi_sensor_update_intervals(const struct scmi_handle *handle,
-+ struct scmi_sensor_info *s)
-+{
-+ int ret, cnt;
-+ u32 desc_index = 0;
-+ u16 num_returned, num_remaining;
-+ struct scmi_xfer *ti;
-+ struct scmi_msg_resp_sensor_list_update_intervals *buf;
-+ struct scmi_msg_sensor_list_update_intervals *msg;
-+
-+ ret = scmi_xfer_get_init(handle, SENSOR_LIST_UPDATE_INTERVALS,
-+ SCMI_PROTOCOL_SENSOR, sizeof(*msg), 0, &ti);
-+ if (ret)
-+ return ret;
-+
-+ buf = ti->rx.buf;
-+ do {
-+ u32 flags;
-+
-+ msg = ti->tx.buf;
-+ /* Set the number of sensors to be skipped/already read */
-+ msg->id = cpu_to_le32(s->id);
-+ msg->index = cpu_to_le32(desc_index);
-+
-+ ret = scmi_do_xfer(handle, ti);
-+ if (ret)
-+ break;
-+
-+ flags = le32_to_cpu(buf->num_intervals_flags);
-+ num_returned = NUM_INTERVALS_RETURNED(flags);
-+ num_remaining = NUM_INTERVALS_REMAINING(flags);
-+
-+ /*
-+ * Max intervals is not declared previously anywhere so we
-+ * assume it's returned+remaining.
-+ */
-+ if (!s->intervals.count) {
-+ s->intervals.segmented = SEGMENTED_INTVL_FORMAT(flags);
-+ s->intervals.count = num_returned + num_remaining;
-+ /* segmented intervals are reported in one triplet */
-+ if (s->intervals.segmented &&
-+ (num_remaining || num_returned != 3)) {
-+ dev_err(handle->dev,
-+ "Sensor ID:%d advertises an invalid segmented interval (%d)\n",
-+ s->id, s->intervals.count);
-+ s->intervals.segmented = false;
-+ s->intervals.count = 0;
-+ ret = -EINVAL;
-+ break;
-+ }
-+ /* Direct allocation when exceeding pre-allocated */
-+ if (s->intervals.count >= SCMI_MAX_PREALLOC_POOL) {
-+ s->intervals.desc =
-+ devm_kcalloc(handle->dev,
-+ s->intervals.count,
-+ sizeof(*s->intervals.desc),
-+ GFP_KERNEL);
-+ if (!s->intervals.desc) {
-+ s->intervals.segmented = false;
-+ s->intervals.count = 0;
-+ ret = -ENOMEM;
-+ break;
-+ }
-+ }
-+ } else if (desc_index + num_returned > s->intervals.count) {
-+ dev_err(handle->dev,
-+ "No. of update intervals can't exceed %d\n",
-+ s->intervals.count);
-+ ret = -EINVAL;
-+ break;
-+ }
-+
-+ for (cnt = 0; cnt < num_returned; cnt++)
-+ s->intervals.desc[desc_index + cnt] =
-+ le32_to_cpu(buf->intervals[cnt]);
-+
-+ desc_index += num_returned;
-+
-+ scmi_reset_rx_to_maxsz(handle, ti);
-+ /*
-+ * check for both returned and remaining to avoid infinite
-+ * loop due to buggy firmware
-+ */
-+ } while (num_returned && num_remaining);
-+
-+ scmi_xfer_put(handle, ti);
-+ return ret;
-+}
-+
-+static int scmi_sensor_axis_description(const struct scmi_handle *handle,
-+ struct scmi_sensor_info *s)
-+{
-+ int ret, cnt;
-+ u32 desc_index = 0;
-+ u16 num_returned, num_remaining;
-+ struct scmi_xfer *te;
-+ struct scmi_msg_resp_sensor_axis_description *buf;
-+ struct scmi_msg_sensor_axis_description_get *msg;
-+
-+ s->axis = devm_kcalloc(handle->dev, s->num_axis,
-+ sizeof(*s->axis), GFP_KERNEL);
-+ if (!s->axis)
-+ return -ENOMEM;
-+
-+ ret = scmi_xfer_get_init(handle, SENSOR_AXIS_DESCRIPTION_GET,
-+ SCMI_PROTOCOL_SENSOR, sizeof(*msg), 0, &te);
-+ if (ret)
-+ return ret;
-+
-+ buf = te->rx.buf;
-+ do {
-+ u32 flags;
-+ struct scmi_axis_descriptor *adesc;
-+
-+ msg = te->tx.buf;
-+ /* Set the number of sensors to be skipped/already read */
-+ msg->id = cpu_to_le32(s->id);
-+ msg->axis_desc_index = cpu_to_le32(desc_index);
-+
-+ ret = scmi_do_xfer(handle, te);
-+ if (ret)
-+ break;
-+
-+ flags = le32_to_cpu(buf->num_axis_flags);
-+ num_returned = NUM_AXIS_RETURNED(flags);
-+ num_remaining = NUM_AXIS_REMAINING(flags);
-+
-+ if (desc_index + num_returned > s->num_axis) {
-+ dev_err(handle->dev, "No. of axis can't exceed %d\n",
-+ s->num_axis);
-+ break;
-+ }
-+
-+ adesc = &buf->desc[0];
-+ for (cnt = 0; cnt < num_returned; cnt++) {
-+ u32 attrh, attrl;
-+ struct scmi_sensor_axis_info *a;
-+ size_t dsize = SCMI_MSG_RESP_AXIS_DESCR_BASE_SZ;
-+
-+ attrl = le32_to_cpu(adesc->attributes_low);
-+
-+ a = &s->axis[desc_index + cnt];
-+
-+ a->id = le32_to_cpu(adesc->id);
-+ a->extended_attrs = SUPPORTS_EXTEND_ATTRS(attrl);
-+
-+ attrh = le32_to_cpu(adesc->attributes_high);
-+ a->scale = S32_EXT(SENSOR_SCALE(attrh));
-+ a->type = SENSOR_TYPE(attrh);
-+ strlcpy(a->name, adesc->name, SCMI_MAX_STR_SIZE);
-+
-+ if (a->extended_attrs) {
-+ unsigned int ares =
-+ le32_to_cpu(adesc->resolution);
-+
-+ a->resolution = SENSOR_RES(ares);
-+ a->exponent =
-+ S32_EXT(SENSOR_RES_EXP(ares));
-+ dsize += sizeof(adesc->resolution);
-+
-+ scmi_parse_range_attrs(&a->attrs,
-+ &adesc->attrs);
-+ dsize += sizeof(adesc->attrs);
-+ }
-+
-+ adesc = (typeof(adesc))((u8 *)adesc + dsize);
-+ }
-+
-+ desc_index += num_returned;
-+
-+ scmi_reset_rx_to_maxsz(handle, te);
-+ /*
-+ * check for both returned and remaining to avoid infinite
-+ * loop due to buggy firmware
-+ */
-+ } while (num_returned && num_remaining);
-+
-+ scmi_xfer_put(handle, te);
-+ return ret;
-+}
-+
- static int scmi_sensor_description_get(const struct scmi_handle *handle,
- struct sensors_info *si)
- {
-@@ -131,9 +402,10 @@ static int scmi_sensor_description_get(const struct scmi_handle *handle,
- buf = t->rx.buf;
-
- do {
-+ struct scmi_sensor_descriptor *sdesc;
-+
- /* Set the number of sensors to be skipped/already read */
- put_unaligned_le32(desc_index, t->tx.buf);
--
- ret = scmi_do_xfer(handle, t);
- if (ret)
- break;
-@@ -147,22 +419,97 @@ static int scmi_sensor_description_get(const struct scmi_handle *handle,
- break;
- }
-
-+ sdesc = &buf->desc[0];
- for (cnt = 0; cnt < num_returned; cnt++) {
- u32 attrh, attrl;
- struct scmi_sensor_info *s;
-+ size_t dsize = SCMI_MSG_RESP_SENS_DESCR_BASE_SZ;
-
-- attrl = le32_to_cpu(buf->desc[cnt].attributes_low);
-- attrh = le32_to_cpu(buf->desc[cnt].attributes_high);
- s = &si->sensors[desc_index + cnt];
-- s->id = le32_to_cpu(buf->desc[cnt].id);
-- s->type = SENSOR_TYPE(attrh);
-- s->scale = SENSOR_SCALE(attrh);
-- /* Sign extend to a full s8 */
-- if (s->scale & SENSOR_SCALE_SIGN)
-- s->scale |= SENSOR_SCALE_EXTEND;
-+ s->id = le32_to_cpu(sdesc->id);
-+
-+ attrl = le32_to_cpu(sdesc->attributes_low);
-+ /* common bitfields parsing */
- s->async = SUPPORTS_ASYNC_READ(attrl);
- s->num_trip_points = NUM_TRIP_POINTS(attrl);
-- strlcpy(s->name, buf->desc[cnt].name, SCMI_MAX_STR_SIZE);
-+ /**
-+ * only SCMIv3.0 specific bitfield below.
-+ * Such bitfields are assumed to be zeroed on non
-+ * relevant fw versions...assuming fw not buggy !
-+ */
-+ s->update = SUPPORTS_UPDATE_NOTIFY(attrl);
-+ s->timestamped = SUPPORTS_TIMESTAMP(attrl);
-+ if (s->timestamped)
-+ s->tstamp_scale =
-+ S32_EXT(SENSOR_TSTAMP_EXP(attrl));
-+ s->extended_scalar_attrs =
-+ SUPPORTS_EXTEND_ATTRS(attrl);
-+
-+ attrh = le32_to_cpu(sdesc->attributes_high);
-+ /* common bitfields parsing */
-+ s->scale = S32_EXT(SENSOR_SCALE(attrh));
-+ s->type = SENSOR_TYPE(attrh);
-+ /* Use pre-allocated pool wherever possible */
-+ s->intervals.desc = s->intervals.prealloc_pool;
-+ if (si->version == SCMIv2_SENSOR_PROTOCOL) {
-+ s->intervals.segmented = false;
-+ s->intervals.count = 1;
-+ /*
-+ * Convert SCMIv2.0 update interval format to
-+ * SCMIv3.0 to be used as the common exposed
-+ * descriptor, accessible via common macros.
-+ */
-+ s->intervals.desc[0] =
-+ (SENSOR_UPDATE_BASE(attrh) << 5) |
-+ SENSOR_UPDATE_SCALE(attrh);
-+ } else {
-+ /*
-+ * From SCMIv3.0 update intervals are retrieved
-+ * via a dedicated (optional) command.
-+ * Since the command is optional, on error carry
-+ * on without any update interval.
-+ */
-+ if (scmi_sensor_update_intervals(handle, s))
-+ dev_dbg(handle->dev,
-+ "Update Intervals not available for sensor ID:%d\n",
-+ s->id);
-+ }
-+ /**
-+ * only > SCMIv2.0 specific bitfield below.
-+ * Such bitfields are assumed to be zeroed on non
-+ * relevant fw versions...assuming fw not buggy !
-+ */
-+ s->num_axis = min_t(unsigned int,
-+ SUPPORTS_AXIS(attrh) ?
-+ SENSOR_AXIS_NUMBER(attrh) : 0,
-+ SCMI_MAX_NUM_SENSOR_AXIS);
-+ strlcpy(s->name, sdesc->name, SCMI_MAX_STR_SIZE);
-+
-+ if (s->extended_scalar_attrs) {
-+ s->sensor_power = le32_to_cpu(sdesc->power);
-+ dsize += sizeof(sdesc->power);
-+ /* Only for sensors reporting scalar values */
-+ if (s->num_axis == 0) {
-+ unsigned int sres =
-+ le32_to_cpu(sdesc->resolution);
-+
-+ s->resolution = SENSOR_RES(sres);
-+ s->exponent =
-+ S32_EXT(SENSOR_RES_EXP(sres));
-+ dsize += sizeof(sdesc->resolution);
-+
-+ scmi_parse_range_attrs(&s->scalar_attrs,
-+ &sdesc->scalar_attrs);
-+ dsize += sizeof(sdesc->scalar_attrs);
-+ }
-+ }
-+ if (s->num_axis > 0) {
-+ ret = scmi_sensor_axis_description(handle, s);
-+ if (ret)
-+ goto out;
-+ }
-+
-+ sdesc = (typeof(sdesc))((u8 *)sdesc + dsize);
- }
-
- desc_index += num_returned;
-@@ -174,6 +521,7 @@ static int scmi_sensor_description_get(const struct scmi_handle *handle,
- */
- } while (num_returned && num_remaining);
-
-+out:
- scmi_xfer_put(handle, t);
- return ret;
- }
-diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h
-index 9cd312a1ff92..0792b0be25a3 100644
---- a/include/linux/scmi_protocol.h
-+++ b/include/linux/scmi_protocol.h
-@@ -8,6 +8,7 @@
- #ifndef _LINUX_SCMI_PROTOCOL_H
- #define _LINUX_SCMI_PROTOCOL_H
-
-+#include <linux/bitfield.h>
- #include <linux/device.h>
- #include <linux/notifier.h>
- #include <linux/types.h>
-@@ -148,13 +149,135 @@ struct scmi_power_ops {
- u32 *state);
- };
-
-+/**
-+ * scmi_range_attrs - specifies a sensor or axis values' range
-+ * @min_range: The minimum value which can be represented by the sensor/axis.
-+ * @max_range: The maximum value which can be represented by the sensor/axis.
-+ */
-+struct scmi_range_attrs {
-+ long long min_range;
-+ long long max_range;
-+};
-+
-+/**
-+ * scmi_sensor_axis_info - describes one sensor axes
-+ * @id: The axes ID.
-+ * @type: Axes type. Chosen amongst one of @enum scmi_sensor_class.
-+ * @scale: Power-of-10 multiplier applied to the axis unit.
-+ * @name: NULL-terminated string representing axes name as advertised by
-+ * SCMI platform.
-+ * @extended_attrs: Flag to indicate the presence of additional extended
-+ * attributes for this axes.
-+ * @resolution: Extended attribute representing the resolution of the axes.
-+ * Set to 0 if not reported by this axes.
-+ * @exponent: Extended attribute representing the power-of-10 multiplier that
-+ * is applied to the resolution field. Set to 0 if not reported by
-+ * this axes.
-+ * @attrs: Extended attributes representing minimum and maximum values
-+ * measurable by this axes. Set to 0 if not reported by this sensor.
-+ */
-+struct scmi_sensor_axis_info {
-+ unsigned int id;
-+ unsigned int type;
-+ int scale;
-+ char name[SCMI_MAX_STR_SIZE];
-+ bool extended_attrs;
-+ unsigned int resolution;
-+ int exponent;
-+ struct scmi_range_attrs attrs;
-+};
-+
-+/**
-+ * scmi_sensor_intervals_info - describes number and type of available update
-+ * intervals
-+ * @segmented: Flag for segmented intervals' representation. When True there
-+ * will be exactly 3 intervals in @desc, with each entry
-+ * representing a member of a segment in this order:
-+ * {lowest update interval, highest update interval, step size}
-+ * @count: Number of intervals described in @desc.
-+ * @desc: Array of @count interval descriptor bitmask represented as detailed in
-+ * the SCMI specification: it can be accessed using the accompanying
-+ * macros.
-+ * @prealloc_pool: A minimal preallocated pool of desc entries used to avoid
-+ * lesser-than-64-bytes dynamic allocation for small @count
-+ * values.
-+ */
-+struct scmi_sensor_intervals_info {
-+ bool segmented;
-+ unsigned int count;
-+#define SCMI_SENS_INTVL_SEGMENT_LOW 0
-+#define SCMI_SENS_INTVL_SEGMENT_HIGH 1
-+#define SCMI_SENS_INTVL_SEGMENT_STEP 2
-+ unsigned int *desc;
-+#define SCMI_SENS_INTVL_GET_SECS(x) FIELD_GET(GENMASK(20, 5), (x))
-+#define SCMI_SENS_INTVL_GET_EXP(x) \
-+ ({ \
-+ int __signed_exp = FIELD_GET(GENMASK(4, 0), (x)); \
-+ \
-+ if (__signed_exp & BIT(4)) \
-+ __signed_exp |= GENMASK(31, 5); \
-+ __signed_exp; \
-+ })
-+#define SCMI_MAX_PREALLOC_POOL 16
-+ unsigned int prealloc_pool[SCMI_MAX_PREALLOC_POOL];
-+};
-+
-+/**
-+ * struct scmi_sensor_info - represents information related to one of the
-+ * available sensors.
-+ * @id: Sensor ID.
-+ * @type: Sensor type. Chosen amongst one of @enum scmi_sensor_class.
-+ * @scale: Power-of-10 multiplier applied to the sensor unit.
-+ * @num_trip_points: Number of maximum configurable trip points.
-+ * @async: Flag for asynchronous read support.
-+ * @update: Flag for continuouos update notification support.
-+ * @timestamped: Flag for timestamped read support.
-+ * @tstamp_scale: Power-of-10 multiplier applied to the sensor timestamps to
-+ * represent it in seconds.
-+ * @num_axis: Number of supported axis if any. Reported as 0 for scalar sensors.
-+ * @axis: Pointer to an array of @num_axis descriptors.
-+ * @intervals: Descriptor of available update intervals.
-+ * @sensor_config: A bitmask reporting the current sensor configuration as
-+ * detailed in the SCMI specification: it can accessed and
-+ * modified through the accompanying macros.
-+ * @name: NULL-terminated string representing sensor name as advertised by
-+ * SCMI platform.
-+ * @extended_scalar_attrs: Flag to indicate the presence of additional extended
-+ * attributes for this sensor.
-+ * @sensor_power: Extended attribute representing the average power
-+ * consumed by the sensor in microwatts (uW) when it is active.
-+ * Reported here only for scalar sensors.
-+ * Set to 0 if not reported by this sensor.
-+ * @resolution: Extended attribute representing the resolution of the sensor.
-+ * Reported here only for scalar sensors.
-+ * Set to 0 if not reported by this sensor.
-+ * @exponent: Extended attribute representing the power-of-10 multiplier that is
-+ * applied to the resolution field.
-+ * Reported here only for scalar sensors.
-+ * Set to 0 if not reported by this sensor.
-+ * @scalar_attrs: Extended attributes representing minimum and maximum
-+ * measurable values by this sensor.
-+ * Reported here only for scalar sensors.
-+ * Set to 0 if not reported by this sensor.
-+ */
- struct scmi_sensor_info {
-- u32 id;
-- u8 type;
-- s8 scale;
-- u8 num_trip_points;
-+ unsigned int id;
-+ unsigned int type;
-+ int scale;
-+ unsigned int num_trip_points;
- bool async;
-+ bool update;
-+ bool timestamped;
-+ int tstamp_scale;
-+ unsigned int num_axis;
-+ struct scmi_sensor_axis_info *axis;
-+ struct scmi_sensor_intervals_info intervals;
- char name[SCMI_MAX_STR_SIZE];
-+ bool extended_scalar_attrs;
-+ unsigned int sensor_power;
-+ unsigned int resolution;
-+ int exponent;
-+ struct scmi_range_attrs scalar_attrs;
- };
-
- /*
-@@ -163,11 +286,100 @@ struct scmi_sensor_info {
- */
- enum scmi_sensor_class {
- NONE = 0x0,
-+ UNSPEC = 0x1,
- TEMPERATURE_C = 0x2,
-+ TEMPERATURE_F = 0x3,
-+ TEMPERATURE_K = 0x4,
- VOLTAGE = 0x5,
- CURRENT = 0x6,
- POWER = 0x7,
- ENERGY = 0x8,
-+ CHARGE = 0x9,
-+ VOLTAMPERE = 0xA,
-+ NITS = 0xB,
-+ LUMENS = 0xC,
-+ LUX = 0xD,
-+ CANDELAS = 0xE,
-+ KPA = 0xF,
-+ PSI = 0x10,
-+ NEWTON = 0x11,
-+ CFM = 0x12,
-+ RPM = 0x13,
-+ HERTZ = 0x14,
-+ SECS = 0x15,
-+ MINS = 0x16,
-+ HOURS = 0x17,
-+ DAYS = 0x18,
-+ WEEKS = 0x19,
-+ MILS = 0x1A,
-+ INCHES = 0x1B,
-+ FEET = 0x1C,
-+ CUBIC_INCHES = 0x1D,
-+ CUBIC_FEET = 0x1E,
-+ METERS = 0x1F,
-+ CUBIC_CM = 0x20,
-+ CUBIC_METERS = 0x21,
-+ LITERS = 0x22,
-+ FLUID_OUNCES = 0x23,
-+ RADIANS = 0x24,
-+ STERADIANS = 0x25,
-+ REVOLUTIONS = 0x26,
-+ CYCLES = 0x27,
-+ GRAVITIES = 0x28,
-+ OUNCES = 0x29,
-+ POUNDS = 0x2A,
-+ FOOT_POUNDS = 0x2B,
-+ OUNCE_INCHES = 0x2C,
-+ GAUSS = 0x2D,
-+ GILBERTS = 0x2E,
-+ HENRIES = 0x2F,
-+ FARADS = 0x30,
-+ OHMS = 0x31,
-+ SIEMENS = 0x32,
-+ MOLES = 0x33,
-+ BECQUERELS = 0x34,
-+ PPM = 0x35,
-+ DECIBELS = 0x36,
-+ DBA = 0x37,
-+ DBC = 0x38,
-+ GRAYS = 0x39,
-+ SIEVERTS = 0x3A,
-+ COLOR_TEMP_K = 0x3B,
-+ BITS = 0x3C,
-+ BYTES = 0x3D,
-+ WORDS = 0x3E,
-+ DWORDS = 0x3F,
-+ QWORDS = 0x40,
-+ PERCENTAGE = 0x41,
-+ PASCALS = 0x42,
-+ COUNTS = 0x43,
-+ GRAMS = 0x44,
-+ NEWTON_METERS = 0x45,
-+ HITS = 0x46,
-+ MISSES = 0x47,
-+ RETRIES = 0x48,
-+ OVERRUNS = 0x49,
-+ UNDERRUNS = 0x4A,
-+ COLLISIONS = 0x4B,
-+ PACKETS = 0x4C,
-+ MESSAGES = 0x4D,
-+ CHARS = 0x4E,
-+ ERRORS = 0x4F,
-+ CORRECTED_ERRS = 0x50,
-+ UNCORRECTABLE_ERRS = 0x51,
-+ SQ_MILS = 0x52,
-+ SQ_INCHES = 0x53,
-+ SQ_FEET = 0x54,
-+ SQ_CM = 0x55,
-+ SQ_METERS = 0x56,
-+ RADIANS_SEC = 0x57,
-+ BPM = 0x58,
-+ METERS_SEC_SQUARED = 0x59,
-+ METERS_SEC = 0x5A,
-+ CUBIC_METERS_SEC = 0x5B,
-+ MM_MERCURY = 0x5C,
-+ RADIANS_SEC_SQUARED = 0x5D,
-+ OEM_UNIT = 0xFF
- };
-
- /**
diff --git a/meta-egvirt/recipes-kernel/linux/linux-yocto/scmi/0003-hwmon-scmi-update-hwmon-internal-scale-data-type.patch b/meta-egvirt/recipes-kernel/linux/linux-yocto/scmi/0003-hwmon-scmi-update-hwmon-internal-scale-data-type.patch
deleted file mode 100644
index efc3bf1d..00000000
--- a/meta-egvirt/recipes-kernel/linux/linux-yocto/scmi/0003-hwmon-scmi-update-hwmon-internal-scale-data-type.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From f32f6399b8a0a72c9e6c5c824a19f09f78f17c13 Mon Sep 17 00:00:00 2001
-From: Cristian Marussi <cristian.marussi@arm.com>
-Date: Thu, 19 Nov 2020 17:49:03 +0000
-Subject: [PATCH] hwmon: scmi: update hwmon internal scale data type
-
-Use an int to calculate scale values inside scmi_hwmon_scale() to match
-the updated scale data type in struct scmi_sensor_info.
-
-Cc: linux-hwmon@vger.kernel.org
-Cc: Guenter Roeck <linux@roeck-us.net>
-Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
-Acked-by: Guenter Roeck <linux@roeck-us.net>
-Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
----
- drivers/hwmon/scmi-hwmon.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/drivers/hwmon/scmi-hwmon.c b/drivers/hwmon/scmi-hwmon.c
-index 09ce30cba54b..17d064e58938 100644
---- a/drivers/hwmon/scmi-hwmon.c
-+++ b/drivers/hwmon/scmi-hwmon.c
-@@ -30,7 +30,7 @@ static inline u64 __pow10(u8 x)
-
- static int scmi_hwmon_scale(const struct scmi_sensor_info *sensor, u64 *value)
- {
-- s8 scale = sensor->scale;
-+ int scale = sensor->scale;
- u64 f;
-
- switch (sensor->type) {
diff --git a/meta-egvirt/recipes-kernel/linux/linux-yocto/scmi/0004-firmware-arm_scmi-add-SCMIv3.0-Sensors-timestamped-r.patch b/meta-egvirt/recipes-kernel/linux/linux-yocto/scmi/0004-firmware-arm_scmi-add-SCMIv3.0-Sensors-timestamped-r.patch
deleted file mode 100644
index e8839d95..00000000
--- a/meta-egvirt/recipes-kernel/linux/linux-yocto/scmi/0004-firmware-arm_scmi-add-SCMIv3.0-Sensors-timestamped-r.patch
+++ /dev/null
@@ -1,236 +0,0 @@
-From bb48061a3f1edd4203518aa4b8a021ae5d1582a4 Mon Sep 17 00:00:00 2001
-From: Cristian Marussi <cristian.marussi@arm.com>
-Date: Thu, 19 Nov 2020 17:49:04 +0000
-Subject: [PATCH] firmware: arm_scmi: add SCMIv3.0 Sensors timestamped reads
-
-Add new .reading_get_timestamped() method to sensor_ops to support SCMIv3.0
-timestamped reads.
-
-Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
-Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
----
- drivers/firmware/arm_scmi/sensors.c | 127 ++++++++++++++++++++++++++--
- include/linux/scmi_protocol.h | 22 +++++
- 2 files changed, 143 insertions(+), 6 deletions(-)
-
-diff --git a/drivers/firmware/arm_scmi/sensors.c b/drivers/firmware/arm_scmi/sensors.c
-index a85827f60a02..2239af5f9e6e 100644
---- a/drivers/firmware/arm_scmi/sensors.c
-+++ b/drivers/firmware/arm_scmi/sensors.c
-@@ -155,6 +155,23 @@ struct scmi_msg_sensor_reading_get {
- #define SENSOR_READ_ASYNC BIT(0)
- };
-
-+struct scmi_resp_sensor_reading_complete {
-+ __le32 id;
-+ __le64 readings;
-+};
-+
-+struct scmi_sensor_reading_le {
-+ __le32 sensor_value_low;
-+ __le32 sensor_value_high;
-+ __le32 timestamp_low;
-+ __le32 timestamp_high;
-+};
-+
-+struct scmi_resp_sensor_reading_complete_v3 {
-+ __le32 id;
-+ struct scmi_sensor_reading_le readings[];
-+};
-+
- struct scmi_sensor_trip_notify_payld {
- __le32 agent_id;
- __le32 sensor_id;
-@@ -575,6 +592,21 @@ scmi_sensor_trip_point_config(const struct scmi_handle *handle, u32 sensor_id,
- return ret;
- }
-
-+/**
-+ * scmi_sensor_reading_get - Read scalar sensor value
-+ * @handle: Platform handle
-+ * @sensor_id: Sensor ID
-+ * @value: The 64bit value sensor reading
-+ *
-+ * This function returns a single 64 bit reading value representing the sensor
-+ * value; if the platform SCMI Protocol implementation and the sensor support
-+ * multiple axis and timestamped-reads, this just returns the first axis while
-+ * dropping the timestamp value.
-+ * Use instead the @scmi_sensor_reading_get_timestamped to retrieve the array of
-+ * timestamped multi-axis values.
-+ *
-+ * Return: 0 on Success
-+ */
- static int scmi_sensor_reading_get(const struct scmi_handle *handle,
- u32 sensor_id, u64 *value)
- {
-@@ -585,20 +617,24 @@ static int scmi_sensor_reading_get(const struct scmi_handle *handle,
- struct scmi_sensor_info *s = si->sensors + sensor_id;
-
- ret = scmi_xfer_get_init(handle, SENSOR_READING_GET,
-- SCMI_PROTOCOL_SENSOR, sizeof(*sensor),
-- sizeof(u64), &t);
-+ SCMI_PROTOCOL_SENSOR, sizeof(*sensor), 0, &t);
- if (ret)
- return ret;
-
- sensor = t->tx.buf;
- sensor->id = cpu_to_le32(sensor_id);
--
- if (s->async) {
- sensor->flags = cpu_to_le32(SENSOR_READ_ASYNC);
- ret = scmi_do_xfer_with_response(handle, t);
-- if (!ret)
-- *value = get_unaligned_le64((void *)
-- ((__le32 *)t->rx.buf + 1));
-+ if (!ret) {
-+ struct scmi_resp_sensor_reading_complete *resp;
-+
-+ resp = t->rx.buf;
-+ if (le32_to_cpu(resp->id) == sensor_id)
-+ *value = get_unaligned_le64(&resp->readings);
-+ else
-+ ret = -EPROTO;
-+ }
- } else {
- sensor->flags = cpu_to_le32(0);
- ret = scmi_do_xfer(handle, t);
-@@ -610,6 +646,84 @@ static int scmi_sensor_reading_get(const struct scmi_handle *handle,
- return ret;
- }
-
-+static inline void
-+scmi_parse_sensor_readings(struct scmi_sensor_reading *out,
-+ const struct scmi_sensor_reading_le *in)
-+{
-+ out->value = get_unaligned_le64((void *)&in->sensor_value_low);
-+ out->timestamp = get_unaligned_le64((void *)&in->timestamp_low);
-+}
-+
-+/**
-+ * scmi_sensor_reading_get_timestamped - Read multiple-axis timestamped values
-+ * @handle: Platform handle
-+ * @sensor_id: Sensor ID
-+ * @count: The length of the provided @readings array
-+ * @readings: An array of elements each representing a timestamped per-axis
-+ * reading of type @struct scmi_sensor_reading.
-+ * Returned readings are ordered as the @axis descriptors array
-+ * included in @struct scmi_sensor_info and the max number of
-+ * returned elements is min(@count, @num_axis); ideally the provided
-+ * array should be of length @count equal to @num_axis.
-+ *
-+ * Return: 0 on Success
-+ */
-+static int
-+scmi_sensor_reading_get_timestamped(const struct scmi_handle *handle,
-+ u32 sensor_id, u8 count,
-+ struct scmi_sensor_reading *readings)
-+{
-+ int ret;
-+ struct scmi_xfer *t;
-+ struct scmi_msg_sensor_reading_get *sensor;
-+ struct sensors_info *si = handle->sensor_priv;
-+ struct scmi_sensor_info *s = si->sensors + sensor_id;
-+
-+ if (!count || !readings ||
-+ (!s->num_axis && count > 1) || (s->num_axis && count > s->num_axis))
-+ return -EINVAL;
-+
-+ ret = scmi_xfer_get_init(handle, SENSOR_READING_GET,
-+ SCMI_PROTOCOL_SENSOR, sizeof(*sensor), 0, &t);
-+ if (ret)
-+ return ret;
-+
-+ sensor = t->tx.buf;
-+ sensor->id = cpu_to_le32(sensor_id);
-+ if (s->async) {
-+ sensor->flags = cpu_to_le32(SENSOR_READ_ASYNC);
-+ ret = scmi_do_xfer_with_response(handle, t);
-+ if (!ret) {
-+ int i;
-+ struct scmi_resp_sensor_reading_complete_v3 *resp;
-+
-+ resp = t->rx.buf;
-+ /* Retrieve only the number of requested axis anyway */
-+ if (le32_to_cpu(resp->id) == sensor_id)
-+ for (i = 0; i < count; i++)
-+ scmi_parse_sensor_readings(&readings[i],
-+ &resp->readings[i]);
-+ else
-+ ret = -EPROTO;
-+ }
-+ } else {
-+ sensor->flags = cpu_to_le32(0);
-+ ret = scmi_do_xfer(handle, t);
-+ if (!ret) {
-+ int i;
-+ struct scmi_sensor_reading_le *resp_readings;
-+
-+ resp_readings = t->rx.buf;
-+ for (i = 0; i < count; i++)
-+ scmi_parse_sensor_readings(&readings[i],
-+ &resp_readings[i]);
-+ }
-+ }
-+
-+ scmi_xfer_put(handle, t);
-+ return ret;
-+}
-+
- static const struct scmi_sensor_info *
- scmi_sensor_info_get(const struct scmi_handle *handle, u32 sensor_id)
- {
-@@ -630,6 +744,7 @@ static const struct scmi_sensor_ops sensor_ops = {
- .info_get = scmi_sensor_info_get,
- .trip_point_config = scmi_sensor_trip_point_config,
- .reading_get = scmi_sensor_reading_get,
-+ .reading_get_timestamped = scmi_sensor_reading_get_timestamped,
- };
-
- static int scmi_sensor_set_notify_enabled(const struct scmi_handle *handle,
-diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h
-index 0792b0be25a3..0c52bf0cbee4 100644
---- a/include/linux/scmi_protocol.h
-+++ b/include/linux/scmi_protocol.h
-@@ -149,6 +149,20 @@ struct scmi_power_ops {
- u32 *state);
- };
-
-+/**
-+ * scmi_sensor_reading - represent a timestamped read
-+ *
-+ * Used by @reading_get_timestamped method.
-+ *
-+ * @value: The signed value sensor read.
-+ * @timestamp: An unsigned timestamp for the sensor read, as provided by
-+ * SCMI platform. Set to zero when not available.
-+ */
-+struct scmi_sensor_reading {
-+ long long value;
-+ unsigned long long timestamp;
-+};
-+
- /**
- * scmi_range_attrs - specifies a sensor or axis values' range
- * @min_range: The minimum value which can be represented by the sensor/axis.
-@@ -390,6 +404,11 @@ enum scmi_sensor_class {
- * @info_get: get the information of the specified sensor
- * @trip_point_config: selects and configures a trip-point of interest
- * @reading_get: gets the current value of the sensor
-+ * @reading_get_timestamped: gets the current value and timestamp, when
-+ * available, of the sensor. (as of v3.0 spec)
-+ * Supports multi-axis sensors for sensors which
-+ * supports it and if the @reading array size of
-+ * @count entry equals the sensor num_axis
- */
- struct scmi_sensor_ops {
- int (*count_get)(const struct scmi_handle *handle);
-@@ -399,6 +418,9 @@ struct scmi_sensor_ops {
- u32 sensor_id, u8 trip_id, u64 trip_value);
- int (*reading_get)(const struct scmi_handle *handle, u32 sensor_id,
- u64 *value);
-+ int (*reading_get_timestamped)(const struct scmi_handle *handle,
-+ u32 sensor_id, u8 count,
-+ struct scmi_sensor_reading *readings);
- };
-
- /**
diff --git a/meta-egvirt/recipes-kernel/linux/linux-yocto/scmi/0005-firmware-arm_scmi-add-SCMIv3.0-Sensor-configuration-.patch b/meta-egvirt/recipes-kernel/linux/linux-yocto/scmi/0005-firmware-arm_scmi-add-SCMIv3.0-Sensor-configuration-.patch
deleted file mode 100644
index 57095fe9..00000000
--- a/meta-egvirt/recipes-kernel/linux/linux-yocto/scmi/0005-firmware-arm_scmi-add-SCMIv3.0-Sensor-configuration-.patch
+++ /dev/null
@@ -1,172 +0,0 @@
-From 3c8f7becd835fc70aee188ad77655a3fdf5a169c Mon Sep 17 00:00:00 2001
-From: Cristian Marussi <cristian.marussi@arm.com>
-Date: Thu, 19 Nov 2020 17:49:05 +0000
-Subject: [PATCH] firmware: arm_scmi: add SCMIv3.0 Sensor configuration support
-
-Add SCMIv3.0 Sensor support for CONFIG_GET/CONFIG_SET commands.
-
-Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
-Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
----
- drivers/firmware/arm_scmi/sensors.c | 63 +++++++++++++++++++++++++++++
- include/linux/scmi_protocol.h | 37 +++++++++++++++++
- 2 files changed, 100 insertions(+)
-
-diff --git a/drivers/firmware/arm_scmi/sensors.c b/drivers/firmware/arm_scmi/sensors.c
-index 2239af5f9e6e..10c271d430e7 100644
---- a/drivers/firmware/arm_scmi/sensors.c
-+++ b/drivers/firmware/arm_scmi/sensors.c
-@@ -23,6 +23,8 @@ enum scmi_sensor_protocol_cmd {
- SENSOR_READING_GET = 0x6,
- SENSOR_AXIS_DESCRIPTION_GET = 0x7,
- SENSOR_LIST_UPDATE_INTERVALS = 0x8,
-+ SENSOR_CONFIG_GET = 0x9,
-+ SENSOR_CONFIG_SET = 0xA,
- };
-
- struct scmi_msg_resp_sensor_attributes {
-@@ -149,6 +151,11 @@ struct scmi_msg_set_sensor_trip_point {
- __le32 value_high;
- };
-
-+struct scmi_msg_sensor_config_set {
-+ __le32 id;
-+ __le32 sensor_config;
-+};
-+
- struct scmi_msg_sensor_reading_get {
- __le32 id;
- __le32 flags;
-@@ -592,6 +599,60 @@ scmi_sensor_trip_point_config(const struct scmi_handle *handle, u32 sensor_id,
- return ret;
- }
-
-+static int scmi_sensor_config_get(const struct scmi_handle *handle,
-+ u32 sensor_id, u32 *sensor_config)
-+{
-+ int ret;
-+ struct scmi_xfer *t;
-+
-+ ret = scmi_xfer_get_init(handle, SENSOR_CONFIG_GET,
-+ SCMI_PROTOCOL_SENSOR, sizeof(__le32),
-+ sizeof(__le32), &t);
-+ if (ret)
-+ return ret;
-+
-+ put_unaligned_le32(cpu_to_le32(sensor_id), t->tx.buf);
-+ ret = scmi_do_xfer(handle, t);
-+ if (!ret) {
-+ struct sensors_info *si = handle->sensor_priv;
-+ struct scmi_sensor_info *s = si->sensors + sensor_id;
-+
-+ *sensor_config = get_unaligned_le64(t->rx.buf);
-+ s->sensor_config = *sensor_config;
-+ }
-+
-+ scmi_xfer_put(handle, t);
-+ return ret;
-+}
-+
-+static int scmi_sensor_config_set(const struct scmi_handle *handle,
-+ u32 sensor_id, u32 sensor_config)
-+{
-+ int ret;
-+ struct scmi_xfer *t;
-+ struct scmi_msg_sensor_config_set *msg;
-+
-+ ret = scmi_xfer_get_init(handle, SENSOR_CONFIG_SET,
-+ SCMI_PROTOCOL_SENSOR, sizeof(*msg), 0, &t);
-+ if (ret)
-+ return ret;
-+
-+ msg = t->tx.buf;
-+ msg->id = cpu_to_le32(sensor_id);
-+ msg->sensor_config = cpu_to_le32(sensor_config);
-+
-+ ret = scmi_do_xfer(handle, t);
-+ if (!ret) {
-+ struct sensors_info *si = handle->sensor_priv;
-+ struct scmi_sensor_info *s = si->sensors + sensor_id;
-+
-+ s->sensor_config = sensor_config;
-+ }
-+
-+ scmi_xfer_put(handle, t);
-+ return ret;
-+}
-+
- /**
- * scmi_sensor_reading_get - Read scalar sensor value
- * @handle: Platform handle
-@@ -745,6 +806,8 @@ static const struct scmi_sensor_ops sensor_ops = {
- .trip_point_config = scmi_sensor_trip_point_config,
- .reading_get = scmi_sensor_reading_get,
- .reading_get_timestamped = scmi_sensor_reading_get_timestamped,
-+ .config_get = scmi_sensor_config_get,
-+ .config_set = scmi_sensor_config_set,
- };
-
- static int scmi_sensor_set_notify_enabled(const struct scmi_handle *handle,
-diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h
-index 0c52bf0cbee4..7e9e2cd3d46b 100644
---- a/include/linux/scmi_protocol.h
-+++ b/include/linux/scmi_protocol.h
-@@ -286,7 +286,38 @@ struct scmi_sensor_info {
- unsigned int num_axis;
- struct scmi_sensor_axis_info *axis;
- struct scmi_sensor_intervals_info intervals;
-+ unsigned int sensor_config;
-+#define SCMI_SENS_CFG_UPDATE_SECS_MASK GENMASK(31, 16)
-+#define SCMI_SENS_CFG_GET_UPDATE_SECS(x) \
-+ FIELD_GET(SCMI_SENS_CFG_UPDATE_SECS_MASK, (x))
-+
-+#define SCMI_SENS_CFG_UPDATE_EXP_MASK GENMASK(15, 11)
-+#define SCMI_SENS_CFG_GET_UPDATE_EXP(x) \
-+ ({ \
-+ int __signed_exp = \
-+ FIELD_GET(SCMI_SENS_CFG_UPDATE_EXP_MASK, (x)); \
-+ \
-+ if (__signed_exp & BIT(4)) \
-+ __signed_exp |= GENMASK(31, 5); \
-+ __signed_exp; \
-+ })
-+
-+#define SCMI_SENS_CFG_ROUND_MASK GENMASK(10, 9)
-+#define SCMI_SENS_CFG_ROUND_AUTO 2
-+#define SCMI_SENS_CFG_ROUND_UP 1
-+#define SCMI_SENS_CFG_ROUND_DOWN 0
-+
-+#define SCMI_SENS_CFG_TSTAMP_ENABLED_MASK BIT(1)
-+#define SCMI_SENS_CFG_TSTAMP_ENABLE 1
-+#define SCMI_SENS_CFG_TSTAMP_DISABLE 0
-+#define SCMI_SENS_CFG_IS_TSTAMP_ENABLED(x) \
-+ FIELD_GET(SCMI_SENS_CFG_TSTAMP_ENABLED_MASK, (x))
-+
-+#define SCMI_SENS_CFG_SENSOR_ENABLED_MASK BIT(0)
-+#define SCMI_SENS_CFG_SENSOR_ENABLE 1
-+#define SCMI_SENS_CFG_SENSOR_DISABLE 0
- char name[SCMI_MAX_STR_SIZE];
-+#define SCMI_SENS_CFG_IS_ENABLED(x) FIELD_GET(BIT(0), (x))
- bool extended_scalar_attrs;
- unsigned int sensor_power;
- unsigned int resolution;
-@@ -409,6 +440,8 @@ enum scmi_sensor_class {
- * Supports multi-axis sensors for sensors which
- * supports it and if the @reading array size of
- * @count entry equals the sensor num_axis
-+ * @config_get: Get sensor current configuration
-+ * @config_set: Set sensor current configuration
- */
- struct scmi_sensor_ops {
- int (*count_get)(const struct scmi_handle *handle);
-@@ -421,6 +454,10 @@ struct scmi_sensor_ops {
- int (*reading_get_timestamped)(const struct scmi_handle *handle,
- u32 sensor_id, u8 count,
- struct scmi_sensor_reading *readings);
-+ int (*config_get)(const struct scmi_handle *handle,
-+ u32 sensor_id, u32 *sensor_config);
-+ int (*config_set)(const struct scmi_handle *handle,
-+ u32 sensor_id, u32 sensor_config);
- };
-
- /**
diff --git a/meta-egvirt/recipes-kernel/linux/linux-yocto/scmi/0006-firmware-arm_scmi-add-SCMIv3.0-Sensor-notifications.patch b/meta-egvirt/recipes-kernel/linux/linux-yocto/scmi/0006-firmware-arm_scmi-add-SCMIv3.0-Sensor-notifications.patch
deleted file mode 100644
index e8c8f420..00000000
--- a/meta-egvirt/recipes-kernel/linux/linux-yocto/scmi/0006-firmware-arm_scmi-add-SCMIv3.0-Sensor-notifications.patch
+++ /dev/null
@@ -1,234 +0,0 @@
-From 53a49c0e12be913ecb81c55e6ee1f214704043cc Mon Sep 17 00:00:00 2001
-From: Cristian Marussi <cristian.marussi@arm.com>
-Date: Thu, 19 Nov 2020 17:49:06 +0000
-Subject: [PATCH] firmware: arm_scmi: add SCMIv3.0 Sensor notifications
-
-Add support for new SCMIv3.0 SENSOR_UPDATE notification.
-
-Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
-Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
----
- drivers/firmware/arm_scmi/sensors.c | 124 +++++++++++++++++++++++-----
- include/linux/scmi_protocol.h | 9 ++
- 2 files changed, 114 insertions(+), 19 deletions(-)
-
-diff --git a/drivers/firmware/arm_scmi/sensors.c b/drivers/firmware/arm_scmi/sensors.c
-index 10c271d430e7..b3d7c08c09a0 100644
---- a/drivers/firmware/arm_scmi/sensors.c
-+++ b/drivers/firmware/arm_scmi/sensors.c
-@@ -25,6 +25,7 @@ enum scmi_sensor_protocol_cmd {
- SENSOR_LIST_UPDATE_INTERVALS = 0x8,
- SENSOR_CONFIG_GET = 0x9,
- SENSOR_CONFIG_SET = 0xA,
-+ SENSOR_CONTINUOUS_UPDATE_NOTIFY = 0xB,
- };
-
- struct scmi_msg_resp_sensor_attributes {
-@@ -132,10 +133,10 @@ struct scmi_msg_resp_sensor_list_update_intervals {
- __le32 intervals[];
- };
-
--struct scmi_msg_sensor_trip_point_notify {
-+struct scmi_msg_sensor_request_notify {
- __le32 id;
- __le32 event_control;
--#define SENSOR_TP_NOTIFY_ALL BIT(0)
-+#define SENSOR_NOTIFY_ALL BIT(0)
- };
-
- struct scmi_msg_set_sensor_trip_point {
-@@ -185,6 +186,12 @@ struct scmi_sensor_trip_notify_payld {
- __le32 trip_point_desc;
- };
-
-+struct scmi_sensor_update_notify_payld {
-+ __le32 agent_id;
-+ __le32 sensor_id;
-+ struct scmi_sensor_reading_le readings[];
-+};
-+
- struct sensors_info {
- u32 version;
- int num_sensors;
-@@ -550,15 +557,16 @@ static int scmi_sensor_description_get(const struct scmi_handle *handle,
- return ret;
- }
-
--static int scmi_sensor_trip_point_notify(const struct scmi_handle *handle,
-- u32 sensor_id, bool enable)
-+static inline int
-+scmi_sensor_request_notify(const struct scmi_handle *handle, u32 sensor_id,
-+ u8 message_id, bool enable)
- {
- int ret;
-- u32 evt_cntl = enable ? SENSOR_TP_NOTIFY_ALL : 0;
-+ u32 evt_cntl = enable ? SENSOR_NOTIFY_ALL : 0;
- struct scmi_xfer *t;
-- struct scmi_msg_sensor_trip_point_notify *cfg;
-+ struct scmi_msg_sensor_request_notify *cfg;
-
-- ret = scmi_xfer_get_init(handle, SENSOR_TRIP_POINT_NOTIFY,
-+ ret = scmi_xfer_get_init(handle, message_id,
- SCMI_PROTOCOL_SENSOR, sizeof(*cfg), 0, &t);
- if (ret)
- return ret;
-@@ -573,6 +581,23 @@ static int scmi_sensor_trip_point_notify(const struct scmi_handle *handle,
- return ret;
- }
-
-+static int scmi_sensor_trip_point_notify(const struct scmi_handle *handle,
-+ u32 sensor_id, bool enable)
-+{
-+ return scmi_sensor_request_notify(handle, sensor_id,
-+ SENSOR_TRIP_POINT_NOTIFY,
-+ enable);
-+}
-+
-+static int
-+scmi_sensor_continuous_update_notify(const struct scmi_handle *handle,
-+ u32 sensor_id, bool enable)
-+{
-+ return scmi_sensor_request_notify(handle, sensor_id,
-+ SENSOR_CONTINUOUS_UPDATE_NOTIFY,
-+ enable);
-+}
-+
- static int
- scmi_sensor_trip_point_config(const struct scmi_handle *handle, u32 sensor_id,
- u8 trip_id, u64 trip_value)
-@@ -815,7 +840,19 @@ static int scmi_sensor_set_notify_enabled(const struct scmi_handle *handle,
- {
- int ret;
-
-- ret = scmi_sensor_trip_point_notify(handle, src_id, enable);
-+ switch (evt_id) {
-+ case SCMI_EVENT_SENSOR_TRIP_POINT_EVENT:
-+ ret = scmi_sensor_trip_point_notify(handle, src_id, enable);
-+ break;
-+ case SCMI_EVENT_SENSOR_UPDATE:
-+ ret = scmi_sensor_continuous_update_notify(handle, src_id,
-+ enable);
-+ break;
-+ default:
-+ ret = -EINVAL;
-+ break;
-+ }
-+
- if (ret)
- pr_debug("FAIL_ENABLED - evt[%X] dom[%d] - ret:%d\n",
- evt_id, src_id, ret);
-@@ -828,20 +865,59 @@ static void *scmi_sensor_fill_custom_report(const struct scmi_handle *handle,
- const void *payld, size_t payld_sz,
- void *report, u32 *src_id)
- {
-- const struct scmi_sensor_trip_notify_payld *p = payld;
-- struct scmi_sensor_trip_point_report *r = report;
-+ void *rep = NULL;
-
-- if (evt_id != SCMI_EVENT_SENSOR_TRIP_POINT_EVENT ||
-- sizeof(*p) != payld_sz)
-- return NULL;
-+ switch (evt_id) {
-+ case SCMI_EVENT_SENSOR_TRIP_POINT_EVENT:
-+ {
-+ const struct scmi_sensor_trip_notify_payld *p = payld;
-+ struct scmi_sensor_trip_point_report *r = report;
-
-- r->timestamp = timestamp;
-- r->agent_id = le32_to_cpu(p->agent_id);
-- r->sensor_id = le32_to_cpu(p->sensor_id);
-- r->trip_point_desc = le32_to_cpu(p->trip_point_desc);
-- *src_id = r->sensor_id;
-+ if (sizeof(*p) != payld_sz)
-+ break;
-
-- return r;
-+ r->timestamp = timestamp;
-+ r->agent_id = le32_to_cpu(p->agent_id);
-+ r->sensor_id = le32_to_cpu(p->sensor_id);
-+ r->trip_point_desc = le32_to_cpu(p->trip_point_desc);
-+ *src_id = r->sensor_id;
-+ rep = r;
-+ break;
-+ }
-+ case SCMI_EVENT_SENSOR_UPDATE:
-+ {
-+ int i;
-+ struct scmi_sensor_info *s;
-+ const struct scmi_sensor_update_notify_payld *p = payld;
-+ struct scmi_sensor_update_report *r = report;
-+ struct sensors_info *sinfo = handle->sensor_priv;
-+
-+ /* payld_sz is variable for this event */
-+ r->sensor_id = le32_to_cpu(p->sensor_id);
-+ if (r->sensor_id >= sinfo->num_sensors)
-+ break;
-+ r->timestamp = timestamp;
-+ r->agent_id = le32_to_cpu(p->agent_id);
-+ s = &sinfo->sensors[r->sensor_id];
-+ /*
-+ * The generated report r (@struct scmi_sensor_update_report)
-+ * was pre-allocated to contain up to SCMI_MAX_NUM_SENSOR_AXIS
-+ * readings: here it is filled with the effective @num_axis
-+ * readings defined for this sensor or 1 for scalar sensors.
-+ */
-+ r->readings_count = s->num_axis ?: 1;
-+ for (i = 0; i < r->readings_count; i++)
-+ scmi_parse_sensor_readings(&r->readings[i],
-+ &p->readings[i]);
-+ *src_id = r->sensor_id;
-+ rep = r;
-+ break;
-+ }
-+ default:
-+ break;
-+ }
-+
-+ return rep;
- }
-
- static const struct scmi_event sensor_events[] = {
-@@ -850,6 +926,16 @@ static const struct scmi_event sensor_events[] = {
- .max_payld_sz = sizeof(struct scmi_sensor_trip_notify_payld),
- .max_report_sz = sizeof(struct scmi_sensor_trip_point_report),
- },
-+ {
-+ .id = SCMI_EVENT_SENSOR_UPDATE,
-+ .max_payld_sz =
-+ sizeof(struct scmi_sensor_update_notify_payld) +
-+ SCMI_MAX_NUM_SENSOR_AXIS *
-+ sizeof(struct scmi_sensor_reading_le),
-+ .max_report_sz = sizeof(struct scmi_sensor_update_report) +
-+ SCMI_MAX_NUM_SENSOR_AXIS *
-+ sizeof(struct scmi_sensor_reading),
-+ },
- };
-
- static const struct scmi_event_ops sensor_event_ops = {
-diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h
-index 7e9e2cd3d46b..be0be5ff7514 100644
---- a/include/linux/scmi_protocol.h
-+++ b/include/linux/scmi_protocol.h
-@@ -657,6 +657,7 @@ enum scmi_notification_events {
- SCMI_EVENT_PERFORMANCE_LIMITS_CHANGED = 0x0,
- SCMI_EVENT_PERFORMANCE_LEVEL_CHANGED = 0x1,
- SCMI_EVENT_SENSOR_TRIP_POINT_EVENT = 0x0,
-+ SCMI_EVENT_SENSOR_UPDATE = 0x1,
- SCMI_EVENT_RESET_ISSUED = 0x0,
- SCMI_EVENT_BASE_ERROR_EVENT = 0x0,
- SCMI_EVENT_SYSTEM_POWER_STATE_NOTIFIER = 0x0,
-@@ -698,6 +699,14 @@ struct scmi_sensor_trip_point_report {
- unsigned int trip_point_desc;
- };
-
-+struct scmi_sensor_update_report {
-+ ktime_t timestamp;
-+ unsigned int agent_id;
-+ unsigned int sensor_id;
-+ unsigned int readings_count;
-+ struct scmi_sensor_reading readings[];
-+};
-+
- struct scmi_reset_issued_report {
- ktime_t timestamp;
- unsigned int agent_id;
diff --git a/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0001-firmware-arm_scmi-smccc-mailbox-Make-shmem-based-tra.patch b/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0001-firmware-arm_scmi-smccc-mailbox-Make-shmem-based-tra.patch
deleted file mode 100644
index 3d9d0fdb..00000000
--- a/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0001-firmware-arm_scmi-smccc-mailbox-Make-shmem-based-tra.patch
+++ /dev/null
@@ -1,119 +0,0 @@
-From 36269e8f5fa1f33a793c472935affe3039c052bd Mon Sep 17 00:00:00 2001
-From: Igor Skalkin <igor.skalkin@opensynergy.com>
-Date: Thu, 5 Nov 2020 22:21:07 +0100
-Subject: [PATCH] firmware: arm_scmi, smccc, mailbox: Make shmem based
- transports optional
-
-Upon adding the virtio transport in this patch series, SCMI will also
-work without shared memory based transports. Also, the mailbox transport
-may not be needed if the smc transport is used.
-
-- Compile shmem.c only if a shmem based transport is available.
-
-- Remove hard dependency of SCMI on mailbox.
-
-Co-developed-by: Peter Hilber <peter.hilber@opensynergy.com>
-Signed-off-by: Peter Hilber <peter.hilber@opensynergy.com>
-Signed-off-by: Igor Skalkin <igor.skalkin@opensynergy.com>
-Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
----
- drivers/firmware/Kconfig | 9 ++++++++-
- drivers/firmware/arm_scmi/Makefile | 2 +-
- drivers/firmware/arm_scmi/common.h | 2 ++
- drivers/firmware/arm_scmi/driver.c | 2 ++
- drivers/firmware/smccc/Kconfig | 1 +
- drivers/mailbox/Kconfig | 1 +
- 6 files changed, 15 insertions(+), 2 deletions(-)
-
-diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig
-index 3315e3c21586..30a85d38d0c0 100644
---- a/drivers/firmware/Kconfig
-+++ b/drivers/firmware/Kconfig
-@@ -9,7 +9,7 @@ menu "Firmware Drivers"
- config ARM_SCMI_PROTOCOL
- tristate "ARM System Control and Management Interface (SCMI) Message Protocol"
- depends on ARM || ARM64 || COMPILE_TEST
-- depends on MAILBOX
-+ depends on ARM_SCMI_HAVE_SHMEM
- help
- ARM System Control and Management Interface (SCMI) protocol is a
- set of operating system-independent software interfaces that are
-@@ -27,6 +27,13 @@ config ARM_SCMI_PROTOCOL
- This protocol library provides interface for all the client drivers
- making use of the features offered by the SCMI.
-
-+config ARM_SCMI_HAVE_SHMEM
-+ bool
-+ default n
-+ help
-+ This declares whether a shared memory based transport for SCMI is
-+ available.
-+
- config ARM_SCMI_POWER_DOMAIN
- tristate "SCMI power domain driver"
- depends on ARM_SCMI_PROTOCOL || (COMPILE_TEST && OF)
-diff --git a/drivers/firmware/arm_scmi/Makefile b/drivers/firmware/arm_scmi/Makefile
-index bc0d54f8e861..3cc7fa40a464 100644
---- a/drivers/firmware/arm_scmi/Makefile
-+++ b/drivers/firmware/arm_scmi/Makefile
-@@ -1,7 +1,7 @@
- # SPDX-License-Identifier: GPL-2.0-only
- scmi-bus-y = bus.o
- scmi-driver-y = driver.o notify.o
--scmi-transport-y = shmem.o
-+scmi-transport-$(CONFIG_ARM_SCMI_HAVE_SHMEM) = shmem.o
- scmi-transport-$(CONFIG_MAILBOX) += mailbox.o
- scmi-transport-$(CONFIG_HAVE_ARM_SMCCC_DISCOVERY) += smc.o
- scmi-protocols-y = base.o clock.o perf.o power.o reset.o sensors.o system.o
-diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h
-index 65063fa948d4..aed192238177 100644
---- a/drivers/firmware/arm_scmi/common.h
-+++ b/drivers/firmware/arm_scmi/common.h
-@@ -242,7 +242,9 @@ struct scmi_desc {
- int max_msg_size;
- };
-
-+#ifdef CONFIG_MAILBOX
- extern const struct scmi_desc scmi_mailbox_desc;
-+#endif
- #ifdef CONFIG_HAVE_ARM_SMCCC
- extern const struct scmi_desc scmi_smc_desc;
- #endif
-diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
-index 6b2ce3f28f7b..7efbf66f117b 100644
---- a/drivers/firmware/arm_scmi/driver.c
-+++ b/drivers/firmware/arm_scmi/driver.c
-@@ -918,7 +918,9 @@ ATTRIBUTE_GROUPS(versions);
-
- /* Each compatible listed below must have descriptor associated with it */
- static const struct of_device_id scmi_of_match[] = {
-+#ifdef CONFIG_MAILBOX
- { .compatible = "arm,scmi", .data = &scmi_mailbox_desc },
-+#endif
- #ifdef CONFIG_HAVE_ARM_SMCCC_DISCOVERY
- { .compatible = "arm,scmi-smc", .data = &scmi_smc_desc},
- #endif
-diff --git a/drivers/firmware/smccc/Kconfig b/drivers/firmware/smccc/Kconfig
-index 15e7466179a6..69c4d6cabf62 100644
---- a/drivers/firmware/smccc/Kconfig
-+++ b/drivers/firmware/smccc/Kconfig
-@@ -9,6 +9,7 @@ config HAVE_ARM_SMCCC_DISCOVERY
- bool
- depends on ARM_PSCI_FW
- default y
-+ select ARM_SCMI_HAVE_SHMEM
- help
- SMCCC v1.0 lacked discoverability and hence PSCI v1.0 was updated
- to add SMCCC discovery mechanism though the PSCI firmware
-diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig
-index 05b1009e2820..5ffe1ab0c869 100644
---- a/drivers/mailbox/Kconfig
-+++ b/drivers/mailbox/Kconfig
-@@ -1,6 +1,7 @@
- # SPDX-License-Identifier: GPL-2.0-only
- menuconfig MAILBOX
- bool "Mailbox Hardware Support"
-+ select ARM_SCMI_HAVE_SHMEM
- help
- Mailbox is a framework to control hardware communication between
- on-chip processors through queued messages and interrupt driven
diff --git a/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0002-firmware-arm_scmi-Document-that-max_msg-is-a-per-cha.patch b/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0002-firmware-arm_scmi-Document-that-max_msg-is-a-per-cha.patch
deleted file mode 100644
index 7a21fedf..00000000
--- a/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0002-firmware-arm_scmi-Document-that-max_msg-is-a-per-cha.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-From 30de0a5e1fec42589469e5ec8951d15d364df63a Mon Sep 17 00:00:00 2001
-From: Igor Skalkin <igor.skalkin@opensynergy.com>
-Date: Thu, 5 Nov 2020 22:21:08 +0100
-Subject: [PATCH] firmware: arm_scmi: Document that max_msg is a per channel
- type limit
-
-struct scmi_desc.max_msg specifies a limit for the pending messages.
-This limit is a per SCMI channel type (tx, rx) limit. State that
-explicitly in the inline documentation. The following patch will add an
-op to override the limit per channel type.
-
-Co-developed-by: Peter Hilber <peter.hilber@opensynergy.com>
-Signed-off-by: Peter Hilber <peter.hilber@opensynergy.com>
-Signed-off-by: Igor Skalkin <igor.skalkin@opensynergy.com>
-Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
----
- drivers/firmware/arm_scmi/common.h | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h
-index aed192238177..38e6aabbe3dd 100644
---- a/drivers/firmware/arm_scmi/common.h
-+++ b/drivers/firmware/arm_scmi/common.h
-@@ -231,8 +231,8 @@ struct scmi_transport_ops {
- *
- * @ops: Pointer to the transport specific ops structure
- * @max_rx_timeout_ms: Timeout for communication with SoC (in Milliseconds)
-- * @max_msg: Maximum number of messages that can be pending
-- * simultaneously in the system
-+ * @max_msg: Maximum number of messages for a channel type (tx or rx) that can
-+ * be pending simultaneously in the system
- * @max_msg_size: Maximum size of data per message that can be handled.
- */
- struct scmi_desc {
diff --git a/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0003-firmware-arm_scmi-Add-op-to-override-max-message.patch b/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0003-firmware-arm_scmi-Add-op-to-override-max-message.patch
deleted file mode 100644
index f58d6d88..00000000
--- a/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0003-firmware-arm_scmi-Add-op-to-override-max-message.patch
+++ /dev/null
@@ -1,165 +0,0 @@
-From 9ffe778acc541cec68c954f84c6fcfef8a35bec2 Mon Sep 17 00:00:00 2001
-From: Igor Skalkin <igor.skalkin@opensynergy.com>
-Date: Thu, 5 Nov 2020 22:21:09 +0100
-Subject: [PATCH] firmware: arm_scmi: Add op to override max message #
-
-The number of messages that the upcoming scmi-virtio transport can
-support depends on the virtio device (SCMI platform) and can differ for
-each channel. (The scmi-virtio transport does only have one tx and at
-most 1 rx channel.)
-
-Add an optional transport op so that scmi-virtio can report the actual
-max message # for each channel type. Respect these new limits.
-
-Co-developed-by: Peter Hilber <peter.hilber@opensynergy.com>
-Signed-off-by: Peter Hilber <peter.hilber@opensynergy.com>
-Signed-off-by: Igor Skalkin <igor.skalkin@opensynergy.com>
-Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
----
- drivers/firmware/arm_scmi/common.h | 8 ++++-
- drivers/firmware/arm_scmi/driver.c | 49 ++++++++++++++++++++++--------
- 2 files changed, 43 insertions(+), 14 deletions(-)
-
-diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h
-index 38e6aabbe3dd..9a8359ecd220 100644
---- a/drivers/firmware/arm_scmi/common.h
-+++ b/drivers/firmware/arm_scmi/common.h
-@@ -203,6 +203,9 @@ struct scmi_chan_info {
- * @chan_available: Callback to check if channel is available or not
- * @chan_setup: Callback to allocate and setup a channel
- * @chan_free: Callback to free a channel
-+ * @get_max_msg: Optional callback to provide max_msg dynamically
-+ * @max_msg: Maximum number of messages for the channel type (tx or rx)
-+ * that can be pending simultaneously in the system
- * @send_message: Callback to send a message
- * @mark_txdone: Callback to mark tx as done
- * @fetch_response: Callback to fetch response
-@@ -215,6 +218,8 @@ struct scmi_transport_ops {
- int (*chan_setup)(struct scmi_chan_info *cinfo, struct device *dev,
- bool tx);
- int (*chan_free)(int id, void *p, void *data);
-+ int (*get_max_msg)(bool tx, struct scmi_chan_info *base_cinfo,
-+ int *max_msg);
- int (*send_message)(struct scmi_chan_info *cinfo,
- struct scmi_xfer *xfer);
- void (*mark_txdone)(struct scmi_chan_info *cinfo, int ret);
-@@ -232,7 +237,8 @@ struct scmi_transport_ops {
- * @ops: Pointer to the transport specific ops structure
- * @max_rx_timeout_ms: Timeout for communication with SoC (in Milliseconds)
- * @max_msg: Maximum number of messages for a channel type (tx or rx) that can
-- * be pending simultaneously in the system
-+ * be pending simultaneously in the system. May be overridden by the
-+ * get_max_msg op.
- * @max_msg_size: Maximum size of data per message that can be handled.
- */
- struct scmi_desc {
-diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
-index 7efbf66f117b..5baa23789a49 100644
---- a/drivers/firmware/arm_scmi/driver.c
-+++ b/drivers/firmware/arm_scmi/driver.c
-@@ -61,11 +61,13 @@ static atomic_t transfer_last_id;
- * Index of this bitmap table is also used for message
- * sequence identifier.
- * @xfer_lock: Protection for message allocation
-+ * @max_msg: Maximum number of messages that can be pending
- */
- struct scmi_xfers_info {
- struct scmi_xfer *xfer_block;
- unsigned long *xfer_alloc_table;
- spinlock_t xfer_lock;
-+ int max_msg;
- };
-
- /**
-@@ -157,13 +159,11 @@ static struct scmi_xfer *scmi_xfer_get(const struct scmi_handle *handle,
- u16 xfer_id;
- struct scmi_xfer *xfer;
- unsigned long flags, bit_pos;
-- struct scmi_info *info = handle_to_scmi_info(handle);
-
- /* Keep the locked section as small as possible */
- spin_lock_irqsave(&minfo->xfer_lock, flags);
-- bit_pos = find_first_zero_bit(minfo->xfer_alloc_table,
-- info->desc->max_msg);
-- if (bit_pos == info->desc->max_msg) {
-+ bit_pos = find_first_zero_bit(minfo->xfer_alloc_table, minfo->max_msg);
-+ if (bit_pos == minfo->max_msg) {
- spin_unlock_irqrestore(&minfo->xfer_lock, flags);
- return ERR_PTR(-ENOMEM);
- }
-@@ -602,32 +602,44 @@ int scmi_handle_put(const struct scmi_handle *handle)
- }
-
- static int __scmi_xfer_info_init(struct scmi_info *sinfo,
-- struct scmi_xfers_info *info)
-+ struct scmi_xfers_info *info,
-+ bool tx,
-+ struct scmi_chan_info *base_cinfo)
- {
- int i;
- struct scmi_xfer *xfer;
- struct device *dev = sinfo->dev;
- const struct scmi_desc *desc = sinfo->desc;
-
-+ info->max_msg = desc->max_msg;
-+
-+ if (desc->ops->get_max_msg) {
-+ int ret =
-+ desc->ops->get_max_msg(tx, base_cinfo, &info->max_msg);
-+
-+ if (ret)
-+ return ret;
-+ }
-+
- /* Pre-allocated messages, no more than what hdr.seq can support */
-- if (WARN_ON(desc->max_msg >= MSG_TOKEN_MAX)) {
-+ if (WARN_ON(info->max_msg >= MSG_TOKEN_MAX)) {
- dev_err(dev, "Maximum message of %d exceeds supported %ld\n",
-- desc->max_msg, MSG_TOKEN_MAX);
-+ info->max_msg, MSG_TOKEN_MAX);
- return -EINVAL;
- }
-
-- info->xfer_block = devm_kcalloc(dev, desc->max_msg,
-+ info->xfer_block = devm_kcalloc(dev, info->max_msg,
- sizeof(*info->xfer_block), GFP_KERNEL);
- if (!info->xfer_block)
- return -ENOMEM;
-
-- info->xfer_alloc_table = devm_kcalloc(dev, BITS_TO_LONGS(desc->max_msg),
-+ info->xfer_alloc_table = devm_kcalloc(dev, BITS_TO_LONGS(info->max_msg),
- sizeof(long), GFP_KERNEL);
- if (!info->xfer_alloc_table)
- return -ENOMEM;
-
- /* Pre-initialize the buffer pointer to pre-allocated buffers */
-- for (i = 0, xfer = info->xfer_block; i < desc->max_msg; i++, xfer++) {
-+ for (i = 0, xfer = info->xfer_block; i < info->max_msg; i++, xfer++) {
- xfer->rx.buf = devm_kcalloc(dev, sizeof(u8), desc->max_msg_size,
- GFP_KERNEL);
- if (!xfer->rx.buf)
-@@ -644,10 +656,21 @@ static int __scmi_xfer_info_init(struct scmi_info *sinfo,
-
- static int scmi_xfer_info_init(struct scmi_info *sinfo)
- {
-- int ret = __scmi_xfer_info_init(sinfo, &sinfo->tx_minfo);
-+ int ret;
-+ struct scmi_chan_info *base_tx_cinfo;
-+ struct scmi_chan_info *base_rx_cinfo;
-+
-+ base_tx_cinfo = idr_find(&sinfo->tx_idr, SCMI_PROTOCOL_BASE);
-+ if (unlikely(!base_tx_cinfo))
-+ return -EINVAL;
-+
-+ ret = __scmi_xfer_info_init(sinfo, &sinfo->tx_minfo, true,
-+ base_tx_cinfo);
-
-- if (!ret && idr_find(&sinfo->rx_idr, SCMI_PROTOCOL_BASE))
-- ret = __scmi_xfer_info_init(sinfo, &sinfo->rx_minfo);
-+ base_rx_cinfo = idr_find(&sinfo->rx_idr, SCMI_PROTOCOL_BASE);
-+ if (!ret && base_rx_cinfo)
-+ ret = __scmi_xfer_info_init(sinfo, &sinfo->rx_minfo, false,
-+ base_rx_cinfo);
-
- return ret;
- }
diff --git a/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0004-firmware-arm_scmi-Add-per-message-transport-data.patch b/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0004-firmware-arm_scmi-Add-per-message-transport-data.patch
deleted file mode 100644
index 644b015d..00000000
--- a/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0004-firmware-arm_scmi-Add-per-message-transport-data.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-From 0771d1d96e6439c00497a521f8d2c9803f7e07e2 Mon Sep 17 00:00:00 2001
-From: Igor Skalkin <igor.skalkin@opensynergy.com>
-Date: Thu, 5 Nov 2020 22:21:10 +0100
-Subject: [PATCH] firmware: arm_scmi: Add per message transport data
-
-The virtio transport in this patch series can be simplified by using the
-scmi_xfer tx/rx buffers for data exchange with the virtio device, and
-for saving the message state. But the virtio transport requires
-prepending a transport-specific header. Also, for data exchange using
-virtqueues, the tx and rx buffers should not overlap.
-
-The first step to solve the aforementioned issues is to add a
-transport-specific data pointer to scmi_xfer.
-
-Co-developed-by: Peter Hilber <peter.hilber@opensynergy.com>
-Signed-off-by: Peter Hilber <peter.hilber@opensynergy.com>
-Signed-off-by: Igor Skalkin <igor.skalkin@opensynergy.com>
-Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
----
- drivers/firmware/arm_scmi/common.h | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h
-index 9a8359ecd220..c998ec29018e 100644
---- a/drivers/firmware/arm_scmi/common.h
-+++ b/drivers/firmware/arm_scmi/common.h
-@@ -131,6 +131,7 @@ struct scmi_msg {
- * buffer for the rx path as we use for the tx path.
- * @done: command message transmit completion event
- * @async_done: pointer to delayed response message received event completion
-+ * @extra_data: Transport-specific private data pointer
- */
- struct scmi_xfer {
- int transfer_id;
-@@ -139,6 +140,7 @@ struct scmi_xfer {
- struct scmi_msg rx;
- struct completion done;
- struct completion *async_done;
-+ void *extra_data;
- };
-
- void scmi_xfer_put(const struct scmi_handle *h, struct scmi_xfer *xfer);
diff --git a/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0005-firmware-arm_scmi-Add-xfer_init_buffers-transport-op.patch b/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0005-firmware-arm_scmi-Add-xfer_init_buffers-transport-op.patch
deleted file mode 100644
index e62e5c50..00000000
--- a/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0005-firmware-arm_scmi-Add-xfer_init_buffers-transport-op.patch
+++ /dev/null
@@ -1,79 +0,0 @@
-From fddb9bcd706ed3bb262f4f37707616dd06c7a4cc Mon Sep 17 00:00:00 2001
-From: Igor Skalkin <igor.skalkin@opensynergy.com>
-Date: Thu, 5 Nov 2020 22:21:11 +0100
-Subject: [PATCH] firmware: arm_scmi: Add xfer_init_buffers transport op
-
-The virtio transport in this patch series can be simplified by using the
-scmi_xfer tx/rx buffers for data exchange with the virtio device, and
-for saving the message state. But the virtio transport requires
-prepending a transport-specific header. Also, for data exchange using
-virtqueues, the tx and rx buffers should not overlap.
-
-After the previous patch, this is the second and final step to enable
-the virtio transport to use the scmi_xfer buffers for data exchange.
-
-Add an optional op through which the transport can allocate the tx/rx
-buffers along with room for the prepended transport-specific headers.
-
-Co-developed-by: Peter Hilber <peter.hilber@opensynergy.com>
-Signed-off-by: Peter Hilber <peter.hilber@opensynergy.com>
-Signed-off-by: Igor Skalkin <igor.skalkin@opensynergy.com>
-Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
----
- drivers/firmware/arm_scmi/common.h | 3 +++
- drivers/firmware/arm_scmi/driver.c | 21 +++++++++++++++------
- 2 files changed, 18 insertions(+), 6 deletions(-)
-
-diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h
-index c998ec29018e..ae5db602e45d 100644
---- a/drivers/firmware/arm_scmi/common.h
-+++ b/drivers/firmware/arm_scmi/common.h
-@@ -208,6 +208,7 @@ struct scmi_chan_info {
- * @get_max_msg: Optional callback to provide max_msg dynamically
- * @max_msg: Maximum number of messages for the channel type (tx or rx)
- * that can be pending simultaneously in the system
-+ * @xfer_init_buffers: Callback to initialize buffers for scmi_xfer
- * @send_message: Callback to send a message
- * @mark_txdone: Callback to mark tx as done
- * @fetch_response: Callback to fetch response
-@@ -222,6 +223,8 @@ struct scmi_transport_ops {
- int (*chan_free)(int id, void *p, void *data);
- int (*get_max_msg)(bool tx, struct scmi_chan_info *base_cinfo,
- int *max_msg);
-+ int (*xfer_init_buffers)(struct scmi_chan_info *cinfo,
-+ struct scmi_xfer *xfer, int max_msg_size);
- int (*send_message)(struct scmi_chan_info *cinfo,
- struct scmi_xfer *xfer);
- void (*mark_txdone)(struct scmi_chan_info *cinfo, int ret);
-diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
-index 5baa23789a49..27dd43dcff5b 100644
---- a/drivers/firmware/arm_scmi/driver.c
-+++ b/drivers/firmware/arm_scmi/driver.c
-@@ -640,12 +640,21 @@ static int __scmi_xfer_info_init(struct scmi_info *sinfo,
-
- /* Pre-initialize the buffer pointer to pre-allocated buffers */
- for (i = 0, xfer = info->xfer_block; i < info->max_msg; i++, xfer++) {
-- xfer->rx.buf = devm_kcalloc(dev, sizeof(u8), desc->max_msg_size,
-- GFP_KERNEL);
-- if (!xfer->rx.buf)
-- return -ENOMEM;
--
-- xfer->tx.buf = xfer->rx.buf;
-+ if (desc->ops->xfer_init_buffers) {
-+ int ret = desc->ops->xfer_init_buffers(
-+ base_cinfo, xfer, desc->max_msg_size);
-+
-+ if (ret)
-+ return ret;
-+ } else {
-+ xfer->rx.buf = devm_kcalloc(dev, sizeof(u8),
-+ desc->max_msg_size,
-+ GFP_KERNEL);
-+ if (!xfer->rx.buf)
-+ return -ENOMEM;
-+
-+ xfer->tx.buf = xfer->rx.buf;
-+ }
- init_completion(&xfer->done);
- }
-
diff --git a/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0006-firmware-arm_scmi-Add-optional-link_supplier-transpo.patch b/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0006-firmware-arm_scmi-Add-optional-link_supplier-transpo.patch
deleted file mode 100644
index 0f5180fa..00000000
--- a/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0006-firmware-arm_scmi-Add-optional-link_supplier-transpo.patch
+++ /dev/null
@@ -1,54 +0,0 @@
-From f0d7ff1f10ab846bf32bae3b7d32bf95653954fa Mon Sep 17 00:00:00 2001
-From: Peter Hilber <peter.hilber@opensynergy.com>
-Date: Thu, 5 Nov 2020 22:21:12 +0100
-Subject: [PATCH] firmware: arm_scmi: Add optional link_supplier() transport op
-
-For the scmi-virtio transport, it might not be possible to refer to the
-proper virtio device at device tree build time. Therefore, add an op
-which will allow scmi-virtio to dynamically link to the proper virtio
-device during probe.
-
-Signed-off-by: Peter Hilber <peter.hilber@opensynergy.com>
-Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
----
- drivers/firmware/arm_scmi/common.h | 2 ++
- drivers/firmware/arm_scmi/driver.c | 6 ++++++
- 2 files changed, 8 insertions(+)
-
-diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h
-index ae5db602e45d..2f55ac71555a 100644
---- a/drivers/firmware/arm_scmi/common.h
-+++ b/drivers/firmware/arm_scmi/common.h
-@@ -202,6 +202,7 @@ struct scmi_chan_info {
- /**
- * struct scmi_transport_ops - Structure representing a SCMI transport ops
- *
-+ * @link_supplier: Optional callback to add link to a supplier device
- * @chan_available: Callback to check if channel is available or not
- * @chan_setup: Callback to allocate and setup a channel
- * @chan_free: Callback to free a channel
-@@ -217,6 +218,7 @@ struct scmi_chan_info {
- * @poll_done: Callback to poll transfer status
- */
- struct scmi_transport_ops {
-+ int (*link_supplier)(struct device *dev);
- bool (*chan_available)(struct device *dev, int idx);
- int (*chan_setup)(struct scmi_chan_info *cinfo, struct device *dev,
- bool tx);
-diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
-index 27dd43dcff5b..0b70f9ef9477 100644
---- a/drivers/firmware/arm_scmi/driver.c
-+++ b/drivers/firmware/arm_scmi/driver.c
-@@ -826,6 +826,12 @@ static int scmi_probe(struct platform_device *pdev)
- handle->dev = info->dev;
- handle->version = &info->version;
-
-+ if (desc->ops->link_supplier) {
-+ ret = desc->ops->link_supplier(dev);
-+ if (ret)
-+ return ret;
-+ }
-+
- ret = scmi_txrx_setup(info, dev, SCMI_PROTOCOL_BASE);
- if (ret)
- return ret;
diff --git a/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0007-firmware-arm_scmi-Add-per-device-transport-private-i.patch b/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0007-firmware-arm_scmi-Add-per-device-transport-private-i.patch
deleted file mode 100644
index 1c82530f..00000000
--- a/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0007-firmware-arm_scmi-Add-per-device-transport-private-i.patch
+++ /dev/null
@@ -1,92 +0,0 @@
-From 9d5366d4765fb60cafa31c2b46cd80d284c847bb Mon Sep 17 00:00:00 2001
-From: Peter Hilber <peter.hilber@opensynergy.com>
-Date: Thu, 5 Nov 2020 22:21:13 +0100
-Subject: [PATCH] firmware: arm_scmi: Add per-device transport private info
-
-The scmi-virtio transport will link a supplier device to the arm-scmi
-device in the link_supplier() op. The transport should then save a
-pointer to the linked device.
-
-To enable this, add a transport private info to the scmi_info. (The
-scmi_info is already reachable through the arm-scmi device driver_data.)
-
-Signed-off-by: Peter Hilber <peter.hilber@opensynergy.com>
-Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
----
- drivers/firmware/arm_scmi/common.h | 2 ++
- drivers/firmware/arm_scmi/driver.c | 35 ++++++++++++++++++++++++++++++
- 2 files changed, 37 insertions(+)
-
-diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h
-index 2f55ac71555a..ec9fd7fce3c7 100644
---- a/drivers/firmware/arm_scmi/common.h
-+++ b/drivers/firmware/arm_scmi/common.h
-@@ -262,6 +262,8 @@ extern const struct scmi_desc scmi_mailbox_desc;
- extern const struct scmi_desc scmi_smc_desc;
- #endif
-
-+int scmi_set_transport_info(struct device *dev, void *transport_info);
-+void *scmi_get_transport_info(struct device *dev);
- void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr);
- void scmi_free_channel(struct scmi_chan_info *cinfo, struct idr *idr, int id);
-
-diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
-index 0b70f9ef9477..93ce17bb4079 100644
---- a/drivers/firmware/arm_scmi/driver.c
-+++ b/drivers/firmware/arm_scmi/driver.c
-@@ -84,6 +84,7 @@ struct scmi_xfers_info {
- * @rx_idr: IDR object to map protocol id to Rx channel info pointer
- * @protocols_imp: List of protocols implemented, currently maximum of
- * MAX_PROTOCOLS_IMP elements allocated by the base protocol
-+ * @transport_info: Transport private info
- * @node: List head
- * @users: Number of users of this instance
- */
-@@ -97,6 +98,7 @@ struct scmi_info {
- struct idr tx_idr;
- struct idr rx_idr;
- u8 *protocols_imp;
-+ void *transport_info;
- struct list_head node;
- int users;
- };
-@@ -315,6 +317,39 @@ void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr)
- }
- }
-
-+/**
-+ * scmi_set_transport_info() - Set transport private info
-+ *
-+ * @dev: SCMI instance device
-+ * @transport_info: transport private info
-+ *
-+ * Return: 0 on success, otherwise error.
-+ */
-+int scmi_set_transport_info(struct device *dev, void *transport_info)
-+{
-+ struct scmi_info *info = dev_get_drvdata(dev);
-+
-+ if (!info)
-+ return -EBADR;
-+
-+ info->transport_info = transport_info;
-+ return 0;
-+}
-+
-+/**
-+ * scmi_get_transport_info() - Get transport private info
-+ *
-+ * @dev: SCMI instance device
-+ *
-+ * Return: transport private info on success, otherwise NULL.
-+ */
-+void *scmi_get_transport_info(struct device *dev)
-+{
-+ struct scmi_info *info = dev_get_drvdata(dev);
-+
-+ return info ? info->transport_info : NULL;
-+}
-+
- /**
- * scmi_xfer_put() - Release a transmit message
- *
diff --git a/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0008-firmware-arm_scmi-Add-is_scmi_protocol_device.patch b/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0008-firmware-arm_scmi-Add-is_scmi_protocol_device.patch
deleted file mode 100644
index 92aad65e..00000000
--- a/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0008-firmware-arm_scmi-Add-is_scmi_protocol_device.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-From c4b299105e74f7863b2aa63bd838e7762761629c Mon Sep 17 00:00:00 2001
-From: Peter Hilber <peter.hilber@opensynergy.com>
-Date: Thu, 5 Nov 2020 22:21:14 +0100
-Subject: [PATCH] firmware: arm_scmi: Add is_scmi_protocol_device()
-
-The scmi-virtio transport driver will need to distinguish SCMI protocol
-devices from the SCMI instance device in the chan_setup() and
-chan_free() ops. Add this internal helper to be able to distinguish the
-two.
-
-Signed-off-by: Peter Hilber <peter.hilber@opensynergy.com>
-Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
----
- drivers/firmware/arm_scmi/bus.c | 5 +++++
- drivers/firmware/arm_scmi/common.h | 2 ++
- 2 files changed, 7 insertions(+)
-
-diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c
-index 1377ec76a45d..4f19faafb2c5 100644
---- a/drivers/firmware/arm_scmi/bus.c
-+++ b/drivers/firmware/arm_scmi/bus.c
-@@ -108,6 +108,11 @@ static struct bus_type scmi_bus_type = {
- .remove = scmi_dev_remove,
- };
-
-+bool is_scmi_protocol_device(struct device *dev)
-+{
-+ return dev->bus == &scmi_bus_type;
-+}
-+
- int scmi_driver_register(struct scmi_driver *driver, struct module *owner,
- const char *mod_name)
- {
-diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h
-index ec9fd7fce3c7..13c9ac176b23 100644
---- a/drivers/firmware/arm_scmi/common.h
-+++ b/drivers/firmware/arm_scmi/common.h
-@@ -158,6 +158,8 @@ int scmi_version_get(const struct scmi_handle *h, u8 protocol, u32 *version);
- void scmi_setup_protocol_implemented(const struct scmi_handle *handle,
- u8 *prot_imp);
-
-+bool is_scmi_protocol_device(struct device *dev);
-+
- int scmi_base_protocol_init(struct scmi_handle *h);
-
- int __init scmi_bus_init(void);
diff --git a/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0009-dt-bindings-arm-Add-virtio-transport-for-SCMI.patch b/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0009-dt-bindings-arm-Add-virtio-transport-for-SCMI.patch
deleted file mode 100644
index beb2d99f..00000000
--- a/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0009-dt-bindings-arm-Add-virtio-transport-for-SCMI.patch
+++ /dev/null
@@ -1,89 +0,0 @@
-From 592064dd36739ad5f3d885b9880ee1bc2d66e2df Mon Sep 17 00:00:00 2001
-From: Igor Skalkin <igor.skalkin@opensynergy.com>
-Date: Thu, 5 Nov 2020 22:21:15 +0100
-Subject: [PATCH] dt-bindings: arm: Add virtio transport for SCMI
-
-Document the properties for arm,scmi-virtio compatible nodes. The
-backing virtio SCMI device is described in patch [1].
-
-[1] https://lists.oasis-open.org/archives/virtio-comment/202005/msg00096.html
-
-Co-developed-by: Peter Hilber <peter.hilber@opensynergy.com>
-Signed-off-by: Peter Hilber <peter.hilber@opensynergy.com>
-Signed-off-by: Igor Skalkin <igor.skalkin@opensynergy.com>
-Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
----
- .../devicetree/bindings/arm/arm,scmi.txt | 35 +++++++++++++++++--
- 1 file changed, 33 insertions(+), 2 deletions(-)
-
-diff --git a/Documentation/devicetree/bindings/arm/arm,scmi.txt b/Documentation/devicetree/bindings/arm/arm,scmi.txt
-index 55deb68230eb..6ded49d82773 100644
---- a/Documentation/devicetree/bindings/arm/arm,scmi.txt
-+++ b/Documentation/devicetree/bindings/arm/arm,scmi.txt
-@@ -13,6 +13,9 @@ the device tree.
- Required properties:
-
- The scmi node with the following properties shall be under the /firmware/ node.
-+Some properties are specific to a transport type.
-+
-+shmem-based transports (mailbox, smc/hvc):
-
- - compatible : shall be "arm,scmi" or "arm,scmi-smc" for smc/hvc transports
- - mboxes: List of phandle and mailbox channel specifiers. It should contain
-@@ -21,6 +24,15 @@ The scmi node with the following properties shall be under the /firmware/ node.
- supported.
- - shmem : List of phandle pointing to the shared memory(SHM) area as per
- generic mailbox client binding.
-+
-+Virtio transport:
-+
-+- compatible : shall be "arm,scmi-virtio".
-+
-+The virtio transport only supports a single device.
-+
-+Additional required properties:
-+
- - #address-cells : should be '1' if the device has sub-nodes, maps to
- protocol identifier for a given sub-node.
- - #size-cells : should be '0' as 'reg' property doesn't have any size
-@@ -42,7 +54,8 @@ Each protocol supported shall have a sub-node with corresponding compatible
- as described in the following sections. If the platform supports dedicated
- communication channel for a particular protocol, the 3 properties namely:
- mboxes, mbox-names and shmem shall be present in the sub-node corresponding
--to that protocol.
-+to that protocol. The virtio transport does not support dedicated communication
-+channels.
-
- Clock/Performance bindings for the clocks/OPPs based on SCMI Message Protocol
- ------------------------------------------------------------
-@@ -106,7 +119,8 @@ Required sub-node properties:
- [4] Documentation/devicetree/bindings/sram/sram.yaml
- [5] Documentation/devicetree/bindings/reset/reset.txt
-
--Example:
-+Example (mailbox transport):
-+----------------------------
-
- sram@50000000 {
- compatible = "mmio-sram";
-@@ -195,3 +209,20 @@ thermal-zones {
- ...
- };
- };
-+
-+Example (virtio transport):
-+---------------------------
-+
-+virtio_mmio@4b001000 {
-+ compatible = "virtio,mmio";
-+ ...
-+};
-+
-+firmware {
-+ ...
-+ scmi {
-+ compatible = "arm,scmi-virtio";
-+ ...
-+
-+The rest is similar to the mailbox transport example, when omitting the
-+mailbox/shmem-specific properties.
diff --git a/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0010-firmware-arm_scmi-Add-virtio-transport.patch b/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0010-firmware-arm_scmi-Add-virtio-transport.patch
deleted file mode 100644
index 35ea04f8..00000000
--- a/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio-scmi/0010-firmware-arm_scmi-Add-virtio-transport.patch
+++ /dev/null
@@ -1,756 +0,0 @@
-From 7b9f3fe0766d6d36ca7465e54754df51ca175079 Mon Sep 17 00:00:00 2001
-From: Igor Skalkin <igor.skalkin@opensynergy.com>
-Date: Thu, 5 Nov 2020 22:21:16 +0100
-Subject: [PATCH] firmware: arm_scmi: Add virtio transport
-
-This transport enables accessing an SCMI platform as a virtio device.
-
-Implement an SCMI virtio driver according to the virtio SCMI device spec
-patch v5 [1]. Virtio device id 32 has been reserved for the SCMI device
-[2].
-
-The virtio transport has one tx channel (virtio cmdq, A2P channel) and
-at most one rx channel (virtio eventq, P2A channel).
-
-The following feature bit defined in [1] is not implemented:
-VIRTIO_SCMI_F_SHARED_MEMORY.
-
-After the preparatory patches, implement the virtio transport as
-paraphrased:
-
-Only support a single arm-scmi device (which is consistent with the SCMI
-spec). Call scmi-virtio init from arm-scmi module init. During the
-arm-scmi probing, link to the first probed scmi-virtio device. Defer
-arm-scmi probing if no scmi-virtio device is bound yet.
-
-Use the scmi_xfer tx/rx buffers for data exchange with the virtio device
-in order to avoid redundant maintenance of additional buffers. Allocate
-the buffers in the SCMI transport, and prepend room for a small header
-used by the virtio transport to the tx/rx buffers.
-
-For simplicity, restrict the number of messages which can be pending
-simultaneously according to the virtqueue capacity. (The virtqueue sizes
-are negotiated with the virtio device.)
-
-As soon as rx channel message buffers are allocated or have been read
-out by the arm-scmi driver, feed them to the virtio device.
-
-Since some virtio devices may not have the short response time exhibited
-by SCMI platforms using other transports, set a generous response
-timeout.
-
-Limitations:
-
-Do not adjust the other SCMI timeouts for delayed response and polling
-for now, since these timeouts are only relevant in special cases which
-are not yet deemed relevant for this transport.
-
-To do (as discussed in the cover letter):
-
-- Avoid re-use of buffers still being used by the virtio device on
- timeouts.
-
-- Avoid race conditions on receiving messages during/after channel free
- on driver probe failure or remove.
-
-[1] https://lists.oasis-open.org/archives/virtio-comment/202005/msg00096.html
-[2] https://www.oasis-open.org/committees/ballot.php?id=3496
-
-Co-developed-by: Peter Hilber <peter.hilber@opensynergy.com>
-Signed-off-by: Peter Hilber <peter.hilber@opensynergy.com>
-Signed-off-by: Igor Skalkin <igor.skalkin@opensynergy.com>
-Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
----
- MAINTAINERS | 1 +
- drivers/firmware/Kconfig | 12 +-
- drivers/firmware/arm_scmi/Makefile | 1 +
- drivers/firmware/arm_scmi/common.h | 14 +
- drivers/firmware/arm_scmi/driver.c | 11 +
- drivers/firmware/arm_scmi/virtio.c | 493 +++++++++++++++++++++++++++++
- include/uapi/linux/virtio_ids.h | 1 +
- include/uapi/linux/virtio_scmi.h | 41 +++
- 8 files changed, 573 insertions(+), 1 deletion(-)
- create mode 100644 drivers/firmware/arm_scmi/virtio.c
- create mode 100644 include/uapi/linux/virtio_scmi.h
-
-diff --git a/MAINTAINERS b/MAINTAINERS
-index 49772b741967..d223a5c3f465 100644
---- a/MAINTAINERS
-+++ b/MAINTAINERS
-@@ -16973,6 +16973,7 @@ F: drivers/firmware/arm_scpi.c
- F: drivers/reset/reset-scmi.c
- F: include/linux/sc[mp]i_protocol.h
- F: include/trace/events/scmi.h
-+F: include/uapi/linux/virtio_scmi.h
-
- SYSTEM RESET/SHUTDOWN DRIVERS
- M: Sebastian Reichel <sre@kernel.org>
-diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig
-index 30a85d38d0c0..82e97904bcae 100644
---- a/drivers/firmware/Kconfig
-+++ b/drivers/firmware/Kconfig
-@@ -9,7 +9,7 @@ menu "Firmware Drivers"
- config ARM_SCMI_PROTOCOL
- tristate "ARM System Control and Management Interface (SCMI) Message Protocol"
- depends on ARM || ARM64 || COMPILE_TEST
-- depends on ARM_SCMI_HAVE_SHMEM
-+ depends on ARM_SCMI_HAVE_SHMEM || VIRTIO_SCMI
- help
- ARM System Control and Management Interface (SCMI) protocol is a
- set of operating system-independent software interfaces that are
-@@ -34,6 +34,16 @@ config ARM_SCMI_HAVE_SHMEM
- This declares whether a shared memory based transport for SCMI is
- available.
-
-+config VIRTIO_SCMI
-+ bool "Virtio transport for SCMI"
-+ default n
-+ depends on VIRTIO
-+ help
-+ This enables the virtio based transport for SCMI.
-+
-+ If you want to use the ARM SCMI protocol between the virtio guest and
-+ a host providing a virtio SCMI device, answer Y.
-+
- config ARM_SCMI_POWER_DOMAIN
- tristate "SCMI power domain driver"
- depends on ARM_SCMI_PROTOCOL || (COMPILE_TEST && OF)
-diff --git a/drivers/firmware/arm_scmi/Makefile b/drivers/firmware/arm_scmi/Makefile
-index 3cc7fa40a464..25caea5e1969 100644
---- a/drivers/firmware/arm_scmi/Makefile
-+++ b/drivers/firmware/arm_scmi/Makefile
-@@ -4,6 +4,7 @@ scmi-driver-y = driver.o notify.o
- scmi-transport-$(CONFIG_ARM_SCMI_HAVE_SHMEM) = shmem.o
- scmi-transport-$(CONFIG_MAILBOX) += mailbox.o
- scmi-transport-$(CONFIG_HAVE_ARM_SMCCC_DISCOVERY) += smc.o
-+scmi-transport-$(CONFIG_VIRTIO_SCMI) += virtio.o
- scmi-protocols-y = base.o clock.o perf.o power.o reset.o sensors.o system.o
- scmi-module-objs := $(scmi-bus-y) $(scmi-driver-y) $(scmi-protocols-y) \
- $(scmi-transport-y)
-diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h
-index 13c9ac176b23..b46dfe84e78b 100644
---- a/drivers/firmware/arm_scmi/common.h
-+++ b/drivers/firmware/arm_scmi/common.h
-@@ -165,6 +165,17 @@ int scmi_base_protocol_init(struct scmi_handle *h);
- int __init scmi_bus_init(void);
- void __exit scmi_bus_exit(void);
-
-+#ifdef CONFIG_VIRTIO_SCMI
-+int __init virtio_scmi_init(void);
-+void __exit virtio_scmi_exit(void);
-+#else
-+static inline int __init virtio_scmi_init(void)
-+{
-+ return 0;
-+}
-+#define virtio_scmi_exit() do { } while (0)
-+#endif
-+
- #define DECLARE_SCMI_REGISTER_UNREGISTER(func) \
- int __init scmi_##func##_register(void); \
- void __exit scmi_##func##_unregister(void)
-@@ -263,6 +274,9 @@ extern const struct scmi_desc scmi_mailbox_desc;
- #ifdef CONFIG_HAVE_ARM_SMCCC
- extern const struct scmi_desc scmi_smc_desc;
- #endif
-+#ifdef CONFIG_VIRTIO_SCMI
-+extern const struct scmi_desc scmi_virtio_desc;
-+#endif
-
- int scmi_set_transport_info(struct device *dev, void *transport_info);
- void *scmi_get_transport_info(struct device *dev);
-diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
-index 93ce17bb4079..540a55285349 100644
---- a/drivers/firmware/arm_scmi/driver.c
-+++ b/drivers/firmware/arm_scmi/driver.c
-@@ -996,6 +996,9 @@ static const struct of_device_id scmi_of_match[] = {
- #endif
- #ifdef CONFIG_HAVE_ARM_SMCCC_DISCOVERY
- { .compatible = "arm,scmi-smc", .data = &scmi_smc_desc},
-+#endif
-+#ifdef CONFIG_VIRTIO_SCMI
-+ { .compatible = "arm,scmi-virtio", .data = &scmi_virtio_desc},
- #endif
- { /* Sentinel */ },
- };
-@@ -1014,8 +1017,14 @@ static struct platform_driver scmi_driver = {
-
- static int __init scmi_driver_init(void)
- {
-+ int ret;
-+
- scmi_bus_init();
-
-+ ret = virtio_scmi_init();
-+ if (ret)
-+ return ret;
-+
- scmi_clock_register();
- scmi_perf_register();
- scmi_power_register();
-@@ -1038,6 +1047,8 @@ static void __exit scmi_driver_exit(void)
- scmi_sensors_unregister();
- scmi_system_unregister();
-
-+ virtio_scmi_exit();
-+
- platform_driver_unregister(&scmi_driver);
- }
- module_exit(scmi_driver_exit);
-diff --git a/drivers/firmware/arm_scmi/virtio.c b/drivers/firmware/arm_scmi/virtio.c
-new file mode 100644
-index 000000000000..f70aa72f34f1
---- /dev/null
-+++ b/drivers/firmware/arm_scmi/virtio.c
-@@ -0,0 +1,493 @@
-+// SPDX-License-Identifier: GPL-2.0
-+/*
-+ * Virtio Transport driver for Arm System Control and Management Interface
-+ * (SCMI).
-+ *
-+ * Copyright (C) 2020 OpenSynergy.
-+ */
-+
-+/**
-+ * DOC: Theory of Operation
-+ *
-+ * The scmi-virtio transport implements a driver for the virtio SCMI device
-+ * proposed in virtio spec patch v5[1].
-+ *
-+ * There is one tx channel (virtio cmdq, A2P channel) and at most one rx
-+ * channel (virtio eventq, P2A channel). Each channel is implemented through a
-+ * virtqueue. Access to each virtqueue is protected by a spinlock.
-+ *
-+ * This SCMI transport uses the scmi_xfer tx/rx buffers for data exchange with
-+ * the virtio device to avoid maintenance of additional buffers.
-+ *
-+ * [1] https://lists.oasis-open.org/archives/virtio-comment/202005/msg00096.html
-+ */
-+
-+#include <linux/errno.h>
-+#include <linux/of.h>
-+#include <linux/of_platform.h>
-+#include <linux/platform_device.h>
-+#include <linux/module.h>
-+#include <linux/slab.h>
-+#include <linux/virtio.h>
-+#include <linux/virtio_config.h>
-+#include <uapi/linux/virtio_ids.h>
-+#include <uapi/linux/virtio_scmi.h>
-+
-+#include "common.h"
-+
-+#define VIRTIO_SCMI_MAX_MSG_SIZE 128 /* Value may be increased. */
-+#define DESCR_PER_TX_MSG 2
-+
-+struct scmi_vio_channel {
-+ spinlock_t lock;
-+ struct virtqueue *vqueue;
-+ struct scmi_chan_info *cinfo;
-+ u8 is_rx;
-+};
-+
-+union virtio_scmi_input {
-+ __virtio32 hdr;
-+ struct virtio_scmi_response response;
-+ struct virtio_scmi_notification notification;
-+};
-+
-+struct scmi_vio_msg {
-+ struct virtio_scmi_request *request;
-+ union virtio_scmi_input *input;
-+ u8 completed;
-+};
-+
-+static int scmi_vio_populate_vq_rx(struct scmi_vio_channel *vioch,
-+ struct scmi_xfer *xfer)
-+{
-+ struct scatterlist sg_in;
-+ struct scmi_vio_msg *msg = xfer->extra_data;
-+ int rc;
-+
-+ msg->completed = false;
-+
-+ sg_init_one(&sg_in, msg->input,
-+ sizeof(*msg->input) + VIRTIO_SCMI_MAX_MSG_SIZE);
-+
-+ rc = virtqueue_add_inbuf(vioch->vqueue, &sg_in, 1, xfer, GFP_ATOMIC);
-+ if (rc)
-+ dev_err(vioch->cinfo->dev, "%s() rc=%d\n", __func__, rc);
-+ else
-+ virtqueue_kick(vioch->vqueue);
-+
-+ return rc;
-+}
-+
-+static void scmi_vio_complete_cb(struct virtqueue *vqueue)
-+{
-+ struct scmi_vio_channel *vioch = vqueue->priv;
-+ unsigned long iflags;
-+ unsigned int length;
-+
-+ spin_lock_irqsave(&vioch->lock, iflags);
-+
-+ do {
-+ struct scmi_xfer *xfer;
-+
-+ virtqueue_disable_cb(vqueue);
-+
-+ while ((xfer = virtqueue_get_buf(vqueue, &length))) {
-+ struct scmi_vio_msg *msg = xfer->extra_data;
-+ u32 msg_hdr =
-+ virtio32_to_cpu(vqueue->vdev, msg->input->hdr);
-+ u8 msg_type = MSG_XTRACT_TYPE(msg_hdr);
-+
-+ if (!vioch->is_rx) { /* tx queue response */
-+ msg->completed = true;
-+ xfer->rx.len =
-+ length - sizeof(msg->input->response);
-+ if (!xfer->hdr.poll_completion)
-+ scmi_rx_callback(vioch->cinfo, msg_hdr);
-+ continue;
-+ }
-+
-+ /* rx queue - notification or delayed response */
-+ switch (msg_type) {
-+ case MSG_TYPE_NOTIFICATION:
-+ xfer->rx.len = length -
-+ sizeof(msg->input->notification);
-+ xfer->rx.buf = msg->input->notification.data;
-+ break;
-+ case MSG_TYPE_DELAYED_RESP:
-+ xfer->rx.len =
-+ length - sizeof(msg->input->response);
-+ xfer->rx.buf = msg->input->response.data;
-+ break;
-+ default:
-+ dev_warn_once(vioch->cinfo->dev,
-+ "rx: unknown message_type %d\n",
-+ msg_type);
-+ scmi_vio_populate_vq_rx(vioch, xfer);
-+ continue;
-+ }
-+
-+ scmi_rx_callback(vioch->cinfo, msg_hdr);
-+ scmi_vio_populate_vq_rx(vioch, xfer);
-+ }
-+
-+ if (unlikely(virtqueue_is_broken(vqueue)))
-+ break;
-+ } while (!virtqueue_enable_cb(vqueue));
-+
-+ spin_unlock_irqrestore(&vioch->lock, iflags);
-+}
-+
-+static const char *const scmi_vio_vqueue_names[] = { "tx", "rx" };
-+
-+static vq_callback_t *scmi_vio_complete_callbacks[] = {
-+ scmi_vio_complete_cb,
-+ scmi_vio_complete_cb
-+};
-+
-+static int scmi_vio_match_any_dev(struct device *dev, const void *data)
-+{
-+ (void)dev;
-+ (void)data;
-+
-+ return 1;
-+}
-+
-+static struct virtio_driver virtio_scmi_driver; /* Forward declaration */
-+
-+static int virtio_link_supplier(struct device *dev)
-+{
-+ struct device *vdev = driver_find_device(
-+ &virtio_scmi_driver.driver, NULL, NULL, scmi_vio_match_any_dev);
-+
-+ if (!vdev) {
-+ dev_notice_once(
-+ dev,
-+ "Deferring probe after not finding a bound scmi-virtio device\n");
-+ return -EPROBE_DEFER;
-+ }
-+
-+ /*
-+ * Add plain device link for completeness. It might have no effect
-+ * beyond sysfs.
-+ */
-+ if (!device_link_add(dev, vdev, DL_FLAG_AUTOREMOVE_CONSUMER)) {
-+ put_device(vdev);
-+ dev_err(dev, "Adding link to supplier virtio device failed\n");
-+ return -ECANCELED;
-+ }
-+
-+ put_device(vdev);
-+ return scmi_set_transport_info(dev, dev_to_virtio(vdev));
-+}
-+
-+static bool virtio_chan_available(struct device *dev, int idx)
-+{
-+ struct virtio_device *vdev;
-+ struct scmi_vio_channel **vioch;
-+
-+ /* scmi-virtio doesn't support per-protocol channels */
-+ if (is_scmi_protocol_device(dev))
-+ return false;
-+
-+ vdev = scmi_get_transport_info(dev);
-+ if (!vdev)
-+ return false;
-+
-+ vioch = vdev->priv;
-+ if (!vioch)
-+ return false;
-+
-+ return vioch[idx] && vioch[idx]->vqueue;
-+}
-+
-+static int virtio_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
-+ bool tx)
-+{
-+ struct virtio_device *vdev;
-+ struct scmi_vio_channel **vioch;
-+ int vioch_index = tx ? VIRTIO_SCMI_VQ_TX : VIRTIO_SCMI_VQ_RX;
-+
-+ /* scmi-virtio doesn't support per-protocol channels */
-+ if (is_scmi_protocol_device(dev))
-+ return -1;
-+
-+ vdev = scmi_get_transport_info(dev);
-+ if (!vdev)
-+ return -1;
-+
-+ vioch = vdev->priv;
-+ if (!vioch) {
-+ dev_err(dev, "Data from scmi-virtio probe not found\n");
-+ return -1;
-+ }
-+ cinfo->transport_info = vioch[vioch_index];
-+ vioch[vioch_index]->cinfo = cinfo;
-+
-+ return 0;
-+}
-+
-+static int virtio_chan_free(int id, void *p, void *data)
-+{
-+ struct scmi_chan_info *cinfo = p;
-+ struct scmi_vio_channel *vioch = cinfo->transport_info;
-+
-+ if (vioch) {
-+ cinfo->transport_info = NULL;
-+ kfree(vioch);
-+ }
-+
-+ scmi_free_channel(cinfo, data, id);
-+ return 0;
-+}
-+
-+static int virtio_get_max_msg(bool tx, struct scmi_chan_info *base_cinfo,
-+ int *max_msg)
-+{
-+ struct scmi_vio_channel *vioch = base_cinfo->transport_info;
-+
-+ *max_msg = virtqueue_get_vring_size(vioch->vqueue);
-+
-+ /* Tx messages need multiple descriptors. */
-+ if (tx)
-+ *max_msg /= DESCR_PER_TX_MSG;
-+
-+ if (*max_msg > MSG_TOKEN_MAX) {
-+ dev_notice(
-+ base_cinfo->dev,
-+ "Only %ld messages can be pending simultaneously, while the virtqueue could hold %d\n",
-+ MSG_TOKEN_MAX, *max_msg);
-+ *max_msg = MSG_TOKEN_MAX;
-+ }
-+
-+ return 0;
-+}
-+
-+static int virtio_xfer_init_buffers(struct scmi_chan_info *cinfo,
-+ struct scmi_xfer *xfer, int max_msg_size)
-+{
-+ struct scmi_vio_channel *vioch = cinfo->transport_info;
-+ struct scmi_vio_msg *msg;
-+
-+ msg = devm_kzalloc(cinfo->dev, sizeof(*msg), GFP_KERNEL);
-+ if (!msg)
-+ return -ENOMEM;
-+
-+ xfer->extra_data = msg;
-+
-+ if (vioch->is_rx) {
-+ int rc;
-+ unsigned long iflags;
-+
-+ msg->input = devm_kzalloc(cinfo->dev,
-+ sizeof(*msg->input) + max_msg_size,
-+ GFP_KERNEL);
-+ if (!msg->input)
-+ return -ENOMEM;
-+
-+ /*
-+ * xfer->rx.buf will be set to notification or delayed response
-+ * specific values in the receive callback, according to the
-+ * type of the received message.
-+ */
-+
-+ spin_lock_irqsave(&vioch->lock, iflags);
-+ rc = scmi_vio_populate_vq_rx(vioch, xfer);
-+ spin_unlock_irqrestore(&vioch->lock, iflags);
-+ if (rc)
-+ return rc;
-+ } else {
-+ msg->request =
-+ devm_kzalloc(cinfo->dev,
-+ sizeof(*msg->request) + max_msg_size,
-+ GFP_KERNEL);
-+ if (!msg->request)
-+ return -ENOMEM;
-+
-+ xfer->tx.buf = msg->request->data;
-+
-+ msg->input = devm_kzalloc(
-+ cinfo->dev, sizeof(msg->input->response) + max_msg_size,
-+ GFP_KERNEL);
-+ if (!msg->input)
-+ return -ENOMEM;
-+
-+ xfer->rx.buf = msg->input->response.data;
-+ }
-+
-+ return 0;
-+}
-+
-+static int scmi_vio_send(struct scmi_vio_channel *vioch, struct scmi_xfer *xfer)
-+{
-+ struct scatterlist sg_out;
-+ struct scatterlist sg_in;
-+ struct scatterlist *sgs[DESCR_PER_TX_MSG] = { &sg_out, &sg_in };
-+ struct scmi_vio_msg *msg = xfer->extra_data;
-+ unsigned long iflags;
-+ int rc;
-+
-+ msg->completed = false;
-+
-+ sg_init_one(&sg_out, msg->request,
-+ sizeof(*msg->request) + xfer->tx.len);
-+ sg_init_one(&sg_in, &msg->input->response,
-+ sizeof(msg->input->response) + xfer->rx.len);
-+
-+ spin_lock_irqsave(&vioch->lock, iflags);
-+ rc = virtqueue_add_sgs(vioch->vqueue, sgs, 1, 1, xfer, GFP_ATOMIC);
-+ if (rc)
-+ dev_err(vioch->cinfo->dev, "%s() rc=%d\n", __func__, rc);
-+ else
-+ virtqueue_kick(vioch->vqueue);
-+ spin_unlock_irqrestore(&vioch->lock, iflags);
-+
-+ return rc;
-+}
-+
-+static int virtio_send_message(struct scmi_chan_info *cinfo,
-+ struct scmi_xfer *xfer)
-+{
-+ uint32_t hdr;
-+ struct scmi_vio_channel *vioch = cinfo->transport_info;
-+ struct virtio_device *vdev = vioch->vqueue->vdev;
-+ struct scmi_vio_msg *msg = xfer->extra_data;
-+
-+ hdr = pack_scmi_header(&xfer->hdr);
-+
-+ msg->request->hdr = cpu_to_virtio32(vdev, hdr);
-+
-+ return scmi_vio_send(vioch, xfer);
-+}
-+
-+static void virtio_fetch_response(struct scmi_chan_info *cinfo,
-+ struct scmi_xfer *xfer)
-+{
-+ struct scmi_vio_channel *vioch = cinfo->transport_info;
-+ struct scmi_vio_msg *msg = xfer->extra_data;
-+
-+ xfer->hdr.status = virtio32_to_cpu(vioch->vqueue->vdev,
-+ msg->input->response.status);
-+}
-+
-+static void dummy_fetch_notification(struct scmi_chan_info *cinfo,
-+ size_t max_len, struct scmi_xfer *xfer)
-+{
-+ (void)cinfo;
-+ (void)max_len;
-+ (void)xfer;
-+}
-+
-+static void dummy_clear_channel(struct scmi_chan_info *cinfo)
-+{
-+ (void)cinfo;
-+}
-+
-+static bool virtio_poll_done(struct scmi_chan_info *cinfo,
-+ struct scmi_xfer *xfer)
-+{
-+ struct scmi_vio_channel *vioch = cinfo->transport_info;
-+ struct scmi_vio_msg *msg = xfer->extra_data;
-+ unsigned long iflags;
-+ bool completed;
-+
-+ spin_lock_irqsave(&vioch->lock, iflags);
-+ completed = msg->completed;
-+ spin_unlock_irqrestore(&vioch->lock, iflags);
-+
-+ return completed;
-+}
-+
-+static const struct scmi_transport_ops scmi_virtio_ops = {
-+ .link_supplier = virtio_link_supplier,
-+ .chan_available = virtio_chan_available,
-+ .chan_setup = virtio_chan_setup,
-+ .chan_free = virtio_chan_free,
-+ .get_max_msg = virtio_get_max_msg,
-+ .send_message = virtio_send_message,
-+ .fetch_response = virtio_fetch_response,
-+ .fetch_notification = dummy_fetch_notification,
-+ .clear_channel = dummy_clear_channel,
-+ .poll_done = virtio_poll_done,
-+ .xfer_init_buffers = virtio_xfer_init_buffers,
-+};
-+
-+const struct scmi_desc scmi_virtio_desc = {
-+ .ops = &scmi_virtio_ops,
-+ .max_rx_timeout_ms = 60000, /* for non-realtime virtio devices */
-+ .max_msg = 0, /* overridden by virtio_get_max_msg() */
-+ .max_msg_size = VIRTIO_SCMI_MAX_MSG_SIZE,
-+};
-+
-+static int scmi_vio_probe(struct virtio_device *vdev)
-+{
-+ struct device *dev = &vdev->dev;
-+ struct scmi_vio_channel **vioch;
-+ bool have_vq_rx;
-+ int vq_cnt;
-+ int i;
-+ struct virtqueue *vqs[VIRTIO_SCMI_VQ_MAX_CNT];
-+
-+ vioch = devm_kcalloc(dev, VIRTIO_SCMI_VQ_MAX_CNT, sizeof(*vioch),
-+ GFP_KERNEL);
-+ if (!vioch)
-+ return -ENOMEM;
-+
-+ have_vq_rx = virtio_has_feature(vdev, VIRTIO_SCMI_F_P2A_CHANNELS);
-+ vq_cnt = have_vq_rx ? VIRTIO_SCMI_VQ_MAX_CNT : 1;
-+
-+ for (i = 0; i < vq_cnt; i++) {
-+ vioch[i] = devm_kzalloc(dev, sizeof(**vioch), GFP_KERNEL);
-+ if (!vioch[i])
-+ return -ENOMEM;
-+ }
-+
-+ if (have_vq_rx)
-+ vioch[VIRTIO_SCMI_VQ_RX]->is_rx = true;
-+
-+ if (virtio_find_vqs(vdev, vq_cnt, vqs, scmi_vio_complete_callbacks,
-+ scmi_vio_vqueue_names, NULL)) {
-+ dev_err(dev, "Failed to get %d virtqueue(s)\n", vq_cnt);
-+ return -1;
-+ }
-+ dev_info(dev, "Found %d virtqueue(s)\n", vq_cnt);
-+
-+ for (i = 0; i < vq_cnt; i++) {
-+ spin_lock_init(&vioch[i]->lock);
-+ vioch[i]->vqueue = vqs[i];
-+ vioch[i]->vqueue->priv = vioch[i];
-+ }
-+
-+ vdev->priv = vioch;
-+
-+ virtio_device_ready(vdev);
-+
-+ return 0;
-+}
-+
-+static unsigned int features[] = {
-+ VIRTIO_SCMI_F_P2A_CHANNELS,
-+};
-+
-+static const struct virtio_device_id id_table[] = {
-+ { VIRTIO_ID_SCMI, VIRTIO_DEV_ANY_ID },
-+ { 0 }
-+};
-+
-+static struct virtio_driver virtio_scmi_driver = {
-+ .driver.name = "scmi-virtio",
-+ .driver.owner = THIS_MODULE,
-+ .feature_table = features,
-+ .feature_table_size = ARRAY_SIZE(features),
-+ .id_table = id_table,
-+ .probe = scmi_vio_probe,
-+};
-+
-+int __init virtio_scmi_init(void)
-+{
-+ return register_virtio_driver(&virtio_scmi_driver);
-+}
-+
-+void __exit virtio_scmi_exit(void)
-+{
-+ unregister_virtio_driver(&virtio_scmi_driver);
-+}
-diff --git a/include/uapi/linux/virtio_ids.h b/include/uapi/linux/virtio_ids.h
-index bc740d6d2259..287daba2abdb 100644
---- a/include/uapi/linux/virtio_ids.h
-+++ b/include/uapi/linux/virtio_ids.h
-@@ -49,5 +49,6 @@
- #define VIRTIO_ID_FS 26 /* virtio filesystem */
- #define VIRTIO_ID_PMEM 27 /* virtio pmem */
- #define VIRTIO_ID_MAC80211_HWSIM 29 /* virtio mac80211-hwsim */
-+#define VIRTIO_ID_SCMI 32 /* virtio SCMI */
-
- #endif /* _LINUX_VIRTIO_IDS_H */
-diff --git a/include/uapi/linux/virtio_scmi.h b/include/uapi/linux/virtio_scmi.h
-new file mode 100644
-index 000000000000..9f21b3dbbfe2
---- /dev/null
-+++ b/include/uapi/linux/virtio_scmi.h
-@@ -0,0 +1,41 @@
-+/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
-+/*
-+ * Copyright (C) 2020 OpenSynergy GmbH
-+ */
-+
-+#ifndef _UAPI_LINUX_VIRTIO_SCMI_H
-+#define _UAPI_LINUX_VIRTIO_SCMI_H
-+
-+#include <linux/virtio_types.h>
-+
-+/* Feature bits */
-+
-+/* Device implements some SCMI notifications, or delayed responses. */
-+#define VIRTIO_SCMI_F_P2A_CHANNELS 0
-+
-+/* Device implements any SCMI statistics shared memory region */
-+#define VIRTIO_SCMI_F_SHARED_MEMORY 1
-+
-+/* Virtqueues */
-+
-+#define VIRTIO_SCMI_VQ_TX 0 /* cmdq */
-+#define VIRTIO_SCMI_VQ_RX 1 /* eventq */
-+#define VIRTIO_SCMI_VQ_MAX_CNT 2
-+
-+struct virtio_scmi_request {
-+ __virtio32 hdr;
-+ __u8 data[];
-+};
-+
-+struct virtio_scmi_response {
-+ __virtio32 hdr;
-+ __virtio32 status;
-+ __u8 data[];
-+};
-+
-+struct virtio_scmi_notification {
-+ __virtio32 hdr;
-+ __u8 data[];
-+};
-+
-+#endif /* _UAPI_LINUX_VIRTIO_SCMI_H */
diff --git a/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio_scmi.cfg b/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio_scmi.cfg
index 4159ae58..b698e64a 100644
--- a/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio_scmi.cfg
+++ b/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio_scmi.cfg
@@ -1,5 +1,25 @@
+# Enable ARM_SCMI_PROTOCOL ("ARM System Control and Management Interface (SCMI)
+# Message Protocol") config located in menu
+#
+# -> Device Drivers
+# -> Firmware Drivers
+# -> ARM System Control and Management Interface Protocol
+#
+# After that, in the same menu enabled:
+#
+# * ARM_SCMI_TRANSPORT_VIRTIO ("SCMI transport based on VirtIO")
+#
+# and disabled not used features:
+#
+# * ARM_SCMI_TRANSPORT_SMC ("SCMI transport based on SMC")
+# * ARM_SCMI_POWER_DOMAIN ("SCMI power domain driver")
+
CONFIG_ARM_SCMI_PROTOCOL=y
-CONFIG_VIRTIO_SCMI=y
+CONFIG_ARM_SCMI_HAVE_TRANSPORT=y
+CONFIG_ARM_SCMI_HAVE_MSG=y
+# CONFIG_ARM_SCMI_TRANSPORT_SMC is not set
+CONFIG_ARM_SCMI_TRANSPORT_VIRTIO=y
# CONFIG_ARM_SCMI_POWER_DOMAIN is not set
# CONFIG_SENSORS_ARM_SCMI is not set
# CONFIG_COMMON_CLK_SCMI is not set
+# CONFIG_IIO_SCMI is not set
diff --git a/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio_video.cfg b/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio_video.cfg
index 252bcfeb..75b1a3ca 100644
--- a/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio_video.cfg
+++ b/meta-egvirt/recipes-kernel/linux/linux-yocto/virtio_video.cfg
@@ -1,4 +1,26 @@
-CONFIG_FRAME_VECTOR=y
+# Enable MEDIA_SUPPORT ("Multimedia support") menuconfig located in menu
+#
+# -> Device Drivers
+#
+# Enable MEDIA_PLATFORM_SUPPORT ("Platform-specific devices") config located in
+# submenu
+#
+# -> Multimedia support (MEDIA_SUPPORT [=y])
+# -> Media device types
+#
+# of the enabled "Multimedia support" menuconfig.
+#
+# Enable VIDEO_VIRTIO ("Virtio video driver") config located in submenu
+#
+# -> Multimedia support (MEDIA_SUPPORT [=y])
+# -> Media drivers
+#
+# of the enabled "Multimedia support" menuconfig.
+#
+# Disable MEDIA_SUBDRV_AUTOSELECT ("Autoselect ancillary drivers (tuners,
+# sensors, i2c, spi, frontends)") config located in the enabled "Multimedia
+# support" menuconfig. This allows avoid autoselection of unneeded drivers.
+
CONFIG_MEDIA_SUPPORT=y
CONFIG_MEDIA_SUPPORT_FILTER=y
# CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set
diff --git a/meta-egvirt/recipes-kernel/linux/linux-yocto_%.bbappend b/meta-egvirt/recipes-kernel/linux/linux-yocto_%.bbappend
index 4401de95..4d276591 100644
--- a/meta-egvirt/recipes-kernel/linux/linux-yocto_%.bbappend
+++ b/meta-egvirt/recipes-kernel/linux/linux-yocto_%.bbappend
@@ -2,32 +2,11 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
# virtio SCMI
SRC_URI += " \
- file://virtio-scmi/0001-firmware-arm_scmi-smccc-mailbox-Make-shmem-based-tra.patch \
- file://virtio-scmi/0002-firmware-arm_scmi-Document-that-max_msg-is-a-per-cha.patch \
- file://virtio-scmi/0003-firmware-arm_scmi-Add-op-to-override-max-message.patch \
- file://virtio-scmi/0004-firmware-arm_scmi-Add-per-message-transport-data.patch \
- file://virtio-scmi/0005-firmware-arm_scmi-Add-xfer_init_buffers-transport-op.patch \
- file://virtio-scmi/0006-firmware-arm_scmi-Add-optional-link_supplier-transpo.patch \
- file://virtio-scmi/0007-firmware-arm_scmi-Add-per-device-transport-private-i.patch \
- file://virtio-scmi/0008-firmware-arm_scmi-Add-is_scmi_protocol_device.patch \
- file://virtio-scmi/0009-dt-bindings-arm-Add-virtio-transport-for-SCMI.patch \
- file://virtio-scmi/0010-firmware-arm_scmi-Add-virtio-transport.patch \
file://virtio_scmi.cfg \
"
-# SCMI updates
-SRC_URI += " \
- file://scmi/0001-firmware-arm_scmi-rework-scmi_sensors_protocol_init.patch \
- file://scmi/0002-firmware-arm_scmi-add-SCMIv3.0-Sensors-descriptors-e.patch \
- file://scmi/0003-hwmon-scmi-update-hwmon-internal-scale-data-type.patch \
- file://scmi/0004-firmware-arm_scmi-add-SCMIv3.0-Sensors-timestamped-r.patch \
- file://scmi/0005-firmware-arm_scmi-add-SCMIv3.0-Sensor-configuration-.patch \
- file://scmi/0006-firmware-arm_scmi-add-SCMIv3.0-Sensor-notifications.patch \
-"
-
# IIO SCMI
SRC_URI += " \
- file://iio-scmi/0001-iio-scmi-Adding-support-for-IIO-SCMI-Based-Sensors.patch \
file://iio-scmi/0002-iio-core-Introduce-IIO_VAL_INT_64.patch \
file://iio-scmi/0003-iio-scmi-Add-reading-raw-attribute.patch \
file://iio_scmi.cfg \