Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5612292ybl; Tue, 10 Dec 2019 08:43:24 -0800 (PST) X-Google-Smtp-Source: APXvYqxSXg6z1Wn+uHHmHypGQHh0U72LfNCzE3Aa6lNqEc5oOuL0+CzO3rWiarKEgFyKNI1WzLPV X-Received: by 2002:a05:6830:1185:: with SMTP id u5mr24812108otq.147.1575996204269; Tue, 10 Dec 2019 08:43:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575996204; cv=none; d=google.com; s=arc-20160816; b=QJBV/kqyalmFqxUcNT/XoWkKGXPu0gnPPDCnNw8V7Mxv5ti5fG1gK6M1AtbvFDKBsX gLo7WZb9x+orK8dZYNxzTuKduQX5rqdF0CO8MYFfEAS4MrlAvhjJBAcEZ2+hoJWft4WN 1Uw+rgtvmr5r2monSVRf4Ssw5HGNgz15DE2T7iiI/XlTR7+DCFLQgFBCR3Xe6VNUzSjS ctPOa5XI3pOX64nmtZI3DJ9UB7HMXEscd/M/Qk3q890odnjJ3BL9f4YiUFYoTOcQyrdQ nRsFtd2SAZxwJluc9EAyLPo0iWyUGpKqOdjAGifUhtafE639WRgYW+4AKqkKFBg9exNJ COiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2b2cjI9ppTDYWjSViWcD+9AH23luExy4LBLn3g5jjpw=; b=EsA8mbgx8Z1TuWCzgmPmIRO3ZtaS5k3q9wbGwlNkjKtbvF3ro1YQzYtkR1CuwTg/O6 wyhERht6OrShTDPE/gzNqT+KgO6htH3RqJlXUngWS2ys1FBN+sQaU8uYsMhJqlwFLjdh UaHmUVkMrq5D8HwsJ08dRIEDhoIDXSrUCJcIHsUtcdeQ1vRr/UEq4w6tKicVqi2Wsrd7 LfIiLt2dVTh+ZKLDONn0QOrT3bbwnHr0/hAMv8tDmZdIhUHG6qM1GkHmjAhsN17e0gJ4 mkHUaOxOxyyadcye6SQcc6E4mZ+hs1PRx5QjiQ6qJvGsJHJ3pGQp6owbPpMveoADj5xe j2kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EUhUSu8H; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i17si2157256otl.149.2019.12.10.08.43.11; Tue, 10 Dec 2019 08:43:24 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=EUhUSu8H; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727842AbfLJQm0 (ORCPT + 99 others); Tue, 10 Dec 2019 11:42:26 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:40133 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727818AbfLJQmX (ORCPT ); Tue, 10 Dec 2019 11:42:23 -0500 Received: by mail-pj1-f68.google.com with SMTP id s35so7613481pjb.7; Tue, 10 Dec 2019 08:42:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2b2cjI9ppTDYWjSViWcD+9AH23luExy4LBLn3g5jjpw=; b=EUhUSu8HjuWa8gIUg0BSvq3u75rGGhe2q57nbZPxShzH3xnWa0+0xUQ3mJYypp8zDA DEQCUllE9EVT7HV+6JapUHzsgDYaPfJQwwCtsiALrQXNW1G8JIuUNtJ42zZYwjgG/+c1 5jcBRwU/sl1Gj2IpSJMlK36LJWQ64GffdlNBhkq/84IIgiT6ukx9uS0K7blDDBRQVL+A 9wI0sfUG3nLju+gODjP+OyeL27MZTbtg9L/h8uVaxzULkIuDfzCzkWnTut34LnczrMgz QXrsghAGFe6pzAt2iAjd1J4lstALygq6/Iu/MNc8TJwABsM5pviZKGJKmu3lrbIR4Wxv LMLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2b2cjI9ppTDYWjSViWcD+9AH23luExy4LBLn3g5jjpw=; b=ceedYVxzDd42BgCh088g9enHQ3KLG8bgoWYOYsvwG7Ux9rmzIEr3gWKu3uKseHrbqX KCAWamn7CFseB4OCVQC+IyS0jl5GaEPVsOgXIFwOn2pjto2WXAUlGknhzycB7GmFZQwV 4M6BjRudb0gglxz9P7lTIjx+j1lufFUPEXWUI+1fidJcicqvORITx063OYdOmataitg2 1kl2BGI0ZSNFOHbu6yeQ51WC4B5em8AHfxKmdJJQ8IhHcppiggapbMfgKA4i7QKbTrwf tw3btt3FHrBDdx/FIOCiLTiwpNh5QdiznzkmHa/f31D1j/3OTT1/GGUqcSJuPucDrEWg AnaQ== X-Gm-Message-State: APjAAAVZvlf33bbKvumWIuy8dqiWA5J+w7FHnw+3EKsbR+zqIadX09CY c/QgUfo6gy49WaISkK8FIlI= X-Received: by 2002:a17:90a:1b6b:: with SMTP id q98mr6559278pjq.106.1575996143035; Tue, 10 Dec 2019 08:42:23 -0800 (PST) Received: from localhost.localdomain (c-67-165-113-11.hsd1.wa.comcast.net. [67.165.113.11]) by smtp.gmail.com with ESMTPSA id j38sm4034634pgj.27.2019.12.10.08.42.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2019 08:42:22 -0800 (PST) From: Andrey Smirnov To: Daniel Lezcano Cc: Andrey Smirnov , Lucas Stach , Chris Healy , Eduardo Valentin , Angus Ainslie , linux-imx@nxp.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v8 09/12] thermal: qoriq: Enable all sensors before registering them Date: Tue, 10 Dec 2019 08:41:50 -0800 Message-Id: <20191210164153.10463-10-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191210164153.10463-1-andrew.smirnov@gmail.com> References: <20191210164153.10463-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Tmu_get_temp will get called as a part of sensor registration via devm_thermal_zone_of_sensor_register(). To prevent it from retruning bogus data we need to enable sensor monitoring before that. Looking at the datasheet (i.MX8MQ RM) there doesn't seem to be any harm in enabling them all, so, for the sake of simplicity, change the code to do just that. Signed-off-by: Andrey Smirnov Tested-by: Lucas Stach Cc: Chris Healy Cc: Lucas Stach Cc: Eduardo Valentin Cc: Daniel Lezcano Cc: Angus Ainslie (Purism) Cc: linux-imx@nxp.com Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/thermal/qoriq_thermal.c | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c index 6227c940b9b0..6c5e53ea7711 100644 --- a/drivers/thermal/qoriq_thermal.c +++ b/drivers/thermal/qoriq_thermal.c @@ -29,6 +29,7 @@ #define TMR_DISABLE 0x0 #define TMR_ME 0x80000000 #define TMR_ALPF 0x0c000000 +#define TMR_MSITE_ALL GENMASK(15, 0) #define REGS_TMTMIR 0x008 /* Temperature measurement interval Register */ #define TMTMIR_DEFAULT 0x0000000f @@ -93,7 +94,15 @@ static const struct thermal_zone_of_device_ops tmu_tz_ops = { static int qoriq_tmu_register_tmu_zone(struct device *dev, struct qoriq_tmu_data *qdata) { - int id, sites = 0; + int id; + + if (qdata->ver == TMU_VER1) { + regmap_write(qdata->regmap, REGS_TMR, + TMR_MSITE_ALL | TMR_ME | TMR_ALPF); + } else { + regmap_write(qdata->regmap, REGS_V2_TMSR, TMR_MSITE_ALL); + regmap_write(qdata->regmap, REGS_TMR, TMR_ME | TMR_ALPF_V2); + } for (id = 0; id < SITES_MAX; id++) { struct thermal_zone_device *tzd; @@ -109,25 +118,9 @@ static int qoriq_tmu_register_tmu_zone(struct device *dev, if (ret) { if (ret == -ENODEV) continue; - else - return ret; - } - if (qdata->ver == TMU_VER1) - sites |= 0x1 << (15 - id); - else - sites |= 0x1 << id; - } - - /* Enable monitoring */ - if (sites != 0) { - if (qdata->ver == TMU_VER1) { - regmap_write(qdata->regmap, REGS_TMR, - sites | TMR_ME | TMR_ALPF); - } else { - regmap_write(qdata->regmap, REGS_V2_TMSR, sites); - regmap_write(qdata->regmap, REGS_TMR, - TMR_ME | TMR_ALPF_V2); + regmap_write(qdata->regmap, REGS_TMR, TMR_DISABLE); + return ret; } } -- 2.21.0