Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp179578imm; Tue, 17 Jul 2018 23:45:04 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcsc47IIHycMtruvNQFJEmV/rgu+mvV73DBValhNaQGRbG2hAGcsfYnCJwzyhXnm4z5uSJG X-Received: by 2002:a62:c0a:: with SMTP id u10-v6mr3914590pfi.43.1531896304635; Tue, 17 Jul 2018 23:45:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531896304; cv=none; d=google.com; s=arc-20160816; b=0dWCq6EYjGxh/wnSYYVY5u+rkFvafBZArhpdg6TPrpyevnjMVwSNoGML2C+UKjiyrb +p8mZ/OTWaGC8rpODKBJbPBsfjIMdAnafJzYBXHowweyll9axWsUSCfmIJsWOItr+slE h03BfbFxHmHtYBWPsb1R+ukqcscTkXPYEotmW3Sie1/usem/YEae2FQZtrCMNqjd3B2X qEi61/qiQyRPdPz8bUfDBNYSFHdzXmjiTcOKUZ5JsV2/SeH1r55ZSykXPG1MtrTMngV4 qZou5eNhgQkdZW4Nd/vYOt289DQBho4rSUFACJ0LXDP3QkQ1op8XCvNah14sSCF9EEtY da1w== 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=xCNHAXsU1A66nE6F3l+jMRv9XshmIp7/x8s7Zjh2oDXaGDuLSqE76rJ3LZgKONtZCy HuJOgeTWFGaO5xCPYR/9WcYrXdImWmGzmTdZbIV5eKN4VR18LNQow7ByFb7yoo5ss4cv Cj6jJNfN25WEsJenF8bjPe/kUce3Fel1MlcNg/rz8FvVP0vrBbnLDQ/F50ERGQqiY1Gw g9LZqFxqTrRM3IaIKjfB2i7DTj/QxCLStiJpdeefFXkyJCBmqoNlsJsT7gVgS2TjxHBb Uyj14CmuG4KcNCVw+2oB/NEV0Nz79iTr8NXW2n+yX8WUlas8ssXjjthW0qxErhh6kft1 vKYA== 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-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 z77-v6si2791309pff.100.2018.07.17.23.44.49; Tue, 17 Jul 2018 23:45:04 -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=CwceE8w+; 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 S1729296AbeGRHUT (ORCPT + 99 others); Wed, 18 Jul 2018 03:20:19 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:36536 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729233AbeGRHUS (ORCPT ); Wed, 18 Jul 2018 03:20:18 -0400 Received: by mail-wr1-f66.google.com with SMTP id h9-v6so3438083wro.3 for ; Tue, 17 Jul 2018 23:44:00 -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=mrIVCOUSO6dZtUAkRDghg7JWSsLCTBu6koEedbBCxYdJGNE/OuqceNZ+MC1ll6u7/G jc2BObapUwIMM2JsWM27sfMULbWr5VjfTU40ofTMGrHdFNNC5IkcvMf+Mo7MoBhPRVI1 BoIQNOUiZhXo9NjGb8R9Pr/35OMpn0E82bUG4xWX41y4qoTPrFVOE10vlyjP+yb6ft9o UXABdnWcE9PnRFjJhJa8x9C8HORj3o8onvjjclPVwSxHmCWvnS1SReDczm+BDmyb6gB7 2qno3tvTIAYnuFG0sKlOqTC+YrnYG2Y6uoYqbZzvCaHi+A0rWusA0HESNnbfx51Sagcq 9KzQ== X-Gm-Message-State: AOUpUlHGstv4AfTdrgHnxt50gKivgcssU43lP8DVNeKxMP1mZuG+06ma WP2aGu8VGw9gtlojMA9xLqOTdRNR2ok= 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) 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]; -- 2.7.4