From: Amit Kucheria <amit.kucheria@linaro.org>
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 <rui.zhang@intel.com>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
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 [thread overview]
Message-ID: <35c332750fe1eddfa2eb53750b810256310866bd.1535462942.git.amit.kucheria@linaro.org> (raw)
In-Reply-To: <cover.1535462942.git.amit.kucheria@linaro.org>
In-Reply-To: <cover.1535462942.git.amit.kucheria@linaro.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 <amit.kucheria@linaro.org>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
---
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 <linux/regmap.h>
#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
next prev parent reply other threads:[~2018-08-28 13:39 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-28 13:38 [PATCH v2 00/11] Another round of tsens cleanups Amit Kucheria
2018-08-28 13:38 ` [PATCH v2 01/11] arm/arm64: dts: msm8974/msm8916: thermal: Split address space into two Amit Kucheria
2018-09-03 20:02 ` Bjorn Andersson
2018-09-06 9:24 ` Amit Kucheria
2018-08-28 13:38 ` [PATCH v2 02/11] arm/arm64: dts: msm8974/msm8916: thermal: Add "qcom,sensors" property Amit Kucheria
2018-09-03 20:03 ` Bjorn Andersson
2018-08-28 13:38 ` [PATCH v2 03/11] dt-bindings: thermal: Fix a typo in documentation Amit Kucheria
2018-09-03 20:04 ` Bjorn Andersson
2018-08-28 13:38 ` [PATCH v2 04/11] thermal: tsens: Add SPDX license identifiers Amit Kucheria
2018-09-03 20:04 ` Bjorn Andersson
2018-08-28 13:38 ` [PATCH v2 05/11] thermal: tsens: Get rid of dead code Amit Kucheria
2018-09-03 20:22 ` Bjorn Andersson
2018-08-28 13:38 ` [PATCH v2 06/11] thermal: tsens: Rename map field in order to add a second address map Amit Kucheria
2018-09-03 20:23 ` Bjorn Andersson
2018-08-28 13:38 ` [PATCH v2 07/11] thermal: tsens: Add the SROT " Amit Kucheria
2018-09-03 20:28 ` Bjorn Andersson
2018-08-28 13:38 ` Amit Kucheria [this message]
2018-08-30 19:23 ` [PATCH v2 08/11] thermal: tsens: Check if the IP is correctly enabled by firmware Amit Kucheria
2018-09-03 20:48 ` Bjorn Andersson
2018-09-06 10:00 ` Amit Kucheria
2018-08-28 13:38 ` [PATCH v2 09/11] thermal: tsens: Get rid of 'id' field Amit Kucheria
2018-09-03 20:26 ` Bjorn Andersson
2018-08-28 13:38 ` [PATCH v2 10/11] arm64: dts: qcom: Add reg-names for all tsens nodes Amit Kucheria
2018-09-03 20:34 ` Bjorn Andersson
2018-09-04 23:42 ` Doug Anderson
2018-08-28 13:38 ` [PATCH v2 11/11] MAINTAINERS: Add entry for Qualcomm TSENS thermal drivers Amit Kucheria
2018-09-03 20:46 ` Bjorn Andersson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=35c332750fe1eddfa2eb53750b810256310866bd.1535462942.git.amit.kucheria@linaro.org \
--to=amit.kucheria@linaro.org \
--cc=andy.gross@linaro.org \
--cc=bjorn.andersson@linaro.org \
--cc=daniel.lezcano@linaro.org \
--cc=dianders@chromium.org \
--cc=edubezval@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mka@chromium.org \
--cc=rnayak@codeaurora.org \
--cc=rui.zhang@intel.com \
--cc=smohanad@codeaurora.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).