Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1435482imm; Thu, 12 Jul 2018 01:40:59 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfbBinnp1p/Cu0nRqrwjhuVPdoqwfXA1ub2qkW7Hpnwq0RBON//hvNi0BvQXO9aZW4pPQyz X-Received: by 2002:a17:902:3281:: with SMTP id z1-v6mr1316996plb.226.1531384859305; Thu, 12 Jul 2018 01:40:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531384859; cv=none; d=google.com; s=arc-20160816; b=Ew31/hQ9r0MOswh4GZIrZO6KooA5C9jC+yFf+p62aAx5gfohvFxqtJy2aaCja7R0BQ 4jxtoLadSpDvZVeX0waqdMrn/ikRHpal053KCV5yrq7wXg7zvDq8lgY3gjB0jG8B0qQZ HoqH9dA2UflRCZnYXMXYXhJBWZfgNAmHdKEBwG+6kKkUL4pfn+Nj2Q4fw7RMi0JJECqc eG3IhOGr2eNj2sTw4SUq9M8f8aUNj22uJ4uHh9MUjE9eyKvrziTosbMuQSUiCBeCROHX sLPpZRr5bKsQwkG0jmUK+QEXD63dpcsvz2a6WcoGKLH7x0qp5nOvvlGsXRlqmQWsUzJ5 gkVg== 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=MDWsqzRynEwyRQCUsbdky1TLitXCzuSAazaHyCyJftE=; b=tm0BEVaDhCeczb1hfixogMlRaHlci4I3DFJDoYTYgE7xRwzOLCNzm6I13y8Uqhr9+x an5g/Pxg+VfftNK16WVom4yj7I5roIMKS30OAkI0yqrn7cYlubY2dg17Lz3kviBBLVV6 hOd1p6qWqz6a2Qo3IwmfeUAPjEI+6Zp7X5/KpBUDoa4RjfJ5ox69PsXWVmS+wEuhHynI T7AaTX3YlVGdjLfpBzrzrMV/pSNPs1xy5VRKeY+eOkrfjRhHO85LzgSxT1wWF1SuOPhm bKMLKG3Egzdf5wfAsWlWIUyECxThXqruSGtO6wPj4ASBHJI1vuKT5rn8AjdGBzurmejE ZjNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M7W2m7yL; 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 z13-v6si22429007pfc.118.2018.07.12.01.40.43; Thu, 12 Jul 2018 01:40:59 -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=M7W2m7yL; 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 S1732439AbeGLIs2 (ORCPT + 99 others); Thu, 12 Jul 2018 04:48:28 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:45819 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727447AbeGLIs2 (ORCPT ); Thu, 12 Jul 2018 04:48:28 -0400 Received: by mail-wr1-f67.google.com with SMTP id c4-v6so8121717wrs.12 for ; Thu, 12 Jul 2018 01:39:53 -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=MDWsqzRynEwyRQCUsbdky1TLitXCzuSAazaHyCyJftE=; b=M7W2m7yLyFe1hk/nRwb3L8NLWxoQj6jxHpYLMzHfD9rPufU81M+snXtK7+n6Alwq/G aStu0vHoaTM1biz0RqK0x7e+3mXsFM/DWTGHLN5twMYi1HiB8BwiWNlm811+DpMtgsTM D6113vDpLjc3JgmpgHD0Ai7STDbl41ZvFVJkQ= 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=MDWsqzRynEwyRQCUsbdky1TLitXCzuSAazaHyCyJftE=; b=AgNrzRfXJl0Qov/5YEns0YhlyfHrCigqI4SWwRA79rErOcoeiEXDKissoBZ86y7vpc OKe/CLjLd1Go60KKzal4x1dGz09kBe9bD+YIoQHuQJ94FiBCuXuyr6svGWYBeFKRKHP0 RILC7d0uAmQ4qQQcWylMHc38ln5RiHHzf2NN7F0UDAZ4qmlDNHKgucs05oLYWWZsdECY FwhJp8vuikxFwgRchR3WYRLR1dztj7lj7JL2yAXYBbPUS8zEg3qJ1RENA9UmyWrVhpuO 3RAxgaFSydYNBdEHlMjf25r7VlU3kQ0AaW0AFJfTQIrbu5MGtxL2N5fDKGlyWdGfOZMl NjHg== X-Gm-Message-State: AOUpUlFBgyk7QAU8XetZTyvIHpYwoMe/9IW8nVjguzSBXqNXTLnc5D/u tjtMGJBIiujODT/pOnOa13pEn3q3kak= X-Received: by 2002:adf:9101:: with SMTP id j1-v6mr764085wrj.3.1531384792650; Thu, 12 Jul 2018 01:39:52 -0700 (PDT) Received: from localhost ([103.249.91.93]) by smtp.gmail.com with ESMTPSA id k14-v6sm18584882wrg.38.2018.07.12.01.39.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jul 2018 01:39:51 -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 v7 2/7] thermal: tsens: Add support to split up register address space into two Date: Thu, 12 Jul 2018 14:09:03 +0530 Message-Id: <8f833fee80565c4dfd381697e47f99fb5f9e65d3.1531384019.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 --- 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