From patchwork Wed Jul 18 06:43:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 142242 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp177717ljj; Tue, 17 Jul 2018 23:44:02 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdPswuF5TkzbCK0JGxbZhz9hPsZvl9T4FJuXNuym/5jODUUxQrU7oaXKUGWM/Xe7Al9cArp X-Received: by 2002:a65:4c87:: with SMTP id m7-v6mr4549222pgt.98.1531896242140; Tue, 17 Jul 2018 23:44:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531896242; cv=none; d=google.com; s=arc-20160816; b=oN4QpHvhunxxtpVo93Jo903a+524d0e8rFCRyPIzil3t8j2u6VPl/G2wEsdZVJSf8i oWJBThdP61g8f5LW4bPsNmJlF0hPsMKxYdSixr5b8KDtM8dg5bWqyIAnHjATejz8A6No xGncldDtNCBsfQaAIhZKp5MsL2GnBgzbdM5ABBgCdps19VmQ3bJyPr6F1KJ7H8WFPXfL vxavzpMyr0h3xVwpZsFnTB1Rj6A1iAqWYYTsZGSzMMrPjXPgk5YOYlt+NkFfLkSrF8oB zzKh+/Lngg8fi3Q+0+JrpCz8/NcPIaiZR6gKHbhLxgMWJDOn13O2okV/uFA1Kr/GewOl a51g== 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 :arc-authentication-results; bh=RbEbuj6f++mKBQ5MixrgklOP10QoklsnpQVeI2hzmS0=; b=wnAkLCjIzPgxVlAvHaO4/BfDpzq1Njq43RMtVddzB3FKjoUXOHKm1GRPcmM08rsbcs THZFxtWN0kOSC+PH6aYuwQKzQ/Yavrm04R6N7QHmiUasT2FvshEyH8gZfGON/a52dY3k 0iThESYSNV9BF/DFhwFMEmxP4HVh1gfSZwHpKbEas5W4F51gPQRpD9erWYXWqFhjJVBa gXnQIGQcl0NP2ossByLvLuCGQ7MnElxPjFDSfvSuLxBMFuliumQHjewZK5AzZtahx/+3 jCP1ytnF3FVF7YesybLXJcqDnapxjncC3BUFprIYgJJ6ALU4U8iQ1Zz8CqDLYayppuqB GMQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CwceE8w+; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 o22-v6si2743180pgk.534.2018.07.17.23.44.01; Tue, 17 Jul 2018 23:44:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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=CwceE8w+; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 S1729058AbeGRHUS (ORCPT + 10 others); Wed, 18 Jul 2018 03:20:18 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:37757 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726830AbeGRHUS (ORCPT ); Wed, 18 Jul 2018 03:20:18 -0400 Received: by mail-wr1-f65.google.com with SMTP id q10-v6so3438823wrd.4 for ; Tue, 17 Jul 2018 23:43:59 -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=RbEbuj6f++mKBQ5MixrgklOP10QoklsnpQVeI2hzmS0=; b=CwceE8w+AoI2wNauLMctOz0WBAYSod543iAzXxWROaxWJVOuwYbwpuSQo0oaUvDRLf 8Ns14bVMbuDRsmFyuR1Vv12XknYsjI6n1IQ71oOMZAt3oBCrnKVquM1iqbz+hvEDd5rI xL0hvjAD/Iib6LP7662pfnvQPcmyC/Ydg+wMU= 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=RbEbuj6f++mKBQ5MixrgklOP10QoklsnpQVeI2hzmS0=; b=i8DXFeWJDWnkTtvGCuEE/Z0BYGF3Mz5X2EEYan0qHq4CWonULxpV7LHVyX4ngi4a6s RC0a0FjYGFCVlPRp35j/9qRFfV3zgGpsZN8ssDB77F0GdyF2/65tyqpWVvWQ7dIC9mnT x0ELYzJ396mntBjvYasRkPLDYp3N8dBdjWQXLfIeJoSpTOIpDovcFnFwz8f4m5T/AizZ hWQs7qyF/G09jwwm7uEQiE+bJjeK07zSqlwTqlPHrggfpgg6l3z+YYj3CVLBnLIO9x1+ FNUDuCLKjMvbAgXbyo2H2lMXk2s8u6eYPkRzKwvz5vIa+1Mo8YQTxNSmypnBsafZE5XN CrhQ== X-Gm-Message-State: AOUpUlH4ZbxX7Pxy7v9o8Tx9gHAU6QJmEfol+ZTWwQx9i3PA8JrhspKL MUka6ezMltz800QukrRDtIsVIbGR3AM= X-Received: by 2002:adf:c08c:: with SMTP id d12-v6mr3246466wrf.268.1531896239238; Tue, 17 Jul 2018 23:43:59 -0700 (PDT) Received: from localhost ([103.249.91.115]) by smtp.gmail.com with ESMTPSA id z7-v6sm1891350wrh.85.2018.07.17.23.43.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Jul 2018 23:43:58 -0700 (PDT) From: Amit Kucheria To: linux-kernel@vger.kernel.org Cc: rnayak@codeaurora.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, smohanad@codeaurora.org, vivek.gautam@codeaurora.org, andy.gross@linaro.org, dianders@chromium.org, mka@chromium.org, Zhang Rui , linux-pm@vger.kernel.org Subject: [PATCH v8 3/7] thermal: tsens: Add support to split up register address space into two Date: Wed, 18 Jul 2018 12:13:09 +0530 Message-Id: <767b27da206b19fe3c957c105a2326f736e14367.1531895128.git.amit.kucheria@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org There are two banks of registers for v2 TSENS IPs: SROT and TM. On older SoCs these were contiguous, leading to DTs mapping them as one register address space of size 0x2000. In newer SoCs, these two banks are not contiguous anymore. Add logic to init_common() to differentiate between old and new DTs and adjust associated offsets for the TM register bank so that the old DTs will continue to function correctly. Signed-off-by: Amit Kucheria Reviewed-by: Bjorn Andersson Tested-by: Matthias Kaehlcke Reviewed-by: Matthias Kaehlcke Reviewed-by: Douglas Anderson --- drivers/thermal/qcom/tsens-8996.c | 4 ++-- drivers/thermal/qcom/tsens-common.c | 12 ++++++++++++ drivers/thermal/qcom/tsens.h | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/thermal/qcom/tsens-8996.c b/drivers/thermal/qcom/tsens-8996.c index e1f7781..3e60cec 100644 --- a/drivers/thermal/qcom/tsens-8996.c +++ b/drivers/thermal/qcom/tsens-8996.c @@ -16,7 +16,7 @@ #include #include "tsens.h" -#define STATUS_OFFSET 0x10a0 +#define STATUS_OFFSET 0xa0 #define LAST_TEMP_MASK 0xfff #define STATUS_VALID_BIT BIT(21) #define CODE_SIGN_BIT BIT(11) @@ -28,7 +28,7 @@ static int get_temp_8996(struct tsens_device *tmdev, int id, int *temp) unsigned int sensor_addr; int last_temp = 0, last_temp2 = 0, last_temp3 = 0, ret; - sensor_addr = STATUS_OFFSET + s->hw_id * 4; + sensor_addr = tmdev->tm_offset + STATUS_OFFSET + s->hw_id * 4; ret = regmap_read(tmdev->map, sensor_addr, &code); if (ret) return ret; diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c index b1449ad..c22dc18 100644 --- a/drivers/thermal/qcom/tsens-common.c +++ b/drivers/thermal/qcom/tsens-common.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include "tsens.h" @@ -126,11 +127,22 @@ static const struct regmap_config tsens_config = { int __init init_common(struct tsens_device *tmdev) { void __iomem *base; + struct platform_device *op = of_find_device_by_node(tmdev->dev->of_node); + if (!op) + return -EINVAL; base = of_iomap(tmdev->dev->of_node, 0); if (!base) return -EINVAL; + /* The driver only uses the TM register address space for now */ + if (op->num_resources > 1) { + tmdev->tm_offset = 0; + } else { + /* old DTs where SROT and TM were in a contiguous 2K block */ + tmdev->tm_offset = 0x1000; + } + tmdev->map = devm_regmap_init_mmio(tmdev->dev, base, &tsens_config); if (IS_ERR(tmdev->map)) { iounmap(base); diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h index dc56e1e..d785b37 100644 --- a/drivers/thermal/qcom/tsens.h +++ b/drivers/thermal/qcom/tsens.h @@ -77,6 +77,7 @@ struct tsens_device { struct device *dev; u32 num_sensors; struct regmap *map; + u32 tm_offset; struct tsens_context ctx; const struct tsens_ops *ops; struct tsens_sensor sensor[0]; From patchwork Wed Jul 18 06:43:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 142244 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp177943ljj; Tue, 17 Jul 2018 23:44:19 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeEJJb5JqaQPzCf1zPSWCaoWKCcBya0WBWTA3WjR6/2ZqB9dR6P5UbNHldLD2jQFxfX0/Ym X-Received: by 2002:a63:e001:: with SMTP id e1-v6mr4533076pgh.380.1531896259127; Tue, 17 Jul 2018 23:44:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531896259; cv=none; d=google.com; s=arc-20160816; b=aPboSqUqLZWp80Ydg89RhtCunrpyzWAX+FWIqGf3ve9nNqHju0pHoygvMx5g80CobO wBK5+7WxOROumM7mqBFpyso0AWD+wralCa1H2epBCb2PH2iBSDJK8TOY7Ei637bQi2KT j9GJuou1jM0kREnhZoEBELozwqvQbqvQ86+ydIDWlXTM16mby/0dY5pmQYrPMne3pkxI 1UDV7yGryYIHmw8CD8eEyajPZjqu6X0l/fjMR6LBi5rFu1eitkDvWqUQI+7nVQCf/Dpp e6DvIP5+MeJ8WSTsyeLLR+wMCz7nmfukKnQI8lyOqqQIVjP/K508995b4U+omWzTHSUc mLEQ== 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 :arc-authentication-results; bh=raVj4mm1Q1ZaAVWpnDqhGG1LI3uXrzTE+7YpEmBVaYA=; b=k0+kMHq+oatmvb1u7ZAFt5tGqqm0pk5vRF+InaTpy1NtIOMoZ+B8lNKNbOKNkNucuU 2Gq8ptJpmXcRUn/0GJRRe/TS/0PiOUOyuLlVJtvz/KpXWeXvzwyQgsQtFs0NYCWIOp9i 0FlXjXB6J2s2scPaIHblTAHhyT59t6YUrUGCioBAD9knnN1VvDDJF3QUYtN/WvWm6L6f OcbzLFHZNuWzrO9l38Ea26qp/a77FLasXrWHIadq6VeZVXKJ/pv1UmSXdmRbvXA84oiS amwQUwPQQecMc3iX3pfdkq7u7+tCIx+faKrXw1FxyKbCSezwWbldEArdUTe657nvT1YI qMVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PoMfg8UJ; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 s10-v6si2452352pgv.47.2018.07.17.23.44.18; Tue, 17 Jul 2018 23:44:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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=PoMfg8UJ; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 S1726592AbeGRHUg (ORCPT + 10 others); Wed, 18 Jul 2018 03:20:36 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:37923 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729332AbeGRHUf (ORCPT ); Wed, 18 Jul 2018 03:20:35 -0400 Received: by mail-wr1-f66.google.com with SMTP id v14-v6so3428029wro.5 for ; Tue, 17 Jul 2018 23:44:16 -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=raVj4mm1Q1ZaAVWpnDqhGG1LI3uXrzTE+7YpEmBVaYA=; b=PoMfg8UJrRkpQpeINHPAZslsXCQ2QTEN6capaRmJhix+eRImwcBCm6aVDH70rjwvVe pa7e+xjWRO03X1z/ZT+NN2pamr07xaWng5vSgcZDRD1ZVEy/r5cIPzR6OQQNfcyMVP2f 1WJRG544RLxFlPuwY563h7MyZM3e/rcUqusu4= 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=raVj4mm1Q1ZaAVWpnDqhGG1LI3uXrzTE+7YpEmBVaYA=; b=NRi6uowyYxsYylP/WfjujXyLj/rqPPOAUP1Uke6VDPfjwibXXvcC9bnpukBFNrUMTY JDKRjvHjx3W8GRv5qhcRsTPhQ7l/d3fjVLA8XCY/K5Af5F+jkb82YjurKbqEDbLJHPSe LajTj8VzZyc9sUpZMzDg8eTIHqdVuP7pXdP8tvCLnpbaR14Gc0NdORvHnV5Y0xQd/+Dk /pG31c4EQeiRCKpQrqM2lD0R56i3Gx/v6zBi+xXBOsn8Qo6Xpm1LEunHHAo2yq3xNCGL KoJrc96UtElC1IVneQeLBIYgqExKLvCz6FJ7n04RAaDla8dUST5YmyqNLFw5bbWpL0sl 4Teg== X-Gm-Message-State: AOUpUlF8D06U3ugxOB/q6l95rsdYKm45s3eHjrRWBE8CaGgR1AO3+yJq Nll7P20NkfB3GL1kweEDCB0YXQ== X-Received: by 2002:adf:b2f4:: with SMTP id g107-v6mr3517316wrd.53.1531896256281; Tue, 17 Jul 2018 23:44:16 -0700 (PDT) Received: from localhost ([103.249.91.115]) by smtp.gmail.com with ESMTPSA id h2-v6sm1191353wmf.28.2018.07.17.23.44.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Jul 2018 23:44:15 -0700 (PDT) From: Amit Kucheria To: linux-kernel@vger.kernel.org Cc: rnayak@codeaurora.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, smohanad@codeaurora.org, vivek.gautam@codeaurora.org, andy.gross@linaro.org, dianders@chromium.org, mka@chromium.org, Zhang Rui , linux-pm@vger.kernel.org Subject: [PATCH v8 5/7] thermal: tsens: Rename tsens-8996 to tsens-v2 for reuse Date: Wed, 18 Jul 2018 12:13:11 +0530 Message-Id: <7f2da230d5612ebb6f5e5397cc4b9d1054757823.1531895128.git.amit.kucheria@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 Reviewed-by: Bjorn Andersson Tested-by: Matthias Kaehlcke Reviewed-by: Matthias Kaehlcke Reviewed-by: Douglas Anderson --- drivers/thermal/qcom/Makefile | 2 +- drivers/thermal/qcom/{tsens-8996.c => tsens-v2.c} | 25 ++++++++--------------- 2 files changed, 9 insertions(+), 18 deletions(-) rename drivers/thermal/qcom/{tsens-8996.c => tsens-v2.c} (66%) -- 2.7.4 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 3e60cec..44d3736 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 0xa0 -#define LAST_TEMP_MASK 0xfff +#define STATUS_OFFSET 0xa0 +#define LAST_TEMP_MASK 0xfff #define STATUS_VALID_BIT BIT(21) #define CODE_SIGN_BIT BIT(11) -static int get_temp_8996(struct tsens_device *tmdev, int id, int *temp) +static int get_temp_tsens_v2(struct tsens_device *tmdev, int id, int *temp) { struct tsens_sensor *s = &tmdev->sensor[id]; u32 code; @@ -73,12 +64,12 @@ static int get_temp_8996(struct tsens_device *tmdev, int id, int *temp) return 0; } -static const struct tsens_ops ops_8996 = { +static const struct tsens_ops ops_generic_v2 = { .init = init_common, - .get_temp = get_temp_8996, + .get_temp = get_temp_tsens_v2, }; const struct tsens_data data_8996 = { .num_sensors = 13, - .ops = &ops_8996, + .ops = &ops_generic_v2, };