From patchwork Thu Jul 11 21:39:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishali Thakkar X-Patchwork-Id: 168847 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp11899876ilk; Thu, 11 Jul 2019 14:39:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqymCexiui+l6HI+6Evke+Gm1IvItj0xjkUtVOgpHarwHn5OAd3ti6O6kCp6hkTOU12UycH6 X-Received: by 2002:a17:90a:d996:: with SMTP id d22mr7306553pjv.86.1562881168890; Thu, 11 Jul 2019 14:39:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562881168; cv=none; d=google.com; s=arc-20160816; b=e4eSV3EiEmRnBueXPR8PE1NUh6mOs9bDinZGvVWjEyAyZo3saTYEMqRgHiRBX4j7Hk hPkkFaYrZQ2+IlJxTDJ9XoSaaFVGt3EeBAEMpaF4ftaMkio8eX5XB42RSajBeEPUVXMD oVENiYwPkM9qktjpsWPzFi90aHv7pXJDsfeAgdVIY77cKGM3uTw5MiHJK0zFg9IQ3e7b PE3J+5Ovm6S3VqVlZf4Jzx1Q8icsJ/cOsF25i0bv1sPNssdHaHBz4X8eKlJ4jYPb9cAG HcTexo8qRIsDL/Vi6udY/2MZDiVtU3r4P8FKsFFOqostBYSbCrcovKu9mKH8ZY6WRe0B DJEQ== 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=9mZ61KKydl7XtmWNflo6S6ZKEPWBoobMC4o1X6705JE=; b=k4jiUaPGkR8d/CofB8SZ5OvF/F1wFAQJrtUeMN/3bQULji8pBWN6IT9x2HXfEmAytN 7t4Ailm0a4ruFLfuNHhj+JQNK32RXe/eeplrslPD2I/sKIQZB0JRV9jYBghH0bL5BnOg RlQClfnSQI/cmNyPICk7efK/F8n7uq5AQlhu672he05IUptqZxE0bs8uWeiEgz2c2HS/ a9kIulgXiBzxfukpgALj8qADAZIaGmtEbm8mjWKHIiHiuP51CFny/SldvPSOZL6KdU31 3OvhrvdyMZ2N6NcEe6dBQ+RZnZNsl95Sw4+1x6ow3uipJsJJ76XXbz86ArPOBoqq6zun TosQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q9kxtIzM; 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 y187si6205337pgd.66.2019.07.11.14.39.28; Thu, 11 Jul 2019 14:39:28 -0700 (PDT) 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=Q9kxtIzM; 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 S1729175AbfGKVj1 (ORCPT + 29 others); Thu, 11 Jul 2019 17:39:27 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:37739 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729152AbfGKVj0 (ORCPT ); Thu, 11 Jul 2019 17:39:26 -0400 Received: by mail-pl1-f193.google.com with SMTP id b3so3696042plr.4 for ; Thu, 11 Jul 2019 14:39:26 -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=9mZ61KKydl7XtmWNflo6S6ZKEPWBoobMC4o1X6705JE=; b=Q9kxtIzMG+/cHPtBtK5ej7nEkTudPoiCgAxJCQ905E8q15MRjvpJyoLePOq5w2Rh9e N2Ki7Q9fEiPGECS399LS7Yu/ysSUP2OYQiWCKg/JHR0b7877DTTWD0mPR5rKWSxbRlgU EJXC09ODygN6Jz3uTqkC13VMVqbT+2I3oKyMwKTkzuoUANWfQ7VDuU0zH1Wp79jU0YGt 1ivqHiuzBXYy7HIw1yygbcFjG0EFSAAws/HWOSVa3XE423YZLx/MrahGIWGJ5axSI0e2 GE/vvqX3qaPw5vfa1+QPeX6m0csee/jdp697Ge7lc5fgiU0E7UBoqgDSHP9PpPkcdLNt ULlA== 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=9mZ61KKydl7XtmWNflo6S6ZKEPWBoobMC4o1X6705JE=; b=XfRozl2YQvcDuqocAC1hW6xV/P/q3jfa0B5v6qF7ACD4ijQORwDfy5DqqKBl+3O6Tf aVvM47UC5oI4s/C3pyLe5gkID0DvDdeGZ4oHhkDhHBNRFLbdny/2Q0z251mtvEumV4Ec i7Qd+97d98Aowc4qUWLcStHaNllM7oewqO2OsGpZhfAigfqsqndnnWmSS2d4qQKfiFfF 8opfwIjrasmXSg3n8Scv7bNbkPPBp/VOk3jUFlaG5ELrLCvS2VMzXNNJKRtgdgjr+gmu FCchKxEjep3r/PgKslCkDRAbS9/on7dTNlaFB1Jf2cwmho559KYK8NecSVD3aXSOIMxX xYig== X-Gm-Message-State: APjAAAVGU7nKM2gpONnEMHLUjLcoHfOEpGLI93pHZcCSEg0pSWBCoXQr SgzdIPSzEY+T7uuH6A6YJfCm4Q== X-Received: by 2002:a17:902:a606:: with SMTP id u6mr6497067plq.275.1562881166311; Thu, 11 Jul 2019 14:39:26 -0700 (PDT) Received: from localhost.localdomain ([27.7.91.104]) by smtp.gmail.com with ESMTPSA id w3sm5709795pgl.31.2019.07.11.14.39.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jul 2019 14:39:25 -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 v5 2/5] base: soc: Export soc_device_register/unregister APIs Date: Fri, 12 Jul 2019 03:09:08 +0530 Message-Id: <20190711213911.23180-3-vaishali.thakkar@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190711213911.23180-1-vaishali.thakkar@linaro.org> References: <20190711213911.23180-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 Reviewed-by: Greg Kroah-Hartman Reviewed-by: Stephen Boyd Reviewed-by: Bjorn Andersson --- 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 @@ -166,0 +167 @@ struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr +EXPORT_SYMBOL_GPL(soc_device_register); @@ -175,0 +177 @@ void soc_device_unregister(struct soc_device *soc_dev) +EXPORT_SYMBOL_GPL(soc_device_unregister); From patchwork Thu Jul 11 21:39:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishali Thakkar X-Patchwork-Id: 168849 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp11899983ilk; Thu, 11 Jul 2019 14:39:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQB9qc3b9Pl41urJeS128kbOlfvfTFsRXK1/ul3CJTz2LjRlsy4QDEOVzjpdy23qi0azjK X-Received: by 2002:a17:90a:3724:: with SMTP id u33mr7191813pjb.19.1562881177190; Thu, 11 Jul 2019 14:39:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562881177; cv=none; d=google.com; s=arc-20160816; b=zYW01GJJEZZnn5UhJUoA/W39z6U/71fGMD4Yib6KKR1vM4uzW9jmprD6uxfAXvauDZ lDDRhqN/sNoQNQstP8SQt2Ege0MDHxTwRyFcIVggPr2rlXXR2yVvMupMRb/py/P+3O2V HSV2r+2/s8wQgcIKgW/hYDZ636c2/4t4+iYXy9gCzZKZks+G3vy79F6MUjFQ5pxlkodp IKKIS0QVgScC2YajyCc+fg+bdkN5eDpd5qpCmHi51DGmgPz08faOd6oXOpvMo1jhpMmT vnhhxuQ8r1G6jcJoiCafLpuDTjJr5zrY0kM7lzAvRIuAnTmO0aWdWhfHaobx6JAVMX85 L67A== 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=jXwph2UfDbz78cSxgU9L336K7eawYBM8cA2q3TIo9E8=; b=gJCH1sm4HuhiqVvsqJZmTUsBARHJ/NDxFnC95bTt8fir89uEif73g4XMYqHdh7L9V7 HPo4Gj0XDsMKvKqY3yCBxip4AH/XgJY1KK7D4mghXUSfNGDQPwNj7Kr/ORK4uEHlSR7N LvCbszQXcRePNUz7qzC4KpGwLfBTZCmyANrs3DjkBHkaXRUvENSATeYPO7w6hrb2HENB lF5+jdGZw6sZKkOvJhUN4lNxS9uoRO7W9BPBdKFbRyzSFapGfcwyqd1P0pXlDlyEUNnq mFl8s4zxlfHUSKQMhe3MlvFoK8rIp1VGBc21+satXfUWKG5E47lalnm08FAn11qSmBS8 cLhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UOlpjPpc; 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 k62si3084841pgd.258.2019.07.11.14.39.36; Thu, 11 Jul 2019 14:39:37 -0700 (PDT) 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=UOlpjPpc; 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 S1729212AbfGKVjg (ORCPT + 29 others); Thu, 11 Jul 2019 17:39:36 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:38672 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728883AbfGKVje (ORCPT ); Thu, 11 Jul 2019 17:39:34 -0400 Received: by mail-pf1-f196.google.com with SMTP id y15so3352230pfn.5 for ; Thu, 11 Jul 2019 14:39:34 -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=jXwph2UfDbz78cSxgU9L336K7eawYBM8cA2q3TIo9E8=; b=UOlpjPpcTtkV8+FVo477lavTksqLf81n2KqNXEiWlWEgHhEhMi7rsZWT2z4lYWdB84 py7eEldL/QN981einS5g7QLZhJle/XYWsQa7e8HNMRiJKazfUPIeytFYk2OsbR9UaZip encC34pr4GyMRD3ScpWitIEVZOAOmDNmVlHsfVW5DykIm5+HDFczOvCzwhEc0FhxXLrZ Cz61KW3hVfxzzti9i8xkt6yiPE4Koal9R34hkuA9o7hhKJd2c2J7ftIadjHRCuo15BBP IB4Z2rdqutE6R5yt5apIP32xspa23qeOERoPP8C12tmg4nJy1t48yP8/bJFZ8zG4vaGC ggCA== 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=jXwph2UfDbz78cSxgU9L336K7eawYBM8cA2q3TIo9E8=; b=Z3dk6KYocIA/awALAXXtGIx0JSl2KWgpzpSTAI7PQvQGKcoJfiAxvT0JYMO8XDk84T JJT8TdGo5cCC1uQzq/iNla4RLIXPnlEJG6to6u8cCFw/Y8noYhL0pRqTz4CSSxvm4Krb 4vxMDOaf6Egt/Ae8JT3AgtfT7VFuSZoolboGzxIcnv3bIrDmIW6UifEH1uCzbPsHkgO+ DmH7ttwettDtTrnVnsKgIiJ7xf1xFbXD16qPOY5DesF3uLtbl+cbXxHVIPN3OnlrA4HC QpUHAd9KpUDkF/osk3QeaSC2q7mO0lQbfGm0hq54bWBK2R2Xwpv76zzQ6l14fex5Y4Tw f7Mw== X-Gm-Message-State: APjAAAUGLAK/7pR/ejgaeivlIOBWT7QOCZNF+jL2Z4rIPAQ97Sueh4K/ c2vvJmUKBU0sn0DYFgK/Aopc5g== X-Received: by 2002:a17:90a:d998:: with SMTP id d24mr7186590pjv.89.1562881174146; Thu, 11 Jul 2019 14:39:34 -0700 (PDT) Received: from localhost.localdomain ([27.7.91.104]) by smtp.gmail.com with ESMTPSA id w3sm5709795pgl.31.2019.07.11.14.39.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jul 2019 14:39: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, Vaishali Thakkar Subject: [PATCH v5 4/5] soc: qcom: socinfo: Expose custom attributes Date: Fri, 12 Jul 2019 03:09:10 +0530 Message-Id: <20190711213911.23180-5-vaishali.thakkar@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190711213911.23180-1-vaishali.thakkar@linaro.org> References: <20190711213911.23180-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 v4: - Introduce socinfo_params and use create_debugfs_{u32,x32} instead of driver specific macros - Remove some unnecessary separate functions [qcom_show_{platform_subtype,accessory_chip}] and use debugfs core functions to expose their values - Use switch to expose custom attributes based on the firmware version - Misc: Drop unnecessory comments, pmic_model->pmic_models, don't pass socinfo pointer in qcom_socinfo - Note: I didn't introduce any new debugfs core functions for printing string values because it wasn't possible to cover both cases of string arrays in this file - pmic_model and build_id by introducing a single function. Morever, I still needed QCOM_OPEN and DEBUGFS_ADD to cover the case of pmic_die_rev so introducing the 'debugfs create string array function' wasn't completely eliminating extra macro code. So, I'm just using the above mentioned macros to print string array values for now. Feel free to on this matter. Thanks! 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 | 190 +++++++++++++++++++++++++++++++++++++ 1 file changed, 190 insertions(+) -- 2.17.1 diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c index 1b9eb44df7fe..6a4795433d57 100644 --- a/drivers/soc/qcom/socinfo.c +++ b/drivers/soc/qcom/socinfo.c @@ -6,0 +7 @@ +#include @@ -22,0 +24 @@ +#define SOCINFO_VERSION(maj, min) ((((maj) & 0xffff) << 16)|((min) & 0xffff)) @@ -31,0 +34,21 @@ +#ifdef CONFIG_DEBUG_FS +static const char *const pmic_models[] = { + [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 */ + @@ -69,0 +93,15 @@ struct socinfo { +#ifdef CONFIG_DEBUG_FS +struct socinfo_params { + u32 raw_device_family; + u32 hw_plat_subtype; + u32 accessory_chip; + u32 raw_device_num; + u32 chip_family; + u32 foundry_id; + u32 plat_ver; + u32 raw_ver; + u32 hw_plat; + u32 fmt; +}; +#endif /* CONFIG_DEBUG_FS */ + @@ -72,0 +111,4 @@ struct qcom_socinfo { +#ifdef CONFIG_DEBUG_FS + struct dentry *dbg_root; + struct socinfo_params info; +#endif /* CONFIG_DEBUG_FS */ @@ -132,0 +175,144 @@ static const char *socinfo_machine(struct device *dev, unsigned int id) +#ifdef CONFIG_DEBUG_FS + +#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(info, name) \ + debugfs_create_file(__stringify(name), 0400, \ + qcom_socinfo->dbg_root, \ + info, &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_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_models[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; +} + +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); + +static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo, + struct socinfo *info) +{ + size_t size; + + qcom_socinfo->dbg_root = debugfs_create_dir("qcom_socinfo", NULL); + + qcom_socinfo->info.fmt = __le32_to_cpu(info->fmt); + + switch (qcom_socinfo->info.fmt) { + case SOCINFO_VERSION(0, 12): + qcom_socinfo->info.chip_family = + __le32_to_cpu(info->chip_family); + qcom_socinfo->info.raw_device_family = + __le32_to_cpu(info->raw_device_family); + qcom_socinfo->info.raw_device_num = + __le32_to_cpu(info->raw_device_num); + + debugfs_create_x32("chip_family", 0400, qcom_socinfo->dbg_root, + &qcom_socinfo->info.chip_family); + debugfs_create_x32("raw_device_family", 0400, + qcom_socinfo->dbg_root, + &qcom_socinfo->info.raw_device_family); + debugfs_create_x32("raw_device_number", 0400, + qcom_socinfo->dbg_root, + &qcom_socinfo->info.raw_device_num); + case SOCINFO_VERSION(0, 11): + case SOCINFO_VERSION(0, 10): + case SOCINFO_VERSION(0, 9): + qcom_socinfo->info.foundry_id = __le32_to_cpu(info->foundry_id); + + debugfs_create_u32("foundry_id", 0400, qcom_socinfo->dbg_root, + &qcom_socinfo->info.foundry_id); + case SOCINFO_VERSION(0, 8): + case SOCINFO_VERSION(0, 7): + DEBUGFS_ADD(info, pmic_model); + DEBUGFS_ADD(info, pmic_die_rev); + case SOCINFO_VERSION(0, 6): + qcom_socinfo->info.hw_plat_subtype = + __le32_to_cpu(info->hw_plat_subtype); + + debugfs_create_u32("hardware_platform_subtype", 0400, + qcom_socinfo->dbg_root, + &qcom_socinfo->info.hw_plat_subtype); + case SOCINFO_VERSION(0, 5): + qcom_socinfo->info.accessory_chip = + __le32_to_cpu(info->accessory_chip); + + debugfs_create_u32("accessory_chip", 0400, + qcom_socinfo->dbg_root, + &qcom_socinfo->info.accessory_chip); + case SOCINFO_VERSION(0, 4): + qcom_socinfo->info.plat_ver = __le32_to_cpu(info->plat_ver); + + debugfs_create_u32("platform_version", 0400, + qcom_socinfo->dbg_root, + &qcom_socinfo->info.plat_ver); + case SOCINFO_VERSION(0, 3): + qcom_socinfo->info.hw_plat = __le32_to_cpu(info->hw_plat); + + debugfs_create_u32("hardware_platform", 0400, + qcom_socinfo->dbg_root, + &qcom_socinfo->info.hw_plat); + case SOCINFO_VERSION(0, 2): + qcom_socinfo->info.raw_ver = __le32_to_cpu(info->raw_ver); + + debugfs_create_u32("raw_version", 0400, qcom_socinfo->dbg_root, + &qcom_socinfo->info.raw_ver); + case SOCINFO_VERSION(0, 1): + DEBUGFS_ADD(info, build_id); + break; + } +} + +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, + struct socinfo *info) +{ +} +static void socinfo_debugfs_exit(struct qcom_socinfo *qcom_socinfo) { } +#endif /* CONFIG_DEBUG_FS */ + @@ -164,0 +351,2 @@ static int qcom_socinfo_probe(struct platform_device *pdev) + socinfo_debugfs_init(qs, info); + @@ -178,0 +367,2 @@ static int qcom_socinfo_remove(struct platform_device *pdev) + socinfo_debugfs_exit(qs); + From patchwork Thu Jul 11 21:39:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishali Thakkar X-Patchwork-Id: 168850 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp11900060ilk; Thu, 11 Jul 2019 14:39:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqznQ5ZBIg6u9qJIfRcUS85GtLkybCLf/1B8YUEPTq8GuQo4jFm0afKO9qQMD73h8i+RzezK X-Received: by 2002:a65:4786:: with SMTP id e6mr6508032pgs.448.1562881182584; Thu, 11 Jul 2019 14:39:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562881182; cv=none; d=google.com; s=arc-20160816; b=Xy0s90fHaBqHm1hwKb81WkI06G7jDmb2LjRpGLk+KxmtlP0KluH/ZjxJSikTtYVxL2 5A3EjUsULCQjeXJFWu1Li8jR8VL7A4tdtHH9zn31JqZCzEm/e7Z0nTG327lxXtY6ReCv SfgMrRRWgPTMqUY1hrxckEhSL0aN3XjoJ/99Xyj7rbbZfetIoaWtDH3pGq6nyQYUKauE 3buWySpFDbnBQec6jdAvh4tDFIl4hHDnbDsMjSS5LbZt7IEXevhs5EUiSGV9fqcxedWm 9OwgoyBnj2s1lFFOipJXly0+FTCkK02htchqdYCDIv44c9RwYo2rljJQWRDDtVR7GD9h 8+eA== 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=xTYoybvYWHee/RFEpMdNa4wDHWkYkkBOifukpaMKMKE=; b=YgkwR+iyd6vhHAEqA46Y5kl/Rzys7WtfFxcfV6Ebo75NPdsf6JbSUAWIOwltxPDeh6 fZgqTgcn8LYciXI7xngb3wAjlH7xVMSJi+8fMp35FW/o9AuTzmTlIq8Xd5U8Rqp8FUcU VRFU8ATOODV+VNkpgP+Gho4yRTtOpqYSOH6ch7Jtt5uQgtiSRJHniL1jzeOgixOgJaKt pvo9nT9wfcVgMVX6g/Fwuv1YJsEBC5euLjjZc5OzlMsjQzIERAG2/MeCHQFL6A/VjB34 4IhovEG//JH4ca2pHLp623UvHdNvPh/+ml6lFfHKfYrqfTMPwMRzx8fx/NfIQsgzmM92 N9+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ok8sIZWd; 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 l9si6628037pgm.43.2019.07.11.14.39.42; Thu, 11 Jul 2019 14:39:42 -0700 (PDT) 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=ok8sIZWd; 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 S1729233AbfGKVjk (ORCPT + 29 others); Thu, 11 Jul 2019 17:39:40 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:46472 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728883AbfGKVji (ORCPT ); Thu, 11 Jul 2019 17:39:38 -0400 Received: by mail-pl1-f195.google.com with SMTP id c2so3673386plz.13 for ; Thu, 11 Jul 2019 14:39:38 -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=xTYoybvYWHee/RFEpMdNa4wDHWkYkkBOifukpaMKMKE=; b=ok8sIZWdQ/jFVh/panVyfJtxBPWBijrFD2XMIe9u0Y8rfYhWfFPzh12uv+/9cyiY0D BJjkr7KrQv3R/SKG+WGR1RivVUxQUspmZwtrWsZfQbI/CLE1nygkCz6Rm6YH220z2pWo +Jq65hoKKSWboUAnZSmT3m7pp/lmd8Cc1MnMLejT1sODBWjPEGQTtEaghlfXuBG0fVvM TqGP+MI7ZridGqgSIICkq6CS/q40EKGMzIyGlt7GxMqIdFSzUeeUTEOSFFU6wuT5+avO hNdmwDWDl4hyW3t6bLdOEAR+DaPur9tRhMsuCaHw7dvCf2v3t/Dfj45/77qAcluc8ANb GUYw== 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=xTYoybvYWHee/RFEpMdNa4wDHWkYkkBOifukpaMKMKE=; b=ZAS5+2g+Bmt4J9/GYjok/4StUKER1jkxQkTc2auFRaNsmah6PGYNcz97y7Tb+zyt2p KydmH8mXzCvUoUfoWZcuiPSNCbtHgq0j/8n6gqhvD+TzhA2qcUZ7mm8bT/GXc9T0bKkm HvHp2Mbb81CgMODV5Q7CkFIsUoicAKkRGOO1q79iIcKrn5aCH7JBfykZhI2fiGPmUuUQ NTbWYWG40RJ3HGfpKXV9JR3yn+MHVIWtnp31qydu9TutB3usXZhvz8fEqeU2po5TQBU4 2ouqgwaYSATeRKyEQHHfSrPoJwKC4iKdCLSlA4H3MpADG4GYbsmuchyOFTo8aw9kNIwH myfA== X-Gm-Message-State: APjAAAWz9k650mqS/TcxwPwu3TKTXBPtGX8f7pOtCCt4jzg6qaK6lHHe XYW9nHFDGYP9o2uHJ1La9Pgi3g== X-Received: by 2002:a17:902:e613:: with SMTP id cm19mr6576707plb.299.1562881178036; Thu, 11 Jul 2019 14:39:38 -0700 (PDT) Received: from localhost.localdomain ([27.7.91.104]) by smtp.gmail.com with ESMTPSA id w3sm5709795pgl.31.2019.07.11.14.39.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jul 2019 14:39:37 -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 v5 5/5] soc: qcom: socinfo: Expose image information Date: Fri, 12 Jul 2019 03:09:11 +0530 Message-Id: <20190711213911.23180-6-vaishali.thakkar@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190711213911.23180-1-vaishali.thakkar@linaro.org> References: <20190711213911.23180-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 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 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 @@ -34,0 +35,33 @@ +#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", +}; + @@ -105,0 +139,7 @@ struct socinfo_params { + +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]; +}; @@ -232,0 +273,24 @@ 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); + @@ -235,0 +300,2 @@ static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo, + struct smem_image_version *versions; + struct dentry *dentry; @@ -236,0 +303 @@ static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo, + int i; @@ -304,0 +372,17 @@ static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo, + + 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); + }