From patchwork Thu Feb 18 20:39:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Nam Cao X-Patchwork-Id: 12094267 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 D695BC433DB for ; Thu, 18 Feb 2021 20:42:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8624F64ECA for ; Thu, 18 Feb 2021 20:42:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231298AbhBRUmF (ORCPT ); Thu, 18 Feb 2021 15:42:05 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:54152 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231340AbhBRUk0 (ORCPT ); Thu, 18 Feb 2021 15:40:26 -0500 Date: Thu, 18 Feb 2021 20:39:41 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1613680782; 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=gQxa8DH6sDsExZ5+tXfTO9Uaj5cx92H5Sfey3KD0yLM=; b=TGDE4+gkioKyhjlz6bK/qxN+v1ElIhxDES3Kl7poBJ5VQPEa2ELndcKVvzvXGKZ25DnN8i ebYywSfesEQoDIy6um8Kc+Am1uyMLAPtWNwO6jWY2+lR9RPJEYRmor4M2B/Acj/I1bf5Cx 2GOSx2LbkVCiSWcqH3TAf5dfO6RZ/s0wXRee5bTIDe5GUzk6nCFLMbFZ18j1NC2l/Wqtqg QL2r1NoN4XwJ7taoIZ4pSFZd28RR/BIxC5Iu8+nw5QugqhINL7MxlwHVAwWWaeHPOeb7FH CrKAKWzg+ZHniuJklNbxs55D4O9TdfBK81GH+7kpBGrBB7KavCTcun+E5Ul4bg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1613680782; 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=gQxa8DH6sDsExZ5+tXfTO9Uaj5cx92H5Sfey3KD0yLM=; b=e7iXSIKeFiCwNeZdJeXQ8gNE4BR3N88NT6xhVLn32hHR2ZOpZDfsRFNYBRSPJxW639OBhr kxdJIx3yX/4v64Aw== From: "thermal-bot for Tony Lindgren" Sender: tip-bot2@linutronix.de Reply-to: linux-pm@vger.kernel.org To: linux-pm@vger.kernel.org Subject: [thermal: thermal/next] thermal: ti-soc-thermal: Simplify polling with iopoll Cc: Adam Ford , Carl Philipp Klemm , Eduardo Valentin , "H. Nikolaus Schaller" , Merlijn Wajer , Pavel Machek , Peter Ujfalusi , Sebastian Reichel , Tony Lindgren , Daniel Lezcano , rui.zhang@intel.com, amitk@kernel.org In-Reply-To: <20210205134534.49200-4-tony@atomide.com> References: <20210205134534.49200-4-tony@atomide.com> MIME-Version: 1.0 Message-ID: <161368078166.20312.4958055839767865943.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: 514cbabb01422d501d533a6495b924e4c22d4822 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//514cbabb01422d501d533a6495b924e4c22d4822 Author: Tony Lindgren AuthorDate: Fri, 05 Feb 2021 15:45:33 +02:00 Committer: Daniel Lezcano CommitterDate: Mon, 15 Feb 2021 21:19:23 +01:00 thermal: ti-soc-thermal: Simplify polling with iopoll We can use iopoll for checking the EOCZ (end of conversion) bit. And with this we now also want to handle the timeout errors properly. For omap3, we need about 1.2ms for the single mode sampling to wait for EOCZ down, so let's use 1.5ms timeout there. Waiting for sampling to start is faster and we can use 1ms timeout. Cc: Adam Ford Cc: Carl Philipp Klemm Cc: Eduardo Valentin Cc: H. Nikolaus Schaller Cc: Merlijn Wajer Cc: Pavel Machek Cc: Peter Ujfalusi Cc: Sebastian Reichel Signed-off-by: Tony Lindgren Tested-by: Adam Ford #logicpd-torpedo-37xx-devkit Acked-by: Pavel Machek Signed-off-by: Daniel Lezcano Link: https://lore.kernel.org/r/20210205134534.49200-4-tony@atomide.com --- drivers/thermal/ti-soc-thermal/ti-bandgap.c | 30 +++++++++----------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.c b/drivers/thermal/ti-soc-thermal/ti-bandgap.c index 6e92551..8a3646e 100644 --- a/drivers/thermal/ti-soc-thermal/ti-bandgap.c +++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -27,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -604,7 +604,9 @@ static int ti_bandgap_force_single_read(struct ti_bandgap *bgp, int id) { struct temp_sensor_registers *tsr = bgp->conf->sensors[id].registers; - u32 counter; + void __iomem *temp_sensor_ctrl = bgp->base + tsr->temp_sensor_ctrl; + int error; + u32 val; /* Select continuous or single conversion mode */ if (TI_BANDGAP_HAS(bgp, MODE_CONFIG)) { @@ -619,26 +621,22 @@ ti_bandgap_force_single_read(struct ti_bandgap *bgp, int id) RMW_BITS(bgp, id, temp_sensor_ctrl, bgap_soc_mask, 1); /* Wait for EOCZ going up */ - counter = 1000; - while (--counter) { - if (ti_bandgap_readl(bgp, tsr->temp_sensor_ctrl) & - tsr->bgap_eocz_mask) - break; - udelay(1); - } + error = readl_poll_timeout_atomic(temp_sensor_ctrl, val, + val & tsr->bgap_eocz_mask, + 1, 1000); + if (error) + dev_warn(bgp->dev, "eocz timed out waiting high\n"); /* Clear Start of Conversion if available */ RMW_BITS(bgp, id, temp_sensor_ctrl, bgap_soc_mask, 0); } /* Wait for EOCZ going down, always needed even if no bgap_soc_mask */ - counter = 1000; - while (--counter) { - if (!(ti_bandgap_readl(bgp, tsr->temp_sensor_ctrl) & - tsr->bgap_eocz_mask)) - break; - udelay(1); - } + error = readl_poll_timeout_atomic(temp_sensor_ctrl, val, + !(val & tsr->bgap_eocz_mask), + 1, 1500); + if (error) + dev_warn(bgp->dev, "eocz timed out waiting low\n"); return 0; }