From patchwork Sun Jul 24 12:24:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupesh Sharma X-Patchwork-Id: 12927514 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91ECAC433EF for ; Sun, 24 Jul 2022 12:24:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231669AbiGXMYn (ORCPT ); Sun, 24 Jul 2022 08:24:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233071AbiGXMYj (ORCPT ); Sun, 24 Jul 2022 08:24:39 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBE3213FB7 for ; Sun, 24 Jul 2022 05:24:38 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id y9so8102410pff.12 for ; Sun, 24 Jul 2022 05:24:38 -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 :mime-version:content-transfer-encoding; bh=knYZVAmP/Bzeklaj6dd4onpv7s/0aWzK0OLPNMow6Oo=; b=Gu/HsqrR9MvT05KxBVxXKeCcEKFqxofoWaMoiatvoYkYAxidxsH0gNet+xxosibt+h UjNlWW8o3T7RTrwGRonynQUAGAlc6PmUdLXVsQBM3bP7iMs4l4AkHNrNltMvYOOYMp3A fZJrgpfEbyuVWyFYhBfEw0tEPPcD+bxIIi9FrkePcBprt1DhHzi2Q8NUERUZI2R52BY/ xN3/OV573jce/dQMTvpix3z/e9CCO1vcFqCPquF4aAgA1xGDfEUvm+5i4mfjoQSLyfR4 Qr6sXwo9DJvdb1vKCqlg05HxNcleMrdIySZTns+CzXq2sN5W922dO1HHoRmkbTQ5TE0/ f2Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=knYZVAmP/Bzeklaj6dd4onpv7s/0aWzK0OLPNMow6Oo=; b=tSTDl8k7W3OI6HMexGfYm7dtQAn/AXnlDeVLs1o7aq4v+fkTcWGRPOlWyqf0t28TYq Y8Qdc+cJiX4sCOQsnk+p82mU+V5I27OgTAGY3jOAF6KBeTCQ03A6rvWfim4pQuDapd4p zh5MYa8YV7uyHgquo67IhLGBa/yJPK3vq9KW22JAkjLIE0oghMDMXNcvyYh1daxUrcZw WzCTBXd1UGS3MtUh8qoTwRbWbTZFS/B7FnM1+kLYs+MiTOmi2IaoVVsjpL5y1jgHH0cW Ai9S49zxg6/UEHZPulnceh5XK1bJkPPD/sWrxM9j5YW4jFZeDNHTSU6zdAwVQu6NNiXN z7tQ== X-Gm-Message-State: AJIora+GTdBDHUNBWMSJwOFk9+62I0LdQ3KlmXw7zEqyKCbpqJgfd/G0 EWPIXfhM777huvUXxxeQpydEfJIBTGIuwQ== X-Google-Smtp-Source: AGRyM1sVMDpgLT6PsBP5HWNqYDJYwXEDCznpcdZ6v7L2qW3t8MvY+9T7wKFcgyxeP+CWu5xfXPA9jg== X-Received: by 2002:a63:b1d:0:b0:41a:20e7:6811 with SMTP id 29-20020a630b1d000000b0041a20e76811mr7172464pgl.75.1658665478186; Sun, 24 Jul 2022 05:24:38 -0700 (PDT) Received: from localhost.localdomain ([2401:4900:1f3a:5a45:a9cd:d7dd:fd01:73c0]) by smtp.gmail.com with ESMTPSA id p23-20020a1709027ed700b0016c0474fbd0sm7048133plb.34.2022.07.24.05.24.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Jul 2022 05:24:37 -0700 (PDT) From: Bhupesh Sharma To: linux-pm@vger.kernel.org Cc: bhupesh.sharma@linaro.org, bhupesh.linux@gmail.com, linux-kernel@vger.kernel.org, bjorn.andersson@linaro.org, konrad.dybcio@somainline.org, linux-arm-msm@vger.kernel.org, daniel.lezcano@linaro.org, robh+dt@kernel.org, rafael@kernel.org, Amit Kucheria , Thara Gopinath Subject: [PATCH v2 1/5] firmware: qcom: scm: Add support for tsens reinit workaround Date: Sun, 24 Jul 2022 17:54:20 +0530 Message-Id: <20220724122424.2509021-2-bhupesh.sharma@linaro.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220724122424.2509021-1-bhupesh.sharma@linaro.org> References: <20220724122424.2509021-1-bhupesh.sharma@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Some versions of Qualcomm tsens controller might enter a 'bad state' while running stability tests causing sensor temperatures/interrupts status to be in an 'invalid' state. It is recommended to re-initialize the tsens controller via trustzone (secure registers) using scm call(s) when that happens. Add support for the same in the qcom_scm driver. Cc: Bjorn Andersson Cc: Amit Kucheria Cc: Thara Gopinath Cc: linux-pm@vger.kernel.org Cc: linux-arm-msm@vger.kernel.org Signed-off-by: Bhupesh Sharma --- drivers/firmware/qcom_scm.c | 15 +++++++++++++++ drivers/firmware/qcom_scm.h | 4 ++++ include/linux/qcom_scm.h | 2 ++ 3 files changed, 21 insertions(+) diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index cdbfe54c8146..93adcc046a62 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -858,6 +858,21 @@ int qcom_scm_mem_protect_video_var(u32 cp_start, u32 cp_size, } EXPORT_SYMBOL(qcom_scm_mem_protect_video_var); +int qcom_scm_tsens_reinit(void) +{ + int ret; + const struct qcom_scm_desc desc = { + .svc = QCOM_SCM_SVC_TSENS, + .cmd = QCOM_SCM_TSENS_INIT_ID, + }; + struct qcom_scm_res res; + + ret = qcom_scm_call(__scm->dev, &desc, &res); + + return ret ? : res.result[0]; +} +EXPORT_SYMBOL(qcom_scm_tsens_reinit); + static int __qcom_scm_assign_mem(struct device *dev, phys_addr_t mem_region, size_t mem_sz, phys_addr_t src, size_t src_sz, phys_addr_t dest, size_t dest_sz) diff --git a/drivers/firmware/qcom_scm.h b/drivers/firmware/qcom_scm.h index 0d51eef2472f..495fa00230c7 100644 --- a/drivers/firmware/qcom_scm.h +++ b/drivers/firmware/qcom_scm.h @@ -94,6 +94,10 @@ extern int scm_legacy_call(struct device *dev, const struct qcom_scm_desc *desc, #define QCOM_SCM_PIL_PAS_IS_SUPPORTED 0x07 #define QCOM_SCM_PIL_PAS_MSS_RESET 0x0a +/* TSENS Services and Function IDs */ +#define QCOM_SCM_SVC_TSENS 0x1E +#define QCOM_SCM_TSENS_INIT_ID 0x5 + #define QCOM_SCM_SVC_IO 0x05 #define QCOM_SCM_IO_READ 0x01 #define QCOM_SCM_IO_WRITE 0x02 diff --git a/include/linux/qcom_scm.h b/include/linux/qcom_scm.h index f8335644a01a..5c37e1658cef 100644 --- a/include/linux/qcom_scm.h +++ b/include/linux/qcom_scm.h @@ -124,4 +124,6 @@ extern int qcom_scm_lmh_dcvsh(u32 payload_fn, u32 payload_reg, u32 payload_val, extern int qcom_scm_lmh_profile_change(u32 profile_id); extern bool qcom_scm_lmh_dcvsh_available(void); +extern int qcom_scm_tsens_reinit(void); + #endif From patchwork Sun Jul 24 12:24:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupesh Sharma X-Patchwork-Id: 12927515 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F985CCA47C for ; Sun, 24 Jul 2022 12:24:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233493AbiGXMYp (ORCPT ); Sun, 24 Jul 2022 08:24:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233481AbiGXMYo (ORCPT ); Sun, 24 Jul 2022 08:24:44 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FF3014D04 for ; Sun, 24 Jul 2022 05:24:43 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id l14-20020a17090a72ce00b001f20ed3c55dso7868440pjk.5 for ; Sun, 24 Jul 2022 05:24:43 -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 :mime-version:content-transfer-encoding; bh=nR0GZSZHxkQfSFgE9IcYh18ZJ6xJzqTkhKj/qxtoCHU=; b=W6+L7khMfz+7HA7bhTobQ6LTa010lauG6Ka970cXn17IPD+uPnjWgQv3xdJQHgbPc8 fAF6bIOYMoXDrQ7tBiWsEvGHHBOXTLKv7FP3RO2jPG/I11U1iypeoKlqsz6U6OK5FsG7 YPesAhl0R+Yo2RD+GpT2Pz+6A6K8wlXxzAcTY0NRXo1GOhdOM6k83Zp6ywijL+5xLyia D+rz17jglQKzjr+U53+C9/9IUXhVKczvqIUXH0MyR1ev47Kv3lBxTrEvg33I4a7qRR9/ PzSetCX+XHgutJYY2a6ggS61KZRb75ThTNCnJcuM4X72cERmkmy/40vOYUctqa03zftu 5OwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nR0GZSZHxkQfSFgE9IcYh18ZJ6xJzqTkhKj/qxtoCHU=; b=lCOIWawMr/19I7aPiwvanVc7TWqvW3+YNGynlr4G7tnLx+XKt1qsjtAcdwYLVMbyq6 fjFRDP+HRhWifgjUx7OYtcDifI/BkdhFsZprl1d4oD4pCmQo0/gBO51FK3MAYtAgY1cA ScrBOYPANmEcOJ1GkAdfJV3LtzlUd/rNraqpznFMYxQ/ZqMqX4ykoIuNWDeFa6+PJnaG sQreTIH2hQYgNuAbeU1uA+ZGOeyjPR3LFRXslhjNW/W1AaAyjoeGZZ/VFryTEjqjd2nC cNpY2cdv2X068DouoRTvgBWBU//CLbsjqjvqsPzk8/yh5H0qFsEGafUKDXn0WNYqouRF BMhg== X-Gm-Message-State: AJIora9GNLQ/smCX1+OIc1pG3I/7kisH+h7dsxevLMtQ3q+n91Gg163X 7gQ0hoxmy2BFGVAPIea9xsBFafKIzWddFw== X-Google-Smtp-Source: AGRyM1uqh/0UFeYKfWwckPYNB7HSliOOZeZQCgsyLv44rpW9oC4v0AzYkGGgWfiup6gsht2bm9DJjQ== X-Received: by 2002:a17:902:6b02:b0:16c:3d67:8a8a with SMTP id o2-20020a1709026b0200b0016c3d678a8amr7874169plk.87.1658665482377; Sun, 24 Jul 2022 05:24:42 -0700 (PDT) Received: from localhost.localdomain ([2401:4900:1f3a:5a45:a9cd:d7dd:fd01:73c0]) by smtp.gmail.com with ESMTPSA id p23-20020a1709027ed700b0016c0474fbd0sm7048133plb.34.2022.07.24.05.24.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Jul 2022 05:24:42 -0700 (PDT) From: Bhupesh Sharma To: linux-pm@vger.kernel.org Cc: bhupesh.sharma@linaro.org, bhupesh.linux@gmail.com, linux-kernel@vger.kernel.org, bjorn.andersson@linaro.org, konrad.dybcio@somainline.org, linux-arm-msm@vger.kernel.org, daniel.lezcano@linaro.org, robh+dt@kernel.org, rafael@kernel.org, Amit Kucheria , Thara Gopinath Subject: [PATCH v2 2/5] thermal: qcom: tsens: Add hooks for supplying platform specific reinit quirks Date: Sun, 24 Jul 2022 17:54:21 +0530 Message-Id: <20220724122424.2509021-3-bhupesh.sharma@linaro.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220724122424.2509021-1-bhupesh.sharma@linaro.org> References: <20220724122424.2509021-1-bhupesh.sharma@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add hooks inside platform specific data which can be used by Qualcomm tsens controller(s) which might need reinitialization via trustzone. Cc: Bjorn Andersson Cc: Amit Kucheria Cc: Thara Gopinath Cc: linux-pm@vger.kernel.org Cc: linux-arm-msm@vger.kernel.org Signed-off-by: Bhupesh Sharma --- drivers/thermal/qcom/tsens.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h index ba05c8233356..92787017c6ab 100644 --- a/drivers/thermal/qcom/tsens.h +++ b/drivers/thermal/qcom/tsens.h @@ -513,6 +513,7 @@ struct tsens_features { * @num_sensors: 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 + * @needs_reinit_wa: tsens controller might need reinit via trustzone * @feat: features of the IP * @fields: bitfield locations */ @@ -520,6 +521,7 @@ struct tsens_plat_data { const u32 num_sensors; const struct tsens_ops *ops; unsigned int *hw_ids; + bool needs_reinit_wa; struct tsens_features *feat; const struct reg_field *fields; }; @@ -542,6 +544,7 @@ struct tsens_context { * @srot_map: pointer to SROT register address space * @tm_offset: deal with old device trees that don't address TM and SROT * address space separately + * @needs_reinit_wa: tsens controller might need reinit via trustzone * @ul_lock: lock while processing upper/lower threshold interrupts * @crit_lock: lock while processing critical threshold interrupts * @rf: array of regmap_fields used to store value of the field @@ -559,6 +562,7 @@ struct tsens_priv { struct regmap *tm_map; struct regmap *srot_map; u32 tm_offset; + bool needs_reinit_wa; /* lock for upper/lower threshold interrupts */ spinlock_t ul_lock; From patchwork Sun Jul 24 12:24:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupesh Sharma X-Patchwork-Id: 12927516 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49ADDC433EF for ; Sun, 24 Jul 2022 12:25:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233329AbiGXMY6 (ORCPT ); Sun, 24 Jul 2022 08:24:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233898AbiGXMYz (ORCPT ); Sun, 24 Jul 2022 08:24:55 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61C7C1659F for ; Sun, 24 Jul 2022 05:24:47 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id x24-20020a17090ab01800b001f21556cf48so11939264pjq.4 for ; Sun, 24 Jul 2022 05:24:47 -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 :mime-version:content-transfer-encoding; bh=6iOQlRmdbJTpHfNsjYsIeuk02p2ItiNyg2ruDmQq+BY=; b=zsh/PeAJJoYBaQeHrhQuMayAwzEvVGr97bdjqPOfoZz5Yz0wf89DcFFnrL3OoGXvB1 cVBAotkKgLusZPlFyVF/kDJFwtJq9YSknp7/aUNTprf93+os2Dp2429HGAbgLdTRezvz Ceo6NbVdePo0xSCkpA6DW+UbAHYC9GeClirJKOLc/iXuPEK4k6TOxbcY3yoKWCDrR7DS 2mtd5jsesuBZ9wAk0ygnzH+MFqFTNVfuw6rqeW+D8fFOXlJrWLEVZrxXnH51gUkjdwyV b1mLZbGXpOlLEfcX5H0Irew8XC+kHwQ+stvvzmdRtAxymys7ZxCk3ULFhuJChhKPnl4F mX/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6iOQlRmdbJTpHfNsjYsIeuk02p2ItiNyg2ruDmQq+BY=; b=w66fCIXAr31kiMEPcH6gsywt0jKrCi7cM8F7zqMtX15KupteSwB3/81PAcNdzbRaVg MUCtxR9MtKstmdi/mNrbmdi4IZwZz07dySiPD+CBMDZd2l8MA/r344d4OsnGMz5UPt/5 irMRoAHB0FyrbdSZRBsolrxHj3v7CtigVwccInZelh7EnfYDKqhKCVsQmcvjfqs31SrO 3Z5CxjBe0DcY9rgFqsyagt/wYoowgPLHztG9YGwytgtBIydQfjBXTNf5MBQXbCZpKI6c vN6OSx6ZTfVEQaPHJgT+pf8CyVETPsqx4eGcotzaHejjVp/ERTdtFiyiqa9PnlSANc4k DFzQ== X-Gm-Message-State: AJIora81Atf0qhrHmWN9Ns9XCy+qCIfgtvXsAOGKmkPzvi2v1wpGocKA qv2lkFpA/f0D5JPeWTnpooZJ72XaGxwGVw== X-Google-Smtp-Source: AGRyM1vJafhRN/xHd5t1GoTSnXJ8kzHtCNRRaRbXw6TE4LuNgTApmdlBx91bN/WVccFIoWL0jYWzbg== X-Received: by 2002:a17:902:8543:b0:16b:fbd1:9f68 with SMTP id d3-20020a170902854300b0016bfbd19f68mr7910318plo.101.1658665486534; Sun, 24 Jul 2022 05:24:46 -0700 (PDT) Received: from localhost.localdomain ([2401:4900:1f3a:5a45:a9cd:d7dd:fd01:73c0]) by smtp.gmail.com with ESMTPSA id p23-20020a1709027ed700b0016c0474fbd0sm7048133plb.34.2022.07.24.05.24.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Jul 2022 05:24:46 -0700 (PDT) From: Bhupesh Sharma To: linux-pm@vger.kernel.org Cc: bhupesh.sharma@linaro.org, bhupesh.linux@gmail.com, linux-kernel@vger.kernel.org, bjorn.andersson@linaro.org, konrad.dybcio@somainline.org, linux-arm-msm@vger.kernel.org, daniel.lezcano@linaro.org, robh+dt@kernel.org, rafael@kernel.org, Amit Kucheria , Thara Gopinath Subject: [PATCH v2 3/5] thermal: qcom: tsens: Add driver support for re-initialization quirk Date: Sun, 24 Jul 2022 17:54:22 +0530 Message-Id: <20220724122424.2509021-4-bhupesh.sharma@linaro.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220724122424.2509021-1-bhupesh.sharma@linaro.org> References: <20220724122424.2509021-1-bhupesh.sharma@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Since for some Qualcomm tsens controllers, its suggested to monitor the controller health periodically and in case an issue is detected, to re-initialize the tsens controller via trustzone, add the support for the same in the qcom tsens driver. Note that once the tsens controller is reset using scm call, all SROT and TM region registers will enter the reset mode. While all the SROT registers will be re-programmed and re-enabled in trustzone prior to the scm call exit, the TM region registers will not re-initialized in trustzone and thus need to be handled by the tsens driver. Cc: Bjorn Andersson Cc: Amit Kucheria Cc: Thara Gopinath Cc: linux-pm@vger.kernel.org Cc: linux-arm-msm@vger.kernel.org Signed-off-by: Bhupesh Sharma Reported-by: kernel test robot --- drivers/thermal/qcom/tsens-v2.c | 3 + drivers/thermal/qcom/tsens.c | 197 ++++++++++++++++++++++++++++++++ drivers/thermal/qcom/tsens.h | 12 ++ 3 files changed, 212 insertions(+) diff --git a/drivers/thermal/qcom/tsens-v2.c b/drivers/thermal/qcom/tsens-v2.c index b293ed32174b..f521e4479cc5 100644 --- a/drivers/thermal/qcom/tsens-v2.c +++ b/drivers/thermal/qcom/tsens-v2.c @@ -88,6 +88,9 @@ static const struct reg_field tsens_v2_regfields[MAX_REGFIELDS] = { /* TRDY: 1=ready, 0=in progress */ [TRDY] = REG_FIELD(TM_TRDY_OFF, 0, 0), + + /* FIRST_ROUND_COMPLETE: 1=complete, 0=not complete */ + [FIRST_ROUND_COMPLETE] = REG_FIELD(TM_TRDY_OFF, 3, 3), }; static const struct tsens_ops ops_generic_v2 = { diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index e49f58e83513..c2d085fb5447 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -594,6 +595,113 @@ static void tsens_disable_irq(struct tsens_priv *priv) regmap_field_write(priv->rf[INT_EN], 0); } +static int tsens_reenable_hw_after_scm(struct tsens_priv *priv) +{ + /* + * Re-enable watchdog, unmask the bark and + * disable cycle completion monitoring. + */ + regmap_field_write(priv->rf[WDOG_BARK_CLEAR], 1); + regmap_field_write(priv->rf[WDOG_BARK_CLEAR], 0); + regmap_field_write(priv->rf[WDOG_BARK_MASK], 0); + regmap_field_write(priv->rf[CC_MON_MASK], 1); + + /* Re-enable interrupts */ + tsens_enable_irq(priv); + + return 0; +} + +static int tsens_health_check_and_reinit(struct tsens_priv *priv, + int hw_id) +{ + int ret, trdy, first_round, sw_reg; + unsigned long timeout; + + /* First check if TRDY is SET */ + ret = regmap_field_read(priv->rf[TRDY], &trdy); + if (ret) + goto err; + + if (!trdy) { + ret = regmap_field_read(priv->rf[FIRST_ROUND_COMPLETE], &first_round); + if (ret) + goto err; + + if (!first_round) { + WARN_ON(!mutex_is_locked(&priv->reinit_mutex)); + + /* Wait for 2 ms for tsens controller to recover */ + timeout = jiffies + msecs_to_jiffies(RESET_TIMEOUT_MS); + do { + ret = regmap_field_read(priv->rf[FIRST_ROUND_COMPLETE], + &first_round); + if (ret) + goto err; + + if (first_round) { + dev_dbg(priv->dev, "tsens controller recovered\n"); + return 0; /* success */ + } + } while (time_before(jiffies, timeout)); + + spin_lock(&priv->reinit_lock); + + /* + * Invoke SCM call only if SW register write is + * reflecting in controller. Try it for 2 ms. + * In case that fails mark the tsens controller + * as unrecoverable. + */ + timeout = jiffies + msecs_to_jiffies(RESET_TIMEOUT_MS); + do { + ret = regmap_field_write(priv->rf[INT_EN], CRITICAL_INT_EN); + if (ret) + goto err; + + ret = regmap_field_read(priv->rf[INT_EN], &sw_reg); + if (ret) + goto err; + } while ((sw_reg & CRITICAL_INT_EN) && (time_before(jiffies, timeout))); + + if (!(sw_reg & CRITICAL_INT_EN)) { + ret = -ENOTRECOVERABLE; + goto err; + } + + /* + * tsens controller did not recover, + * proceed with SCM call to re-init it. + */ + ret = qcom_scm_tsens_reinit(); + if (ret) { + dev_err(priv->dev, "tsens reinit scm call failed (%d)\n", ret); + goto err; + } + + /* + * After the SCM call, we need to re-enable + * the interrupts and also set active threshold + * for each sensor. + */ + ret = tsens_reenable_hw_after_scm(priv); + if (ret) { + dev_err(priv->dev, + "tsens re-enable after scm call failed (%d)\n", ret); + goto err; + } + + /* Notify reinit wa worker */ + queue_work(system_highpri_wq, &priv->reinit_wa_notify); + + spin_unlock(&priv->reinit_lock); + } + } + +err: + return ret; +} + int get_temp_tsens_valid(const struct tsens_sensor *s, int *temp) { struct tsens_priv *priv = s->priv; @@ -607,6 +715,21 @@ int get_temp_tsens_valid(const struct tsens_sensor *s, int *temp) if (tsens_version(priv) == VER_0) goto get_temp; + /* + * For some tsens controllers, its suggested to + * monitor the controller health periodically + * and in case an issue is detected to reinit + * tsens controller via trustzone. + */ + if (priv->needs_reinit_wa) { + mutex_lock(&priv->reinit_mutex); + ret = tsens_health_check_and_reinit(priv, hw_id); + mutex_unlock(&priv->reinit_mutex); + + if (ret) + return ret; + } + /* Valid bit is 0 for 6 AHB clock cycles. * At 19.2MHz, 1 AHB clock is ~60ns. * We should enter this loop very, very rarely. @@ -739,6 +862,40 @@ static const struct regmap_config tsens_srot_config = { .reg_stride = 4, }; +static void __tsens_reinit_worker(struct tsens_priv *priv) +{ + int ret, temp; + unsigned int i; + struct tsens_irq_data d; + + for (i = 0; i < priv->num_sensors; i++) { + const struct tsens_sensor *s = &priv->sensor[i]; + u32 hw_id = s->hw_id; + + if (!s->tzd) + continue; + if (!tsens_threshold_violated(priv, hw_id, &d)) + continue; + + ret = get_temp_tsens_valid(s, &temp); + if (ret) { + dev_err(priv->dev, "[%u] error reading sensor during reinit\n", hw_id); + continue; + } + + tsens_read_irq_state(priv, hw_id, s, &d); + + if ((d.up_thresh < temp) || (d.low_thresh > temp)) { + dev_dbg(priv->dev, "[%u] TZ update trigger during reinit (%d mC)\n", + hw_id, temp); + thermal_zone_device_update(s->tzd, THERMAL_EVENT_UNSPECIFIED); + } else { + dev_dbg(priv->dev, "[%u] no violation during reinit (%d)\n", + hw_id, temp); + } + } +} + int __init init_common(struct tsens_priv *priv) { void __iomem *tm_base, *srot_base; @@ -860,6 +1017,14 @@ int __init init_common(struct tsens_priv *priv) goto err_put_device; } + priv->rf[FIRST_ROUND_COMPLETE] = devm_regmap_field_alloc(dev, + priv->tm_map, + priv->fields[FIRST_ROUND_COMPLETE]); + if (IS_ERR(priv->rf[FIRST_ROUND_COMPLETE])) { + ret = PTR_ERR(priv->rf[FIRST_ROUND_COMPLETE]); + goto err_put_device; + } + /* This loop might need changes if enum regfield_ids is reordered */ for (j = LAST_TEMP_0; j <= UP_THRESH_15; j += 16) { for (i = 0; i < priv->feat->max_sensors; i++) { @@ -1082,6 +1247,14 @@ static int tsens_register(struct tsens_priv *priv) return ret; } +static void tsens_reinit_worker_notify(struct work_struct *work) +{ + struct tsens_priv *priv = container_of(work, struct tsens_priv, + reinit_wa_notify); + + __tsens_reinit_worker(priv); +} + static int tsens_probe(struct platform_device *pdev) { int ret, i; @@ -1123,6 +1296,11 @@ static int tsens_probe(struct platform_device *pdev) priv->dev = dev; priv->num_sensors = num_sensors; + priv->needs_reinit_wa = data->needs_reinit_wa; + + if (priv->needs_reinit_wa && !qcom_scm_is_available()) + return -EPROBE_DEFER; + priv->ops = data->ops; for (i = 0; i < priv->num_sensors; i++) { if (data->hw_ids) @@ -1138,6 +1316,25 @@ static int tsens_probe(struct platform_device *pdev) if (!priv->ops || !priv->ops->init || !priv->ops->get_temp) return -EINVAL; + /* + * Reinitialization workaround is currently supported only for + * tsens controller versions v2. + * + * If incorrect platform data is passed to this effect, ignore + * the requested setting and move forward. + */ + if (priv->needs_reinit_wa && (tsens_version(priv) < VER_2_X)) { + dev_warn(dev, + "%s: Reinit quirk available only for tsens v2\n", __func__); + priv->needs_reinit_wa = false; + } + + mutex_init(&priv->reinit_mutex); + spin_lock_init(&priv->reinit_lock); + + if (priv->needs_reinit_wa) + INIT_WORK(&priv->reinit_wa_notify, tsens_reinit_worker_notify); + ret = priv->ops->init(priv); if (ret < 0) { dev_err(dev, "%s: init failed\n", __func__); diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h index 92787017c6ab..900d2a74d25e 100644 --- a/drivers/thermal/qcom/tsens.h +++ b/drivers/thermal/qcom/tsens.h @@ -14,9 +14,12 @@ #define SLOPE_FACTOR 1000 #define SLOPE_DEFAULT 3200 #define TIMEOUT_US 100 +#define RESET_TIMEOUT_MS 2 #define THRESHOLD_MAX_ADC_CODE 0x3ff #define THRESHOLD_MIN_ADC_CODE 0x0 +#define CRITICAL_INT_EN (BIT(2)) + #include #include #include @@ -165,6 +168,7 @@ enum regfield_ids { /* ----- TM ------ */ /* TRDY */ TRDY, + FIRST_ROUND_COMPLETE, /* INTERRUPT ENABLE */ INT_EN, /* v2+ has separate enables for crit, upper and lower irq */ /* STATUS */ @@ -564,6 +568,14 @@ struct tsens_priv { u32 tm_offset; bool needs_reinit_wa; + struct work_struct reinit_wa_notify; + + /* protects reinit related serialization */ + struct mutex reinit_mutex; + + /* lock for reinit workaround */ + spinlock_t reinit_lock; + /* lock for upper/lower threshold interrupts */ spinlock_t ul_lock; From patchwork Sun Jul 24 12:24:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupesh Sharma X-Patchwork-Id: 12927517 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF6A3C433EF for ; Sun, 24 Jul 2022 12:25:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234192AbiGXMZC (ORCPT ); Sun, 24 Jul 2022 08:25:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234169AbiGXMY5 (ORCPT ); Sun, 24 Jul 2022 08:24:57 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7952F17AB2 for ; Sun, 24 Jul 2022 05:24:51 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id v16-20020a17090abb9000b001f25244c65dso4576427pjr.2 for ; Sun, 24 Jul 2022 05:24:51 -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 :mime-version:content-transfer-encoding; bh=aeM1+URF6K22PChBXxuUTBq3ki6hGotwl2mOvNpT7uo=; b=ggljdyyrK7ebpzFisHZHoz8VWg9b9ZNcPtsOdY57V7tsaSjo0mGxsv2cOONNvpLCUc NEQ902c1A5zxderuIrTa86Hc9d00lOzR3oHqZSSqrod9p5+2WjkBLndzpvK91rORzOUi q1KTZjaubvFz3YRqImMHcB03n0wfsDaVElk5w9ZLhuDpeOsaanKR+MGXR8DnWDpzFXjR 1IrJEehccVfrKGcmK2TjKACRcJ/RSOQD/qw7YC6lnDAam3zJufPI3POS2PZT0dfbL+cy 6Qn+RptlGvRCGdP0iFtp4exZd2LBb+TShV/J5U5Ii1ysavOPxaw7i94kSswIZKxSK1cW iBrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aeM1+URF6K22PChBXxuUTBq3ki6hGotwl2mOvNpT7uo=; b=snlV1oqDaFx3W3VvqBL0pOPQPwnVk+HI6dSbcJKrUxXzvOF1PV29TedFFOh07MtVs1 YVw1AYv1NP0EP8qum+DOAt+xpV7DWQy8kAfgTBMrhFhLoNgcA5BQGlq6s6YkDASvdmBf SOKOwgPU5ekzgc67eBxuSeTlXxvARcD9Q2VgvY+vSxYyj0SzjRktAKrqZ9lLCvh2jQ2g OAJnErTZSxN+24dANIbYbuyGxnVKteXURYPsUkyvA6lffSPl3Cnfcwz7bC5OijuS7hqB vk38c+p9k8hjSI50z1VAaJC+9bxFXJMIZU4hnxHEgejOzn5l7mAgxDXDBjTu0uHI1sHV 8TzA== X-Gm-Message-State: AJIora+WFEm23F6ZgwSajY4jWdEdPfEr+hPKKV5btYnY7nZj5vKVoDQL ky3Hd6AvBiDUCd7K0p1p2hv3tdio6j3aQA== X-Google-Smtp-Source: AGRyM1s8Oik61Alx4is/FDtweo4FH2WtkiMsaKQgJXGDBBfEVDVUL3P/crOsxsNGFtjQEG+OBJHQkg== X-Received: by 2002:a17:90b:4c03:b0:1f2:b977:c64e with SMTP id na3-20020a17090b4c0300b001f2b977c64emr6278pjb.211.1658665490929; Sun, 24 Jul 2022 05:24:50 -0700 (PDT) Received: from localhost.localdomain ([2401:4900:1f3a:5a45:a9cd:d7dd:fd01:73c0]) by smtp.gmail.com with ESMTPSA id p23-20020a1709027ed700b0016c0474fbd0sm7048133plb.34.2022.07.24.05.24.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Jul 2022 05:24:50 -0700 (PDT) From: Bhupesh Sharma To: linux-pm@vger.kernel.org Cc: bhupesh.sharma@linaro.org, bhupesh.linux@gmail.com, linux-kernel@vger.kernel.org, bjorn.andersson@linaro.org, konrad.dybcio@somainline.org, linux-arm-msm@vger.kernel.org, daniel.lezcano@linaro.org, robh+dt@kernel.org, rafael@kernel.org, Amit Kucheria , Thara Gopinath Subject: [PATCH v2 4/5] thermal: qcom: tsens: Add reinit quirk support for tsens v2 controllers Date: Sun, 24 Jul 2022 17:54:23 +0530 Message-Id: <20220724122424.2509021-5-bhupesh.sharma@linaro.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220724122424.2509021-1-bhupesh.sharma@linaro.org> References: <20220724122424.2509021-1-bhupesh.sharma@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Some Qualcomm tsens v2 controllers like those present on sm8150 SoC might require re-initialization via trustzone [via scm call(s)] when it enters a 'bad state' causing sensor temperatures/interrupts status to be in an 'invalid' state. Add hooks for the same in the qcom tsens driver. Devices requiring the same can pass the relevant compatible string in dt and the driver hook can be used accordingly. Cc: Bjorn Andersson Cc: Amit Kucheria Cc: Thara Gopinath Cc: linux-pm@vger.kernel.org Cc: linux-arm-msm@vger.kernel.org Signed-off-by: Bhupesh Sharma --- drivers/thermal/qcom/tsens-v2.c | 12 ++++++++++++ drivers/thermal/qcom/tsens.c | 3 +++ drivers/thermal/qcom/tsens.h | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/qcom/tsens-v2.c b/drivers/thermal/qcom/tsens-v2.c index f521e4479cc5..431f17f99d34 100644 --- a/drivers/thermal/qcom/tsens-v2.c +++ b/drivers/thermal/qcom/tsens-v2.c @@ -104,6 +104,18 @@ struct tsens_plat_data data_tsens_v2 = { .fields = tsens_v2_regfields, }; +/* + * For some tsens v2 controllers, its suggested to monitor the + * controller health periodically and in case an issue is detected + * to reinit tsens controller via trustzone. + */ +struct tsens_plat_data data_tsens_v2_reinit = { + .ops = &ops_generic_v2, + .feat = &tsens_v2_feat, + .needs_reinit_wa = true, + .fields = tsens_v2_regfields, +}; + /* Kept around for backward compatibility with old msm8996.dtsi */ struct tsens_plat_data data_8996 = { .num_sensors = 13, diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index c2d085fb5447..928b6a44fda8 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -1145,6 +1145,9 @@ static const struct of_device_id tsens_table[] = { }, { .compatible = "qcom,msm8996-tsens", .data = &data_8996, + }, { + .compatible = "qcom,sm8150-tsens", + .data = &data_tsens_v2_reinit, }, { .compatible = "qcom,tsens-v1", .data = &data_tsens_v1, diff --git a/drivers/thermal/qcom/tsens.h b/drivers/thermal/qcom/tsens.h index 900d2a74d25e..03cc3a790972 100644 --- a/drivers/thermal/qcom/tsens.h +++ b/drivers/thermal/qcom/tsens.h @@ -607,6 +607,6 @@ extern struct tsens_plat_data data_8916, data_8939, data_8974, data_9607; extern struct tsens_plat_data data_tsens_v1, data_8976; /* TSENS v2 targets */ -extern struct tsens_plat_data data_8996, data_tsens_v2; +extern struct tsens_plat_data data_8996, data_tsens_v2_reinit, data_tsens_v2; #endif /* __QCOM_TSENS_H__ */ From patchwork Sun Jul 24 12:24:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupesh Sharma X-Patchwork-Id: 12927518 X-Patchwork-Delegate: daniel.lezcano@linaro.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C10FC433EF for ; Sun, 24 Jul 2022 12:25:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234920AbiGXMZU (ORCPT ); Sun, 24 Jul 2022 08:25:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234363AbiGXMZA (ORCPT ); Sun, 24 Jul 2022 08:25:00 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08DD918349 for ; Sun, 24 Jul 2022 05:24:56 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id o5-20020a17090a3d4500b001ef76490983so7891020pjf.2 for ; Sun, 24 Jul 2022 05:24:55 -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 :mime-version:content-transfer-encoding; bh=139SGHEUeM2aejnfQkWBOsWtu/AlzldGV/6Rxr/OVqQ=; b=Rck6hZeQJcCVdN98Q/BXR/RPDTY17uN8lQXphU17j7nsJX4HEQUw6qRHCDNu2nE8cy 0c4i94UTYgtOaZCJNYvETWSIEI9aTAWgoxNX9nPwwjlk67BXJVXyDUteDhSzc53ufoES 5HIdV3OHGNEEMPjB+vCCAbKrabrCTmjYoB7se8OfOaMBV7rZQCwZ8Fly15ZMRew/P2vl M5N5zkX6Gw/nx+yNsf6enQFr3F97YYKftOQC9EQMPmZFfA0wpMSETMrjxcgWFG+jEysV srUzQqq67HzdIvd9aPP9ZmV9PEitb+5kBBqMMJW4sao6Yf5J/KSowlVfdHXv2vEy1L+O Zd3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=139SGHEUeM2aejnfQkWBOsWtu/AlzldGV/6Rxr/OVqQ=; b=SM2numyGLM3r+38drFPvZF7lnJqs/m41nYY1JA18sJkjPXiSsMhGcWNA3YlnATineF t32hc8xAy1uw16QHKlweumo0tQ7fS23fwBa3c4jzJTjYO59Hwgo128gJUdLGJK7y8b2B XNm5hNoZuweoBVxkgHtgGFXI2c1EZz3ib+6PIuexpIq7ez+4wShWBqNiIv3/oHyJLWkG eRBH8Ump0/y0oQd2b5aS2ua45QbXiVN1o5Mf9KyTWGrO8iwMDzCRb3J5fAzjwLsBiR1V PtbunkLBZJxaJwhHeRsArcWnhyzr//JoEGJ7N8oKMA98z7RL3JazBBezFU8g1zDNhrMP NQzg== X-Gm-Message-State: AJIora9qJGpe0MZSF2TDVHbISRTCT+CWu9wzk9M20HO7aH4xGxgyRYhn ULNrYzVGzgxfHvLEoW364TeekUg/K6l4UQ== X-Google-Smtp-Source: AGRyM1vLVdU42vU5ntfcZhh5BW+Q6etxX3Wuk7EEylfDOeb4Vng+8HSL26YkBARIQUfBxg2d9rnpsA== X-Received: by 2002:a17:902:da92:b0:16c:4f7b:8703 with SMTP id j18-20020a170902da9200b0016c4f7b8703mr7946675plx.75.1658665495077; Sun, 24 Jul 2022 05:24:55 -0700 (PDT) Received: from localhost.localdomain ([2401:4900:1f3a:5a45:a9cd:d7dd:fd01:73c0]) by smtp.gmail.com with ESMTPSA id p23-20020a1709027ed700b0016c0474fbd0sm7048133plb.34.2022.07.24.05.24.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Jul 2022 05:24:54 -0700 (PDT) From: Bhupesh Sharma To: linux-pm@vger.kernel.org Cc: bhupesh.sharma@linaro.org, bhupesh.linux@gmail.com, linux-kernel@vger.kernel.org, bjorn.andersson@linaro.org, konrad.dybcio@somainline.org, linux-arm-msm@vger.kernel.org, daniel.lezcano@linaro.org, robh+dt@kernel.org, rafael@kernel.org, Amit Kucheria , Thara Gopinath Subject: [PATCH v2 5/5] thermal: qcom: tsens: Add reinit quirk support for sm6375 controller Date: Sun, 24 Jul 2022 17:54:24 +0530 Message-Id: <20220724122424.2509021-6-bhupesh.sharma@linaro.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220724122424.2509021-1-bhupesh.sharma@linaro.org> References: <20220724122424.2509021-1-bhupesh.sharma@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 Cc: Amit Kucheria Cc: Thara Gopinath Cc: linux-pm@vger.kernel.org Cc: linux-arm-msm@vger.kernel.org Signed-off-by: Bhupesh Sharma --- drivers/thermal/qcom/tsens.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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,