From patchwork Mon Feb 25 06:50:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishali Thakkar X-Patchwork-Id: 159151 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp1697646jad; Sun, 24 Feb 2019 22:51:00 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia+5MdOXoPJC9OEnLPY991p95queSK9fwN0nL5XvqDZ+ynAIndhPhwuBNL4SuVVLlaHoiUN X-Received: by 2002:a17:902:728d:: with SMTP id d13mr5159566pll.12.1551077460201; Sun, 24 Feb 2019 22:51:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551077460; cv=none; d=google.com; s=arc-20160816; b=p4+b8mY4OIOHn8FUc0ERmYvBdWC2eH0HMVC8emhibtBWA28JV79ZsdOyCtHu5UElBB Ly1DPvPoB5zggBCAF63q3iffcdUZbCfKtT564DNPBjt4TnPlHuiWo4HLkkDuFCabkPAV 5LmWFQJr23+BNAh0ec1jFE1olzNeODh9krVPbZqDxwFy6xzI6yn+7044UygJS9Hom2AU cFiR6ysWlI1gw+KJiCXqAvjDfzFoCuvtjzIFPH5BBuO1uR2H7h/LkOF1QvY6IVz+9zl9 85qGutbCbvT/JdcgBYF98tqkdBSp//JS2SK5EBsAFNw0nbWYUByj6iOFd3/Vx/iTL/a6 xs2A== 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:dkim-signature; bh=DlhuYm7lEFT/d5+8ok6R/t5CWe4qZ+5HUIyf9sTH8IM=; b=SjIiTDUVmT+pTXLsLA9O2oZ1rj515GZr77PAVkse5nv9plYCmAhwb64QBLHzsnAC/i YgBJWDvFSn1J5iKvC/0ZUiZFIp82sInNlRizVyo6pENGDf5zo8f9+ob1expNg0bvhklS 7eCGFRHkB2ZmLL2OlCNOUcSuZUMOp4FqgdPfA+lzY0MY1By7yxNpSm7fbvay75423AFG u7IMp5h6OPGVie9YpgnT57wr4bhAcLaeNU2p7SPp8u4iPPHkxy+Tc4CEKEjOPS+WitZ9 lJj14Tz0YeMSFfw9A4w+xI/jSL7hmnqNvM6U/IvlVpSNBSewzD1T7gj65co1KDONA2qd oiig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AP31cvDx; 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 z17si8229943pgv.292.2019.02.24.22.50.59; Sun, 24 Feb 2019 22:51:00 -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; dkim=pass header.i=@linaro.org header.s=google header.b=AP31cvDx; 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 S1728567AbfBYGu6 (ORCPT + 32 others); Mon, 25 Feb 2019 01:50:58 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:36971 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726822AbfBYGu5 (ORCPT ); Mon, 25 Feb 2019 01:50:57 -0500 Received: by mail-pg1-f193.google.com with SMTP id q206so4030771pgq.4 for ; Sun, 24 Feb 2019 22:50:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DlhuYm7lEFT/d5+8ok6R/t5CWe4qZ+5HUIyf9sTH8IM=; b=AP31cvDx6a8aHKUBN9/qcPrhVapsik3G4yDVdB5n4jAmQRgpMKOR63inTX9fxFiymw Y/wx4J6ydcOD9zPSzVJZ8uXOQRqtRjJzDFtFJtaIOnYhWqG3O3LczbuOe6r2c0EeyDky Dhq90+08IC8Mf7UgY2C2Y8ehdD8r1vj0V76VqMY3BN11X7LK8oXmnpUTvtqaSakTPHvy LbcOFsP19YW6Q3sHI3Wd8MNbRuVg7Tcai5pLOWrztICiaczKMocEsS8ISAZXWUhfn+ct VRdpWnMOoPG1fbz3J1L7HtcE/esU3Ya+6YYpa2EtjAlSPQWSezGx+qJ5SN+NEcmVLcMK 0z3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DlhuYm7lEFT/d5+8ok6R/t5CWe4qZ+5HUIyf9sTH8IM=; b=sm4xKWqaIay8VqlyicjwEHFhGGhh0fbsBosLASovNpb+eWfJtHT+LHws3M3jnnKy3i pWtyTonqc+R/P2lGyV5oJQyZxfcYtHTix4UZqIlzA/A3t9dMTsxz6/Yt8gEOJPiENroB vj5FfK2hoErWppFk3RLdU0C2YHttUH7Xnu7PRjJHO0O7OCtVq4VgrdrPv0YOzrGkPt0M hAgHN7KqPfea34iVDRgj7l3FHsAzeCAL06CEodbgzO0KDrpbcyTs5JBXsxoP3l5enL+m OxwB30dNMihnwpzXg1KWIJnIUxFPYKLAMlcLOeOScXmWPqC9NIudV/5uO8l5SxKB/yZm YzHg== X-Gm-Message-State: AHQUAuZzZM1cFwWwFOMbjmH+p0tmurSZjlPfKboBAVH3ix04HeUDKl5u PWuAQgJHYA3UBWqdVauHExc+uA== X-Received: by 2002:a63:6bc6:: with SMTP id g189mr17761292pgc.427.1551077456778; Sun, 24 Feb 2019 22:50:56 -0800 (PST) Received: from localhost.localdomain ([116.75.87.120]) by smtp.gmail.com with ESMTPSA id f16sm9990021pgg.20.2019.02.24.22.50.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 22:50:56 -0800 (PST) From: Vaishali Thakkar To: andy.gross@linaro.org Cc: david.brown@linaro.org, gregkh@linuxfoundation.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, rafael@kernel.org, bjorn.andersson@linaro.org, vkoul@kernel.org, Vaishali Thakkar Subject: [PATCH v4 1/5] base: soc: Add serial_number attribute to soc Date: Mon, 25 Feb 2019 12:20:40 +0530 Message-Id: <20190225065044.11023-2-vaishali.thakkar@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190225065044.11023-1-vaishali.thakkar@linaro.org> References: <20190225065044.11023-1-vaishali.thakkar@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bjorn Andersson Add new attribute named "serial_number" as a standard interface for user space to acquire the serial number of the device. For ST-Ericsson SoCs this is exposed by the cryptically named "soc_id" attribute, but this provides a human readable standardized name for this property. Signed-off-by: Bjorn Andersson Signed-off-by: Vaishali Thakkar Reviewed-by: Greg Kroah-Hartman --- Changes since v3: - Add Greg's Reviewed-by Changes since v2: - None Changes since v1: - Make comment more clear for the case when serial number is not available --- Documentation/ABI/testing/sysfs-devices-soc | 7 +++++++ drivers/base/soc.c | 7 +++++++ include/linux/sys_soc.h | 1 + 3 files changed, 15 insertions(+) -- 2.17.1 diff --git a/Documentation/ABI/testing/sysfs-devices-soc b/Documentation/ABI/testing/sysfs-devices-soc index 6d9cc253f2b2..ba3a3fac0ee1 100644 --- a/Documentation/ABI/testing/sysfs-devices-soc +++ b/Documentation/ABI/testing/sysfs-devices-soc @@ -26,6 +26,13 @@ Description: Read-only attribute common to all SoCs. Contains SoC family name (e.g. DB8500). +What: /sys/devices/socX/serial_number +Date: January 2019 +contact: Bjorn Andersson +Description: + Read-only attribute supported by most SoCs. Contains the SoC's + serial number, if available. + What: /sys/devices/socX/soc_id Date: January 2012 contact: Lee Jones diff --git a/drivers/base/soc.c b/drivers/base/soc.c index 10b280f30217..b0933b9fe67f 100644 --- a/drivers/base/soc.c +++ b/drivers/base/soc.c @@ -33,6 +33,7 @@ static struct bus_type soc_bus_type = { static DEVICE_ATTR(machine, S_IRUGO, soc_info_get, NULL); static DEVICE_ATTR(family, S_IRUGO, soc_info_get, NULL); +static DEVICE_ATTR(serial_number, S_IRUGO, soc_info_get, NULL); static DEVICE_ATTR(soc_id, S_IRUGO, soc_info_get, NULL); static DEVICE_ATTR(revision, S_IRUGO, soc_info_get, NULL); @@ -57,6 +58,9 @@ static umode_t soc_attribute_mode(struct kobject *kobj, if ((attr == &dev_attr_revision.attr) && (soc_dev->attr->revision != NULL)) return attr->mode; + if ((attr == &dev_attr_serial_number.attr) + && (soc_dev->attr->serial_number != NULL)) + return attr->mode; if ((attr == &dev_attr_soc_id.attr) && (soc_dev->attr->soc_id != NULL)) return attr->mode; @@ -77,6 +81,8 @@ static ssize_t soc_info_get(struct device *dev, return sprintf(buf, "%s\n", soc_dev->attr->family); if (attr == &dev_attr_revision) return sprintf(buf, "%s\n", soc_dev->attr->revision); + if (attr == &dev_attr_serial_number) + return sprintf(buf, "%s\n", soc_dev->attr->serial_number); if (attr == &dev_attr_soc_id) return sprintf(buf, "%s\n", soc_dev->attr->soc_id); @@ -87,6 +93,7 @@ static ssize_t soc_info_get(struct device *dev, static struct attribute *soc_attr[] = { &dev_attr_machine.attr, &dev_attr_family.attr, + &dev_attr_serial_number.attr, &dev_attr_soc_id.attr, &dev_attr_revision.attr, NULL, diff --git a/include/linux/sys_soc.h b/include/linux/sys_soc.h index bed223b70217..2a13bc033bd6 100644 --- a/include/linux/sys_soc.h +++ b/include/linux/sys_soc.h @@ -12,6 +12,7 @@ struct soc_device_attribute { const char *machine; const char *family; const char *revision; + const char *serial_number; const char *soc_id; const void *data; }; From patchwork Mon Feb 25 06:50:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishali Thakkar X-Patchwork-Id: 159153 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp1697734jad; Sun, 24 Feb 2019 22:51:09 -0800 (PST) X-Google-Smtp-Source: AHgI3IbJTMnl3lSHpfBl448NcNPRPJxopyhOA71fmTl0JLaO5sWKH5O9vyXV54l/582Pba901ZE5 X-Received: by 2002:a63:1746:: with SMTP id 6mr10799678pgx.127.1551077468914; Sun, 24 Feb 2019 22:51:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551077468; cv=none; d=google.com; s=arc-20160816; b=TrDTcbvP7VTZKBqUo4UB3facEJhMFN/byVRSiymOg8g+M3tJJA6lQMqI+LsHDeBsAq 7aazE5BAXDkyYfAtvMUTSP4SiEJ30h5wlgG2cPAo2B4Z3MK11uUIqLmweOQ1hNs/0iz6 1XM5euVNb7e+ELDQSplfX9JSjLZbOEPgfk9Ufl+CXMDNgTm9Sgs9P1XzUJpg6cjrdAiS HExq5O98WuMsDPkeHKFb0wIv7+NfY6Rah6R8lx4FIPe1V1X7FT5OI8tpKzs13IiZg3z8 Tgp76AyTEiN6hyCYhrWGyauTeOTSSKmH6iytczvGJ14r/cDl0Vwp9xOCiFMYdx2DJuKv Rs5g== 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:dkim-signature; bh=RhUKT30yUKIdkg9qgg6wCX7+ac0RIeVucNnuN6jjtLg=; b=MP1RaysCIhukoupnmz/h1XtQo3HvI9sY0SHLVIwVYDgaOrCPikPUbyIGBu+ndqR/W4 Sn7EFbwEIVAUUCgQzqQPMqr2yckH2ZUc23/MS5ZxOx2Fm4SktaYzSSckfvSGBuZL8S+H 0O0st4aAga9kuzoZggjHajGCyvK/CFk9vll9zA8WNsl9zCOvdZuQSKMOgt7wyOw+UaTp FGLdha1OlGRFjDSTwJrwd28+RibCKA0crA2Fw3rX6R+j0ibU27ToTU7doKlOevTGRUbr 4guIN97OFAX0r82hMXBHavMbSaev8plcik8AwEOvo4XNDTK94Ijm3llGM5inN9shZ5tn cmqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kRrL78XP; 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 i9si8108080pgs.156.2019.02.24.22.51.08; Sun, 24 Feb 2019 22:51:08 -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; dkim=pass header.i=@linaro.org header.s=google header.b=kRrL78XP; 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 S1728633AbfBYGvH (ORCPT + 32 others); Mon, 25 Feb 2019 01:51:07 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:46141 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728599AbfBYGvG (ORCPT ); Mon, 25 Feb 2019 01:51:06 -0500 Received: by mail-pl1-f196.google.com with SMTP id c17so852554plz.13 for ; Sun, 24 Feb 2019 22:51:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RhUKT30yUKIdkg9qgg6wCX7+ac0RIeVucNnuN6jjtLg=; b=kRrL78XPA3pMG0mjD1i5VeUWLX23WFJeUPXDlzUbFpgo8jBPkyBJdGoXAEMa58Tww4 WMRuBqDEuCInrzO0E7PMpQPiI/ix3c7W4B3PFME2cBhHr8fB8xAQebRJNoo6284z0xP4 pfHg1vwmDbFu2/hwo46mlHWNUXz3UPN97Rm5qOy3iYjpWNq2qLckwzMY27MvwKtoRiTc SUK4cZIvCNgP5rcMo/NmHhw8ZUGmm36YbUvlPmllDH/gCI5HOMRvj3nbWnSHI9hpGJjv +you5rgZpdg+qdJ2ZcMkGRq1WTlaG+cVWKrGsmUN3rIoaGEqfM8uPM9p2sKM9rYMMmph 8LCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RhUKT30yUKIdkg9qgg6wCX7+ac0RIeVucNnuN6jjtLg=; b=clmQDnCBV/0upuS6JKjTWz0Lu15siJjmbDDirlkCmrz1s2aGu+kzkUiHpC/PLutONF HNDJrTy1aZFpILvttHnYLbIa8yMAs27PR1KGnDCb/VXBLRaQi5WuIB8Akg5aT7ZNihf6 rHPp4B65h5G/Yc5YNIOvOxQDPxKRUK4jGryoXmD9wmgG+H0YijrLByVPD1zv0hPjO+xD lF2FeB/VgspB4+QMrc4m3d+vKXoIqh8zaHI7QkTZ2cXfGiUei6sav8RUxzxAFAuJH7BF itOX1Zcq1LMSE2jSehFwdj8euZcp7aByDIdl355nBPN7Tw9vse7wKD6lz40ndPjnfQHm ndgA== X-Gm-Message-State: AHQUAua5pQCimciCkbPAJoBiwqzUYxFnjHTVcCtwhCPLH+8I6bYg4FBq +gfo1j5y5nQ9YoTQd3UfpOTzVg== X-Received: by 2002:a17:902:a03:: with SMTP id 3mr18841389plo.112.1551077465855; Sun, 24 Feb 2019 22:51:05 -0800 (PST) Received: from localhost.localdomain ([116.75.87.120]) by smtp.gmail.com with ESMTPSA id f16sm9990021pgg.20.2019.02.24.22.51.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 22:51:05 -0800 (PST) From: Vaishali Thakkar To: andy.gross@linaro.org Cc: david.brown@linaro.org, gregkh@linuxfoundation.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, rafael@kernel.org, bjorn.andersson@linaro.org, vkoul@kernel.org, Imran Khan , Vaishali Thakkar Subject: [PATCH v4 3/5] soc: qcom: Add socinfo driver Date: Mon, 25 Feb 2019 12:20:42 +0530 Message-Id: <20190225065044.11023-4-vaishali.thakkar@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190225065044.11023-1-vaishali.thakkar@linaro.org> References: <20190225065044.11023-1-vaishali.thakkar@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Imran Khan The Qualcomm socinfo driver exposes information about the SoC, its version and its serial number to user space. Signed-off-by: Imran Khan [Bjorn: Extract code to platform_driver, split patch in multiple] Signed-off-by: Bjorn Andersson [Vaishali: Simplify declarations, introduce qcom_socinfo struc, Fix memory leak, Remove extra code and Misc code refactoring] Signed-off-by: Vaishali Thakkar --- Changes since v3: - None Changes since v2: - Fix typo in the work log under signed off by s Changes since v1: - None --- drivers/soc/qcom/Kconfig | 8 ++ drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/smem.c | 8 ++ drivers/soc/qcom/socinfo.c | 197 +++++++++++++++++++++++++++++++++++++ 4 files changed, 214 insertions(+) create mode 100644 drivers/soc/qcom/socinfo.c -- 2.17.1 diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index fcbf8a2e4080..1e31eda07934 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -144,6 +144,14 @@ config QCOM_SMSM Say yes here to support the Qualcomm Shared Memory State Machine. The state machine is represented by bits in shared memory. +config QCOM_SOCINFO + tristate "Qualcomm socinfo driver" + depends on QCOM_SMEM + select SOC_BUS + help + Say yes here to support the Qualcomm socinfo driver, providing + information about the SoC to user space. + config QCOM_WCNSS_CTRL tristate "Qualcomm WCNSS control driver" depends on ARCH_QCOM || COMPILE_TEST diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile index f25b54cd6cf8..c817da4f4140 100644 --- a/drivers/soc/qcom/Makefile +++ b/drivers/soc/qcom/Makefile @@ -14,6 +14,7 @@ qcom_rpmh-y += rpmh-rsc.o qcom_rpmh-y += rpmh.o obj-$(CONFIG_QCOM_SMD_RPM) += smd-rpm.o obj-$(CONFIG_QCOM_SMEM) += smem.o +obj-$(CONFIG_QCOM_SOCINFO) += socinfo.o obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o obj-$(CONFIG_QCOM_SMP2P) += smp2p.o obj-$(CONFIG_QCOM_SMSM) += smsm.o diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index f80d040601fd..efe0b053ef82 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -276,6 +276,7 @@ struct qcom_smem { struct smem_partition_header *partitions[SMEM_HOST_COUNT]; size_t cacheline[SMEM_HOST_COUNT]; u32 item_count; + struct platform_device *socinfo; unsigned num_regions; struct smem_region regions[]; @@ -971,11 +972,18 @@ static int qcom_smem_probe(struct platform_device *pdev) __smem = smem; + smem->socinfo = platform_device_register_data(&pdev->dev, "qcom-socinfo", + PLATFORM_DEVID_NONE, NULL, + 0); + if (IS_ERR(smem->socinfo)) + dev_err(&pdev->dev, "failed to register socinfo device\n"); + return 0; } static int qcom_smem_remove(struct platform_device *pdev) { + hwspin_lock_free(__smem->hwlock); __smem = NULL; diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c new file mode 100644 index 000000000000..02078049fac7 --- /dev/null +++ b/drivers/soc/qcom/socinfo.c @@ -0,0 +1,197 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2009-2017, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2019, Linaro Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * SoC version type with major number in the upper 16 bits and minor + * number in the lower 16 bits. + */ +#define SOCINFO_MAJOR(ver) (((ver) >> 16) & 0xffff) +#define SOCINFO_MINOR(ver) ((ver) & 0xffff) + +#define SMEM_SOCINFO_BUILD_ID_LENGTH 32 + +/* + * SMEM item ids, used to acquire handles to respective + * SMEM region. + */ +#define SMEM_HW_SW_BUILD_ID 137 + +/* Socinfo SMEM item structure */ +struct socinfo { + __le32 fmt; + __le32 id; + __le32 ver; + char build_id[SMEM_SOCINFO_BUILD_ID_LENGTH]; + /* Version 2 */ + __le32 raw_id; + __le32 raw_ver; + /* Version 3 */ + __le32 hw_plat; + /* Version 4 */ + __le32 plat_ver; + /* Version 5 */ + __le32 accessory_chip; + /* Version 6 */ + __le32 hw_plat_subtype; + /* Version 7 */ + __le32 pmic_model; + __le32 pmic_die_rev; + /* Version 8 */ + __le32 pmic_model_1; + __le32 pmic_die_rev_1; + __le32 pmic_model_2; + __le32 pmic_die_rev_2; + /* Version 9 */ + __le32 foundry_id; + /* Version 10 */ + __le32 serial_num; + /* Version 11 */ + __le32 num_pmics; + __le32 pmic_array_offset; + /* Version 12 */ + __le32 chip_family; + __le32 raw_device_family; + __le32 raw_device_num; +}; + +struct qcom_socinfo { + struct soc_device *soc_dev; + struct soc_device_attribute attr; +}; + +struct soc_of_id { + unsigned int id; + const char *name; +}; + +static const struct soc_of_id soc_of_id[] = { + {87, "MSM8960"}, + {109, "APQ8064"}, + {122, "MSM8660A"}, + {123, "MSM8260A"}, + {124, "APQ8060A"}, + {126, "MSM8974"}, + {130, "MPQ8064"}, + {138, "MSM8960AB"}, + {139, "APQ8060AB"}, + {140, "MSM8260AB"}, + {141, "MSM8660AB"}, + {178, "APQ8084"}, + {184, "APQ8074"}, + {185, "MSM8274"}, + {186, "MSM8674"}, + {194, "MSM8974PRO"}, + {206, "MSM8916"}, + {208, "APQ8074-AA"}, + {209, "APQ8074-AB"}, + {210, "APQ8074PRO"}, + {211, "MSM8274-AA"}, + {212, "MSM8274-AB"}, + {213, "MSM8274PRO"}, + {214, "MSM8674-AA"}, + {215, "MSM8674-AB"}, + {216, "MSM8674PRO"}, + {217, "MSM8974-AA"}, + {218, "MSM8974-AB"}, + {246, "MSM8996"}, + {247, "APQ8016"}, + {248, "MSM8216"}, + {249, "MSM8116"}, + {250, "MSM8616"}, + {291, "APQ8096"}, + {305, "MSM8996SG"}, + {310, "MSM8996AU"}, + {311, "APQ8096AU"}, + {312, "APQ8096SG"}, +}; + +static const char *socinfo_machine(struct device *dev, unsigned int id) +{ + int idx; + + for (idx = 0; idx < ARRAY_SIZE(soc_of_id); idx++) { + if (soc_of_id[idx].id == id) + return soc_of_id[idx].name; + } + + if (IS_ERR(soc_of_id[idx].name)) + dev_err(dev, "Unknown soc id\n"); + + return NULL; +} + +static int qcom_socinfo_probe(struct platform_device *pdev) +{ + struct qcom_socinfo *qs; + struct socinfo *info; + size_t item_size; + + info = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_HW_SW_BUILD_ID, + &item_size); + if (IS_ERR(info)) { + dev_err(&pdev->dev, "Couldn't find socinfo\n"); + return -EINVAL; + } + + qs = devm_kzalloc(&pdev->dev, sizeof(*qs), GFP_KERNEL); + if (!qs) + return -ENOMEM; + + qs->attr.family = "Snapdragon"; + qs->attr.machine = socinfo_machine(&pdev->dev, + le32_to_cpu(info->id)); + qs->attr.revision = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%u.%u", + SOCINFO_MAJOR(le32_to_cpu(info->ver)), + SOCINFO_MINOR(le32_to_cpu(info->ver))); + if (le32_to_cpu(info->fmt) >= 10) + qs->attr.serial_number = devm_kasprintf(&pdev->dev, GFP_KERNEL, + "%u", + le32_to_cpu(info->serial_num)); + + qs->soc_dev = soc_device_register(&qs->attr); + if (IS_ERR(qs->soc_dev)) + return PTR_ERR(qs->soc_dev); + + /* Feed the soc specific unique data into entropy pool */ + add_device_randomness(info, item_size); + + platform_set_drvdata(pdev, qs->soc_dev); + + return 0; +} + +static int qcom_socinfo_remove(struct platform_device *pdev) +{ + struct qcom_socinfo *qs = platform_get_drvdata(pdev); + + soc_device_unregister(qs->soc_dev); + + return 0; +} + +static struct platform_driver qcom_socinfo_driver = { + .probe = qcom_socinfo_probe, + .remove = qcom_socinfo_remove, + .driver = { + .name = "qcom-socinfo", + }, +}; + +module_platform_driver(qcom_socinfo_driver); + +MODULE_DESCRIPTION("Qualcomm socinfo driver"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:qcom-socinfo"); From patchwork Mon Feb 25 06:50:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishali Thakkar X-Patchwork-Id: 159154 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp1697785jad; Sun, 24 Feb 2019 22:51:13 -0800 (PST) X-Google-Smtp-Source: AHgI3IZE3uemIPvbi/HUZvxAAOP740BNGZp3Q73G5UcvIqnYb8QDWy/PxvERpO/gZNJytSJlDwH4 X-Received: by 2002:a63:f07:: with SMTP id e7mr17628068pgl.173.1551077473180; Sun, 24 Feb 2019 22:51:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551077473; cv=none; d=google.com; s=arc-20160816; b=OoVxBw1AVY/S0ZoDjYRAS7wW86bvEfRqMjvMGXDMrgqRDwoPs76rTbEiNyJ+92HEvR ljU3M5FuzibbcmUbRrdjZgOz/4Xr/kcA5qXI4ByIjomJVwDeeohxyxsbNX1H8MO8jzff 7iYCh9gDUAEpa+f/gUf9JlxsMt3ULQTEz4zWfCPmk2yyuIDj+INNlMF4rLQ52vMzmjfi VhPNKemGLdRYOQKWvcS4n4TmIed5k9C6qzl59bc9A1APATDV2IsfGDnEC+xeJMjXRSTn aMXyv2g+qw2koHWa6PVRlNq060ibQPPl2wIiWbrggjWBK8hPG7ZBdmxHJ4e+SPPpDLGj +zzg== 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:dkim-signature; bh=WgMiTupxL1h7FFD3rtr3bGCDzKlQIo5tIk2sc+S1nSg=; b=EYSmka1TkIr/1G7/k0lEB9YM0+PfQ0uVOv5ibPLc6fmE4XZ0CKmXcrQgG7RqK27JkV fouQXg6p4jQwjFg98a7sp8MlPh7KWHrjpqwXdV6O8goJ9GD/4PJKcC7RMl0qgsxsdSDk oIU+Cyf5uWuzN6Plh2kANbVLR/HRxHoBh0kbqyl21DOCRGFnC/OP+BxLFuOrdmLHM7rK aaE3qBaRTnNwfnIqHYJiLJ80U9aE96V8L93bXpNW+tthDdIRfHV+bibUFKDbRF5QSIbJ sNZfOVSjnHvKdtfAoEFc5rLXABXCKWNaKyCTQHx3wJGETT7CnrvH2oKioTkbhvBLhPUY 48/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FdO1DHFN; 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 i9si8108080pgs.156.2019.02.24.22.51.12; Sun, 24 Feb 2019 22:51:13 -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; dkim=pass header.i=@linaro.org header.s=google header.b=FdO1DHFN; 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 S1728653AbfBYGvL (ORCPT + 32 others); Mon, 25 Feb 2019 01:51:11 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:38896 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728599AbfBYGvK (ORCPT ); Mon, 25 Feb 2019 01:51:10 -0500 Received: by mail-pl1-f193.google.com with SMTP id g37so1223380plb.5 for ; Sun, 24 Feb 2019 22:51:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WgMiTupxL1h7FFD3rtr3bGCDzKlQIo5tIk2sc+S1nSg=; b=FdO1DHFNOnygWfF55GpRHTpUNEuHzrQ9OEo1DmmVJ4gvci3exQZ+qNNK1GCUHwL5s1 L199Vx3ivwsAU4suYq/y7GW52YJzDHtp7sHD8YP1odjX3gp2fU5pAm8U3mRtm9HJNRVD gOVi4o6QC0wA9cHmKK98C4CD6cG279MWkZPurqNe5+i+a3QsbWrgBvip+JDPL9o4SoNT 2d1IzFvJP+TOBLS5uABsNy/D5hECFBDirqoayX83iRqWuuoEbCs5iKD8NT3JLoAvLoRh fUb5nJgOt/h3BR5bdn2vh9ozDQJh1av4SUNbAbl2fGLbzLmd7rVSNgHCaQHZGkDybH4y niyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WgMiTupxL1h7FFD3rtr3bGCDzKlQIo5tIk2sc+S1nSg=; b=GiSGs506GUw250gwgfux6xEEnFlG3JGf7iuZR69csCRUHFx1vwsiK3eklLI6UGAnAB WYg5VbIqueBf9mr669btf/ysaHyGcAG4ksEIgGUR2Q+273x018ha3UFsn0NuSVbOjvuL q18z7mrg2yDXCwIC8KppMvVDqe5HquRm+cTv1i/mH7H1L02SJKXOuY5zZDd+C8Zlkfst bKdaN+53A1FtFptxQcukRsLf6I86zsSqMpfdEL3klNydJxwvhoQCXfCns7dfuCPKn/zV fRii3ELqh6VwlaQX1Eg9VQjQlK4UIw6/uo2lWT3qIwE3jF4oKzYUDuWePYM51MOs8ORC YarA== X-Gm-Message-State: AHQUAuaMbkqDV1o7D5uj23i4OrhQ2Lsrm6xo6pQdxlMbJ+YUG9wi3yt8 rXnKG7CiQ4OGgX1pONzuYXPRMg== X-Received: by 2002:a17:902:33c1:: with SMTP id b59mr18560941plc.220.1551077469814; Sun, 24 Feb 2019 22:51:09 -0800 (PST) Received: from localhost.localdomain ([116.75.87.120]) by smtp.gmail.com with ESMTPSA id f16sm9990021pgg.20.2019.02.24.22.51.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 22:51:09 -0800 (PST) From: Vaishali Thakkar To: andy.gross@linaro.org Cc: david.brown@linaro.org, gregkh@linuxfoundation.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, rafael@kernel.org, bjorn.andersson@linaro.org, vkoul@kernel.org, Vaishali Thakkar Subject: [PATCH v4 4/5] soc: qcom: socinfo: Expose custom attributes Date: Mon, 25 Feb 2019 12:20:43 +0530 Message-Id: <20190225065044.11023-5-vaishali.thakkar@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190225065044.11023-1-vaishali.thakkar@linaro.org> References: <20190225065044.11023-1-vaishali.thakkar@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The Qualcomm socinfo provides a number of additional attributes, add these to the socinfo driver and expose them via debugfs functionality. Signed-off-by: Vaishali Thakkar --- Changes since v3: - Fix compilation error in function signatures when debugfs is disabled Changes since v2: - None Changes since v1: - Remove unnecessary debugfs dir creation check - Align ifdefs to left - Fix function signatures for debugfs init/exit --- drivers/soc/qcom/socinfo.c | 198 +++++++++++++++++++++++++++++++++++++ 1 file changed, 198 insertions(+) -- 2.17.1 diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c index 02078049fac7..ccadeba69a81 100644 --- a/drivers/soc/qcom/socinfo.c +++ b/drivers/soc/qcom/socinfo.c @@ -4,6 +4,7 @@ * Copyright (c) 2017-2019, Linaro Ltd. */ +#include #include #include #include @@ -29,6 +30,28 @@ */ #define SMEM_HW_SW_BUILD_ID 137 +#ifdef CONFIG_DEBUG_FS +/* pmic model info */ +static const char *const pmic_model[] = { + [0] = "Unknown PMIC model", + [9] = "PM8994", + [11] = "PM8916", + [13] = "PM8058", + [14] = "PM8028", + [15] = "PM8901", + [16] = "PM8027", + [17] = "ISL9519", + [18] = "PM8921", + [19] = "PM8018", + [20] = "PM8015", + [21] = "PM8014", + [22] = "PM8821", + [23] = "PM8038", + [24] = "PM8922", + [25] = "PM8917", +}; +#endif /* CONFIG_DEBUG_FS */ + /* Socinfo SMEM item structure */ struct socinfo { __le32 fmt; @@ -70,6 +93,10 @@ struct socinfo { struct qcom_socinfo { struct soc_device *soc_dev; struct soc_device_attribute attr; +#ifdef CONFIG_DEBUG_FS + struct dentry *dbg_root; +#endif /* CONFIG_DEBUG_FS */ + struct socinfo *socinfo; }; struct soc_of_id { @@ -133,6 +160,171 @@ static const char *socinfo_machine(struct device *dev, unsigned int id) return NULL; } +#ifdef CONFIG_DEBUG_FS + +#define UINT_SHOW(name, attr) \ +static int qcom_show_##name(struct seq_file *seq, void *p) \ +{ \ + struct socinfo *socinfo = seq->private; \ + seq_printf(seq, "%u\n", le32_to_cpu(socinfo->attr)); \ + return 0; \ +} \ +static int qcom_open_##name(struct inode *inode, struct file *file) \ +{ \ + return single_open(file, qcom_show_##name, inode->i_private); \ +} \ + \ +static const struct file_operations qcom_ ##name## _ops = { \ + .open = qcom_open_##name, \ + .read = seq_read, \ + .llseek = seq_lseek, \ + .release = single_release, \ +} + +#define DEBUGFS_UINT_ADD(name) \ + debugfs_create_file(__stringify(name), 0400, \ + qcom_socinfo->dbg_root, \ + qcom_socinfo->socinfo, &qcom_ ##name## _ops) + +#define HEX_SHOW(name, attr) \ +static int qcom_show_##name(struct seq_file *seq, void *p) \ +{ \ + struct socinfo *socinfo = seq->private; \ + seq_printf(seq, "0x%x\n", le32_to_cpu(socinfo->attr)); \ + return 0; \ +} \ +static int qcom_open_##name(struct inode *inode, struct file *file) \ +{ \ + return single_open(file, qcom_show_##name, inode->i_private); \ +} \ + \ +static const struct file_operations qcom_ ##name## _ops = { \ + .open = qcom_open_##name, \ + .read = seq_read, \ + .llseek = seq_lseek, \ + .release = single_release, \ +} + +#define DEBUGFS_HEX_ADD(name) \ + debugfs_create_file(__stringify(name), 0400, \ + qcom_socinfo->dbg_root, \ + qcom_socinfo->socinfo, &qcom_ ##name## _ops) + + +#define QCOM_OPEN(name, _func) \ +static int qcom_open_##name(struct inode *inode, struct file *file) \ +{ \ + return single_open(file, _func, inode->i_private); \ +} \ + \ +static const struct file_operations qcom_ ##name## _ops = { \ + .open = qcom_open_##name, \ + .read = seq_read, \ + .llseek = seq_lseek, \ + .release = single_release, \ +} + +#define DEBUGFS_ADD(name) \ + debugfs_create_file(__stringify(name), 0400, \ + qcom_socinfo->dbg_root, \ + qcom_socinfo->socinfo, &qcom_ ##name## _ops) + + +static int qcom_show_build_id(struct seq_file *seq, void *p) +{ + struct socinfo *socinfo = seq->private; + + seq_printf(seq, "%s\n", socinfo->build_id); + + return 0; +} + +static int qcom_show_accessory_chip(struct seq_file *seq, void *p) +{ + struct socinfo *socinfo = seq->private; + + seq_printf(seq, "%d\n", le32_to_cpu(socinfo->accessory_chip)); + + return 0; +} + +static int qcom_show_platform_subtype(struct seq_file *seq, void *p) +{ + struct socinfo *socinfo = seq->private; + int subtype = le32_to_cpu(socinfo->hw_plat_subtype); + + if (subtype < 0) + return -EINVAL; + + seq_printf(seq, "%u\n", subtype); + + return 0; +} + +static int qcom_show_pmic_model(struct seq_file *seq, void *p) +{ + struct socinfo *socinfo = seq->private; + int model = SOCINFO_MINOR(le32_to_cpu(socinfo->pmic_model)); + + if (model < 0) + return -EINVAL; + + seq_printf(seq, "%s\n", pmic_model[model]); + + return 0; +} + +static int qcom_show_pmic_die_revision(struct seq_file *seq, void *p) +{ + struct socinfo *socinfo = seq->private; + + seq_printf(seq, "%u.%u\n", + SOCINFO_MAJOR(le32_to_cpu(socinfo->pmic_die_rev)), + SOCINFO_MINOR(le32_to_cpu(socinfo->pmic_die_rev))); + + return 0; +} + +UINT_SHOW(raw_version, raw_ver); +UINT_SHOW(hardware_platform, hw_plat); +UINT_SHOW(platform_version, plat_ver); +UINT_SHOW(foundry_id, foundry_id); +HEX_SHOW(chip_family, chip_family); +HEX_SHOW(raw_device_family, raw_device_family); +HEX_SHOW(raw_device_number, raw_device_num); +QCOM_OPEN(build_id, qcom_show_build_id); +QCOM_OPEN(accessory_chip, qcom_show_accessory_chip); +QCOM_OPEN(pmic_model, qcom_show_pmic_model); +QCOM_OPEN(platform_subtype, qcom_show_platform_subtype); +QCOM_OPEN(pmic_die_revision, qcom_show_pmic_die_revision); + +static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo) +{ + qcom_socinfo->dbg_root = debugfs_create_dir("qcom_socinfo", NULL); + + DEBUGFS_UINT_ADD(raw_version); + DEBUGFS_UINT_ADD(hardware_platform); + DEBUGFS_UINT_ADD(platform_version); + DEBUGFS_UINT_ADD(foundry_id); + DEBUGFS_HEX_ADD(chip_family); + DEBUGFS_HEX_ADD(raw_device_family); + DEBUGFS_HEX_ADD(raw_device_number); + DEBUGFS_ADD(build_id); + DEBUGFS_ADD(accessory_chip); + DEBUGFS_ADD(pmic_model); + DEBUGFS_ADD(platform_subtype); + DEBUGFS_ADD(pmic_die_revision); +} + +static void socinfo_debugfs_exit(struct qcom_socinfo *qcom_socinfo) +{ + debugfs_remove_recursive(qcom_socinfo->dbg_root); +} +#else +static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo) { } +static void socinfo_debugfs_exit(struct qcom_socinfo *qcom_socinfo) { } +#endif /* CONFIG_DEBUG_FS */ + static int qcom_socinfo_probe(struct platform_device *pdev) { struct qcom_socinfo *qs; @@ -165,6 +357,10 @@ static int qcom_socinfo_probe(struct platform_device *pdev) if (IS_ERR(qs->soc_dev)) return PTR_ERR(qs->soc_dev); + qs->socinfo = info; + + socinfo_debugfs_init(qs); + /* Feed the soc specific unique data into entropy pool */ add_device_randomness(info, item_size); @@ -179,6 +375,8 @@ static int qcom_socinfo_remove(struct platform_device *pdev) soc_device_unregister(qs->soc_dev); + socinfo_debugfs_exit(qs); + return 0; } From patchwork Mon Feb 25 06:50:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishali Thakkar X-Patchwork-Id: 159155 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp1697862jad; Sun, 24 Feb 2019 22:51:18 -0800 (PST) X-Google-Smtp-Source: AHgI3IbpPxrmg1FJE9DCm9mHfA05OZNGkorfbmMdh+n68SAWgwNDufrWgBEaVeZ0eYqTPF/U5DCB X-Received: by 2002:a17:902:b402:: with SMTP id x2mr18541116plr.53.1551077478436; Sun, 24 Feb 2019 22:51:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551077478; cv=none; d=google.com; s=arc-20160816; b=oFO6SYhSq+YzNcysmhoDXn6dxyHggOfuW2Ar0VxqTPbVHu1lhxxAJgOzx9vp8rp7xC lnBt0M0ITkPYGKAZRHCbG0yOaC/M4PPfHt5GJFkUfQNEy6ppMcKG6gNo/4tJCsb86tWE DAVwcXwnx8mPs7eli2hcqnstbb3aFh052okQj7QHKdf5+/LXXlnevppr3bIQPXGyFS/y K8OFvTTDnAkTzUzL21NttwxHu9jV6wk3DyBWBpXU3p34Nkaik3POSVmNxsK7NY0qWbO2 VrHv6kQ77FjUWCB+CQm2YVKHVSG6G7BoDggV3lEV4XNJUK/AAiwbroZ+nQKQd+NANEnm htjQ== 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:dkim-signature; bh=yTOxTtmZbkPAZtakCDu5P9EEMXa2Aqz4JPWcUR/5qyY=; b=BzN+17XH0ypsxaFIUPwnG3jWQMoIf+uwDhoN8N0azPsYDPCVlQcgWaHO+Jl2yMD8+n cA1a9ctxY97B6zUqbl09RytLxObMawzad6nvp8zAPmcn2NKQrSqS5pmj5BP4q3NXwj8W chp+xomgTRXTMA2eqarUV+Z4mvZceOQx0YrgxNQAygX86gMtQa8B2/ieAB+VtnwrlUs9 hsj63a3nOcWtDkwzNc5jCN6Bw8cMdqGJk9bWnsQpBPF8htN3faEziaPZPVyc6jaTZ1wT HStc6ynoHN3gYkFrvdrqngTk66SJ3P8D5eF+arqortlk0rcytLdbZXqh/HwpD0rBdYya lRbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FWQGMGs8; 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 15si9293575pfv.209.2019.02.24.22.51.17; Sun, 24 Feb 2019 22:51:18 -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; dkim=pass header.i=@linaro.org header.s=google header.b=FWQGMGs8; 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 S1728675AbfBYGvQ (ORCPT + 32 others); Mon, 25 Feb 2019 01:51:16 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:32979 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728658AbfBYGvP (ORCPT ); Mon, 25 Feb 2019 01:51:15 -0500 Received: by mail-pf1-f194.google.com with SMTP id i19so4044740pfd.0 for ; Sun, 24 Feb 2019 22:51:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yTOxTtmZbkPAZtakCDu5P9EEMXa2Aqz4JPWcUR/5qyY=; b=FWQGMGs8Y3rXjHw3vuPjZ6ceklbzhJD4NCuM0R6zeCMACOkrt4KBnYvZmuFT1S2Fp/ DHf0v03Bm6s7h31tGNHo2l1y0g0Inzfwubb6YwUzdU2nf//FBXeblfbfXs0wxjUatOsw SJ+ocbSlHNJVCZmO4aOPEF4aZzNz1GGCqJF4K+cqU/qC5x9vCUW9e2l/z+t2Zt+W8l3v Jk3+cYF3isx7EcsualKxVnAA+UFGH2KRTpUnwQaBqTQlm9MtQXrr3rnt8vvuNvVzMOKP FQdKeqzIVYwt10Hv2iezr3+N6uNY34VfVtqNnHVxB5oVRn5NmBx7i3yjrIyyWZ/pRmBl PWcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=yTOxTtmZbkPAZtakCDu5P9EEMXa2Aqz4JPWcUR/5qyY=; b=oy3wKgI6NtvwevPR0jcyqmVhFQgxDZZ+eLXMM4vEychd3nszUNT7Ppa/mE8J0JP+Ob PELLqkrVSo0WIjStsljW/q+ip+g5O3eTbQh2Dh8d1ZUPDnbWPVG0MpU4pz/3rBeZMvwW /CKJyOKFL7fdEy1cbklPAwUVwZQ2RzX4kmRuq/1zbNng5JxIGK4zQiHALQDtjsqoU9Ov kec9jwPITo62a1RCQbkYuQATIALxpV8YbNh9qOJ1j9eE+/pmCFHdGY6S+vtmqizQswSA 9ls1ROrRHExIeTvKqcNj0bytFLj6Yp9lXyyoZR5MlOuU6swallcHZNRoZyK44aIePjsP 1WsQ== X-Gm-Message-State: AHQUAuZ8gbWN+j9fbMtx4f+ErCNNsphb4tybYk6ddI7r6ZAmkAyEABI7 IudWDkkVRvnkZBOgo336gGjVlw== X-Received: by 2002:a63:f84d:: with SMTP id v13mr17704887pgj.384.1551077474414; Sun, 24 Feb 2019 22:51:14 -0800 (PST) Received: from localhost.localdomain ([116.75.87.120]) by smtp.gmail.com with ESMTPSA id f16sm9990021pgg.20.2019.02.24.22.51.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Feb 2019 22:51:13 -0800 (PST) From: Vaishali Thakkar To: andy.gross@linaro.org Cc: david.brown@linaro.org, gregkh@linuxfoundation.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, rafael@kernel.org, bjorn.andersson@linaro.org, vkoul@kernel.org, Vaishali Thakkar Subject: [PATCH v4 5/5] soc: qcom: socinfo: Expose image information Date: Mon, 25 Feb 2019 12:20:44 +0530 Message-Id: <20190225065044.11023-6-vaishali.thakkar@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190225065044.11023-1-vaishali.thakkar@linaro.org> References: <20190225065044.11023-1-vaishali.thakkar@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The socinfo driver provides information about version of the various images loaded in the system. Expose this to user space for debugging purpose. Signed-off-by: Vaishali Thakkar --- Changes since v3: - Remove extra debugfs directory creation checks Changes since v2: - None Changes since v1: - None --- drivers/soc/qcom/socinfo.c | 178 +++++++++++++++++++++++++++++++++++++ 1 file changed, 178 insertions(+) -- 2.17.1 diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c index ccadeba69a81..5d77265054a3 100644 --- a/drivers/soc/qcom/socinfo.c +++ b/drivers/soc/qcom/socinfo.c @@ -31,6 +31,25 @@ #define SMEM_HW_SW_BUILD_ID 137 #ifdef CONFIG_DEBUG_FS +#define SMEM_IMAGE_VERSION_BLOCKS_COUNT 32 +#define SMEM_IMAGE_VERSION_SIZE 4096 +#define SMEM_IMAGE_VERSION_NAME_SIZE 75 +#define SMEM_IMAGE_VERSION_VARIANT_SIZE 20 +#define SMEM_IMAGE_VERSION_OEM_SIZE 32 + +/* + * SMEM Image table indices + */ +#define SMEM_IMAGE_TABLE_BOOT_INDEX 0 +#define SMEM_IMAGE_TABLE_TZ_INDEX 1 +#define SMEM_IMAGE_TABLE_RPM_INDEX 3 +#define SMEM_IMAGE_TABLE_APPS_INDEX 10 +#define SMEM_IMAGE_TABLE_MPSS_INDEX 11 +#define SMEM_IMAGE_TABLE_ADSP_INDEX 12 +#define SMEM_IMAGE_TABLE_CNSS_INDEX 13 +#define SMEM_IMAGE_TABLE_VIDEO_INDEX 14 +#define SMEM_IMAGE_VERSION_TABLE 469 + /* pmic model info */ static const char *const pmic_model[] = { [0] = "Unknown PMIC model", @@ -90,11 +109,21 @@ struct socinfo { __le32 raw_device_num; }; +#ifdef CONFIG_DEBUG_FS +struct smem_image_version { + char name[SMEM_IMAGE_VERSION_NAME_SIZE]; + char variant[SMEM_IMAGE_VERSION_VARIANT_SIZE]; + char pad; + char oem[SMEM_IMAGE_VERSION_OEM_SIZE]; +}; +#endif /* CONFIG_DEBUG_FS */ + struct qcom_socinfo { struct soc_device *soc_dev; struct soc_device_attribute attr; #ifdef CONFIG_DEBUG_FS struct dentry *dbg_root; + struct dentry *boot, *tz, *rpm, *apps, *mpss, *adsp, *cnss, *video; #endif /* CONFIG_DEBUG_FS */ struct socinfo *socinfo; }; @@ -298,8 +327,97 @@ QCOM_OPEN(pmic_model, qcom_show_pmic_model); QCOM_OPEN(platform_subtype, qcom_show_platform_subtype); QCOM_OPEN(pmic_die_revision, qcom_show_pmic_die_revision); +#define IMAGE_SHOW_NAME(attr) \ +static int show_ ##attr## _name(struct seq_file *seq, void *p) \ +{ \ + struct smem_image_version *image_version = seq->private; \ + seq_puts(seq, image_version->name); \ + seq_puts(seq, "\n"); \ + return 0; \ +} \ +static int open_ ##attr## _name(struct inode *inode, struct file *file) \ +{ \ + return single_open(file, show_ ##attr## _name, inode->i_private); \ +} \ + \ +static const struct file_operations qcom_ ##attr## _name_ops = { \ + .open = open_ ##attr## _name, \ + .read = seq_read, \ + .llseek = seq_lseek, \ + .release = single_release, \ +} \ + +#define DEBUGFS_IMAGE_NAME(fname, attr, index) \ +debugfs_create_file(__stringify(fname), 0400, qcom_socinfo->attr, \ + &smem_image_version[index], &qcom_ ##attr## _name_ops) + +#define IMAGE_SHOW_VARIANT(attr) \ +static int show_ ##attr## _variant(struct seq_file *seq, void *p) \ +{ \ + struct smem_image_version *image_version = seq->private; \ + seq_puts(seq, image_version->variant); \ + seq_puts(seq, "\n"); \ + return 0; \ +} \ +static int open_ ##attr## _variant(struct inode *inode, struct file *file) \ +{ \ + return single_open(file, show_ ##attr## _variant, inode->i_private); \ +} \ + \ +static const struct file_operations qcom_ ##attr## _variant_ops = { \ + .open = open_ ##attr## _variant, \ + .read = seq_read, \ + .llseek = seq_lseek, \ + .release = single_release, \ +} + +#define DEBUGFS_IMAGE_VARIANT(fname, attr, index) \ +debugfs_create_file(__stringify(fname), 0400, qcom_socinfo->attr, \ + &smem_image_version[index], &qcom_ ##attr## _variant_ops) + +#define IMAGE_SHOW_OEM(attr) \ +static int show_ ##attr## _oem(struct seq_file *seq, void *p) \ +{ \ + struct smem_image_version *image_version = seq->private; \ + seq_puts(seq, image_version->oem); \ + seq_puts(seq, "\n"); \ + return 0; \ +} \ +static int open_ ##attr## _oem(struct inode *inode, struct file *file) \ +{ \ + return single_open(file, show_ ##attr## _oem, inode->i_private); \ +} \ + \ +static const struct file_operations qcom_ ##attr## _oem_ops = { \ + .open = open_ ##attr## _oem, \ + .read = seq_read, \ + .llseek = seq_lseek, \ + .release = single_release, \ +} + +#define DEBUGFS_IMAGE_OEM(fname, attr, index) \ +debugfs_create_file(__stringify(fname), 0400, qcom_socinfo->attr, \ + &smem_image_version[index], &qcom_ ##attr## _oem_ops) + +#define IMAGE_SHOW(name) \ + IMAGE_SHOW_NAME(name); \ + IMAGE_SHOW_VARIANT(name); \ + IMAGE_SHOW_OEM(name) \ + +IMAGE_SHOW(boot); +IMAGE_SHOW(tz); +IMAGE_SHOW(rpm); +IMAGE_SHOW(apps); +IMAGE_SHOW(mpss); +IMAGE_SHOW(adsp); +IMAGE_SHOW(cnss); +IMAGE_SHOW(video); + static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo) { + struct smem_image_version *smem_image_version; + size_t size; + qcom_socinfo->dbg_root = debugfs_create_dir("qcom_socinfo", NULL); DEBUGFS_UINT_ADD(raw_version); @@ -314,6 +432,66 @@ static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo) DEBUGFS_ADD(pmic_model); DEBUGFS_ADD(platform_subtype); DEBUGFS_ADD(pmic_die_revision); + + smem_image_version = qcom_smem_get(QCOM_SMEM_HOST_ANY, + SMEM_IMAGE_VERSION_TABLE, + &size); + + qcom_socinfo->boot = debugfs_create_dir("boot", + qcom_socinfo->dbg_root); + + DEBUGFS_IMAGE_NAME(name, boot, SMEM_IMAGE_TABLE_BOOT_INDEX); + DEBUGFS_IMAGE_VARIANT(variant, boot, SMEM_IMAGE_TABLE_BOOT_INDEX); + DEBUGFS_IMAGE_OEM(oem, boot, SMEM_IMAGE_TABLE_BOOT_INDEX); + + qcom_socinfo->tz = debugfs_create_dir("tz", + qcom_socinfo->dbg_root); + + DEBUGFS_IMAGE_NAME(name, tz, SMEM_IMAGE_TABLE_TZ_INDEX); + DEBUGFS_IMAGE_VARIANT(variant, tz, SMEM_IMAGE_TABLE_TZ_INDEX); + DEBUGFS_IMAGE_OEM(oem, tz, SMEM_IMAGE_TABLE_TZ_INDEX); + + qcom_socinfo->rpm = debugfs_create_dir("rpm", + qcom_socinfo->dbg_root); + + DEBUGFS_IMAGE_NAME(name, rpm, SMEM_IMAGE_TABLE_RPM_INDEX); + DEBUGFS_IMAGE_VARIANT(variant, rpm, SMEM_IMAGE_TABLE_RPM_INDEX); + DEBUGFS_IMAGE_OEM(oem, rpm, SMEM_IMAGE_TABLE_RPM_INDEX); + + qcom_socinfo->apps = debugfs_create_dir("apps", + qcom_socinfo->dbg_root); + + DEBUGFS_IMAGE_NAME(name, apps, SMEM_IMAGE_TABLE_APPS_INDEX); + DEBUGFS_IMAGE_VARIANT(variant, apps, SMEM_IMAGE_TABLE_APPS_INDEX); + DEBUGFS_IMAGE_OEM(oem, apps, SMEM_IMAGE_TABLE_APPS_INDEX); + + qcom_socinfo->mpss = debugfs_create_dir("mpss", + qcom_socinfo->dbg_root); + + DEBUGFS_IMAGE_NAME(name, mpss, SMEM_IMAGE_TABLE_MPSS_INDEX); + DEBUGFS_IMAGE_VARIANT(variant, mpss, SMEM_IMAGE_TABLE_MPSS_INDEX); + DEBUGFS_IMAGE_OEM(oem, mpss, SMEM_IMAGE_TABLE_MPSS_INDEX); + + qcom_socinfo->adsp = debugfs_create_dir("adsp", + qcom_socinfo->dbg_root); + + DEBUGFS_IMAGE_NAME(name, adsp, SMEM_IMAGE_TABLE_ADSP_INDEX); + DEBUGFS_IMAGE_VARIANT(variant, adsp, SMEM_IMAGE_TABLE_ADSP_INDEX); + DEBUGFS_IMAGE_OEM(oem, adsp, SMEM_IMAGE_TABLE_ADSP_INDEX); + + qcom_socinfo->cnss = debugfs_create_dir("cnss", + qcom_socinfo->dbg_root); + + DEBUGFS_IMAGE_NAME(name, cnss, SMEM_IMAGE_TABLE_CNSS_INDEX); + DEBUGFS_IMAGE_VARIANT(variant, cnss, SMEM_IMAGE_TABLE_CNSS_INDEX); + DEBUGFS_IMAGE_OEM(oem, cnss, SMEM_IMAGE_TABLE_CNSS_INDEX); + + qcom_socinfo->video = debugfs_create_dir("video", + qcom_socinfo->dbg_root); + + DEBUGFS_IMAGE_NAME(name, video, SMEM_IMAGE_TABLE_VIDEO_INDEX); + DEBUGFS_IMAGE_VARIANT(variant, video, SMEM_IMAGE_TABLE_VIDEO_INDEX); + DEBUGFS_IMAGE_OEM(oem, video, SMEM_IMAGE_TABLE_VIDEO_INDEX); } static void socinfo_debugfs_exit(struct qcom_socinfo *qcom_socinfo)