Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp91628ima; Thu, 31 Jan 2019 23:39:22 -0800 (PST) X-Google-Smtp-Source: ALg8bN7nE7DOmlx4Z7+eHZIpGQyNisL6EujU7g94+O6MqeuQgDdkKFBCV18mW35EhM0nUSOt3mSg X-Received: by 2002:a17:902:d68c:: with SMTP id v12mr37886572ply.4.1549006762714; Thu, 31 Jan 2019 23:39:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549006762; cv=none; d=google.com; s=arc-20160816; b=QrgHWvjofpX0BF01Rghr8TSHJX8SJS0O7YAQ0uzOLZQ3ZQCGPxgxMGhdT+lQQWqdbe JL+7K6VSDW61gnyQVwYdp98CPraWVPwO1rjWFgGBjhoyebuXW2njKZ/1aweL/MhAVFYO bro07FCboHohURe8MuRB+DPTw2Jnf26FGJjG/SZTAhCPDwd1CFAiZt6832Pl47DhRTnQ U/d+5MZuToI2m792KXysiM0dxKsI4rNiPDMR7ubo0tkvh+czDwvIK/4XSPkNalof6M/V V7Sci/ErFcLTTZf3mdCm7XMCOWP/QMMyTPVRFwAVJzYHlMPxypSRdKfJS7uVz3ME/wZH FyfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=cNdkuaD8dNkyE5ZEVVVAvyx12uCYQOkbOxpjuIShGmQ=; b=zO8IEIgQ1hJlciZSq5/Kv9VhdUQd2hKWsJLmjbAWqypEyK8Y7M/Kv7YBmfWh6K6Frc Zpkmg76WLDdKI1TOfM0Zn7baQx8T0ZYVjStaz3Y09vln51oCrUcMvcJlyq2Zy99IeQhK oN5SNgrRLQ+AdtmFI5RmSreUqaIwVhu6XoLAzu6hW5ajsRCC0/RON2BmOF0L3TicY5We sbzuFT9QH/d/iMi3uISvR7dXLhqcbdA16TX/rcR99FACw2INbtDrU+/4oO0XPKDUKrFr 0r1i2gsuo7FQADcimXLEt2lxtwqYOrhnAXlVinvuKGupBmSWDNiA3hf5zRYuJ/qz1Nkx ZxXA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v190si6800358pfv.8.2019.01.31.23.39.07; Thu, 31 Jan 2019 23:39:22 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726967AbfBAHiW (ORCPT + 99 others); Fri, 1 Feb 2019 02:38:22 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:50298 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726514AbfBAHiW (ORCPT ); Fri, 1 Feb 2019 02:38:22 -0500 X-UUID: 809b82bef53a4b709289c00b435083a2-20190201 X-UUID: 809b82bef53a4b709289c00b435083a2-20190201 Received: from mtkcas09.mediatek.inc [(172.21.101.178)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 661500967; Fri, 01 Feb 2019 15:38:17 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs03n2.mediatek.inc (172.21.101.182) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 1 Feb 2019 15:38:15 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Fri, 1 Feb 2019 15:38:15 +0800 From: To: =Zhang Rui , =Eduardo Valentin , =Daniel Lezcano , =Rob Herring , =Mark Rutland , =Matthias Brugger CC: , , , , , , Michael Kao Subject: [PATCH 3/7] thermal: mediatek: add calibration item Date: Fri, 1 Feb 2019 15:38:09 +0800 Message-ID: <1549006693-11659-4-git-send-email-michael.kao@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1549006693-11659-1-git-send-email-michael.kao@mediatek.com> References: <1549006693-11659-1-git-send-email-michael.kao@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: C4ADFAE3290338AA62FF0C4E2A82435AEE7CA07CF566417FC364522C8B91CF892000:8 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 + /* * 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; -- 1.9.1