Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5218901imm; Wed, 12 Sep 2018 02:55:00 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZdOQuLUPz3cqq57jil1BqKQ7JLIqz/CT3FCIFT9GLDWMEVuwUgd60Khas3QxENXSuQAo1S X-Received: by 2002:a65:5284:: with SMTP id y4-v6mr158580pgp.283.1536746100755; Wed, 12 Sep 2018 02:55:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536746100; cv=none; d=google.com; s=arc-20160816; b=h1k5QMwcfq5//fQv5Fa3ZbQHrEKJ9ukxpMLilR0JxI7s+9zBb9BRMVFHoZpv43pHEd Q5GDvlxbspXVvRNK77+nCr7TOEbsaEwSE8rKudebmOEghzeolQDU4qCiqvdLhyvugR6o SRNNYTqdkar3W9zfFP2lll4vzk41VoiWmolfXGn2fx5Th9IJeQDbRLi1spj08d1zLabU 8slcMSLzXAjalXNu5UgfF6EZy+H76cm+bjpS7YrJ58/CPb6hmltMBebdFdZV2RfE124I lKvHRkyRiohx758iml8mNwDGuY77WmkxKiMI+F9JLJscvyd2lA7yGvLVo0hNuBNoEE3O pIsg== 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=f5bkI9k4W2c9XfxovD/lpb7m212pStl1rJ1cHBfU/w8=; b=r1jtRH53kR9wRo7wsCXVTj2Ptep9XoPR/Lj/oZF3K0iXuL4q29BmKidGYZxbDasIo3 n+GRzin/Y3ilyOS1hRLhDwPKVXeyUrFW08DVtGb5d1qPPZ/7AAV+KTVE11Po9koLuOFl VO7wQ+/NiyYuPWxbZcIGMS6kJXswGenyd/w7dvxlEutLC8X7GLnH2mjIIEqdOesSy3lf xOc2tUIajlYaWIAm/DhrQYxkKV5zZqkF3PzO7d5/T71eV7IvunHlD5xHmNKfQaN+FG+E jSy/Fq7ux7yWy/ODgw8/t/YRwmBjUSef8cAolBawXZco32YGnSX3EtCeyxtZmtkU2b/s vpGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VdS5xPkq; 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 w1-v6si553733plq.352.2018.09.12.02.54.46; Wed, 12 Sep 2018 02:55:00 -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=VdS5xPkq; 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 S1727778AbeILO6D (ORCPT + 99 others); Wed, 12 Sep 2018 10:58:03 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:34233 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727685AbeILO6C (ORCPT ); Wed, 12 Sep 2018 10:58:02 -0400 Received: by mail-ed1-f65.google.com with SMTP id u1-v6so1277792eds.1 for ; Wed, 12 Sep 2018 02:54:15 -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=f5bkI9k4W2c9XfxovD/lpb7m212pStl1rJ1cHBfU/w8=; b=VdS5xPkqWD6huuj6drH9txEG/ptP+bfjajMdOn+cz2qpUtJh5vgHCFhg8v7ObU0t1D OxcIdFHzjrQIscgwb1WYW5ZTRfRNEN0eFsNsLjpJJ2P5KLWhHBfCQyQRjagq5jxRMyMB DQLwd/g2rjIrv71lJ+mmjLQbtv3Z0mHGx+rys= 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=f5bkI9k4W2c9XfxovD/lpb7m212pStl1rJ1cHBfU/w8=; b=hF9eQDwJzx6/P3RQiZ1xyRx4V166epzy6WY6v9EzDc1fu0SJS7/NqFbRYX4ne7kOmW E2G/0JbaNgkEKLvB8VMhG+q1+IVBm/CtIQ/TtA1U5c25A2bX9IA9jym4nEhLYj9y86aR 19q1PLZJgqmIEgD6AtEv36kv5pC1YcovBHMAUYwZzarwpQdGtl8M4mCio22jzUU4sWHc qPfEviIe8NzcKV62OxPPrJePoclII0efJZ83ZUqbethzHvlqC5u1u2VpqIHCoSCq42xv AxO6o1yf/14w6nZwTAlFDaE/EVb9VPf+M4dPaXh1qorym+R37oKuqsmXg/A552W39aY1 w73w== X-Gm-Message-State: APzg51B8XY3PRHZ/82AEi2Dh4CJYGkzVaLjXsbDvnB5ZQxFWf2Y9hQQr 1hb86ycNfyLr/2dwLb4sghiLVx/bPsY= X-Received: by 2002:a50:a804:: with SMTP id j4-v6mr1808568edc.105.1536746054401; Wed, 12 Sep 2018 02:54:14 -0700 (PDT) Received: from localhost ([49.248.190.214]) by smtp.gmail.com with ESMTPSA id h8-v6sm400574edi.68.2018.09.12.02.54.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Sep 2018 02:54:13 -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, andy.gross@linaro.org, dianders@chromium.org, mka@chromium.org, Zhang Rui , Daniel Lezcano , linux-pm@vger.kernel.org Subject: [PATCH v3 07/16] thermal: tsens: Pass register offsets as private data Date: Wed, 12 Sep 2018 15:22:52 +0530 Message-Id: X-Mailer: git-send-email 2.17.1 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 Registers have moved around across TSENS generations. For example, the CTRL register was at offset 0x0 in the SROT region on msm8916 but is at offset 0x4 in newer v2 based TSENS HW blocks. Allow passing offsets of important registers so that we can continue to use common functions. Signed-off-by: Amit Kucheria --- drivers/thermal/qcom/tsens-8916.c | 1 + drivers/thermal/qcom/tsens-8974.c | 1 + drivers/thermal/qcom/tsens-v2.c | 2 ++ drivers/thermal/qcom/tsens.c | 3 +++ drivers/thermal/qcom/tsens.h | 9 +++++++++ 5 files changed, 16 insertions(+) diff --git a/drivers/thermal/qcom/tsens-8916.c b/drivers/thermal/qcom/tsens-8916.c index c4955c85e922..c6dd620ac029 100644 --- a/drivers/thermal/qcom/tsens-8916.c +++ b/drivers/thermal/qcom/tsens-8916.c @@ -100,5 +100,6 @@ static const struct tsens_ops ops_8916 = { const struct tsens_data data_8916 = { .num_sensors = 5, .ops = &ops_8916, + .reg_offsets = { [SROT_CTRL_OFFSET] = 0x0 }, .hw_ids = (unsigned int []){0, 1, 2, 4, 5 }, }; diff --git a/drivers/thermal/qcom/tsens-8974.c b/drivers/thermal/qcom/tsens-8974.c index 7e149edbfeb6..3d3fda3d731b 100644 --- a/drivers/thermal/qcom/tsens-8974.c +++ b/drivers/thermal/qcom/tsens-8974.c @@ -232,4 +232,5 @@ static const struct tsens_ops ops_8974 = { const struct tsens_data data_8974 = { .num_sensors = 11, .ops = &ops_8974, + .reg_offsets = { [SROT_CTRL_OFFSET] = 0x0 }, }; diff --git a/drivers/thermal/qcom/tsens-v2.c b/drivers/thermal/qcom/tsens-v2.c index 1bdef92e4521..381a212872bf 100644 --- a/drivers/thermal/qcom/tsens-v2.c +++ b/drivers/thermal/qcom/tsens-v2.c @@ -68,10 +68,12 @@ static const struct tsens_ops ops_generic_v2 = { const struct tsens_data data_tsens_v2 = { .ops = &ops_generic_v2, + .reg_offsets = { [SROT_CTRL_OFFSET] = 0x4 }, }; /* Kept around for backward compatibility with old msm8996.dtsi */ const struct tsens_data data_8996 = { .num_sensors = 13, .ops = &ops_generic_v2, + .reg_offsets = { [SROT_CTRL_OFFSET] = 0x4 }, }; diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index 9a8e8f7b4ae1..f1ec9bbe4717 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -144,6 +144,9 @@ static int tsens_probe(struct platform_device *pdev) else tmdev->sensor[i].hw_id = i; } + for (i = 0; i < REG_ARRAY_SIZE; i++) { + tmdev->reg_offsets[i] = data->reg_offsets[i]; + } if (!tmdev->ops || !tmdev->ops->init || !tmdev->ops->get_temp) return -EINVAL; diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h index b9c4bcf255fa..7b7feee5dc46 100644 --- a/drivers/thermal/qcom/tsens.h +++ b/drivers/thermal/qcom/tsens.h @@ -48,15 +48,23 @@ struct tsens_ops { int (*get_trend)(struct tsens_device *, int, enum thermal_trend *); }; +enum reg_list { + SROT_CTRL_OFFSET, + + REG_ARRAY_SIZE, +}; + /** * struct tsens_data - tsens instance specific data * @num_sensors: Max number of sensors supported by platform * @ops: operations the tsens instance supports * @hw_ids: Subset of sensors ids supported by platform, if not the first n + * @reg_offsets: Register offsets for commonly used registers */ struct tsens_data { const u32 num_sensors; const struct tsens_ops *ops; + const u16 reg_offsets[REG_ARRAY_SIZE]; unsigned int *hw_ids; }; @@ -72,6 +80,7 @@ struct tsens_device { struct regmap *tm_map; struct regmap *srot_map; u32 tm_offset; + u16 reg_offsets[REG_ARRAY_SIZE]; struct tsens_context ctx; const struct tsens_ops *ops; struct tsens_sensor sensor[0]; -- 2.17.1