From: Amit Kucheria <amit.kucheria@linaro.org> 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:46:16 -0700 [thread overview] Message-ID: <0d972069de14750f76b8545af6abfa44aad9c485.1537547011.git.amit.kucheria@linaro.org> (raw) In-Reply-To: <20180918193448.GA1367@tuxbook-pro> In-Reply-To: <cover.1537547011.git.amit.kucheria@linaro.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 <amit.kucheria@linaro.org> Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org> --- 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
WARNING: multiple messages have this Message-ID (diff)
From: Amit Kucheria <amit.kucheria@linaro.org> 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 [thread overview] Message-ID: <0d972069de14750f76b8545af6abfa44aad9c485.1537547011.git.amit.kucheria@linaro.org> (raw) Message-ID: <20180921172511.diKyVyZa11PLqA5DIA3YEWhUBUhy8KTPyXh09MwXd_E@z> (raw) In-Reply-To: <20180918193448.GA1367@tuxbook-pro> In-Reply-To: <cover.1537547011.git.amit.kucheria@linaro.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 <amit.kucheria@linaro.org> Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org> --- 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
next prev parent reply other threads:[~2018-09-21 17:48 UTC|newest] Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-09-12 9:52 [PATCH v3 00/16] Another round of tsens cleanups Amit Kucheria 2018-09-12 9:52 ` [PATCH v3 01/16] thermal: tsens: Prepare 8916 and 8974 tsens to use SROT and TM address space Amit Kucheria 2018-09-12 9:52 ` [PATCH v3 02/16] thermal: tsens: Add SPDX license identifiers Amit Kucheria 2018-09-12 9:52 ` [PATCH v3 03/16] thermal: tsens: Get rid of dead code Amit Kucheria 2018-09-12 9:52 ` [PATCH v3 04/16] thermal: tsens: Rename map field in order to add a second address map Amit Kucheria 2018-09-12 9:52 ` [PATCH v3 05/16] thermal: tsens: Add the SROT " Amit Kucheria 2018-09-12 9:52 ` [PATCH v3 06/16] MAINTAINERS: Add entry for Qualcomm TSENS thermal drivers Amit Kucheria 2018-09-12 9:52 ` [PATCH v3 07/16] thermal: tsens: Pass register offsets as private data Amit Kucheria 2018-09-18 19:34 ` Bjorn Andersson [not found] ` <cover.1537547011.git.amit.kucheria@linaro.org> 2018-09-21 17:25 ` Amit Kucheria [this message] 2018-09-21 17:25 ` [PATCH v4 " Amit Kucheria 2018-09-21 17:46 ` Amit Kucheria 2018-09-12 9:52 ` [PATCH v3 08/16] thermal: tsens: Check if the IP is correctly enabled by firmware Amit Kucheria 2018-09-12 9:52 ` [PATCH v3 09/16] arm: dts: msm8974: thermal: split address space into two Amit Kucheria 2018-09-20 18:57 ` Andy Gross 2018-09-12 9:52 ` [PATCH v3 10/16] arm64: dts: msm8916: " Amit Kucheria 2018-09-20 18:57 ` Andy Gross 2018-09-12 9:52 ` [PATCH v3 11/16] arm: dts: msm8974: thermal: Add "qcom,sensors" property Amit Kucheria 2018-09-20 18:58 ` Andy Gross 2018-09-12 9:52 ` [PATCH v3 12/16] arm64: dts: msm8916: " Amit Kucheria 2018-09-20 18:58 ` Andy Gross 2018-09-12 9:52 ` [PATCH v3 13/16] dt-bindings: thermal: Fix a typo in documentation Amit Kucheria 2018-09-12 9:52 ` [PATCH v3 14/16] arm64: dts: msm8916: Add gpu thermal zone Amit Kucheria 2018-09-20 18:59 ` Andy Gross 2018-09-12 9:53 ` [PATCH v3 15/16] arm64: dts: msm8916: Add camera " Amit Kucheria 2018-09-20 19:00 ` Andy Gross 2018-09-12 9:53 ` [PATCH v3 16/16] arm64: dts: sdm845: enable tsens thermal zones Amit Kucheria 2018-09-20 19:01 ` Andy Gross 2018-10-25 19:25 ` Matthias Kaehlcke 2018-10-25 20:03 ` Amit Kucheria 2018-10-25 20:37 ` Matthias Kaehlcke 2018-09-18 15:01 ` [PATCH v3 00/16] Another round of tsens cleanups Amit Kucheria 2018-09-18 15:01 ` Amit Kucheria 2018-09-20 19:02 ` Andy Gross 2018-09-21 17:48 ` Amit Kucheria 2018-09-21 17:48 ` Amit Kucheria
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=0d972069de14750f76b8545af6abfa44aad9c485.1537547011.git.amit.kucheria@linaro.org \ --to=amit.kucheria@linaro.org \ --cc=linux-kernel@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.