From patchwork Tue Dec 10 14:53:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 181123 Delivered-To: patch@linaro.org Received: by 2002:ac9:44c4:0:0:0:0:0 with SMTP id t4csp5605899och; Tue, 10 Dec 2019 06:54:14 -0800 (PST) X-Google-Smtp-Source: APXvYqykSrQgUPyshU/Uey6gzAfc5Q3ExigwqBkSD1p04G2d5lfrH/eoF9Z5p65z3xeFnQG7PrYs X-Received: by 2002:aca:fc07:: with SMTP id a7mr4351524oii.28.1575989654779; Tue, 10 Dec 2019 06:54:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575989654; cv=none; d=google.com; s=arc-20160816; b=QhgxyvMsukUC5WTexPdLCBoLC+qlXfkhoCA86y88gRpzE9WNk++sN8cEMgrJ9V7NAo uX64cyzOyNF8/Lw9jfJITgP9F3W0LplUOxpbON7zEt07fHytYrp4kJwdsKl+c31fI7j3 UEma0KIFHQpHPXH64so7BTmf4u7nafg7BvNKnw1PjShly+I9JbdMmGhEtFuUOvJAM3GB wAPs4rebRjwZ4RhwF4KBlf3IBZHKlZZXbkH4rhj4+VZWws94C5+QkM3PoJ7wGcnl6sOL 01X0OooxfGEnusCcAt591AGnxbGr3HqA6spRCjAZz/tr3XkRaTVe+2WlWtGphk7QHjX2 litQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=9KvzuCVrR3cmC256dnaRGDdFwv51oP8954ExbdqKZus=; b=r1r2bh/hhNFW5PSrxy3SsVGIdPf8F5GyVNYyrfhidhs8Rc+LQTFfA0kPAZ1MS04Kn/ GIx05c7/aGE2+SJKjLcQHsBIxWaBY+peqBwx/7uIPjS4hyHf5Z7yUuEpZyix72fiGA6z x5GzUZe/KUVnSPpJSC0/nlFoo/1vcSHjD9iHAZuu4Kq4J+FEqfiJFrM6xk9wEs2+/mb+ CD3JLw5qfB4gTnVuAAmmP7AyjdtZPDm23vbO4oWOZHn/2vhsKaSXYZj/GfN1H1xffgVN 7UvTPluKIi2V2F0Ladh7TzcSuDDBsvg1iMWGaWY4bHcP3wHXn8zAdoTRiESw2IwZlGu2 +G/Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a12si2053135oie.87.2019.12.10.06.54.14; Tue, 10 Dec 2019 06:54:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727695AbfLJOyN (ORCPT + 27 others); Tue, 10 Dec 2019 09:54:13 -0500 Received: from foss.arm.com ([217.140.110.172]:47140 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727659AbfLJOyJ (ORCPT ); Tue, 10 Dec 2019 09:54:09 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 43EF61396; Tue, 10 Dec 2019 06:54:09 -0800 (PST) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 940C63F67D; Tue, 10 Dec 2019 06:54:08 -0800 (PST) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Cristian Marussi Subject: [PATCH 05/15] firmware: arm_scmi: Add versions and identifier attributes using dev_groups Date: Tue, 10 Dec 2019 14:53:35 +0000 Message-Id: <20191210145345.11616-6-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191210145345.11616-1-sudeep.holla@arm.com> References: <20191210145345.11616-1-sudeep.holla@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/firmware/arm_scmi/driver.c | 47 ++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) -- 2.17.1 Reviewed-by: Cristian Marussi 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,