From patchwork Thu Jul 25 22:18:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 169767 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp12183203ilk; Thu, 25 Jul 2019 15:20:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqzDXfA2G0sJsPnhNCJVzHoYsJfA1YnC7iPoU6N8WY85fEDHqj5vymv2CadHmkrd68Ul861m X-Received: by 2002:a62:1d8f:: with SMTP id d137mr19313140pfd.207.1564093217543; Thu, 25 Jul 2019 15:20:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564093217; cv=none; d=google.com; s=arc-20160816; b=hqQULjtookw1GdfVFRfN9euNBTXSTTsjgyazDhkfiu5xpxJy5Sue/Ksga3Q2ebTe+f sT82mAs92S3zbfJzds1/bRKtCOoL5ro1W5kqOju/F8oq52xdgP3BHbiB2+ieo5hQiu4x R5a+pgmhiXx7bpPIZ1rzQL8OKckHrV9NxsJ1OIpZOPxcKHq5vlyEFbh00pMgEOmBL7Ek 650ISPw1bDNTn0vhzG8Pdl/8SNP19zscuITFB4ox59bzAUG6Kkh5pghXArXT6k8rcd2i AMlfrRuPjY0ErzZE8DVDYU+v9lci51XWYfCn5KnQFDojE/gGRb/UPkhxxXs+NS8armvg IpXQ== 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=sgLAsMf3tNoy5aMAxpDD6qYpvryasSPOG21vNe1gMGQ=; b=BwkbtUce6F3r0gt1Vgqk+niMjwoMRT7V+JPgnTV7NnY2BldD1y5DiSOJRk7x4iERbV Iogy0sQ1NBeBmWJju9jfMGzIXW3Ov4wheaLZ+exGwjU7oBsWmlSEAJJ8KG+cvgivEOdc Mtpd9+fkh9HwjIa0JMOpPSXaDpgc10VCOd8O3OFGcUjAfxy/dRboYQSj6+CTLnVp/VNT 9HC+ZZdOYKy47eGxOJVDarQ3GyiLJ9BA25pKeUfc62O4agWG+eMEd82M0tPu/pA29u/O NNouRrjZSmzVnVI7MHtN0O62CHQGq/gcPNtJ6s+qgKBf+h7/PQ6bi74MkJjdgJKx7M0G PTeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xCw3C5AX; 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 bg2si16076220plb.263.2019.07.25.15.20.17; Thu, 25 Jul 2019 15:20:17 -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=xCw3C5AX; 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 S1726829AbfGYWUQ (ORCPT + 15 others); Thu, 25 Jul 2019 18:20:16 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:36311 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726959AbfGYWTO (ORCPT ); Thu, 25 Jul 2019 18:19:14 -0400 Received: by mail-pl1-f194.google.com with SMTP id k8so23942017plt.3 for ; Thu, 25 Jul 2019 15:19:13 -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=sgLAsMf3tNoy5aMAxpDD6qYpvryasSPOG21vNe1gMGQ=; b=xCw3C5AXZ3iwVVspZ/Sf7un1Xb/Y4ptsWpDNoVLh+zKSqefc1xJXf6Njj/TLjTMVO5 Y21PIn9jQvX7V1Cx0GJrSmxAU8xRmVOZMFr2xdbaNNHSMpK9BL72d9/6Fccmo1k8Puf6 14hjjLAjP6lE2HM6wF5bUr/5jQOfoU+gw5zj+Ij6OzjmlkmpuQgDLd6OD47TL0s1qAa7 CCGzY/E7uzgwcNDKXCHA3e9mM4YUfsBmPi3jboqweXzwDjhPwyWVw/xkycFVej9+JUa7 sqtaKqkWnv5mivp2UxDpl1cRO4EHYhFCzwRsVpiYw4fS7oMfpJNRTC1KGiipLbL7kZg5 E+Sg== 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=sgLAsMf3tNoy5aMAxpDD6qYpvryasSPOG21vNe1gMGQ=; b=Y0dL3FZED7FQk4RYjCJZMMW+yEj2dMsqUxwmNAHXtYHn/it/7d7YPOji6yuP4TybKK Os6CPb0ycKOfgctEqbzU9SMYvsfnRDSH0wYK2nOWmQCHJTevvUOxb8oQAY6c+vG6XvSA ah5RsTbmIm62OSqRdt5vGzgVC6VE6IVOUw/uXln33hOQ7OCJNq3rQRGNOfK07VxeLG2p UPVYsEzsbC3ceU8cWjZIpPsCvRr/zkICoFJ9lKHYlnGQRobUpi0Fg0gjP05qXGM/0dHD srJlKr2qusid4SIsRH/QnWvfjQ5mCNhKuG2zF1MtmcLmziEqT0M5ag4C2a7HEOYFnx48 jD/w== X-Gm-Message-State: APjAAAU7YBcvOyV8fNs0Z/NQx7AWPG9ng6ND9+Hry9X06l9DzbzRk2f2 cT4G4Ka0kTkwTYFGwUfiohrHNA== X-Received: by 2002:a17:902:102c:: with SMTP id b41mr91445248pla.204.1564093153359; Thu, 25 Jul 2019 15:19:13 -0700 (PDT) Received: from localhost ([49.248.170.216]) by smtp.gmail.com with ESMTPSA id p68sm61956062pfb.80.2019.07.25.15.19.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Jul 2019 15:19:12 -0700 (PDT) From: Amit Kucheria To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, andy.gross@linaro.org, Andy Gross , Daniel Lezcano , Mark Rutland , Rob Herring , Zhang Rui Cc: linux-pm@vger.kernel.org Subject: [PATCH 04/15] drivers: thermal: tsens: Add debugfs support Date: Fri, 26 Jul 2019 03:48:39 +0530 Message-Id: <534b5017c2210ba8d541c206dace204d6617b4c9.1564091601.git.amit.kucheria@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Dump some basic version info and sensor details into debugfs Signed-off-by: Amit Kucheria --- drivers/thermal/qcom/tsens-common.c | 85 +++++++++++++++++++++++++++++ drivers/thermal/qcom/tsens.c | 2 + drivers/thermal/qcom/tsens.h | 6 ++ 3 files changed, 93 insertions(+) -- 2.17.1 diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c index 7437bfe196e5..7ab2e740a1da 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,79 @@ 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); + + return; +} +#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 +273,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 +321,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 06c6bbd69a1a..772aa76b50e1 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 d022e726d074..e1d6af71b2b9 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]; };