Received: by 2002:a25:1104:0:0:0:0:0 with SMTP id 4csp424462ybr; Fri, 22 May 2020 09:48:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwo7+T+NlGM0qL8ckQPzsDLkJkI/AEBOg3eTH995riY77gwbngopkcmHP/U5qSJ+GWWxFXO X-Received: by 2002:a05:6402:1cb6:: with SMTP id cz22mr3546681edb.86.1590166116480; Fri, 22 May 2020 09:48:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590166116; cv=none; d=google.com; s=arc-20160816; b=aOHiHRIbZgtU9GRJbj+YaO9Tj0q0eftnBRntOdKYd3yDbVcOtmvvkYtC+6gfk/MF9S wXBCIQ2ak6+brUt4W3S5M2hRvctlqUUBGKNtNXZpUuLxBVeIFuugvBNPlJGW+j/29+1B cUAhCq/UlFdMnraTlwfVtywV7OZbzPMteRmBTBfXo0j4FjoKlKg2KEHYZ9dzwfju5xsK jxoy9zhH+36yPg/p2hDevDQ2kq8apto02wB+4AlSxdv/z/8piedy0orNyL7Tpe+QixtC iImTsgm835bKmvYWCVMmx1bmLgUbsK0rL6WK+/qy55j//Kh10BUGCpQQwu5PGHjEGfuX SvXQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=jD3qtCbQBfxkGztEcewlFtFpSycVMkWT5K4Cw3TN4rk=; b=sWZzGxYNht2lZjoWSF8JsxbaBLCctkCy4IFZ6uqyjuDOd78Gf63BP5kw6405BhaobT c+ozWg9CeB8IH8e0Dcsr2GX6o4PPlEi1ScByesgX5UsG3FS0zNxwA3Fd0clak684uIE9 G3Y1z7FvvM7YSunMrRQh1hg4debN23kXeavGzoVj6nngYAcYy6x7VUuJo2G5GfeIMPG8 PClVNCSNgD8wtO4w4XBJPUpyy7wVBwaqQ6May29ni7TQm1s+YL0Ka85njUp/stSmwSTM tFrF3u13AYNxR7TXX9oheHWK1DISmJqmjfdDuOCUgnDjfHmm7S+d6S6V3rx5UicaNBDa YHFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="rj4s/cH9"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d13si5269995edt.406.2020.05.22.09.48.13; Fri, 22 May 2020 09:48:36 -0700 (PDT) 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; dkim=pass header.i=@linaro.org header.s=google header.b="rj4s/cH9"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730487AbgEVQoo (ORCPT + 99 others); Fri, 22 May 2020 12:44:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730387AbgEVQon (ORCPT ); Fri, 22 May 2020 12:44:43 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01F48C05BD43 for ; Fri, 22 May 2020 09:44:42 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id g12so9589650wrw.1 for ; Fri, 22 May 2020 09:44:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=jD3qtCbQBfxkGztEcewlFtFpSycVMkWT5K4Cw3TN4rk=; b=rj4s/cH9LimVn2JVzIq9fCumTNw917XQ/+Y5qPVhj6ff1QiCqfh7oa8SvU9bNx+bn2 4yA0enZBjJRl/l9pgiQ2Xud3NnPGZeqGKj5H2AdYkMDHwqFsdnEkU6tvpN4KcwPj93c+ P6OgDMHaJSM1UrLfFyGNI9V+fOc6bBMA5Z6etJwu8m19lOW/3MV5kHnwxvRQCyOERv38 /8QYAn1kSOlEAWzo2E5r3PvngIwAv8ksx9yqUbfiFRfClp/qlJeAxOt9zhZ0QEIO9A// F2zhXcqPkx9CIi14YLcYnVcflSOsMIEzZN6OW14rncrxYyADaajQgvhSaNgvo2mc5lrO ohyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=jD3qtCbQBfxkGztEcewlFtFpSycVMkWT5K4Cw3TN4rk=; b=cedE+GXNoMEhIIc9jkk6sC9cxrCMsOcVdXjSgVKzefwg2enRB2JqcHNGCm5MwaZo4N aggZN3VoxfwPHitlT7Le3zAwqEo5qtF23NKOP4s1f+jFspB3fQZ+CEsStbT2GJPNnk9e 3rwqdGGWkezRn9xht08kIgk6VRDoP60kgO1eHW1E4YrWTd9gTMoEIhptrCAoMWuF6wBx D3y5x2oGdbnT1XYQl+yE1aSXkoEGj3N/iaNhceQ5afFKKr+cyOxxPjZ9yVoiaq1vAhUc veD1WGW+H1lDnN5J2es19yqYp6M2CV2rzt9uhAOhv6UcEQddZTP0fNjgJLTtTZkh6GPp tcDw== X-Gm-Message-State: AOAM530mQcIXq23omasYEdD3zHVmTphGxuaJdCT/CHIMLGUlm9kIutUR UQ2Ty9X/gY8KPr/XT/eYUPIkMFdxnNg= X-Received: by 2002:a5d:6943:: with SMTP id r3mr3966974wrw.113.1590165881375; Fri, 22 May 2020 09:44:41 -0700 (PDT) Received: from ?IPv6:2a01:e34:ed2f:f020:a82f:eaec:3c49:875a? ([2a01:e34:ed2f:f020:a82f:eaec:3c49:875a]) by smtp.googlemail.com with ESMTPSA id n4sm9346454wmc.31.2020.05.22.09.44.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 22 May 2020 09:44:40 -0700 (PDT) Subject: Re: [PATCH v2] thermal: qoriq: Update the settings for TMUv2 To: Yuantian Tang , rui.zhang@intel.com, edubezval@gmail.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20200416093940.34371-1-andy.tang@nxp.com> From: Daniel Lezcano Message-ID: <7fa1d7c2-e967-926b-772a-a2025a391aab@linaro.org> Date: Fri, 22 May 2020 18:44:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200416093940.34371-1-andy.tang@nxp.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16/04/2020 11:39, Yuantian Tang wrote: > For TMU v2, TMSAR registers need to be set properly to get the > accurate temperature values. > Also temperature reading needs to convert to degree Celsius > since it is in degrees Kelvin. Please have a look at units.h for celsius <-> kelvin conversion > Signed-off-by: Yuantian Tang > --- > v2: > - change the temp in millicelsius > > drivers/thermal/qoriq_thermal.c | 15 ++++++++++++++- > 1 file changed, 14 insertions(+), 1 deletion(-) > > diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c > index 028a6bbf75dc..f6371127f707 100644 > --- a/drivers/thermal/qoriq_thermal.c > +++ b/drivers/thermal/qoriq_thermal.c > @@ -23,6 +23,7 @@ > #define TMTMIR_DEFAULT 0x0000000f > #define TIER_DISABLE 0x0 > #define TEUMR0_V2 0x51009c00 > +#define TMSARA_V2 0xe > #define TMU_VER1 0x1 > #define TMU_VER2 0x2 > > @@ -50,6 +51,9 @@ > * Site Register > */ > #define TRITSR_V BIT(31) > +#define REGS_V2_TMSAR(n) (0x304 + 16 * (n)) /* TMU monitoring > + * site adjustment register > + */ > #define REGS_TTRnCR(n) (0xf10 + 4 * (n)) /* Temperature Range n > * Control Register > */ > @@ -100,7 +104,11 @@ static int tmu_get_temp(void *p, int *temp) > 10 * USEC_PER_MSEC)) > return -ENODATA; > > - *temp = (val & 0xff) * 1000; > + /* For TMUv2, temperature reading in degrees Kelvin */ > + if (qdata->ver == TMU_VER1) > + *temp = (val & 0xff) * 1000; > + else > + *temp = ((val & 0x1ff) - 273) * 1000; > > return 0; > } > @@ -192,6 +200,8 @@ static int qoriq_tmu_calibration(struct device *dev, > > static void qoriq_tmu_init_device(struct qoriq_tmu_data *data) > { > + int i; > + > /* Disable interrupt, using polling instead */ > regmap_write(data->regmap, REGS_TIER, TIER_DISABLE); > > @@ -202,6 +212,8 @@ static void qoriq_tmu_init_device(struct qoriq_tmu_data *data) > } else { > regmap_write(data->regmap, REGS_V2_TMTMIR, TMTMIR_DEFAULT); > regmap_write(data->regmap, REGS_V2_TEUMR(0), TEUMR0_V2); > + for (i = 0; i < 7; i++) > + regmap_write(data->regmap, REGS_V2_TMSAR(i), TMSARA_V2); > } > > /* Disable monitoring */ > @@ -212,6 +224,7 @@ static const struct regmap_range qoriq_yes_ranges[] = { > regmap_reg_range(REGS_TMR, REGS_TSCFGR), > regmap_reg_range(REGS_TTRnCR(0), REGS_TTRnCR(3)), > regmap_reg_range(REGS_V2_TEUMR(0), REGS_V2_TEUMR(2)), > + regmap_reg_range(REGS_V2_TMSAR(0), REGS_V2_TMSAR(15)), > regmap_reg_range(REGS_IPBRR(0), REGS_IPBRR(1)), > /* Read only registers below */ > regmap_reg_range(REGS_TRITSR(0), REGS_TRITSR(15)), > -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog