Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2473862imm; Thu, 9 Aug 2018 13:38:54 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzZ/Za0aXYu8tQrNIo9+SHq+fIClG3eYozXUj9/I6cXOC5FdRkXcLwNB4QMNeT4Ny+58p9D X-Received: by 2002:a17:902:9a8b:: with SMTP id w11-v6mr3350464plp.333.1533847134562; Thu, 09 Aug 2018 13:38:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533847134; cv=none; d=google.com; s=arc-20160816; b=qeZSLr2zUa6qp04J3WFpSRxMuLPHZfzM4NAfuVGvDXvmGVZuMumaO/vxOBfkOgaSpK dlgXdt6eG6ZjHap4x5K5/3hU8eAB1e8Ox6J6+wX8DmztQkoqTrHSUv9oOjxzKeM0mgMy e9wxieWiDJd96yjMNf284sOg+hRyhvNlubxmCJnhUfp0AMtQR3EfjYpWLlnahddl/puB qVTCSpp3sZCvUYEQlqXu5/4cFQpESYKL1cjdxP0+TjtiRA4jUZkaTyMvfDhdYsDPHVk8 RS+RL0E9Hd/xk/qBa4g0XPkuN5ScEV7RKG3ZhpeOQuRaydNtgXoU/QYtyH6Lo8GMWmmk j3BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=uFWqEG8UBRBqeWfwnx2ondjG6e8vdPzEuZWTCDmCXn8=; b=aCtKHUY8IeUM0yUffTdefL2t1BRAJXGjDnmygCQ/YX8rCJ7EGYkNPgRGy6QwXH9Ok4 pNl7799nSX1kl/w8+t/COu1T2FJtLNOBoG7Qul/tjlBMTPJBl3/2TLWqbHwfh3jTTn4H midychrRCutoKSjzGeMcqjEkfnlnrkphWAwbUwewX8VB1Bz7WH7mP1pFknqS1XxmoJby SCKtrK/QbHj7BigN6cB8jZYAXrpmxdlmOtLDTrvt/Yz2uwxBCb46XQomq5cCaGyHDU31 wefK7pNscw5Vepg6OBrCkiKn+3/71Ul8++aMFRqCd7nmZUMW56OtFfpPGdU5tflPhD3G 9sJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=OwE5nn9E; 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=REJECT sp=REJECT dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 64-v6si6295842plk.257.2018.08.09.13.38.26; Thu, 09 Aug 2018 13:38:54 -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=@chromium.org header.s=google header.b=OwE5nn9E; 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=REJECT sp=REJECT dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727208AbeHIXEH (ORCPT + 99 others); Thu, 9 Aug 2018 19:04:07 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:44496 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727104AbeHIXEH (ORCPT ); Thu, 9 Aug 2018 19:04:07 -0400 Received: by mail-pl0-f65.google.com with SMTP id ba4-v6so3022033plb.11 for ; Thu, 09 Aug 2018 13:37:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=uFWqEG8UBRBqeWfwnx2ondjG6e8vdPzEuZWTCDmCXn8=; b=OwE5nn9EOI5NbLlZNvVOsFwGFTXEQqm5Lz/ZeSPo4Y6a3XUcttTGggoE7fVHqIp7/J VtbkKYMsmjXMOZWQVP7vARAceQvZ29CH4RAUWzwnHxupGaM8PjVzmkwrfZ/Bc1kSKvwS x14N1CAum5u06+oNOL4gRDqH0AetxUk/AVyyY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=uFWqEG8UBRBqeWfwnx2ondjG6e8vdPzEuZWTCDmCXn8=; b=n0YwKGoPB3iGViOgMnZXd1LCGbzunJX0JxEtqDZW/6Cf2tH927mGWkQmfOidFu4M45 KGj2502cwZk6Gc1jPw0ycAhvFICvHzOl4nAsmONFypPCGTOaFgORDNVUWKVilxPBZsfy WDrnwzyKXS7yFzKAStxygeTu2rfhl2Jn1ZbJ56KpekVBg0JwSIlpxtgvTh/JX+SyHoot BZnUg3EBjz9U50FfuxepQkMLD1Yj14/nG9dAOKdFPH7vj81Ry/VMDGkOo4f0K1SSeT++ DsF5ukTlUWHGWivPBSQc7v+jR8drbqmCbrAXGaccx/sccOJAs6N7wllD7ViEdywZqLLi 0hKg== X-Gm-Message-State: AOUpUlGl3RNKS5sQqS9e4rl+yooapmf5kZmRFTVu4q9odc3JGQXSw5fN AZsA4isYKgFLZpk7GC5ZJWIhfA== X-Received: by 2002:a17:902:123:: with SMTP id 32-v6mr3305140plb.181.1533847056836; Thu, 09 Aug 2018 13:37:36 -0700 (PDT) Received: from localhost ([2620:15c:202:1:b6af:f85:ed6c:ac6a]) by smtp.gmail.com with ESMTPSA id f6-v6sm16089029pgf.52.2018.08.09.13.37.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Aug 2018 13:37:35 -0700 (PDT) Date: Thu, 9 Aug 2018 13:37:35 -0700 From: Matthias Kaehlcke To: Amit Kucheria Cc: linux-kernel@vger.kernel.org, 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, Zhang Rui , linux-pm@vger.kernel.org Subject: Re: [PATCH v1 07/10] thermal: tsens: Check if the IP is correctly enabled by firmware Message-ID: <20180809203735.GO160295@google.com> References: <985ed415774fdac9ac21afad4b4b74f30f6c5068.1533815718.git.amit.kucheria@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <985ed415774fdac9ac21afad4b4b74f30f6c5068.1533815718.git.amit.kucheria@linaro.org> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 09, 2018 at 06:02:39PM +0530, Amit Kucheria wrote: > 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; > } Reviewed-by: Matthias Kaehlcke