From patchwork Tue Apr 27 19:44:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: thermal-bot for Julien Panis X-Patchwork-Id: 428989 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B424EC433B4 for ; Tue, 27 Apr 2021 19:44:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8142E611F2 for ; Tue, 27 Apr 2021 19:44:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238923AbhD0TpN (ORCPT ); Tue, 27 Apr 2021 15:45:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238943AbhD0TpM (ORCPT ); Tue, 27 Apr 2021 15:45:12 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45AE5C061574 for ; Tue, 27 Apr 2021 12:44:29 -0700 (PDT) Date: Tue, 27 Apr 2021 19:44:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1619552667; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rDiSM8hZBs0z1tVXxpM9XmQmbQhbuDSwhmn/BVkTRVo=; b=HCbmWXUxe054Dbd1HXb0toAl0cgN8UBLDyLzhMtTyZUjjhsmXBT+BBwvPjAZfjikqejM/1 X5mYwNtzzOHAwJxlkizDCiIj2WG2PlzQwRhT/fsDHv/eXMhZgAtJsjt8ZJGl2VFZQdBU0u a9MDfd3AX4cVBYYuf1pXvk9/vRhdIfFFJjrpjgPsmI5N2ovst6fz2w0JhK2cg0hyGgBOzz QEJlqyG26OTZSAL1r2Vz9MNZWGMshD41CqA1N0a7Nj8rc9CMttgNLrD8gU+4UsTv2k8RRT SGUUKbZVvsqDrJYBDL4rgOn7pn1cKPDvT743OkIDDxI9rkmMDs2yh7kWv/IsqQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1619552667; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rDiSM8hZBs0z1tVXxpM9XmQmbQhbuDSwhmn/BVkTRVo=; b=tPLoP3/gIm3m+/yzlNVLMsBSXz7ZJ/mX5HU5wlvHieO0Lrq9PuiXjAuHTuJeuQs5xeCVl3 TEIKFqHRPg3VtBDQ== From: "thermal-bot for Ansuel Smith" Sender: tip-bot2@linutronix.de Reply-to: linux-pm@vger.kernel.org To: linux-pm@vger.kernel.org Subject: [thermal: thermal/next] thermal/drivers/tsens: Fix bug in sensor enable for msm8960 Cc: Ansuel Smith , Thara Gopinath , Daniel Lezcano , rui.zhang@intel.com, amitk@kernel.org In-Reply-To: <20210420183343.2272-6-ansuelsmth@gmail.com> References: <20210420183343.2272-6-ansuelsmth@gmail.com> MIME-Version: 1.0 Message-ID: <161955266728.29796.16635306148146997440.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The following commit has been merged into the thermal/next branch of thermal: Commit-ID: 3d08f029fdbbd29c8b363ef4c8c4bfe3b8f79ad0 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//3d08f029fdbbd29c8b363ef4c8c4bfe3b8f79ad0 Author: Ansuel Smith AuthorDate: Tue, 20 Apr 2021 20:33:39 +02:00 Committer: Daniel Lezcano CommitterDate: Thu, 22 Apr 2021 14:09:32 +02:00 thermal/drivers/tsens: Fix bug in sensor enable for msm8960 Device based on tsens VER_0 contains a hardware bug that results in some problem with sensor enablement. Sensor id 6-11 can't be enabled selectively and all of them must be enabled in one step. Signed-off-by: Ansuel Smith Acked-by: Thara Gopinath Signed-off-by: Daniel Lezcano Link: https://lore.kernel.org/r/20210420183343.2272-6-ansuelsmth@gmail.com --- drivers/thermal/qcom/tsens-8960.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/qcom/tsens-8960.c b/drivers/thermal/qcom/tsens-8960.c index 83746ee..a96d37c 100644 --- a/drivers/thermal/qcom/tsens-8960.c +++ b/drivers/thermal/qcom/tsens-8960.c @@ -27,9 +27,9 @@ #define EN BIT(0) #define SW_RST BIT(1) #define SENSOR0_EN BIT(3) +#define MEASURE_PERIOD BIT(18) #define SLP_CLK_ENA BIT(26) #define SLP_CLK_ENA_8660 BIT(24) -#define MEASURE_PERIOD 1 #define SENSOR0_SHIFT 3 /* INT_STATUS_ADDR bitmasks */ @@ -126,17 +126,34 @@ static int resume_8960(struct tsens_priv *priv) static int enable_8960(struct tsens_priv *priv, int id) { int ret; - u32 reg, mask; + u32 reg, mask = BIT(id); ret = regmap_read(priv->tm_map, CNTL_ADDR, ®); if (ret) return ret; - mask = BIT(id + SENSOR0_SHIFT); + /* HARDWARE BUG: + * On platforms with more than 6 sensors, all remaining sensors + * must be enabled together, otherwise undefined results are expected. + * (Sensor 6-7 disabled, Sensor 3 disabled...) In the original driver, + * all the sensors are enabled in one step hence this bug is not + * triggered. + */ + if (id > 5) + mask = GENMASK(10, 6); + + mask <<= SENSOR0_SHIFT; + + /* Sensors already enabled. Skip. */ + if ((reg & mask) == mask) + return 0; + ret = regmap_write(priv->tm_map, CNTL_ADDR, reg | SW_RST); if (ret) return ret; + reg |= MEASURE_PERIOD; + if (priv->num_sensors > 1) reg |= mask | SLP_CLK_ENA | EN; else