]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
firmware: arm_scmi: Add versions and identifier attributes using dev_groups
authorSudeep Holla <sudeep.holla@arm.com>
Tue, 22 Oct 2019 09:09:01 +0000 (10:09 +0100)
committerSudeep Holla <sudeep.holla@arm.com>
Tue, 24 Dec 2019 11:35:49 +0000 (11:35 +0000)
Platform drivers now have the option to have the platform core create
and remove any needed sysfs attribute files. Using the same, let's add
the scmi firmware and protocol version attributes as well as vendor and
sub-vendor identifiers to sysfs.

It helps to identify the firmware details from the sysfs entries similar
to ARM SCPI implementation.

Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
drivers/firmware/arm_scmi/driver.c

index 0bbdc7c9eb0fbd1007dc3ad0231f13b03e204aef..26b2c438bd594bb8d94dd0a236d1917727b9f818 100644 (file)
@@ -979,6 +979,52 @@ static int scmi_remove(struct platform_device *pdev)
        return ret;
 }
 
+static ssize_t protocol_version_show(struct device *dev,
+                                    struct device_attribute *attr, char *buf)
+{
+       struct scmi_info *info = dev_get_drvdata(dev);
+
+       return sprintf(buf, "%u.%u\n", info->version.major_ver,
+                      info->version.minor_ver);
+}
+static DEVICE_ATTR_RO(protocol_version);
+
+static ssize_t firmware_version_show(struct device *dev,
+                                    struct device_attribute *attr, char *buf)
+{
+       struct scmi_info *info = dev_get_drvdata(dev);
+
+       return sprintf(buf, "0x%x\n", info->version.impl_ver);
+}
+static DEVICE_ATTR_RO(firmware_version);
+
+static ssize_t vendor_id_show(struct device *dev,
+                             struct device_attribute *attr, char *buf)
+{
+       struct scmi_info *info = dev_get_drvdata(dev);
+
+       return sprintf(buf, "%s\n", info->version.vendor_id);
+}
+static DEVICE_ATTR_RO(vendor_id);
+
+static ssize_t sub_vendor_id_show(struct device *dev,
+                                 struct device_attribute *attr, char *buf)
+{
+       struct scmi_info *info = dev_get_drvdata(dev);
+
+       return sprintf(buf, "%s\n", info->version.sub_vendor_id);
+}
+static DEVICE_ATTR_RO(sub_vendor_id);
+
+static struct attribute *versions_attrs[] = {
+       &dev_attr_firmware_version.attr,
+       &dev_attr_protocol_version.attr,
+       &dev_attr_vendor_id.attr,
+       &dev_attr_sub_vendor_id.attr,
+       NULL,
+};
+ATTRIBUTE_GROUPS(versions);
+
 static const struct scmi_desc scmi_generic_desc = {
        .max_rx_timeout_ms = 30,        /* We may increase this if required */
        .max_msg = 20,          /* Limited by MBOX_TX_QUEUE_LEN */
@@ -997,6 +1043,7 @@ static struct platform_driver scmi_driver = {
        .driver = {
                   .name = "arm-scmi",
                   .of_match_table = scmi_of_match,
+                  .dev_groups = versions_groups,
                   },
        .probe = scmi_probe,
        .remove = scmi_remove,