diff mbox series

[v2,5/5] thermal: qcom: tsens: Add reinit quirk support for sm6375 controller

Message ID 20220724122424.2509021-6-bhupesh.sharma@linaro.org
State New
Headers show
Series Add support for tsens controller reinit via trustzone | expand

Commit Message

Bhupesh Sharma July 24, 2022, 12:24 p.m. UTC
tsens controller(s) on Qualcomm sm6375 SoC might start in
an unknown state or start with TSENS_EN indicating
a 'disabled' state when they enter linux world.

In such cases, it is useful to try and reinit them via
trustzone [via scm call(s)], at the very start.

Add hooks for the same in the qcom tsens driver.

Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Amit Kucheria <amitk@kernel.org>
Cc: Thara Gopinath <thara.gopinath@gmail.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-arm-msm@vger.kernel.org
Signed-off-by: Bhupesh Sharma <bhupesh.sharma@linaro.org>
---
 drivers/thermal/qcom/tsens.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Konrad Dybcio July 28, 2022, 2:12 p.m. UTC | #1
On 24.07.2022 14:24, Bhupesh Sharma wrote:
> tsens controller(s) on Qualcomm sm6375 SoC might start in
> an unknown state or start with TSENS_EN indicating
> a 'disabled' state when they enter linux world.
> 
> In such cases, it is useful to try and reinit them via
> trustzone [via scm call(s)], at the very start.
> 
> Add hooks for the same in the qcom tsens driver.
> 
> Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
> Cc: Amit Kucheria <amitk@kernel.org>
> Cc: Thara Gopinath <thara.gopinath@gmail.com>
> Cc: linux-pm@vger.kernel.org
> Cc: linux-arm-msm@vger.kernel.org
> Signed-off-by: Bhupesh Sharma <bhupesh.sharma@linaro.org>
> ---
This sadly doesn't work.. the issue on 6375 is that the controller
is in some weird state at boot and this bit that's higher up:

        ret = regmap_field_read(priv->rf[TSENS_EN], &enabled);
        if (ret)
                goto err_put_device;
        if (!enabled) {
                dev_err(dev, "%s: device not enabled\n", __func__);
                ret = -ENODEV;
                goto err_put_device;
        }

does not succeed.

Moving the code added in the patch up or calling
qcom_scm_tsens_reinit() or qcom_scm_tsens_reinit() and 
tsens_reenable_hw_after_scm(priv) directly before this enable
check also fails. In fact, the latter crashes the platform..

I don't want to block this series, so I suggest the 6375 part can
be dropped for now.

Konrad
Bhupesh Sharma Aug. 3, 2022, 5:32 a.m. UTC | #2
Hi Konrad,

On Thu, 28 Jul 2022 at 19:42, Konrad Dybcio
<konrad.dybcio@somainline.org> wrote:
>
>
>
> On 24.07.2022 14:24, Bhupesh Sharma wrote:
> > tsens controller(s) on Qualcomm sm6375 SoC might start in
> > an unknown state or start with TSENS_EN indicating
> > a 'disabled' state when they enter linux world.
> >
> > In such cases, it is useful to try and reinit them via
> > trustzone [via scm call(s)], at the very start.
> >
> > Add hooks for the same in the qcom tsens driver.
> >
> > Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
> > Cc: Amit Kucheria <amitk@kernel.org>
> > Cc: Thara Gopinath <thara.gopinath@gmail.com>
> > Cc: linux-pm@vger.kernel.org
> > Cc: linux-arm-msm@vger.kernel.org
> > Signed-off-by: Bhupesh Sharma <bhupesh.sharma@linaro.org>
> > ---
> This sadly doesn't work.. the issue on 6375 is that the controller
> is in some weird state at boot and this bit that's higher up:
>
>         ret = regmap_field_read(priv->rf[TSENS_EN], &enabled);
>         if (ret)
>                 goto err_put_device;
>         if (!enabled) {
>                 dev_err(dev, "%s: device not enabled\n", __func__);
>                 ret = -ENODEV;
>                 goto err_put_device;
>         }
>
> does not succeed.
>
> Moving the code added in the patch up or calling
> qcom_scm_tsens_reinit() or qcom_scm_tsens_reinit() and
> tsens_reenable_hw_after_scm(priv) directly before this enable
> check also fails. In fact, the latter crashes the platform..
>
> I don't want to block this series, so I suggest the 6375 part can
> be dropped for now.

Many thanks for testing the patchset. I agree.. let me drop this patch
from the v3 version and we can later target this sm6375 issue via a
separate patch.

Regards,
Bhupesh
diff mbox series

Patch

diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
index 928b6a44fda8..0141ea43c290 100644
--- a/drivers/thermal/qcom/tsens.c
+++ b/drivers/thermal/qcom/tsens.c
@@ -1083,6 +1083,16 @@  int __init init_common(struct tsens_priv *priv)
 	if (tsens_version(priv) >= VER_0_1)
 		tsens_enable_irq(priv);
 
+	/*
+	 * For some tsens controllers, which start in
+	 * an unknown state or start with TSENS_EN indicating
+	 * a 'disabled' state, its useful to try and reinit
+	 * them via trustzone, at the very start.
+	 */
+	if (priv->needs_reinit_wa &&
+	    (of_device_is_compatible(dev->of_node, "qcom,sm6375-tsens")))
+		__tsens_reinit_worker(priv);
+
 	tsens_debug_init(op);
 
 err_put_device:
@@ -1145,6 +1155,9 @@  static const struct of_device_id tsens_table[] = {
 	}, {
 		.compatible = "qcom,msm8996-tsens",
 		.data = &data_8996,
+	}, {
+		.compatible = "qcom,sm6375-tsens",
+		.data = &data_tsens_v2_reinit,
 	}, {
 		.compatible = "qcom,sm8150-tsens",
 		.data = &data_tsens_v2_reinit,