Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp90124imm; Fri, 21 Sep 2018 10:49:28 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda2rYCBHMib+vg7hi2q93YIV9BcZPM5FKlvHb2FQZKLnHWgSuylIZVN3L8G4szJPlZd249p X-Received: by 2002:a62:ca0d:: with SMTP id n13-v6mr47695842pfg.69.1537552168167; Fri, 21 Sep 2018 10:49:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537552168; cv=none; d=google.com; s=arc-20160816; b=vZ52qnBh9Jfd1kDwJC/U8ZMESGi92kOifkC/NzQorwRgYY5NCodUZKGO0Rx6aMl+dD KYJqZYc1L7TSxVIEN/1cPKn72eGacU1vTZwZQZ0pP06D+5z8DC1/+y/eptH5wL8qhRwx mk7tgxNmGfzMLUnkcPgyh4SlWQFmAuvIkrZh2kNNn6wDw3QRHSNY3FmP2CVr89O2yKFL QzKY3Sfx/2ka6WqAEmEQQgMRjuwa3qZwe0z7GER/fW9HF/kdrc3ABL96ZotAw69Bdl5X izu1Q5lYQZMGRbjHuGdYIsf/A2nwXDNK21vpphfPJhp7V5gnvSv/pvqdO4R9ME240hjd lUbQ== 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:to:from:dkim-signature; bh=rC4Rj3P1k/Q6QD7WX93Els8mh/I6lZrdcdTj1aL5lPo=; b=Yo3RXv3NcAWxAgeG80Mn8Y9p1pmPjhleHRucjbKSaDARTPre9mK8MIUuJyOSoUefsZ 9dRHQMz9SlzpTGBU8tZ82GmX9LjsGwKIlPEywk7SQjZWiOOABipun4/pa4BqntWqWrop rpVeqgYf51mIQwt8185zm8RTLsS9YCfuzcXUM//U5ZjCkdEAIUacFj8je3RvTyNUfYZJ 1bvPUs2TLAzC7poly3W7fzQ8xTaZlWIATKgSLzwp66gkFxI9dXBkXssfxzR012ItKCAF d/qWr/XPjMQWVdDF+Pr6v0jkB2XKx/KgR954jyx9jai6RjiijM+6caSxjxeoRO0mZcpa N1tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VNxVaqk8; 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 u3-v6si5651107plz.353.2018.09.21.10.49.12; Fri, 21 Sep 2018 10:49:28 -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=VNxVaqk8; 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 S2391134AbeIUXi3 (ORCPT + 99 others); Fri, 21 Sep 2018 19:38:29 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:36256 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728149AbeIUXi2 (ORCPT ); Fri, 21 Sep 2018 19:38:28 -0400 Received: by mail-pg1-f194.google.com with SMTP id d1-v6so6381807pgo.3 for ; Fri, 21 Sep 2018 10:48:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:in-reply-to :references; bh=rC4Rj3P1k/Q6QD7WX93Els8mh/I6lZrdcdTj1aL5lPo=; b=VNxVaqk89fuASli0i598dlUGJAgaYNnxg1qgYLN6eNYHPJ5pc67dgVPwnT1Oi5D7H4 LRjCkCBS2zP9VIot8+ZDaemdv4T10n9MoxvzcLiJcle2lKYib0qZPUFr2gxDFuudxcQ2 97ud0VlsA7aSAP42HOeFLoGH7IPaXP1nPp6Hw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=rC4Rj3P1k/Q6QD7WX93Els8mh/I6lZrdcdTj1aL5lPo=; b=g2oGttMwbfkREsKxiyRgdxtCUWeH3bMkURJbF/mlBE9poibmn1JflWgtgnSZUCauFl NzZjOmNt357bWn2Gysoyap9BK2LiFknkxSer43GOpzjvXnxrx9Mh8z2Z5qQAzv0/cGEs 7uL7s80NuMThc/9FQza6aSBsf3u3grsVHpo2tAs7lzQ4AwHU120NFj5d1h+KHwqrwGPL 4dpACcfx4m/hx5ZIyxhzdaFRz4cm5id2ZGo4YIFqzhMTN1D9HJ1X+22B2GGrb/n4ebHx VC/IBoBluWT9b1paaonO5vxLQNjHeFUTBbANMal0Gko51TNJrWHBZeV+jrfqXNOF+5WE 6qEQ== X-Gm-Message-State: APzg51CNyHnHnadUCBNd29FSsrZd5hr8wlDvLfNmhKIecdEQ6RGQYIJc VCS8nmicqIS2QyaoGEJic95r/HuuOlo4Bg== X-Received: by 2002:a63:cf52:: with SMTP id b18-v6mr41651596pgj.194.1537552110891; Fri, 21 Sep 2018 10:48:30 -0700 (PDT) Received: from localhost ([209.121.128.187]) by smtp.gmail.com with ESMTPSA id x4-v6sm34082224pfm.119.2018.09.21.10.48.29 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 21 Sep 2018 10:48:29 -0700 (PDT) From: Amit Kucheria To: linux-kernel@vger.kernel.org Subject: [PATCH v4 07/16] thermal: tsens: Pass register offsets as private data Date: Fri, 21 Sep 2018 10:25:11 -0700 Message-Id: <0d972069de14750f76b8545af6abfa44aad9c485.1537547011.git.amit.kucheria@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180918193448.GA1367@tuxbook-pro> References: <20180918193448.GA1367@tuxbook-pro> 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 Reviewed-by: Bjorn Andersson --- Here is a fixup patch. Eduardo, if you like I can resend the entire series or you can find the entire series hosted with all tags applied here: https://git.linaro.org/people/amit.kucheria/kernel.git/log/?h=up/thermal/tsens-preirq-cleanup-v4 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 | 2 ++ drivers/thermal/qcom/tsens.h | 9 +++++++++ 5 files changed, 15 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..3c8776e55252 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -144,6 +144,8 @@ 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..f62d2b6281da 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 + * @reg_offsets: Register offsets for commonly used registers * @hw_ids: Subset of sensors ids supported by platform, if not the first n */ 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