Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp7114799imm; Tue, 28 Aug 2018 06:42:06 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZFgcIw03ZX8YHoUVzXwK/GMzcUw1jxA0GB7elAJNxG9T+Lb4NZ5oNmUgtkC497Erfuassj X-Received: by 2002:a65:608b:: with SMTP id t11-v6mr1656870pgu.259.1535463726456; Tue, 28 Aug 2018 06:42:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535463726; cv=none; d=google.com; s=arc-20160816; b=SMG/2holKH5BugUDCCjR5cNNupufvEkwSqHU5RHrtoch4PxQL5z8egzkLOOTf+pH3j CYLUhZ5DR3O+m1Wv7jxBF2/08yq/n3oBkU3DxaiReHAXU4V5YBZwglbr3LnUip1Kke8x dndcLRbEqZdu8rv1s7tJefd8QJx544PKg7u2lXW9OCFGeHfzNDy2AZtowLfea/YaSkvD 3NfLEQyWarKfziWCLdYtN8A5c5OALPegFBWBBMA7+SB1nA43fNuf+vldlX8UKVSuA66E UmcVBpwgqvo/9g2OUX9m2NV0ze1XwhLnEgMESLm+LKknqKgFRwSH7qjHj9rgtvjq9hEd EXIA== 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 :arc-authentication-results; bh=KGPNhtmxbZmY2SbJ8bQ/3ZZChD9pwNRV/BvwQjyiwy0=; b=UUm5sdyWCRCa7NwxlG/QGVoK7yQVCYhkhpV6+c7YteATcIduAYCC+00Rpo+ZiPpqBg y2XOVoRnf/k8fXJxwwlbehD7ChPcinTIX8L10Ky6amgwGYzBm+Pkk+nX3SaG+BnGSS1O SSGIc6EB9ywW1jhdowQA+jos2zHDnrGHIA5SizfpJt2LO+4QFsQqq2iom9HNwDZWfCUy 7o+EeNgOggqkX7hICMX9L6lAmxnyp9VKHcKUs20cl024jcrYvDZzbOxeRtAcxpnPEW4y s5sKgs/n91n4STsobZeK4GHUi2Jyf/zA5/FVwxdS/am2EpzXFjJr8K7ZHWmeWpWYJwt5 ob3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jRz3TMe7; 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 b87-v6si1079021pfm.5.2018.08.28.06.41.51; Tue, 28 Aug 2018 06:42:06 -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=jRz3TMe7; 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 S1728218AbeH1Rbd (ORCPT + 99 others); Tue, 28 Aug 2018 13:31:33 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:43838 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728204AbeH1Rbc (ORCPT ); Tue, 28 Aug 2018 13:31:32 -0400 Received: by mail-ed1-f67.google.com with SMTP id z27-v6so1390276edb.10 for ; Tue, 28 Aug 2018 06:39:49 -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=KGPNhtmxbZmY2SbJ8bQ/3ZZChD9pwNRV/BvwQjyiwy0=; b=jRz3TMe71F2b9UgCkzD8872RQyACr9ec+apqRnpZ79KaxeZs95GJKrl7EJ7TP00HmN oBiZ0SKVAN6ysQkAy+RL2UDW4xGMHE6tXVr/nRVaYGwrXKeiZkuR8q3sd9mnYnR+th+G fpdheiArd7vZQW4X0JODc4FlL8p+MrCKfCZVs= 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=KGPNhtmxbZmY2SbJ8bQ/3ZZChD9pwNRV/BvwQjyiwy0=; b=fYrp6mDYR3ycywpqYU2N1hFOBSj8Mri5NI1m4H5F0khKurg6BUTFr1N+JgL83+lu4k fz2FLvxmBJYI3Ms9F5jGOdnxmN44rkylW8Kd1NuzrZ0FMy9AWAdKoavNe7v+EVV6UjrU 9qcKqPYFddlX09C/6T9iJgwBAzLyGlUvIuDqFlzaebF/PrYyPISfV9Gt8Bnbse6PPlQI YROoOtO12x638XMvQEyQmzh6flTeAJ4Jq31CCPUolV4mACkIxajj6+qE2n6oFmIkFSpw W2FTX3c5/aRoMWO2itkjGGPqE9Cwf3byeleTq3X4eh5vu0gQoZRkjy7NH4ePHpVP06Ee qY7g== X-Gm-Message-State: APzg51BCza7uBysXOgUceVrX+fxPPrRuCTiSGB4nOPVOUlU4samY9R/Z 92GR3eeLbyjnHeXrlINFxtOHebQf3HQ= X-Received: by 2002:a50:a9a4:: with SMTP id n33-v6mr2656458edc.208.1535463588592; Tue, 28 Aug 2018 06:39:48 -0700 (PDT) Received: from localhost ([49.248.200.109]) by smtp.gmail.com with ESMTPSA id r11-v6sm536788edh.32.2018.08.28.06.39.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 06:39:48 -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 v2 08/11] thermal: tsens: Check if the IP is correctly enabled by firmware Date: Tue, 28 Aug 2018 19:08:37 +0530 Message-Id: <35c332750fe1eddfa2eb53750b810256310866bd.1535462942.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: Matthias Kaehlcke --- 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..d250b757d1f0 100644 --- a/drivers/thermal/qcom/tsens-common.c +++ b/drivers/thermal/qcom/tsens-common.c @@ -12,6 +12,11 @@ #include #include "tsens.h" +/* SROT */ +#define CTRL_OFFSET 0x4 +#define TSENS_EN BIT(0) + +/* TM */ #define STATUS_OFFSET 0x30 #define SN_ADDR_OFFSET 0x4 #define SN_ST_TEMP_MASK 0x3ff @@ -119,6 +124,8 @@ 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); if (!op) @@ -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