Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1986777imm; Thu, 9 Aug 2018 05:34:47 -0700 (PDT) X-Google-Smtp-Source: AA+uWPz+vd32tlcmjyYc61IETHSJanRABMdbfe1yBudF1F3v/MJxwtD5/rJcyOJ/4FD8KnG3zGwU X-Received: by 2002:a17:902:530a:: with SMTP id b10-v6mr1963492pli.101.1533818087374; Thu, 09 Aug 2018 05:34:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533818087; cv=none; d=google.com; s=arc-20160816; b=QeOlLpxdDLl6mpOIHreW8cYro7kRI1TTES+59rR5QYAIJfVdBdvTtQL+yeA2DwtOVS dwjNfNXoMeauGEiIN+RMYgLE/P5wdiz84/OuS9bu5Kbooe03kX+IqgrNCDpEC4nWnVPc HdRo/QvADGhvQjnc5Cd1aZjMWOlYAnFCRLqBoBqBwv2Ez0h0MiajtT25BJ3oH556oPtq QZrH+PJ734TujNcJGNge8pFFwpgNXXBks9seLeEAnA+pgV0mxfeEy+i5cXCBoPGhGJ/E sr6UBmHWOwhCRjDt0RADRHsUi8iKKgzOBC9il30BOMVJD4ubkF+EGZpEo7StP1sOOd4x rGeg== 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=njW6jAZWOPdw7KJ/kbY+W+hKS572y0dkgyYwoknGJBU=; b=ZqqBkLYOVmfLWK16/XJPAsGXe8CKedx3LtElwe4lVe06MulK1+Q4fFWqJzUKfAz1cr cJujNK6frg87KeTWd/+/OrXNY9GHSGb3CNvzptjYnN7i/U3Ollk/WyTTcJ5ojbSMO69a Pj03oSq5chRkumC6luGg6wPehpWBSac3Zy6MJU/HkyRZFkNu7PC+ddg74wy7uPhHCEws LtqKKJqN1LNXORKLui8RQLQb2EnC3JFnY8VbHPtO5YuRlLWxq8TrbZBklb5tFBuClyIm AM2VB3+Ht3cVEJ5rLNafcDtbVc0erdhnqJweSKI6We3TLOA9zjavlvvJXuKzDPaNyfXa IrUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kBj3KSKq; 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 f7-v6si7390551pfj.284.2018.08.09.05.34.32; Thu, 09 Aug 2018 05:34:47 -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=kBj3KSKq; 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 S1732253AbeHIO6D (ORCPT + 99 others); Thu, 9 Aug 2018 10:58:03 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:39239 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732236AbeHIO6D (ORCPT ); Thu, 9 Aug 2018 10:58:03 -0400 Received: by mail-pf1-f196.google.com with SMTP id j8-v6so2792304pff.6 for ; Thu, 09 Aug 2018 05:33: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=njW6jAZWOPdw7KJ/kbY+W+hKS572y0dkgyYwoknGJBU=; b=kBj3KSKqdrGbKlEZB8ILVyoVK8wPo4sqH0Ttz37olDY7oM8X97IojsYz+ogQTBqhZ4 pv3pbYSRO5b8h6DWWzDe4oFYlcmpQ+YOlq1IK0PKsTs9YjjkOXnFlOi2IFJw0m6Ha8Am w2Z2T16cRauQxtQDRoQjCYmPqzYfWEY+OX/0o= 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=njW6jAZWOPdw7KJ/kbY+W+hKS572y0dkgyYwoknGJBU=; b=j93qJDoSan/Jpf24SQIlWeRJcBbpi0iFjlDJMcokuL81tCTFRz1zi5u1uXKvHozn7W woF6bqMq62CEJBgxQ6N7+NE3FPMYmEZnZXjGA693a2WTS/6f/dKQ2XtM4bfwZpZLZvoj EDF91EbXhiWmPWR0UVGOOB3ZBvrDFLuS5n3LkdT2C/KKFOyV44dsA7SOF76aAIUsjTn2 NhRd/dW6E/n2bHsY6FXoOH2a6vonZvyrW+mYp0aLiL8jWW31xdLq8X0lEP3gKPmh6HSp 8dwDu4+lvap7VMdcXs0z1+EDRQqqJSRRpr0CuUMfYthZZ/A8aTOFs5lT3VMScyBEBX64 qKHg== X-Gm-Message-State: AOUpUlH6rg2aJCfbUzbV4zUu6KpRCXmByoqTp0lhpIMdDCKHTbSl1uEf wlgO+e/WfgAzoSCH2zieyiiFFRzNgks= X-Received: by 2002:a62:1449:: with SMTP id 70-v6mr2234037pfu.222.1533818001059; Thu, 09 Aug 2018 05:33:21 -0700 (PDT) Received: from localhost ([45.113.251.134]) by smtp.gmail.com with ESMTPSA id w192-v6sm7818876pfd.74.2018.08.09.05.33.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Aug 2018 05:33:20 -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 , linux-pm@vger.kernel.org Subject: [PATCH v1 07/10] thermal: tsens: Check if the IP is correctly enabled by firmware Date: Thu, 9 Aug 2018 18:02:39 +0530 Message-Id: <985ed415774fdac9ac21afad4b4b74f30f6c5068.1533815718.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 --- 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