Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp763064imm; Wed, 4 Jul 2018 05:40:56 -0700 (PDT) X-Google-Smtp-Source: AAOMgperbIgEQgPSncvJG81WOjcKH6QJDxWWdXjrd61kjhVKkE27au/dieU69eETB0rJhnsXcboT X-Received: by 2002:a62:998:: with SMTP id 24-v6mr457970pfj.99.1530708055970; Wed, 04 Jul 2018 05:40:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530708055; cv=none; d=google.com; s=arc-20160816; b=MnTdR0cqTB+EY8QTUXJDptmJjJp93/Ka/8xu00w7OIgxbHCc7hCw68Xztx42HRHIBP Y8MT3IcIpsZqEmB9KXs/7NKg+2/lWuBdTlkjYq9Nal9AP3MXhqeu5UYL+/iM1ciVRSsV WLI2ZcRPm3/71bGN6g2hYjVhcXCtqFh/oweqxRF+xWPiGwP3c51hTObCmTOa+iYi77mS r8fmXH9w/2bx9A8jpwkbmYIXOB0hlNPLbWj3YJ5JXb7yQTAUxpnKDpl1w6f+E0rSCh5F NTJIoMq4dmTS96oKJpAftjbQILuv7GYBSb1yqiEk2gy6JM2lw6y0y0m7+lKFdyA5Wsug Odrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=Rd4UUJQ6Zk3/xcTu4yTKZ7EMzqap7F6YLq2NRy1EvcI=; b=tdqzdmj2zQhqj1XdcRiv8/RBdjqLK3dOB4sGZyfd7mQVsTUvpkn0g+sqiAXNSA46bj LMShox2KnBY8I1zsgW6cSFNt1RHBbev7x40unjQp44RAJG2NbVTMlIB58oh5KIp4QsiL ZsBdauGsMZZbyZ1Yk9Ou9W0TotkKQiH64Ao0vfwgNabV/S/oGQbxNyX1YGx43hHo6Ve/ Do1xrEHGnk/UEqQAZ3tG4dxursSeB/S0nfguKEkvZjj689Yp1fvDypDTcQBStukgwpWV uxiGXriRBROFGvIz1qfvrYn+4zmi7yTHARLhwfAAvuuuY3ur+TDV4sphtIa2W+JqXc+z E9Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KwW2oZZ9; 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 a5-v6si3533417plh.340.2018.07.04.05.40.41; Wed, 04 Jul 2018 05:40:55 -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=KwW2oZZ9; 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 S934787AbeGDMim (ORCPT + 99 others); Wed, 4 Jul 2018 08:38:42 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:35305 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934324AbeGDMij (ORCPT ); Wed, 4 Jul 2018 08:38:39 -0400 Received: by mail-qt0-f193.google.com with SMTP id z6-v6so4384086qti.2 for ; Wed, 04 Jul 2018 05:38:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Rd4UUJQ6Zk3/xcTu4yTKZ7EMzqap7F6YLq2NRy1EvcI=; b=KwW2oZZ92Y8p48+QoyDaDy83n1dJhXHJoJgOERQ//v0FvqIunPSIoGWqJtx1YxUIkl 0Hf7yU69t5SECT5Oyturs9nJZXNFW4IrGLz7EunvhF7GHQ1HlraAQsWKDBiFXU8fvIs8 riTt3t2xQpiX5LLU48ri19vvK67doYY83CJQ4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Rd4UUJQ6Zk3/xcTu4yTKZ7EMzqap7F6YLq2NRy1EvcI=; b=CFhr6jqAl5wdxXaSf3pWEv427/YDLSC1UpN59EUpeWTsTFjYYhxdIcjnkYJFg0jSJB 1U/nQv+8/I6+9gE/h8+0sB8FuhSnR7sNwmBIN6TB/M5REbC7grZjHR08TAN10noMOuyv SDiP+hWl5Y9jreufdY2jTvB5xcrQbpy8Er8hZr96JU4cfaRcoJUHErYQBXO1wEjtwljt TzUHlZhJ3TBokbAciKlojG1DOLHE+0NHQL8jc1LVM7poP+R/qh9cLIqjt4cZ89+vpewl nDRpEsg9lwysfe+1vhJ8nfD7xfyPpHMIlircNIcCPsyivuE4Q/cOcidPLNHBCXpA8mEi nvxQ== X-Gm-Message-State: APt69E0b0TO42QFz+jNDnGIhrQOi3vo2cdIH981CHfdlVdHesyos8WHp yDLeJtqHuJDbQq4vBX8cdh/2z7PpL6Yq3rpSwg5O3Q== X-Received: by 2002:ac8:29e:: with SMTP id p30-v6mr1508255qtg.131.1530707918454; Wed, 04 Jul 2018 05:38:38 -0700 (PDT) MIME-Version: 1.0 References: <7e9beaa3218b1c46ea6a7399c5978c1538fce261.1530533998.git.amit.kucheria@linaro.org> <20180702185530.GD2050@tuxbook-pro> In-Reply-To: <20180702185530.GD2050@tuxbook-pro> From: Amit Kucheria Date: Wed, 4 Jul 2018 18:08:27 +0530 Message-ID: Subject: Re: [PATCH v4 3/6] thermal: tsens: Rename tsens-8996 to tsens-v2 for reuse To: Bjorn Andersson Cc: Linux Kernel Mailing List , Rajendra Nayak , linux-arm-msm , Eduardo Valentin , smohanad@codeaurora.org, Vivek Gautam , Andy Gross , Zhang Rui , Linux PM list Content-Type: multipart/mixed; boundary="000000000000bc395105702bb51a" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --000000000000bc395105702bb51a Content-Type: text/plain; charset="UTF-8" On Tue, Jul 3, 2018 at 12:23 AM Bjorn Andersson wrote: > > On Mon 02 Jul 05:44 PDT 2018, Amit Kucheria wrote: > > > The TSENS block inside the 8996 is internally classified as version 2 of > > the IP. Several other SoC families use this block and can share this code. > > > > We rename get_temp() to reflect that it can be used across the v2 family. > > > > Signed-off-by: Amit Kucheria > > --- > > drivers/thermal/qcom/Makefile | 2 +- > > drivers/thermal/qcom/{tsens-8996.c => tsens-v2.c} | 26 ++++++++--------------- > > 2 files changed, 10 insertions(+), 18 deletions(-) > > rename drivers/thermal/qcom/{tsens-8996.c => tsens-v2.c} (66%) > > > > diff --git a/drivers/thermal/qcom/Makefile b/drivers/thermal/qcom/Makefile > > index 2cc2193..a821929 100644 > > --- a/drivers/thermal/qcom/Makefile > > +++ b/drivers/thermal/qcom/Makefile > > @@ -1,2 +1,2 @@ > > obj-$(CONFIG_QCOM_TSENS) += qcom_tsens.o > > -qcom_tsens-y += tsens.o tsens-common.o tsens-8916.o tsens-8974.o tsens-8960.o tsens-8996.o > > +qcom_tsens-y += tsens.o tsens-common.o tsens-8916.o tsens-8974.o tsens-8960.o tsens-v2.o > > diff --git a/drivers/thermal/qcom/tsens-8996.c b/drivers/thermal/qcom/tsens-v2.c > > similarity index 66% > > rename from drivers/thermal/qcom/tsens-8996.c > > rename to drivers/thermal/qcom/tsens-v2.c > > index e1f7781..2eca7ff 100644 > > --- a/drivers/thermal/qcom/tsens-8996.c > > +++ b/drivers/thermal/qcom/tsens-v2.c > > @@ -1,27 +1,18 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > /* > > * Copyright (c) 2015, The Linux Foundation. All rights reserved. > > - * > > - * This program is free software; you can redistribute it and/or modify > > - * it under the terms of the GNU General Public License version 2 and > > - * only version 2 as published by the Free Software Foundation. > > - * > > - * This program is distributed in the hope that it will be useful, > > - * but WITHOUT ANY WARRANTY; without even the implied warranty of > > - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > > - * GNU General Public License for more details. > > - * > > + * Copyright (c) 2018, Linaro Limited > > */ > > > > -#include > > #include > > #include "tsens.h" > > > > -#define STATUS_OFFSET 0x10a0 > > -#define LAST_TEMP_MASK 0xfff > > +#define STATUS_OFFSET 0xa0 > > This is not backwards compatible with present day dts files, you need to > keep this effectively 0x10a0 when the memory region isn't split in two. Argh!! Good catch. > Perhaps you can just offset the ioremap by 4k when there's only one > region? That'll cause problems when we want to access some features exposed in the other register bank through the common get_temp_tsens_v2 function. The SW reset bit is in there that I'd like to add support for, for example. I can see a few other ways to detect this at runtime. None of them look pretty but option 3 looks least ugly at least to me. Any preferences? 1. Don't try to combine get_temp for 8996 with other v2 platforms. This would mean retaining a separate ops_8996, pointing to a custom get_temp(). We end up with two copies of the function. 2. In get_temp_tsens_v2(), check for number of regions but this has an overhead for each temperature read. struct platform_device *op = of_find_device_by_node(tmdev->dev->of_node); if (op->num_resources > 1) status_offset = 0xa0; else status_offset = 0x10a0; Read temperature(status_offset); 3. Restrict to init time (ideal) by storing the status_offset to struct tsens_device. This is then used directly in get_temp_generic_v2() to determine the actual address. This should work for 8996, 8916 and 8974 which all have a single memory region iomapp'ed. The last two don't even need this value since they have their own get_temp functions. See diff attached. I have to ask: Are there really devices in the field that rely on the existing *upstream* code and DT? If not, could we consider deprecating the "qcom,msm8996-tsens" property immediately or at least mark it for future removal? Regards, Amit --000000000000bc395105702bb51a Content-Type: text/plain; charset="US-ASCII"; name="3.diff.txt" Content-Disposition: attachment; filename="3.diff.txt" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_jj73xf8o0 ZGlmZiAtLWdpdCBpL2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