Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2351560pxb; Fri, 5 Feb 2021 16:05:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJzwR24Rnf2h2zgXOQm3XW/feNgrbX2jatIqT0ExBqQ+NudRQjS9DnT3oJEctX9RfPvJigpS X-Received: by 2002:a17:906:607:: with SMTP id s7mr6311393ejb.301.1612569937182; Fri, 05 Feb 2021 16:05:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612569937; cv=none; d=google.com; s=arc-20160816; b=TFU4b3yTwzl1Q3PE1e3mAHfEV7s42QYlAJ5tMLiokOX+2g5hHjuDC+txgGYZeG/1SI 9JHjpYo77ga3o6vGkHRdeoym1+LnsZmkVnK1STTynFy84odOIcbJcQywagUZT7SdZRGQ FBZFwzKfytXRQ1r+i0NVddlmnxcf3WAZwyZEhx5HiRbuN2F8Kuq7q91oHKIQ7r1oXsD9 /BNGxqv0RZRA+I/Dv+NSRjg9Nahh7icnkh5roncEDWEVkJzbsqDnsHkxktmcWhnJ/jls uazXx3RCRRFVvip73BcOBdasrlGkHEjVd1f8HMCqb773oVnlqzlBlwmh4FZkkb24eAnp 8KVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=h45DdgTRFF5LtHM7u3nqMecj0oDXa6SYubmBskmpeuU=; b=dIKDJUqozPBxDpuxwbPZWpzci3MRxfQPrBArMTMlx07Aho1ll6xM66jwN6rMbRb7A6 o2311D3NWaiJ//jPRt4PBtPiwYMTcOksHU0rSOgJQQyJxDg4MXv+bCOfVEJ/nD4GvrJN L+VX51ZLGVDLqEJmb1wIn/EPNUFdjTKUE8epXIRCgflYjdN2Wqc4yMg9oX0fB9JPkwlG ro1+QKxpcapbF8iYJixqgSBFlH8jyaj08ANM6yrtZXCzsDYYLGRwK14oNSZm24XGh+FB PKcTKUUMTzJcAKjHi/C81oMBYiJhVHXd4QX1ZZRTgUDtP+D0mQyPd5BVYCqUfDWmszIq aEIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sb9si7467781ejb.162.2021.02.05.16.05.12; Fri, 05 Feb 2021 16:05:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230388AbhBFACj (ORCPT + 99 others); Fri, 5 Feb 2021 19:02:39 -0500 Received: from muru.com ([72.249.23.125]:57620 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230264AbhBENqX (ORCPT ); Fri, 5 Feb 2021 08:46:23 -0500 Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 281BD80F1; Fri, 5 Feb 2021 13:45:53 +0000 (UTC) From: Tony Lindgren To: Amit Kucheria , Daniel Lezcano , Zhang Rui Cc: Eduardo Valentin , Keerthy , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, Adam Ford , Carl Philipp Klemm , "H . Nikolaus Schaller" , Merlijn Wajer , Pavel Machek , Peter Ujfalusi , Sebastian Reichel Subject: [PATCH 1/4] thermal: ti-soc-thermal: Skip pointless register access for dra7 Date: Fri, 5 Feb 2021 15:45:31 +0200 Message-Id: <20210205134534.49200-2-tony@atomide.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210205134534.49200-1-tony@atomide.com> References: <20210205134534.49200-1-tony@atomide.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On dra7, there is no Start of Conversion (SOC) register bit and we have an empty bgap_soc_mask in the configuration for the thermal driver. Let's not do pointless reads and writes with the empty mask. There's also no point waiting for End of Conversion bit (EOCZ) to go high on dra7. We only care about it going down, and are now mostly timing out waiting for EOCZ high while it has already gone down. When we add checking for the timeout errors in a later patch, waiting for EOCZ high would cause bogus time out errors. 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 --- drivers/thermal/ti-soc-thermal/ti-bandgap.c | 29 +++++++++++---------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.c b/drivers/thermal/ti-soc-thermal/ti-bandgap.c --- a/drivers/thermal/ti-soc-thermal/ti-bandgap.c +++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.c @@ -602,29 +602,30 @@ void *ti_bandgap_get_sensor_data(struct ti_bandgap *bgp, int id) static int ti_bandgap_force_single_read(struct ti_bandgap *bgp, int id) { - u32 counter = 1000; - struct temp_sensor_registers *tsr; + struct temp_sensor_registers *tsr = bgp->conf->sensors[id].registers; + u32 counter; /* Select single conversion mode */ if (TI_BANDGAP_HAS(bgp, MODE_CONFIG)) RMW_BITS(bgp, id, bgap_mode_ctrl, mode_ctrl_mask, 0); - /* Start of Conversion = 1 */ - RMW_BITS(bgp, id, temp_sensor_ctrl, bgap_soc_mask, 1); + /* Set Start of Conversion if available */ + if (tsr->bgap_soc_mask) { + RMW_BITS(bgp, id, temp_sensor_ctrl, bgap_soc_mask, 1); - /* Wait for EOCZ going up */ - tsr = bgp->conf->sensors[id].registers; + /* Wait for EOCZ going up */ + counter = 1000; + while (--counter) { + if (ti_bandgap_readl(bgp, tsr->temp_sensor_ctrl) & + tsr->bgap_eocz_mask) + break; + } - while (--counter) { - if (ti_bandgap_readl(bgp, tsr->temp_sensor_ctrl) & - tsr->bgap_eocz_mask) - break; + /* Clear Start of Conversion if available */ + RMW_BITS(bgp, id, temp_sensor_ctrl, bgap_soc_mask, 0); } - /* Start of Conversion = 0 */ - RMW_BITS(bgp, id, temp_sensor_ctrl, bgap_soc_mask, 0); - - /* Wait for EOCZ going down */ + /* 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) & -- 2.30.0