From patchwork Wed Dec 18 11:17: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: 181979 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp503833ile; Wed, 18 Dec 2019 03:17:54 -0800 (PST) X-Google-Smtp-Source: APXvYqxtotXCo3anArRzcFQGzrQhqLmBrwHW2JbGAfxsNEn3d+VT2X6wwTDFE4ekVFapp7aQsY2F X-Received: by 2002:a05:6830:109a:: with SMTP id y26mr1927148oto.227.1576667874714; Wed, 18 Dec 2019 03:17:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576667874; cv=none; d=google.com; s=arc-20160816; b=TX61mzVfGS5/lPi0ahuW7dOMNL1QCTeilZd6QtvVM14FR9QdiJBLgFTXZb8mMTeA71 sg5hdYjkkn/rfHqeyNKH0wmlCHIFzMDD/SCuaE2UL5xkBaHTm44KXo9zgkRLXynuhS0A y9IPprtatu70O9h3Ox6YFFtP6eYVs9WxUdXPch9hw4fN/mClNDNUtZf6j4zr7YfRjjbo xCaT/VnpHvzASKqtZASgEhNAAV+CqVwzFD+Tn/mSAmYyEE6kUuB1b09l62Eb020oXPEe F0Q7F99fxLR4iPYXzVd94P9WBJuCb0NP6DpYuY7VZ9J68zzsRA0VraWbX5i1q9mdehb4 XqtA== 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=eeFX//xhocunBOo2isqUer3x7gJOvlao2xl5WVoPFRI=; b=PRgIrwdPCceXH8p49WCMTOVLbGqTzfzapjNm1Rpx9qoAeEIexiPQo85Uu/4q8wtT+r QOXIMSRUEFY0VVpQq+F6tZVowyRfWQOZzGYLpW0zuLkboeyZiipmLv6Y+fyPnnszCtOn 2Vbz3yzeLAV8d/NpMHbRzbYpLZLHh5x87yku/VwdDkcgbZg8vhWNIPHJOFx+emeMz5Kh +Gr3o8MAPci6nmZM+nZ0wz7wLx6wnkgMKNMgOAn8zj7MqKVhKWycpollI90cJlO11UDa m6UtVSiBVjgvYYBd8JXYgtXoiwhCFHT/wg6Lu1nE0nzr4NcnDPh4oni8VhQGieS3Psy5 VIfA== 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 e23si1101679otj.239.2019.12.18.03.17.54; Wed, 18 Dec 2019 03:17:54 -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 S1726861AbfLRLRx (ORCPT + 27 others); Wed, 18 Dec 2019 06:17:53 -0500 Received: from foss.arm.com ([217.140.110.172]:42362 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726141AbfLRLRv (ORCPT ); Wed, 18 Dec 2019 06:17:51 -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 349A030E; Wed, 18 Dec 2019 03:17:51 -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 85D8B3F6CF; Wed, 18 Dec 2019 03:17:50 -0800 (PST) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Sudeep Holla , Cristian Marussi Subject: [PATCH v2 04/11] firmware: arm_scmi: Add versions and identifier attributes using dev_groups Date: Wed, 18 Dec 2019 11:17:35 +0000 Message-Id: <20191218111742.29731-5-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191218111742.29731-1-sudeep.holla@arm.com> References: <20191218111742.29731-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. Reviewed-by: Cristian Marussi Signed-off-by: Sudeep Holla --- drivers/firmware/arm_scmi/driver.c | 47 ++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) -- 2.17.1 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,