From patchwork Thu Aug 9 12:32:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 143835 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2038691ljj; Thu, 9 Aug 2018 05:33:23 -0700 (PDT) X-Google-Smtp-Source: AA+uWPytXCPVcmTVv39N5mdPuPJN63kOSFp1Pf1vgMvewflWaH5SCHJYhkWgmyKRLOo50HkFO/96 X-Received: by 2002:a17:902:74c2:: with SMTP id f2-v6mr1914949plt.260.1533818003367; Thu, 09 Aug 2018 05:33:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533818003; cv=none; d=google.com; s=arc-20160816; b=qJCrAJgoKluwU/PTDUUGG6dJGwkQSjB7k34xuxJ+VX6LMMpbKBTDt0U6FbLJyKwxfU IwEPGuHpO3X6cZ0evqehGQMOSm0d7m+8rW5vql/FHMCmcvDZ9+yg6awDW9U9ptKBK8cV qpvEKJ0Bqc8je4iMwWapLXZ+qWWDi0NH3LWlC9yWzsMs818qtQMlphkxKfGHPpKHnhHt 7GIFHCqIaCFzM1/h8eXEcNtnQgsT8XW4Nx/l7TEkQf2WCa7iGmYKglT63v5h0lxa1nuV pUpxg6UZlDCSzVUeiBtkqF5wpqy9QlY6kb22GnB+P48q7s1bNtCIzZDni2y1MZQp5IWf y3aQ== 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=ssFzQhXAqL5/8wCjTh2YuAtHH9A+saw4YW2/AAQBY/1JastivMfURvk+yW+lCeUC2w gVyIWURDlbJZe4P6CMZ1v/gLJDJcIwDT67hrcU2PYDbLzHxTXYcFHTvI78r563Jl3uBy Gmc0bEiJDqU0jIQXo0UNOhXW5BKkzyCP7JABmKSxPIZh6OiRJoycBXGc9C+hYlm5u9bU SYG/EDwF+L5lyal+GTVumQV690hr91P4ispiiG5k0u97D7w6/SyuScp/qy6si8084Iz4 YWuT3lrJySvN2XSbg08+S3eA/EVTb0m3zcBZJhJKtkU8x+KhLmueHxWfj7X+PZZDk/7t OL7Q== 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-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 a5-v6si5465648plh.312.2018.08.09.05.33.22; Thu, 09 Aug 2018 05:33:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 S1732170AbeHIO6D (ORCPT + 10 others); Thu, 9 Aug 2018 10:58:03 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:42362 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731130AbeHIO6C (ORCPT ); Thu, 9 Aug 2018 10:58:02 -0400 Received: by mail-pf1-f195.google.com with SMTP id l9-v6so2780883pff.9 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=HbKpfPWdgGdUPiLW+4fYF6t2FOwaA42G1lOANiH5Qj4wrRAKmkQmIELofxJ9/I/gN5 HqAihxuk59HjmZ6G3ArS4cLf8px+opvDcXAWFQLnVyxjTqMiVLSI0sL/CWiTXRmjFeNL wf3qzrvApB4XmaeNSwFftkhtg/ofQjaKZ4Hx6N1YBs0fATXpx9FMkS297ZIVW2bZejo8 Z9td4AaXFXup74htZxqAfYPWBiob3TLDAc0yswH7Pu0Ejv4E5wTg7/DCK+29mdlZrKgX mfyVYIp/ABRNnVH+1lEV1TOaNvpTd+7QLyJRU14diYMvu3tULnE+D1M/jvsgmYopdxSX ts0g== X-Gm-Message-State: AOUpUlFD02hAkrq7bw3gqhBmvi9kUE8MeWJJAIM0BwHYtxejyjbJ84Do N9B13slD6Dk5PicyFI15qfVucw== 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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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(+) -- 2.17.1 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; }