Received: by 2002:ac0:8c8e:0:0:0:0:0 with SMTP id r14csp70760ima; Tue, 5 Feb 2019 18:13:06 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibyrdp0ON4noK2Soklbk5B7aFB5yXTEz6Li7WUvDGOKd6pjgCWxfb7I0m4LAWHzaVM54+Bf X-Received: by 2002:a17:902:e489:: with SMTP id cj9mr8387893plb.80.1549419186410; Tue, 05 Feb 2019 18:13:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549419186; cv=none; d=google.com; s=arc-20160816; b=R9DE+cUZKhQU+2AOpr/a8mJ8E1Of3xzsJZl+0kymfdGMz5e9MadPG2oF1cDEHeSGjr 8opNj3yDnWQBfwIjz8xusuXQtrpulZJMs1+qTPNqP2eEFm4JoT8fCGvsRB5QPa1KMtt6 XK3pqwGExUkvadCwzy+z9D3CKBYhkqI4XCnShAy5lJV8eNcYegkLQWHkMi7nsiDYN2xE M+dDfM+46VNo/mZ4uCQOQxPWbsKZOJTt679s5Th0gJccydwWKsj2ycpBQCmebY6qxSoT uO5cC09OgVul00DqeQbzGruzGpI6ppeyityQkbICHZf3Ebi+VoDU7Yh1H6vDsxUNu86Y QRHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=fygf7zWkpHlUBvY4zArgNZspQNtVM7b7j+lUpAebLec=; b=MKxXlXH56Hmgiz0hycCgTBuH7AdGmNfNTxbES1EGDbNs/P4XKg3GLXpRT4yAkfrF4x v+2U6hrWZ82SwKF5h2pZY+m7zhebcRsNvbdsRm5zCx+TQ3V4sl5ISiUK2NzVxl5TVp1w 9aX4geaiRFgWht63Elw6WUYGHPq7s17lGqN6UEA0PtrM6soiyB8HzaDk2Hkp+dgyV0Qm ON95ILAvW863k2a8aNZG7igND/mxx+phtfcnBkPZF4DecX0HnjDqVR24gNxcGlk+rU75 8Ql2/0LMZ9UY74io4LYulIp8twKCsx1lfqtE2c1rxZ6RjbASlW7VkzhSrcf413BHWhIR m41A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hdOtrgUc; 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 e6si4480224pgk.201.2019.02.05.18.12.50; Tue, 05 Feb 2019 18:13:06 -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=hdOtrgUc; 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 S1728033AbfBFAtC (ORCPT + 99 others); Tue, 5 Feb 2019 19:49:02 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:44017 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726062AbfBFAtC (ORCPT ); Tue, 5 Feb 2019 19:49:02 -0500 Received: by mail-pg1-f193.google.com with SMTP id v28so2164674pgk.10; Tue, 05 Feb 2019 16:49:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=fygf7zWkpHlUBvY4zArgNZspQNtVM7b7j+lUpAebLec=; b=hdOtrgUc1ADXkYukL13QGUfJ7CwesoZ7E0n4bgeu5erX7Gn44rpWwpINfAat/4tUGD fUQH98Ykl7AGGNgHMMKhgOltgsCUMTvVJHAFMd7pZRBHRnFnLZmmBT/lL3N4zyXXek/a fGhG1BptWMCDJyvihwNYcddyEi1/VJlzv9RwkpS4f8V45+gS/XjbWxTcF/SJNeGonzNx BSeWoPJNxnegoxGkYrsnNCt/lg/AQa4bFMUw9WN/720K7v4FbuWXZZ2uDRIJw7SzbcEH hZITZ68bezkJ+1NQP8b4ZT5nqISifouRybaiuSJZenWoBXxBVU5hoXyj4ZKF7ViMGZJx ODRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=fygf7zWkpHlUBvY4zArgNZspQNtVM7b7j+lUpAebLec=; b=eTEwy9bYg7L4VAsD7ismRVONZX4zrNsPletKhxnTNI4It+FTl+pk76iZMTrhaHxBli 3HvrMdt2tDk++m95Guk8HDhAKkdJScE4lhdcnoqCnzICuMjGxqYel4JE+1YQYSJTsusL kg+BG69P26yXTjkmPnk8ok4e9fPBPf2XApeYoO99f+sBOLnZFU/b9KEnWw+P9h7Vwt7I zFIdOPaw8HaJkrHFzFwducIljAzHjGf2WYEB3kudxuhX5SfrXDLumbvV80UTvAKXXaqK yqIYWul/XlCfvC/ADUJdEqWLgH7dE8miQ2ZVY/fQhVnsoje90OeU1eq6EoKRd1y1oTJC Kmvw== X-Gm-Message-State: AHQUAuY1onlThiW9Oj1lqbcVqZAXweoKng3K/Ai5+PuY+GVdxzYicVNE ZO9cCP9G/dQOwg2Q6CarBfk= X-Received: by 2002:a63:be0a:: with SMTP id l10mr2349341pgf.292.1549414141257; Tue, 05 Feb 2019 16:49:01 -0800 (PST) Received: from localhost.localdomain ([2601:644:8201:32e0:7256:81ff:febd:926d]) by smtp.gmail.com with ESMTPSA id g6sm6990242pgq.18.2019.02.05.16.48.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Feb 2019 16:48:59 -0800 (PST) Date: Tue, 5 Feb 2019 16:48:51 -0800 From: Eduardo Valentin To: Matthias Brugger Cc: michael.kao@mediatek.com, =Zhang Rui , =Daniel Lezcano , =Rob Herring , =Mark Rutland , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, srv_heupstream@mediatek.com Subject: Re: [PATCH 3/7] thermal: mediatek: add calibration item Message-ID: <20190206004837.GC19687@localhost.localdomain> References: <1549006693-11659-1-git-send-email-michael.kao@mediatek.com> <1549006693-11659-4-git-send-email-michael.kao@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 04, 2019 at 06:31:41PM +0100, Matthias Brugger wrote: > > > On 01/02/2019 08:38, michael.kao@mediatek.com wrote: > > From: Michael Kao > > > > Add calibration item in thermal_data to support > > the project with different calibration coefficient. > > > > Signed-off-by: Michael Kao > > --- > > drivers/thermal/mtk_thermal.c | 19 ++++++++++++++++++- > > 1 file changed, 18 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c > > index 07f8ad7..45c6587 100644 > > --- a/drivers/thermal/mtk_thermal.c > > +++ b/drivers/thermal/mtk_thermal.c > > @@ -105,6 +105,9 @@ > > /* The number of sensing points per bank */ > > #define MT8173_NUM_SENSORS_PER_ZONE 4 > > > > +/* The calibration coefficient of sensor */ > > +#define MT8173_CALIBRATION 165 > > + > > Calibration value is the same for all SoCs (including mt8183), we can define it > once and use it in all mtk_thermal structs. Well, on patch 7 we have: +#define MT8183_CALIBRATION 153 > > Regards, > Matthias > > > > /* > > * Layout of the fuses providing the calibration data > > * These macros could be used for MT8173, MT2701, and MT2712. > > @@ -147,6 +150,9 @@ enum { > > /* The number of sensing points per bank */ > > #define MT2701_NUM_SENSORS_PER_ZONE 3 > > > > +/* The calibration coefficient of sensor */ > > +#define MT2701_CALIBRATION 165 > > + > > /* MT2712 thermal sensors */ > > #define MT2712_TS1 0 > > #define MT2712_TS2 1 > > @@ -162,12 +168,18 @@ enum { > > /* The number of sensing points per bank */ > > #define MT2712_NUM_SENSORS_PER_ZONE 4 > > > > +/* The calibration coefficient of sensor */ > > +#define MT2712_CALIBRATION 165 > > + > > #define MT7622_TEMP_AUXADC_CHANNEL 11 > > #define MT7622_NUM_SENSORS 1 > > #define MT7622_NUM_ZONES 1 > > #define MT7622_NUM_SENSORS_PER_ZONE 1 > > #define MT7622_TS1 0 > > > > +/* The calibration coefficient of sensor */ > > +#define MT7622_CALIBRATION 165 > > + > > struct mtk_thermal; > > > > struct thermal_bank_cfg { > > @@ -188,6 +200,7 @@ struct mtk_thermal_data { > > const int *sensor_mux_values; > > const int *msr; > > const int *adcpnp; > > + const int cali_val; > > struct thermal_bank_cfg bank_data[]; > > }; > > > > @@ -295,6 +308,7 @@ struct mtk_thermal { > > .num_banks = MT8173_NUM_ZONES, > > .num_sensors = MT8173_NUM_SENSORS, > > .vts_index = mt8173_vts_index, > > + .cali_val = MT8173_CALIBRATION, > > .bank_data = { > > { > > .num_sensors = 2, > > @@ -330,6 +344,7 @@ struct mtk_thermal { > > .num_banks = 1, > > .num_sensors = MT2701_NUM_SENSORS, > > .vts_index = mt2701_vts_index, > > + .cali_val = MT2701_CALIBRATION, > > .bank_data = { > > { > > .num_sensors = 3, > > @@ -356,6 +371,7 @@ struct mtk_thermal { > > .num_banks = 1, > > .num_sensors = MT2712_NUM_SENSORS, > > .vts_index = mt2712_vts_index, > > + .cali_val = MT2712_CALIBRATION, > > .bank_data = { > > { > > .num_sensors = 4, > > @@ -376,6 +392,7 @@ struct mtk_thermal { > > .num_banks = MT7622_NUM_ZONES, > > .num_sensors = MT7622_NUM_SENSORS, > > .vts_index = mt7622_vts_index, > > + .cali_val = MT7622_CALIBRATION, > > .bank_data = { > > { > > .num_sensors = 1, > > @@ -402,7 +419,7 @@ static int raw_to_mcelsius(struct mtk_thermal *mt, int sensno, s32 raw) > > raw &= 0xfff; > > > > tmp = 203450520 << 3; > > - tmp /= 165 + mt->o_slope; > > + tmp /= mt->conf->cali_val + mt->o_slope; > > tmp /= 10000 + mt->adc_ge; > > tmp *= raw - mt->vts[sensno] - 3350; > > tmp >>= 3; > >