Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5219043imm; Wed, 12 Sep 2018 02:55:09 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb3hviGiMklLZV5AdkHL8jWQDXgjqVtHiE4++2nxyhY7mSYx77UhHtfPGuqICXMdj9THLDK X-Received: by 2002:a17:902:4201:: with SMTP id g1-v6mr1256451pld.203.1536746109408; Wed, 12 Sep 2018 02:55:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536746109; cv=none; d=google.com; s=arc-20160816; b=cQbIz/8L0XE72ZvxFml0PvQ8ZgfLr16e0xk7mLOQWGI1EY545N8oiZMXI8v4vRtp1c oi2R+A2oYp2PtHoovo+t4CzlWyPMaK/WsSiHzeZvCxZEOjXaULFemWWUEmOUSpkRsKbe kpxwO3sJyiNoesqK2avT906Bp13p49aAAdPdopv7ceO1vHU69H2EO+lLybpG5SB5JoMV UfitwxfiV1LZQmoq4QTYVZVxcQcN6ZvOE0yaNB/KGi8hkdTwmG8VfOoGEimvEoaCO4mR KkOM5ytSTy6KGnbvQmkYfi1u+YK1GRuUcujtW17t4ZPEW7NQrB75JXFN17ipH1z2ggT0 2DXw== 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=p+l9eG3EJUvs5PqroE1oN9/c9Y5I3RjwbnuwyKuwaKQ=; b=VqR6Ym+R58Nlr1jOP0F1pkrBP0k8UAfedIbf0HZVazim5CL2E30MXO+EKuCJPtIJ+0 ILlJR559pP5jSo1aYvedYBoP6oTkoMUBuNOto87b76YICMec0WvEjcv23SLz63kccwQt pkNRSu/yl4Vvx9KPA4MO42EDT+Bek47VvGM50m97YU5i0VbCqAfqbWmxCZZy+I/52LoN QGnRNEpC6hmAdExWXSFSZ+us1v4pcUksOIISffSickJ+xpl3MXFU8umar1X0Q0UNNjpU aftRZLI7p0O7Op+m7GiswHcbOlGMcnhb6FvGpD/s5BZDkmkFzI++NXFZXgWOJ2SML80z akmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J9L6R4gf; 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 b4-v6si608817pgg.537.2018.09.12.02.54.54; Wed, 12 Sep 2018 02:55:09 -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=J9L6R4gf; 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 S1727820AbeILO6J (ORCPT + 99 others); Wed, 12 Sep 2018 10:58:09 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:36685 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727796AbeILO6I (ORCPT ); Wed, 12 Sep 2018 10:58:08 -0400 Received: by mail-ed1-f65.google.com with SMTP id f4-v6so1274553edq.3 for ; Wed, 12 Sep 2018 02:54:21 -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=p+l9eG3EJUvs5PqroE1oN9/c9Y5I3RjwbnuwyKuwaKQ=; b=J9L6R4gfDqVWuTaZEOBoz4A2w3TIHW5Klx19orLgDv4Sl9La0s0FWXmR7JLmcigpEW DKdX1UdAg4XCcBHHnA6xPilTPpyQPnTZrgTwqHzUH+7yNsz7VXqCYTy2XnAIoSuRiR5R Wtnd7im10Eb7dMJnSui63aISD1ETTo4synyUs= 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=p+l9eG3EJUvs5PqroE1oN9/c9Y5I3RjwbnuwyKuwaKQ=; b=F022DfVh6GS5IqXKPYPVHaTBU/9h9dj21g9iOPU6delTklEJqzLhstfVlhXyIRQ71t RHvGErM7e1LWs1VuDYz9Gxqf4N9iP/hNliv7jsKtnV85e1pBZ/hnJlTJT8TBXqMEJnsa 4v0N9Oyw08sh3joRSauUwsd+mQWVqZ8ypOpFO0p82dJG8ImZWAkZE8leCFqZKPRbqKbQ uiCm1S1Jx55ZBzi2t7zp2Qjoouk524Oaprvk0uLKttUY1UKbzfEIX9cg3a8+8jFOt6Sp dJDJddLdUOECs2bK36vZtGkI43MDuehOfmwtuaAfgAWd+vXBwttB5fN2U3niSUSeryMg owdQ== X-Gm-Message-State: APzg51BX+KqIzq+1MJZNZuAkpw6E8apQanx+EQqyhCkCYJHzXDzMWyTS yg8OgDePp0AU4ugSaGjhJmLXWQcIkJk= X-Received: by 2002:a50:de03:: with SMTP id z3-v6mr1749903edk.245.1536746060744; Wed, 12 Sep 2018 02:54:20 -0700 (PDT) Received: from localhost ([49.248.190.214]) by smtp.gmail.com with ESMTPSA id f13-v6sm690554edf.50.2018.09.12.02.54.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Sep 2018 02:54:19 -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 08/16] thermal: tsens: Check if the IP is correctly enabled by firmware Date: Wed, 12 Sep 2018 15:22:53 +0530 Message-Id: <140b054230a61e13995ae4b685746c8faf068d61.1536744310.git.amit.kucheria@linaro.org> 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 The SROT registers are initialised by the secure firmware at boot. We don't have write access to the registers. Check if the block is enabled before continuing. Signed-off-by: Amit Kucheria Reviewed-by: Bjorn Andersson --- drivers/thermal/qcom/tsens-common.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c index 0b8a793f15f4..3be4be2e0465 100644 --- a/drivers/thermal/qcom/tsens-common.c +++ b/drivers/thermal/qcom/tsens-common.c @@ -12,6 +12,10 @@ #include #include "tsens.h" +/* SROT */ +#define TSENS_EN BIT(0) + +/* TM */ #define STATUS_OFFSET 0x30 #define SN_ADDR_OFFSET 0x4 #define SN_ST_TEMP_MASK 0x3ff @@ -119,7 +123,10 @@ int __init init_common(struct tsens_device *tmdev) { void __iomem *tm_base, *srot_base; struct resource *res; + u32 code; + int ret; struct platform_device *op = of_find_device_by_node(tmdev->dev->of_node); + u16 ctrl_offset = tmdev->reg_offsets[SROT_CTRL_OFFSET]; if (!op) return -EINVAL; @@ -151,5 +158,15 @@ int __init init_common(struct tsens_device *tmdev) if (IS_ERR(tmdev->tm_map)) return PTR_ERR(tmdev->tm_map); + if (tmdev->srot_map) { + ret = regmap_read(tmdev->srot_map, ctrl_offset, &code); + if (ret) + return ret; + if (!(code & TSENS_EN)) { + dev_err(tmdev->dev, "tsens device is not enabled\n"); + return -ENODEV; + } + } + return 0; } -- 2.17.1