[05/15] firmware: arm_scmi: Add versions and identifier attributes using dev_groups
diff mbox series

Message ID 20191210145345.11616-6-sudeep.holla@arm.com
State New
Headers show
Series
  • firmware: arm_scmi: Add support for multiple device per protocol
Related show

Commit Message

Sudeep Holla Dec. 10, 2019, 2:53 p.m. UTC
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.

Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 drivers/firmware/arm_scmi/driver.c | 47 ++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

--
2.17.1

Comments

Cristian Marussi Dec. 11, 2019, 1:21 p.m. UTC | #1
On 10/12/2019 14:53, Sudeep Holla wrote:
> 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.
> 
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
>  drivers/firmware/arm_scmi/driver.c | 47 ++++++++++++++++++++++++++++++
>  1 file changed, 47 insertions(+)
> 
> diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
> index 0bbdc7c9eb0f..26b2c438bd59 100644
> --- a/drivers/firmware/arm_scmi/driver.c
> +++ b/drivers/firmware/arm_scmi/driver.c
> @@ -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,
> --
> 2.17.1
> 

LGTM.

Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>


Cristian

Patch
diff mbox series

diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index 0bbdc7c9eb0f..26b2c438bd59 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -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,