From patchwork Tue Jul 23 22:35:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishali Thakkar X-Patchwork-Id: 169579 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp9425579ilk; Tue, 23 Jul 2019 15:35:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqxCoqdUin2b9FbtJUBm0gsc1E2d57Ne4KNwLB231kKgaWn5cpYoxY1EEuTTWi87yBq7uO4n X-Received: by 2002:a63:89c7:: with SMTP id v190mr75739065pgd.299.1563921332270; Tue, 23 Jul 2019 15:35:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563921332; cv=none; d=google.com; s=arc-20160816; b=Ana0UOYlVxpMr5B0nCn6FYT+f2+TWc7Smrwft6eOOQu/I7uLbOstr1WmcGkOBuP9Gs K/FiQ1YQRbPYX9/aCCSbxK6rmjfWgcdvDOKsgSvFbk4kFepkDGii8bZ/V49DEDeZL6li p87j2C3FgdPLHvr6XkEmNo82d3CJ/jaEFSGvIweB5zkCaJs11DEN0ytaw431qoZElwFr Vqz9fQZxZpPAVMSesiHjyZHQLARDtq+8pguK2ye3dXm9Zesw2KnYDCGsXkB9st7MJiN4 ffLGDUZ7kl77UVNaax9laT6+Mu5lI4n+QE4H9rtqzaMIpvh6FkK8MJV6NgZrzyIefExH Xu9g== 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=XiSb/xm4DCwF5YKTrgrsnR/pgd/JHfF4jO/yKlf55Xw=; b=pN/cWavUfd2YXxQcPWBT6mWFPeF2M0lCAJefN8u2nkpsEQNGIYWLV+6TqNh0sk8tJc vda6DWKXadfDjF12enbttZxae1Ud1NQkkFNfmucvYnb523+UeWLEUYPiT5BIiHONASI6 NPu8bQ4nXn/bObQ3rK4JDDTiwpnDHVhN2xzAaHMmK7ZgHfxBquwvk07CQGg8KUvU5Alc 9+MGWv4QP6hH2YRd6E+B2lYIAZ5kuBGZ3Wpio65DaVyf5kbfu+IoWw2tQnAJc4EkLV4c AAynLdNsecB2bcILNnKwazWAxOIjm7f8th5S6PPg2MsUJEH/XmXyuxFQ5rd5tRJw9vaH kFHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UIcCj7zG; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v20si12517999pgb.182.2019.07.23.15.35.32; Tue, 23 Jul 2019 15:35:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=UIcCj7zG; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389571AbfGWWfb (ORCPT + 15 others); Tue, 23 Jul 2019 18:35:31 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:44037 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728170AbfGWWfa (ORCPT ); Tue, 23 Jul 2019 18:35:30 -0400 Received: by mail-pf1-f196.google.com with SMTP id t16so19821790pfe.11 for ; Tue, 23 Jul 2019 15:35:29 -0700 (PDT) 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=XiSb/xm4DCwF5YKTrgrsnR/pgd/JHfF4jO/yKlf55Xw=; b=UIcCj7zGKNeQd38ejX8qLsDggMutycfth0tbzNIdR6CHdwx00EJrTxiUeVBNbX16TX Gtd4Na72AzruzwW2DidqG3ah8MqqRAvy3n/+/gHWgoQpHBSPNKTf6YS8yEpBNkK5+T5D TIA/DRnhgixXmDWF7S4c/yoicBW386TtzL8oyVNKKN1+fZVhYXrjW6fi6bexHHxoTOdH Y5cYjYETesyRZ3PEWthJTe6fxiNlfl6yDbacb2y7Tamt8ZIErwA/gUzxyuSyAwKG389o xcVSv5MjMgEBXzJP3WGpuMInzRCli9mrrsz3lNTS00n6q16G6WZQTs/PZf5fZuxAJk28 pBzw== 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=XiSb/xm4DCwF5YKTrgrsnR/pgd/JHfF4jO/yKlf55Xw=; b=jSP1wlLiB91HkX/1SAX7gU//fT58jvb8Qyon1uvbmVOSZBkVgI9ZSdn9Q3kaHu0qJV Ie9TV3lXjm802mF/ffeTjpq0HlaZmGadXnO2OQAOQQrYN9LWOlS61xige7DRqYuL0Bvv ssdIiTBclJaNpbQKBAzGvUikBIrEt5tzz7h75WlQRLj3V8bjGu9lH5ZKdkAv9p9b3Ry5 wsbHyxhJ+7DJoKywH6mizfI+riL2qd8CpXlXuHRRzb+e7JVY2P0JCjZgMEeN9ke2PyCY YGG+5/ETbnsJscfVnfVUEytDONgSuwAyv8kKEwW68HrPF9WTmU7bTDp5j2WKMQxmGhou C70A== X-Gm-Message-State: APjAAAVdFNwZhhQvXwm2zBrf4RnbXhsMZ/NLJWzdhXBkJFRbynl0tL0N 3HzBNL8+B82nAEfhnU3QFC+3FQ== X-Received: by 2002:a63:774c:: with SMTP id s73mr78620059pgc.238.1563921329404; Tue, 23 Jul 2019 15:35:29 -0700 (PDT) Received: from localhost.localdomain ([115.99.187.56]) by smtp.gmail.com with ESMTPSA id h16sm49036917pfo.34.2019.07.23.15.35.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Jul 2019 15:35:29 -0700 (PDT) From: Vaishali Thakkar To: agross@kernel.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 v6 2/5] base: soc: Export soc_device_register/unregister APIs Date: Wed, 24 Jul 2019 04:05:12 +0530 Message-Id: <20190723223515.27839-3-vaishali.thakkar@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190723223515.27839-1-vaishali.thakkar@linaro.org> References: <20190723223515.27839-1-vaishali.thakkar@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Vinod Koul Qcom Socinfo driver can be built as a module, so export these two APIs. Signed-off-by: Vinod Koul Signed-off-by: Vaishali Thakkar Reviewed-by: Greg Kroah-Hartman Reviewed-by: Stephen Boyd Reviewed-by: Bjorn Andersson --- Changes since v5: - No code changes, fix diff.context setting for formatting patches. Version 5 was adding context at the bottom of the file with 'git am'. Changes since v4: - Add Bjorn and Stephen's Reviewed-by 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 --- drivers/base/soc.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.17.1 diff --git a/drivers/base/soc.c b/drivers/base/soc.c index b0933b9fe67f..7c0c5ca5953d 100644 --- a/drivers/base/soc.c +++ b/drivers/base/soc.c @@ -164,6 +164,7 @@ struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr out1: return ERR_PTR(ret); } +EXPORT_SYMBOL_GPL(soc_device_register); /* Ensure soc_dev->attr is freed prior to calling soc_device_unregister. */ void soc_device_unregister(struct soc_device *soc_dev) @@ -173,6 +174,7 @@ void soc_device_unregister(struct soc_device *soc_dev) device_unregister(&soc_dev->dev); early_soc_dev_attr = NULL; } +EXPORT_SYMBOL_GPL(soc_device_unregister); static int __init soc_bus_register(void) { From patchwork Tue Jul 23 22:35:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishali Thakkar X-Patchwork-Id: 169580 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp9425656ilk; Tue, 23 Jul 2019 15:35:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqyFbSL2OUkrzQf8d32LFuCyyBPxJldHXQU7cp9esMfpI4dqXhnyLJmCN8cO3fx1Z4x+ISTR X-Received: by 2002:aa7:8acb:: with SMTP id b11mr7739208pfd.109.1563921337348; Tue, 23 Jul 2019 15:35:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563921337; cv=none; d=google.com; s=arc-20160816; b=Xvka0+F3S9KfrDuyU6qGd8cQ7+bd3Lb1APjwBYO2L3ZCVKakORmhgeI4zfqbQvg7YW RVrVgBKbnagIO5wDsBS4VU89uBKL42OXaFajKTN/ZS6I2itOpzQAf+VYt0R7fjPXQ+d3 oM4r/5oJA+4lcrzUfoE4sjOE9eHvJWmDJGf0d5ZpI8z8xwfIJfBB7VgSajAvEFeJWCrr UL50bVnN9/mF1/lFUs9kDAIy1ixt2euAFj2PdVlmSuarrf9YaRt8sCDsfYz36psg3GHY 4tnRyqaIBuaFgXXyXetS1YsqGdeaPg5aWj0IRUmyQyeKqC3JJ87Br9Xe6SXZJom2R60X 398g== 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=a9df1aBp8aRLCGR2a9/ePqT7IGRC3SBDVB33J06YG3E=; b=rV07luHqeL88cW45ZY8RzALkaqmGLbJzz4Al6JgIm6YIEE0BxPVxPU0T5RXnQo+U3g AJQm1y9W2q/Qpm02jCa2P9xTSiCU7tC/WY3WWqdWOKWIKnrweEdlKuU2ozMNi6fN7AMB O26epbYZvMzGsWhnH7jr8nHS/mw3R1ROwOGfYTOxX7tEKy78zVlN6/igkcbeJ2EFSqDF 1m3dr2ZpKbokJ+lGzkptlOr8C62kmBUkTmT8PeWUOONxsWZ9x1YPi54qFK5Yd9t7SjcV RC8YTfoYfSOZRU6fOh/NIivk0G54/kKT5bWwczbRhDIzTsdP/SHuVIln7kMf/0+bxByX ZZRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mvD+jRhh; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d34si38877369pla.283.2019.07.23.15.35.37; Tue, 23 Jul 2019 15:35:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=mvD+jRhh; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389434AbfGWWff (ORCPT + 15 others); Tue, 23 Jul 2019 18:35:35 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:33792 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389589AbfGWWfe (ORCPT ); Tue, 23 Jul 2019 18:35:34 -0400 Received: by mail-pg1-f193.google.com with SMTP id n9so13896344pgc.1 for ; Tue, 23 Jul 2019 15:35:33 -0700 (PDT) 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=a9df1aBp8aRLCGR2a9/ePqT7IGRC3SBDVB33J06YG3E=; b=mvD+jRhhI2hqAwqkMhcgItMuaZfI4koFazSdjTev8IR7/2NMFOofFgmP1HhpSM1iD4 jp8d/9iXunM2UmR3hWUETUkBCI0bx2jfKRvlL6gt3CQmvu+n/Gs6NQHAvxZwPmfc1DII dM8ZYTQ2NSvj5B9Wf375+WrOd6BtU9fC4ctwhe3zZuKMNTHg7z825fVJtBGgKreKrH79 qZQbohrlqFpFWLeCzpW5ct1Z1NmBqgDXI4OedBGIyiGGgdddXbaKiFKXbOJJCcBEdj4L hTa07EiOfuObbMDwvPIk7RXIpjdFqZspY9r17ZFRpJrPHt97hkJ0VkhIqwN0XoipVzIe vl/A== 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=a9df1aBp8aRLCGR2a9/ePqT7IGRC3SBDVB33J06YG3E=; b=elr7Hu8Jcrf5+WXNg2oUdEaJXJrMr1YS/FC0/SCxug4Fq5G4Z7elFY/AQD/2OwTHRM /YI1s71qtarImLxwYmVsw+SOsD1jaFDIrXsxZmuImGbwrwQdmHlKtxSnIvqpSjzX+RWa IqFplFgOTjSqFdmkARr7vjze9T3KCY1e4oyTpwfle5+wNbuwn5Qg0VxEm323sRW+P5AN fTUGiXkvbnLMckpBPEBGOtcjHnDgK7g+MFYDyklXutMMjOdtc/am+FtOnYPdDQduhBTe bEMUSXRoialGLtjaXBpXcwlvPnI2fMXvgT0Yp0+w2gKBd9Zu1zfFnRxovDMZuYq6wKMy xBaA== X-Gm-Message-State: APjAAAVMGirRiar1eCMYjjHLQPqhyOMJqt18Twl4v6P/R/K6i3TVbI2l vbGYC49qlbbwcg0yGeZDEnmC6Wsie78= X-Received: by 2002:a17:90a:2ec1:: with SMTP id h1mr84641946pjs.101.1563921333450; Tue, 23 Jul 2019 15:35:33 -0700 (PDT) Received: from localhost.localdomain ([115.99.187.56]) by smtp.gmail.com with ESMTPSA id h16sm49036917pfo.34.2019.07.23.15.35.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Jul 2019 15:35:33 -0700 (PDT) From: Vaishali Thakkar To: agross@kernel.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 v6 3/5] soc: qcom: Add socinfo driver Date: Wed, 24 Jul 2019 04:05:13 +0530 Message-Id: <20190723223515.27839-4-vaishali.thakkar@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190723223515.27839-1-vaishali.thakkar@linaro.org> References: <20190723223515.27839-1-vaishali.thakkar@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 struct, Fix memory leak, Remove extra code and Misc code refactoring] Signed-off-by: Vaishali Thakkar --- Changes since v5: -No code changes, fix diff.context setting for formatting patches. Version 5 was adding context at the bottom of the file with 'git am'. Changes since v4: - Return PTR_ERR in qcom_socinfo_probe instead of error value - Return PTR_ERR in smem probe to print proper error message when we fail to register the socinfo device - Use dev_dbg instead of dev_err in qcom_smem_probe - Use offset_of for exposing the value of serial_number - Unregister the platform device in smem remove function - Drop error message in socinfo_machine - Misc: Add spaces between brackets and strings/numbers in soc_of_id, item ids->item id, socinfo->SoCinfo, soc_of_id->soc_id 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 | 9 ++ drivers/soc/qcom/socinfo.c | 194 +++++++++++++++++++++++++++++++++++++ 4 files changed, 212 insertions(+) create mode 100644 drivers/soc/qcom/socinfo.c -- 2.17.1 Reviewed-by: Vinod Koul diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index a6d1bfb17279..661e47acc354 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -175,6 +175,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 eeb088beb15f..162788701a77 100644 --- a/drivers/soc/qcom/Makefile +++ b/drivers/soc/qcom/Makefile @@ -18,6 +18,7 @@ obj-$(CONFIG_QCOM_SMEM) += smem.o obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o obj-$(CONFIG_QCOM_SMP2P) += smp2p.o obj-$(CONFIG_QCOM_SMSM) += smsm.o +obj-$(CONFIG_QCOM_SOCINFO) += socinfo.o obj-$(CONFIG_QCOM_WCNSS_CTRL) += wcnss_ctrl.o obj-$(CONFIG_QCOM_APR) += apr.o obj-$(CONFIG_QCOM_LLCC) += llcc-slice.o diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index f27c00d82ae4..0caf67e2f037 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -268,6 +268,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[]; @@ -963,11 +964,19 @@ 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_dbg(&pdev->dev, "failed to register socinfo device\n"); + return 0; } static int qcom_smem_remove(struct platform_device *pdev) { + platform_device_unregister(__smem->socinfo); + 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..1b9eb44df7fe --- /dev/null +++ b/drivers/soc/qcom/socinfo.c @@ -0,0 +1,194 @@ +// 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 id, 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_id { + unsigned int id; + const char *name; +}; + +static const struct soc_id soc_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_id); idx++) { + if (soc_id[idx].id == id) + return soc_id[idx].name; + } + + 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 PTR_ERR(info); + } + + 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 (offsetof(struct socinfo, serial_num) <= item_size) + 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 Tue Jul 23 22:35:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishali Thakkar X-Patchwork-Id: 169582 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp9425766ilk; Tue, 23 Jul 2019 15:35:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzfoSg+HCMvAHLwYJnyhtxhRp2UM9QXPIhtOUrOSWVdko0YPfZVRL+OFeEcNCq+eskogKPL X-Received: by 2002:a63:2ec9:: with SMTP id u192mr76778398pgu.16.1563921346391; Tue, 23 Jul 2019 15:35:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563921346; cv=none; d=google.com; s=arc-20160816; b=UXS11LRP+ALdLVbLcuWn4lPmSfzTqer1q6hQRiQ9++0h19kbc50DGVLDFDos6xVokq 7ErfIMeoVe4E5nGmzZkI2emD8Xxv5n+tRYIn7mhjYQkV4vkk/Ik6M/Mm2MM+9t2nP5mG 1mhnfX17+SuxF0PMpcJEqUxfZ3fs3AePVqlIT7rxErSX/3Lag3x2GvuP+MZ465LoykYj uBCKeuszdUQk67oFkr5J3w45U0KJARQurK8l9tIHpif4qB34uH3ER0ea6kPAEs1aPeaW iUEhpMUXb8M0unR9F4dox/QoVeVCEYCJAx4klGqLcrB6eXUNfRrosM7RqG5+WHKkS51R T9pQ== 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=ISDhy1lFnV9frfiPyjqolFGkkeA7zQy7U6U1fLUKzLo=; b=pqzGupNcI/iAoqHZ8JdVnd6nyGu+YR23vgrs0Ronv9YI18YfcynGDlcgOi0pKtDJG8 /s7zwaVJ6PV+L50z0Had4kZKJTvb76CEbvOibCcWJa18QPhqWWECEqv7VROwWLuyz2Ie wF9lvXhzsaDKq+K75XWivwL66X6AdJhnCil1jozzHERykppWxk0tO7MN4hY0CyAbawCB lmiFnznw52N4fwi1FpIJusOZnDTSMdiGIYAbA3jmK2z68HieKfHiQlCWVDo/2EdinuPl By8+Z15zd0n+7WWZ6Mx5lI5BjUX21vuccsjOR+2zDYSWuedA3X1t1X9L5o2iq4vKFSUD AGuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rp7bZn35; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i15si15353350pfd.259.2019.07.23.15.35.46; Tue, 23 Jul 2019 15:35:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=Rp7bZn35; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389591AbfGWWfn (ORCPT + 15 others); Tue, 23 Jul 2019 18:35:43 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:38488 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389613AbfGWWfm (ORCPT ); Tue, 23 Jul 2019 18:35:42 -0400 Received: by mail-pg1-f194.google.com with SMTP id f5so11294618pgu.5 for ; Tue, 23 Jul 2019 15:35:41 -0700 (PDT) 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=ISDhy1lFnV9frfiPyjqolFGkkeA7zQy7U6U1fLUKzLo=; b=Rp7bZn35T+JvwV7+QL8xoDSQlaAjqcHc/tZR4YkCtTIwA8n8wayhgPQVWb9sD5E7g6 dszvbClvBisaSBUQbBAt66RjSHa1MMgvh8+ZS6vXbZgB5PLlJWRysGVUfYe+1eUg9trh efdqJqz8EnjZcxqBcIJEtHqUL9jZmoiAnTcxr7A17djpPzN0BOjSpPMBqUHBpxl8gSPc O0pG33xSiQmnq9va+q87ygPc/o0TxFUzWRXeid8TBaRMdQ+8YJQ4E+MQIyYJyFiPZwiJ FAMFffHFF/gZANt0bI8fECO6AD9wN5C4nvhCxASZuhvHdlmVjSh74tFkmiMUvoIdHSj+ vrZw== 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=ISDhy1lFnV9frfiPyjqolFGkkeA7zQy7U6U1fLUKzLo=; b=eKgCMWfXWrWsogn9O3JvvqWQsuvRf3rrP0PGRy6DSya/8ORVZBigAn0gF78LjsATNZ 1d563xO57//GJjAR83HIdWPNOSnkkIgCzmJC/ZrLiN7y6jYAUxU1WkGg9a9bN26Rd2wo u/nBmEQP4WDp+g/SSCi0NDIQQQ3OMMzybZjzgAF+VSb2kEW+dBHP/uplWBRukvZXLj3S EytE8Sd+su/NOjriXpN3QuxRUDVmxzf9305lzNzLwAE2dT1zThLG5d7trpaNSJuAME2r TQp5osUpeCEcRrFZxrY4Y1OSpMuFV2o3q3A6EYVMmqdGgPUqRgEik6VW2y8sHwKhRRHg vt8g== X-Gm-Message-State: APjAAAWiX4h+U4/qvV5XGevvcVUz8+xPbiCfox38gD3IJL3IJKsAemxe hcLpSIdkisdBwWl86IMC9lRtfA== X-Received: by 2002:a63:1743:: with SMTP id 3mr338246pgx.435.1563921341327; Tue, 23 Jul 2019 15:35:41 -0700 (PDT) Received: from localhost.localdomain ([115.99.187.56]) by smtp.gmail.com with ESMTPSA id h16sm49036917pfo.34.2019.07.23.15.35.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Jul 2019 15:35:41 -0700 (PDT) From: Vaishali Thakkar To: agross@kernel.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 v6 5/5] soc: qcom: socinfo: Expose image information Date: Wed, 24 Jul 2019 04:05:15 +0530 Message-Id: <20190723223515.27839-6-vaishali.thakkar@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190723223515.27839-1-vaishali.thakkar@linaro.org> References: <20190723223515.27839-1-vaishali.thakkar@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 v5: - No code changes, fix diff.context setting for formatting patches. Version 5 was adding context at the bottom of the file with 'git am'. Changes since v4: - Reduce number of duplicate image macros and functions - Introduce array for image info debugfs entries and use it instead of open coding Changes since v3: - Remove extra debugfs directory creation checks Changes since v2: - None Changes since v1: - None --- drivers/soc/qcom/socinfo.c | 84 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) -- 2.17.1 Reviewed-by: Vinod Koul diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c index 6a4795433d57..855353bed19e 100644 --- a/drivers/soc/qcom/socinfo.c +++ b/drivers/soc/qcom/socinfo.c @@ -32,6 +32,39 @@ #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 + +/* + * SMEM Image table names + */ +static const char *const socinfo_image_names[] = { + [SMEM_IMAGE_TABLE_ADSP_INDEX] = "adsp", + [SMEM_IMAGE_TABLE_APPS_INDEX] = "apps", + [SMEM_IMAGE_TABLE_BOOT_INDEX] = "boot", + [SMEM_IMAGE_TABLE_CNSS_INDEX] = "cnss", + [SMEM_IMAGE_TABLE_MPSS_INDEX] = "mpss", + [SMEM_IMAGE_TABLE_RPM_INDEX] = "rpm", + [SMEM_IMAGE_TABLE_TZ_INDEX] = "tz", + [SMEM_IMAGE_TABLE_VIDEO_INDEX] = "video", +}; + static const char *const pmic_models[] = { [0] = "Unknown PMIC model", [9] = "PM8994", @@ -103,6 +136,13 @@ struct socinfo_params { u32 hw_plat; u32 fmt; }; + +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 { @@ -230,10 +270,37 @@ QCOM_OPEN(build_id, qcom_show_build_id); QCOM_OPEN(pmic_model, qcom_show_pmic_model); QCOM_OPEN(pmic_die_rev, qcom_show_pmic_die_revision); +#define DEFINE_IMAGE_OPS(type) \ +static int show_image_##type(struct seq_file *seq, void *p) \ +{ \ + struct smem_image_version *image_version = seq->private; \ + seq_puts(seq, image_version->type); \ + seq_puts(seq, "\n"); \ + return 0; \ +} \ +static int open_image_##type(struct inode *inode, struct file *file) \ +{ \ + return single_open(file, show_image_##type, inode->i_private); \ +} \ + \ +static const struct file_operations qcom_image_##type##_ops = { \ + .open = open_image_##type, \ + .read = seq_read, \ + .llseek = seq_lseek, \ + .release = single_release, \ +} + +DEFINE_IMAGE_OPS(name); +DEFINE_IMAGE_OPS(variant); +DEFINE_IMAGE_OPS(oem); + static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo, struct socinfo *info) { + struct smem_image_version *versions; + struct dentry *dentry; size_t size; + int i; qcom_socinfo->dbg_root = debugfs_create_dir("qcom_socinfo", NULL); @@ -302,6 +369,23 @@ static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo, DEBUGFS_ADD(info, build_id); break; } + + versions = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_IMAGE_VERSION_TABLE, + &size); + + for (i = 0; i < ARRAY_SIZE(socinfo_image_names); i++) { + if (!socinfo_image_names[i]) + continue; + + dentry = debugfs_create_dir(socinfo_image_names[i], + qcom_socinfo->dbg_root); + debugfs_create_file("name", 0400, dentry, &versions[i], + &qcom_image_name_ops); + debugfs_create_file("variant", 0400, dentry, &versions[i], + &qcom_image_variant_ops); + debugfs_create_file("oem", 0400, dentry, &versions[i], + &qcom_image_oem_ops); + } } static void socinfo_debugfs_exit(struct qcom_socinfo *qcom_socinfo)