Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5467515ybl; Tue, 27 Aug 2019 05:16:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqz56e/rfW4NAHmAQFIrSoZ+4DIIbnioHWnNssbTXBAUR6mRTKg3SSJ69dADkpxITpg1f6oH X-Received: by 2002:a62:f24b:: with SMTP id y11mr26115312pfl.0.1566908166703; Tue, 27 Aug 2019 05:16:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566908166; cv=none; d=google.com; s=arc-20160816; b=TEgQEvZjAgfxdkMMYWwOduI/i/o08OjVtXtjOdLiwndrgFOVZdxHaWxiJlgaNDyMxl VLqK06f+xez2T4RUQUPuuxihzZe4bOnx2zXZK3Qm5gUppKsSnTRndFkfy8kXNfl9bQtN URsLTTLm4hr51KGqtvi1DPbCPVTHs2X2tBIIJT1CEdhefAQvxq9OTpfa2nY6IDQ5LZua 2ghLPLm+Tjx6HqESlV58Bn+eSchIiUL9OtzsRa1XFDWsSLuPbrO9WM3et+iaKOlIxMAt Q652ErXqMWu3TLpEH1yfRpOtKjejk17RISzkB9rNbv6z0icDMq41gO3HC7/6bSFkKWyU cJzA== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=txPasp1wzNBQGWPXENBmgM/OMI6t6T6Qqvvtan2Z3Gs=; b=ipXBGDmL3CsoBtNlOcGhbhNeJbjy/HgqbRbXmvPQpsNoK5M56JqflkmJ2TfnV0JIE8 EJmm+qYu1xkLi6Nkhtn6fC+kUmFqmrRRTA7xmLrEcDxg6jyEg/XETKNRrwG91I0bJ/O0 aqqbCz8B+Na4HiSvnstd8HlVX6ZgiOhObUMAMJ/zNNoE8X3L7KjdLhY7U9qBI0qdqGiS tjKRMLvT3Mb+LaiqC3Eedj2WCL1B73uxnMhBioaDyVtJDPiEvOFaA7WZoKezNB2BBlWi mlDX+xGPRszyIwRi7T4kr3Lc/cxQ13kSyC+7XuBncT1SM2uvTXwQQRUwXTCPYd5et7cK KuoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hccm/k4B"; 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 t17si11409216pgu.48.2019.08.27.05.15.50; Tue, 27 Aug 2019 05:16:06 -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="hccm/k4B"; 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 S1729750AbfH0MOn (ORCPT + 99 others); Tue, 27 Aug 2019 08:14:43 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:43888 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729717AbfH0MOl (ORCPT ); Tue, 27 Aug 2019 08:14:41 -0400 Received: by mail-pf1-f194.google.com with SMTP id v12so14008252pfn.10 for ; Tue, 27 Aug 2019 05:14:40 -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 :in-reply-to:references; bh=txPasp1wzNBQGWPXENBmgM/OMI6t6T6Qqvvtan2Z3Gs=; b=hccm/k4BT6LsSDKcZ7iWMQe5ikVb9f2HaL9Zxp8U+ENditovQoGgf7xJxZt8bcUX+b /tZFFzoSb/Opj7lG41EVMTiVk3o6awWJKG8f/yIqR7ZS1LnbAmAA46ONjbycW4jayWuN Agz5GNuPAx2YQbhBVwFm9ZQNEXs1yU9Pk6h3QPGpJbmkKr7IGmUztr+4tecwrWN+qxc9 RK+pjRTyWTa9CBNqKC+5BdTkAYDoIQCztH++Z4gIeqAu+lse5FwnuzW11esiXk6kWMwS gqKqgiQUKJzD6a+JXsbvGuxVl3cWkZrLO0PkcmeFQ92W3W3eBDO1haebMkIidfLiP0M5 UgDg== 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:in-reply-to:references; bh=txPasp1wzNBQGWPXENBmgM/OMI6t6T6Qqvvtan2Z3Gs=; b=XDimo9ExJZlTnmjXZyO+NqRPKReR9qscZbVcRg009zKc8GwlPsLJDrl/Bn/WJHYBny J2tQ+JPzDhhHqPdt9vw00+2v6WnIidhoOA+ZXLhcfM0lta9szqZpV2FNG362tf9nXPr+ +ogwh/fnY07KvWRWHVnzSDkbdFYo9dBrieGVrxDmAxilH+zDQo+jmFA74ilvtUrtgxvV JJTHg4U4r2otfBepjcdKurWIjtUIFPGd/DL5+irUxnZ4Qa7ukk/kitb9d1AeHOGTmWnQ qBvXnJfO2Apd6yRi03py9V4DWzbqQcPFI0N0L4i9NZmF12wQ8Y0C/GcPFgZkgvFlCZJ1 GyTw== X-Gm-Message-State: APjAAAVN8bxx4rFRAapkgqItGFneyV2AxX7KVC9mQZ8G8qj3Rw1LA4/8 FraSsAFDP4qnRo4cZBSBhBCYheQNZaHoeA== X-Received: by 2002:a63:5d54:: with SMTP id o20mr21212194pgm.413.1566908079872; Tue, 27 Aug 2019 05:14:39 -0700 (PDT) Received: from localhost ([49.248.54.193]) by smtp.gmail.com with ESMTPSA id y10sm2584243pjp.27.2019.08.27.05.14.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Aug 2019 05:14:39 -0700 (PDT) From: Amit Kucheria To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, agross@kernel.org, sboyd@kernel.org, masneyb@onstation.org, marc.w.gonzalez@free.fr, Daniel Lezcano , Mark Rutland , Rob Herring , Zhang Rui Cc: linux-pm@vger.kernel.org Subject: [PATCH v2 04/15] drivers: thermal: tsens: Add debugfs support Date: Tue, 27 Aug 2019 17:44:00 +0530 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dump some basic version info and sensor details into debugfs. Example from qcs404 below: --(/sys/kernel/debug) $ ls tsens/ 4a9000.thermal-sensor version --(/sys/kernel/debug) $ cat tsens/version 1.4.0 --(/sys/kernel/debug) $ cat tsens/4a9000.thermal-sensor/sensors max: 11 num: 10 id slope offset ------------------------ 0 3200 404000 1 3200 404000 2 3200 404000 3 3200 404000 4 3200 404000 5 3200 404000 6 3200 404000 7 3200 404000 8 3200 404000 9 3200 404000 Signed-off-by: Amit Kucheria --- drivers/thermal/qcom/tsens-common.c | 83 +++++++++++++++++++++++++++++ drivers/thermal/qcom/tsens.c | 2 + drivers/thermal/qcom/tsens.h | 6 +++ 3 files changed, 91 insertions(+) diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c index 7437bfe196e50..ea2c46cc6a66a 100644 --- a/drivers/thermal/qcom/tsens-common.c +++ b/drivers/thermal/qcom/tsens-common.c @@ -3,6 +3,7 @@ * Copyright (c) 2015, The Linux Foundation. All rights reserved. */ +#include #include #include #include @@ -139,6 +140,77 @@ int get_temp_common(struct tsens_sensor *s, int *temp) return 0; } +#ifdef CONFIG_DEBUG_FS +static int dbg_sensors_show(struct seq_file *s, void *data) +{ + struct platform_device *pdev = s->private; + struct tsens_priv *priv = platform_get_drvdata(pdev); + int i; + + seq_printf(s, "max: %2d\nnum: %2d\n\n", + priv->feat->max_sensors, priv->num_sensors); + + seq_puts(s, " id slope offset\n--------------------------\n"); + for (i = 0; i < priv->num_sensors; i++) { + seq_printf(s, "%8d %8d %8d\n", priv->sensor[i].hw_id, + priv->sensor[i].slope, priv->sensor[i].offset); + } + + return 0; +} + +static int dbg_version_show(struct seq_file *s, void *data) +{ + struct platform_device *pdev = s->private; + struct tsens_priv *priv = platform_get_drvdata(pdev); + u32 maj_ver, min_ver, step_ver; + int ret; + + if (tsens_ver(priv) > VER_0_1) { + ret = regmap_field_read(priv->rf[VER_MAJOR], &maj_ver); + if (ret) + return ret; + ret = regmap_field_read(priv->rf[VER_MINOR], &min_ver); + if (ret) + return ret; + ret = regmap_field_read(priv->rf[VER_STEP], &step_ver); + if (ret) + return ret; + seq_printf(s, "%d.%d.%d\n", maj_ver, min_ver, step_ver); + } else { + seq_puts(s, "0.1.0\n"); + } + + return 0; +} + +DEFINE_SHOW_ATTRIBUTE(dbg_version); +DEFINE_SHOW_ATTRIBUTE(dbg_sensors); + +static void tsens_debug_init(struct platform_device *pdev) +{ + struct tsens_priv *priv = platform_get_drvdata(pdev); + struct dentry *root, *file; + + root = debugfs_lookup("tsens", NULL); + if (!root) + priv->debug_root = debugfs_create_dir("tsens", NULL); + else + priv->debug_root = root; + + file = debugfs_lookup("version", priv->debug_root); + if (!file) + debugfs_create_file("version", 0444, priv->debug_root, + pdev, &dbg_version_fops); + + /* A directory for each instance of the TSENS IP */ + priv->debug = debugfs_create_dir(dev_name(&pdev->dev), priv->debug_root); + debugfs_create_file("sensors", 0444, priv->debug, pdev, &dbg_sensors_fops); +} +#else +static inline void tsens_debug_init(struct platform_device *pdev) {} +#endif + static const struct regmap_config tsens_config = { .name = "tm", .reg_bits = 32, @@ -199,6 +271,15 @@ int __init init_common(struct tsens_priv *priv) goto err_put_device; } + if (tsens_ver(priv) > VER_0_1) { + for (i = VER_MAJOR; i <= VER_STEP; i++) { + priv->rf[i] = devm_regmap_field_alloc(dev, priv->srot_map, + priv->fields[i]); + if (IS_ERR(priv->rf[i])) + return PTR_ERR(priv->rf[i]); + } + } + priv->rf[TSENS_EN] = devm_regmap_field_alloc(dev, priv->srot_map, priv->fields[TSENS_EN]); if (IS_ERR(priv->rf[TSENS_EN])) { @@ -238,6 +319,8 @@ int __init init_common(struct tsens_priv *priv) } } + tsens_debug_init(op); + return 0; err_put_device: diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index 06c6bbd69a1a7..772aa76b50e12 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -3,6 +3,7 @@ * Copyright (c) 2015, The Linux Foundation. All rights reserved. */ +#include #include #include #include @@ -176,6 +177,7 @@ static int tsens_remove(struct platform_device *pdev) { struct tsens_priv *priv = platform_get_drvdata(pdev); + debugfs_remove_recursive(priv->debug_root); if (priv->ops->disable) priv->ops->disable(priv); diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h index d022e726d0747..e1d6af71b2b9a 100644 --- a/drivers/thermal/qcom/tsens.h +++ b/drivers/thermal/qcom/tsens.h @@ -292,6 +292,8 @@ struct tsens_context { * @feat: features of the IP * @fields: bitfield locations * @ops: pointer to list of callbacks supported by this device + * @debug_root: pointer to debugfs dentry for all tsens + * @debug: pointer to debugfs dentry for tsens controller * @sensor: list of sensors attached to this device */ struct tsens_priv { @@ -305,6 +307,10 @@ struct tsens_priv { const struct tsens_features *feat; const struct reg_field *fields; const struct tsens_ops *ops; + + struct dentry *debug_root; + struct dentry *debug; + struct tsens_sensor sensor[0]; }; -- 2.17.1