From patchwork Thu Feb 21 16:24:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishali Thakkar X-Patchwork-Id: 158921 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp678111jaa; Thu, 21 Feb 2019 08:24:40 -0800 (PST) X-Google-Smtp-Source: AHgI3Ian+qIrKh6awnVeESLpwg/4wzmcPAT6V5Gops4G34lN5JlXSj3LSsIAhHbgw3gTNDcYGnoo X-Received: by 2002:a17:902:c05:: with SMTP id 5mr43789879pls.155.1550766279916; Thu, 21 Feb 2019 08:24:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550766279; cv=none; d=google.com; s=arc-20160816; b=fL/8ZvbBNuLbSWLo4Ka8qnJc0+LdIWqytV8ER5Ssg+4lXJ6mlfVydDBT12KKq37aDO O68BEWj9Uw0XVGC2rFuCLiWOQcWJKzu8uG9AUinvbKVzUm22i+kBCF1HdFhOUHGgnr+U QWDul/sp9FEzV/Dg/L5KDyoDw2w37EhNFPMlbOBATq+1vLW6n0977/pGzI3jyLajUPal hlJ9RbKrTCdlLXeD6G9G1JYEPlnkmWg5deFl12oNz+nlem5ZRNu807NLA/O0W+1BrIvM Zx7O23OQTRen7cAKnhYFICMFdkERsRN6NUev2cVprE1SSh1ijDanrWygG/lC6VSq1y8k xTnQ== 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=USzj74M59gvJ0Ydb19s1rmXKxEc/2juHtDduMISBNPU=; b=VXTRsK0MXUSBQG1Xcc0q3r6YP1CxGoj2QLnSs71ZPYDKXUBQoP1lfyHpfjJ6g8509a YFjfrJhKgidANdpVk5iPwauvll8aFomONlZ9bLOpzBuq/ZL1/4PYksj0k+ufMQPeEsBf eY2dzp2kKcWG7eIErKo2VSo2A6DCpPZlltm/TXnkM6dGt/wglSYnOyHGUAe+5jwtB4K+ m7jS/fP6LCZQqws88/lsbtOYCVvIO9afSNUv6KEs6u6SpwLDq1Bs7My0UWw02gCBDM8p akpQ4v5cYZR5Vrevwvzlv2JBPvZVLjrbnYJ6ALRAk4q1QGh756qBjIvmpR/maM9uSs1C c+nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ebbLroa7; 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; 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 f33si20466217pgl.437.2019.02.21.08.24.39; Thu, 21 Feb 2019 08:24:39 -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=ebbLroa7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728457AbfBUQYi (ORCPT + 32 others); Thu, 21 Feb 2019 11:24:38 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:37458 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728383AbfBUQYh (ORCPT ); Thu, 21 Feb 2019 11:24:37 -0500 Received: by mail-pf1-f193.google.com with SMTP id s22so14072195pfh.4 for ; Thu, 21 Feb 2019 08:24:36 -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=USzj74M59gvJ0Ydb19s1rmXKxEc/2juHtDduMISBNPU=; b=ebbLroa7cvk1/WDpxo+gZch1kmqcLROZT//ejrxQixC4HdO/Frf6hdPMgyZq2VUi8h bUDDbZS+cq1UU5Q30GudNUTcqxyt80zIRfZoMwXsXM3mLNxi5xiw1MKbBnV9e1iaZr5V 9bxKd4YbZ39p/czczIDooLSQC3l+V/h6H1iPemEGrjM9kY5WiXsbSzfoKWokjuL9wH6Y 83NX4t6+ZkTZ4K45QCAeekz8kkp9JLnjMiUbsK6CVM4TeIEa6PQtw9Ls1uvhYXt3YA2o ydWk0wUiQf6rietw/Z4EIpPsK4u0mZZEKyHFN+R9wUlVwcKxDJ5YD7b6oTZPhwluWIXf WljA== 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=USzj74M59gvJ0Ydb19s1rmXKxEc/2juHtDduMISBNPU=; b=F04dQ8vpvX029mwzDDofCCt4qULxu/+acMz62UJ2NTf8fIVQr9/KpHvfuZ0DFh+3d0 dyxrMlDRzHFPBHLd8OkNGQhhRmsGSVEasKaR/6wMSCLCxbUIElF2Ih/Bj9vudzWEDyXs wVaLkfqQZnUjW+83flrjN2941JNct3XMCYMyUkUucc6cUsMpk2FGvsZ+n05/6VHdnQ92 fkWfWI3XYB2CK5aPeIZPN14m8Rcp3Qz1nBmk54Ot+FRKmNWQD13ibR3b6KXqKId0C9ZF BOaLD8jrp6tuo21zV7/Rlqch8/RqdP3VvE+qJ65MIjEXA98aV1f9jLrh3cabL0fDl6lZ +aqA== X-Gm-Message-State: AHQUAuanYuiD9hDMG1spCQ6yH3qC2yxee4PpHUm9dAScAaZMnabCtBeJ Dm595l7NNFyv7E5VRGdRaJpl5w== X-Received: by 2002:a63:5702:: with SMTP id l2mr6740622pgb.2.1550766276529; Thu, 21 Feb 2019 08:24:36 -0800 (PST) Received: from localhost.localdomain ([116.75.87.120]) by smtp.gmail.com with ESMTPSA id 20sm21382910pfs.182.2019.02.21.08.24.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 08:24:35 -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 v3 2/5] base: soc: Export soc_device_register/unregister APIs Date: Thu, 21 Feb 2019 21:54:16 +0530 Message-Id: <20190221162419.32384-3-vaishali.thakkar@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190221162419.32384-1-vaishali.thakkar@linaro.org> References: <20190221162419.32384-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: 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 --- Changes since v2: - Reordered patches [patch 5->patch 2] Changes since v1: - None --- 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 Thu Feb 21 16:24:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishali Thakkar X-Patchwork-Id: 158922 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp678228jaa; Thu, 21 Feb 2019 08:24:46 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ9teMI/tBhLu5O+rYIq5TBSOxJfhjpiyFNkNURvcqw0C/0Ism/tWCP4od2k4+/UTRkLEV4 X-Received: by 2002:a65:51ca:: with SMTP id i10mr38250347pgq.371.1550766286612; Thu, 21 Feb 2019 08:24:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550766286; cv=none; d=google.com; s=arc-20160816; b=EY0CiGi65gVNHqkfg+Sinrccta63F5CUZyGpaiS5cMzSmbq/2paEr0vDfhQdDFpcp6 wdFcXuv5bdb4u93G/qT27WIuXWJm/7dYHh6LdqzPbLau9RQnArVvjITSTvQd/qgUJZti z/o6e7F/2f5pSrArthOfFFaQ0AoZhy8hz/mmIrOALhg2nZy99JiKnfS/7ZXpjzXrdyCi 5X26r/Y+nCj0h9sugcDnFE8io1AvzgVAVZTeHNb/2Tf8DaLvuhD47yvA4t1cE1xS+8Fp KHvJKeMn3VX1dIO9WzjUCLVWxBySkSv0lOOujWePnMa3gfL38iDGtBjkQqYgLLtBsU7N jD1Q== 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=PJmvqAwF3oqiVW9Wtm0jWxTiw32xCfcf5GpcZ6VkcGE=; b=kZPu3MKjeQC3plc5fqNAJqF+MaL6043Bcj1aMbN8ZhPqO48GHaPZFTMvVVRvwcH8T4 /W16KyLQwP4a97m5YrjW4pRiIDE0VoVrDFzOI6eaKB5Jf04C07Z5+U9cHI0pl7gBU6KV GS75/naUAZkN/W2iFXw4sG/wwojc68D9sWxxBwBvM3ufPilmoAMJx3liwC81uOU+QytT xru7wg6iRwhh1MLNzaj1SuKeJTjdETI/IwW/7G2Lcm8R/LiHpjyHiubbkm0aOwa9lNQJ GXRjxkxxVHgyjhOGlWgIlRbSt27rRVKRH/KREr7T/CixkJHyYD6dtJ7Wqlq+3NeoKPR4 H/1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="fdR/6U1k"; 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; 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 r4si20235232pgv.245.2019.02.21.08.24.46; Thu, 21 Feb 2019 08:24:46 -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="fdR/6U1k"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728599AbfBUQYn (ORCPT + 32 others); Thu, 21 Feb 2019 11:24:43 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:41671 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728515AbfBUQYk (ORCPT ); Thu, 21 Feb 2019 11:24:40 -0500 Received: by mail-pl1-f195.google.com with SMTP id y5so8845514plk.8 for ; Thu, 21 Feb 2019 08:24:40 -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=PJmvqAwF3oqiVW9Wtm0jWxTiw32xCfcf5GpcZ6VkcGE=; b=fdR/6U1k26QH27VjUBcseridwPhDDOMunLYNHoyiHaoq/oTAfBhoLjM07OZ8IGH2cJ W0IV7D+GJJg4l9rH+Pw3rdv21T0fQ1AvC6ttZSezixpFyiG19GNcrwERS9YUC95FNsGV KA28gOPK12n64JRx+cCIQ4K/tvWOjeVLsdptnU2P9gWn04eLx7VXJ99+jhKuK4j8ToLV AEoeMBhSQ4txyMdzKuF43fuNf4QLFm6n7Qa9JYRlfaUB/yQ9XV40WjS+q/SAT59wojVn MNAxC7UvYIvD1E9NI5+4VBp9OvxP/ZwODjOfnyU8IdNMGhA98GJxqUr0LRbResPWWzBL eYXQ== 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=PJmvqAwF3oqiVW9Wtm0jWxTiw32xCfcf5GpcZ6VkcGE=; b=Nsv0rMqT93YgnPJ1ISZwelHVh6dBy+JrwgXO/ih4lENqaRy81mzfU14kPeMssy/Iw4 IpUf8DpFEK+sZmaj4ZAbwl7P5V03EGeJ9W5oeoQ0YSZPooqxlFUNJNCXqLu2X4jcSdcj XSOpyWk+kn4afpNCAnok6j0ZJyxqecM5OXQ0HufgkntflS8S6KmgbOMtGbPub9D7bYLU YX+isNBDME0mYRBFW4nlmOx1vqFDU/hNCos1Z6dT63/9zzeTAQ1kFqJE645sua+xmakV OQ+s2hwoefF22GpIKTnHJ8g5drXx0uMhNerBuy7N2k9+Ug/lwu1HjRZEQiGMpcgV2d93 0RDA== X-Gm-Message-State: AHQUAubnHC8SWfXckNFBfn9zEbUNvxEWd6RBAcbTXdfjrpd3yltakFq/ Qzw3JZDJq1tdt/oAsk4lBxFv+g== X-Received: by 2002:a17:902:ba85:: with SMTP id k5mr43363763pls.130.1550766280022; Thu, 21 Feb 2019 08:24:40 -0800 (PST) Received: from localhost.localdomain ([116.75.87.120]) by smtp.gmail.com with ESMTPSA id 20sm21382910pfs.182.2019.02.21.08.24.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 08:24:39 -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 v3 3/5] soc: qcom: Add socinfo driver Date: Thu, 21 Feb 2019 21:54:17 +0530 Message-Id: <20190221162419.32384-4-vaishali.thakkar@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190221162419.32384-1-vaishali.thakkar@linaro.org> References: <20190221162419.32384-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 struct, Fix memory leak, Remove extra code and Misc code refactoring] Signed-off-by: Vaishali Thakkar --- 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 Thu Feb 21 16:24:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishali Thakkar X-Patchwork-Id: 158923 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp678263jaa; Thu, 21 Feb 2019 08:24:49 -0800 (PST) X-Google-Smtp-Source: AHgI3Iahm0tVpScUJfq0Xp0ccEUZERal71oOL9b/nYwIvZndWbc11kxKaU0WzeVBxyv/FsAWXQJp X-Received: by 2002:a62:68c5:: with SMTP id d188mr42058403pfc.194.1550766289378; Thu, 21 Feb 2019 08:24:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550766289; cv=none; d=google.com; s=arc-20160816; b=O/CKDjgRU0ECMTgJ4oWBGfHmkDRmBBlv/Qqsw/s/tudc9cugl1Qa0/sEOIFxT16P58 aVXYeNQZ25m2BH0JNzKizthlxMuKS+G+KR9L9yYCQkQ7IAsa/0FBWgcsMe+ZommodHv8 vQE971tqql89JSijtOGA6hFsrXU6IjPb9ly1/j2aD8pAWLx+0GU5IxP6cONKyZ29yo/U AKNRTshuRX6jBuBycWJFYl5klkDDvVTm03ZzoRzZX43mwxFYFG5EJ7b/H0r+QJvo28yc FVBXPwy9a6kDbvujdlNVee/l2fN457Kn11VyY/DKnUAQXRacNbUimfalGgUKA74XXatp s+5A== 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=kQRoPtMOamkgZkyhmGYLC1s9RHzT1SIt4HeXiehVEB4=; b=P3VAWd2xQlPewLczB+yn6NhOkNxz24VMhG+fJJgrobf42CiDiVUGk3hQH2dD6+Iccm 7mSq+nr8GTETTVKaE0Vq15Hc5eTb80IOzil78LI+qSXWze57R2G8hKnxstbV8RXjSvlN QkYa6tp9E38RocEZVj9tqwWq3MxW1NPvkZkB9LFLinaCvuu7nUw/1GuvM6wdBJz8lPTI hvescWZqXGdx+UbmvtpvNEEyzheWRGY9DzvRZ6J61jv6kFWuoenz/dtpJvmiq4Sqctib 683xC6AuYLFJ3wJVX3euZEdFtBta948zLeQd9OYPFZEiW6fg4oVyIQnEQDCr8oJfe8T8 dhUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bob33HTx; 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; 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 r16si14411907pgm.483.2019.02.21.08.24.49; Thu, 21 Feb 2019 08:24:49 -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=bob33HTx; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728630AbfBUQYq (ORCPT + 32 others); Thu, 21 Feb 2019 11:24:46 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:33316 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728515AbfBUQYo (ORCPT ); Thu, 21 Feb 2019 11:24:44 -0500 Received: by mail-pf1-f195.google.com with SMTP id i19so1046429pfd.0 for ; Thu, 21 Feb 2019 08:24:43 -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=kQRoPtMOamkgZkyhmGYLC1s9RHzT1SIt4HeXiehVEB4=; b=bob33HTxuo1IF9d+wwsH8FC+/tcaYe7Z1NYkeos8o2io9pSu3sS4QszDlWvaDxcQQU X+pHdchlDCitbWbcpd/WzV9KFyBWmKYXgu61gBHZH5gjgRLIJDToIppqNyRfpjZHbpz1 91S9+lnJMtAnmNoan7myseDc3Mq8SbS4rhScDqgSnC52XB24PcMAA29pG8CNOeeq8/Hg UhWDoUtKSlVYGTsfaX/hm2aUgT0GWV1uFcToebF4iGkfxo91ypJWjmc6EO95j5f7y4FV YVtonvS7ivcAqbZCIvSsKYmwIDF6xt+ChsxHFPFwcTjAo/U056SmsVZzC6itW3che8b8 vneQ== 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=kQRoPtMOamkgZkyhmGYLC1s9RHzT1SIt4HeXiehVEB4=; b=ZfblzNqu5ylA5BYOKsGWwlwqcQc+9W3d5Lex/8b7oeV4OL5hymV8b/7nQGlud6tjME feaUP9Q7g2+WQFd77QJLrUFGt7WAvsInUzFrsy4JBmPLwwtXRaL1MEcom5ku2u/p002H 4tGTSiWN1rynWJR2iqan5MZEtqgqRtGaw+UJtLlAx7T9bXrG+vxHjFsGQep1R82yx8Fu 3zYTg1NxXfDtWTwHGUTzGCtZvZF0kMI8Al/5qoA+9wttuNqVo1AtuK5kSivJighNNrak meqg+0QQdFA63wtCYdXhvJjKDEzX9RBj4PO50KaYveodEiG00F7y5INrltgWAZcSqjHw VXCw== X-Gm-Message-State: AHQUAub73a77poSos7GixgzJFeENEc1Ojm2eGpMLpx7Y9BHa6d24bs3k fbybNTjnItT6cIcgPO8btWsP/g== X-Received: by 2002:aa7:8847:: with SMTP id k7mr40332576pfo.99.1550766283495; Thu, 21 Feb 2019 08:24:43 -0800 (PST) Received: from localhost.localdomain ([116.75.87.120]) by smtp.gmail.com with ESMTPSA id 20sm21382910pfs.182.2019.02.21.08.24.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 08:24:43 -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 v3 4/5] soc: qcom: socinfo: Expose custom attributes Date: Thu, 21 Feb 2019 21:54:18 +0530 Message-Id: <20190221162419.32384-5-vaishali.thakkar@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190221162419.32384-1-vaishali.thakkar@linaro.org> References: <20190221162419.32384-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 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..5f4bef216ae1 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) { return 0; } +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 Thu Feb 21 16:24:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishali Thakkar X-Patchwork-Id: 158924 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp678311jaa; Thu, 21 Feb 2019 08:24:52 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib0Bo95j1wXkuW5UBjuyuHFgGP+6QEIzD4woEkV+nvvKKSYKtKhS5sKZF0W/V0/dvI1uvtn X-Received: by 2002:a62:1ac3:: with SMTP id a186mr10487220pfa.48.1550766292453; Thu, 21 Feb 2019 08:24:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550766292; cv=none; d=google.com; s=arc-20160816; b=K7RCx+Jw3r7oE1ser9ox6t5zi1g2gW1JIhyXiEV0+tRThEeYYWQJpYMHp23qD4I9I5 am/XORNRlHMHGvEiuV5hcchL8si/ss7+FjMkNGbhc3QRwKLCZXZVgpIQftCZGO9e+rPt WTJ3QS118JZ9sTVFYJqfOnyuyBEsdnY9WB/ShwtoikYCAGiEbH4gje2DNUosbSoJbQoh O23xyucSf0DfUOLBBnUNCJ+k774JkhVGmUIceNA7+HANKDP3HSbcdF+4nnw/OUWukAmn n2qlmhdViGNJLi8yQq3TudkTnR033ciJpaJINQKxiS6T46ECG5jiecLIEdZSxcenIBWB dLsQ== 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=rlvsGRSh3G6WjLZNcIcj8XNsHwQFnfAHDnDC9UKd33s=; b=JCSFz/EW7CGSUgnadwJyESeimO3FIQLd3xtZ5d5FQ/dCl16ykjY/dpZ5QSyFgWs414 MG5BfV7eCgqmlLHcQ8p/jfHkswDnZ1nnWis/m14A+Mb1FL/CwZLdfJtM1S5QsiOFd0Xj rCEXQtZCzUGKikHK2oPBPSb2hD/r8+/wB/WxpWoWoBEoO7y2yr/LQ6IC/glq/PvucxER +IrWXssm9k6o6HsL+9tqVQHahU68gg6mXAxTLzm9YkdJkzp/4BlObg8bvaXKJtf1rd73 wWMTTpAl8gpL3jycqvRpSQMM8Pd6ZbsZqQvnv67hkjViCvT1Ip5HC4GPMWHhrNFSBb3W gwHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nvXzikna; 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; 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 r16si14411907pgm.483.2019.02.21.08.24.51; Thu, 21 Feb 2019 08:24:52 -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=nvXzikna; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728659AbfBUQYu (ORCPT + 32 others); Thu, 21 Feb 2019 11:24:50 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:39200 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728515AbfBUQYr (ORCPT ); Thu, 21 Feb 2019 11:24:47 -0500 Received: by mail-pg1-f193.google.com with SMTP id r11so13914387pgp.6 for ; Thu, 21 Feb 2019 08:24:47 -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=rlvsGRSh3G6WjLZNcIcj8XNsHwQFnfAHDnDC9UKd33s=; b=nvXziknaaVshWu6Ezo3NvverMmrNNtpRS2Sc2DiZ1WEtW8H05P25ULr1FIBBpaekvC uXe5kQqhr5PD2+8SnxM50kt1xiuqO9x2AdgfPzzvoAdwF4rLjUBRFf7qDE2pvuB5ZPE8 8Opheva/dgHf1/snK8VeAar3GNXMAfUC8ATFKXlsFKqyO7UJ686a3CHv65xXmN/Yj5eP J5SFjm+2oAKAgHK4rciGM8fvPy5fHxsDVPUyyqTbW4LR2ac3SrdnJYUdZ/C2aldX0iu0 2gtWBP0A+S9hFDRfL5xJZcxBy3QJK7u7+J1FUCsSzHFQMgiei0YCZMEPpwW3dIfzbnx+ H/FA== 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=rlvsGRSh3G6WjLZNcIcj8XNsHwQFnfAHDnDC9UKd33s=; b=icKvHmWeuSEzSfnvf74go+Bh3Mb/JrcN2kp0xTc/y+KbbLqhawgtvqOyIzRa185Ltl tsMo/4is5siuiKtlc0pKxssJpoM3+7n29jmsH9nEmjPxk7QEnPQVCVBTUYd8KBmGTcXy nDsbgUYYyqHRw2W49UbKzYf5vZApV5PEtYmSpaKu++pcGXWmp5F+9e/E792fOKy8UdKj /X50PIEL0mCOAsSRWP91XKpIJpIBm61ivXrkZKYD1KR7o6gsaQ3MCrkOV3uKzxludbQd Q9A98oT5UIgfmjnM6mNSYpi/gr5z5iRv8vC9YsQaByAb3vh4HlxfiLPO0gVJjQ26PL3U PDsA== X-Gm-Message-State: AHQUAua8DB8mwC6muLhtsMeQoj0t9oDpk+tP0smom8f3Y96F/7yitaXq rIog4fZNT7qhAVKEy9YaGUoivA== X-Received: by 2002:a63:1625:: with SMTP id w37mr21612940pgl.13.1550766287013; Thu, 21 Feb 2019 08:24:47 -0800 (PST) Received: from localhost.localdomain ([116.75.87.120]) by smtp.gmail.com with ESMTPSA id 20sm21382910pfs.182.2019.02.21.08.24.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 08:24:46 -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 v3 5/5] soc: qcom: socinfo: Expose image information Date: Thu, 21 Feb 2019 21:54:19 +0530 Message-Id: <20190221162419.32384-6-vaishali.thakkar@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190221162419.32384-1-vaishali.thakkar@linaro.org> References: <20190221162419.32384-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 v2: - None Changes since v1: - None --- drivers/soc/qcom/socinfo.c | 210 +++++++++++++++++++++++++++++++++++++ 1 file changed, 210 insertions(+) -- 2.17.1 diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c index 5f4bef216ae1..f6a931ca8953 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,98 @@ 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); + if (!qcom_socinfo->boot) { + pr_err("Cannot create boot image directory\n"); + return; + } + + 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); + if (!qcom_socinfo->tz) { + pr_err("Cannot create tz image directory\n"); + return; + } + + 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); + if (!qcom_socinfo->rpm) { + pr_err("Cannot create rpm image directory\n"); + return; + } + + 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); + if (!qcom_socinfo->apps) { + pr_err("Cannot create apps image directory\n"); + return; + } + + 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); + if (!qcom_socinfo->mpss) { + pr_err("Cannot create mpss image directory\n"); + return; + } + + 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); + if (!qcom_socinfo->adsp) { + pr_err("Cannot create adsp image directory\n"); + return; + } + + 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); + if (!qcom_socinfo->cnss) { + pr_err("Cannot create cnss image directory\n"); + return; + } + + 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); + if (!qcom_socinfo->video) { + pr_err("Cannot create video image directory\n"); + return; + } + + 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)