Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp523826imp; Wed, 20 Feb 2019 04:32:37 -0800 (PST) X-Google-Smtp-Source: AHgI3IbpGGubFl8BDc2tTC3mbf4HAuR5+HLGctsLxFPsgra6coyUmsG7wM2CrBMudIyu4hYYgxav X-Received: by 2002:a17:902:583:: with SMTP id f3mr37245263plf.202.1550665957836; Wed, 20 Feb 2019 04:32:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550665957; cv=none; d=google.com; s=arc-20160816; b=oW8TbO1I7L7ZrC0BUrqbn1DQovkQPEtegzjB89rCNWH16yu3QwJvS0EaUc8CUktdjZ IoTh6fXnrQeXsdszk4vGUeNM0w/2TK9EfxOaFppkjptZxZ2mXX9BjoTnXY5lphoLkkW1 OMQDw7pL/NAQtVZb84Jvr9C0APq5dULrUz3Lln0yErzd6MKvTqCni8LrnhQ91ZooMqZG mPmdY5HpSonlCD2zypdFD7ipb+lhSwiCb+T7XdsI63mXMMSUFkVTfPqEG8XcxMMKTE3q Xhg6M+elAAkiI0T+wDVBhfuYUor1Tpw+tEPzLDdXtwd2g4XxEfbuQoPS9bcp0IjJKA2F tdSg== 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=siMvxBk4GhhQKJqr9wK2xz1Yl6Z5fTtUTr4sJd5Y7ZQ=; b=hRGPcqEeGvWFPn5OPL7nxm/RGbRnx8ZiZ467+t1CG1IKuGOfQgo0wAYjnlhyMHa1PB tyKiQ0M86AEpk2SR8lUWpDQk0W/dfliIlEbUR1eAA7AfpdcQv/+ge/Mcuy/7u1FlzU5h OlR5btQJjuBZU58FJgwQwSDsw6kHNBRIFKusZRqQHlPgKUKSelAVxoX9CtTaIQPdOFoS qQEZ52xmZmY19xwvEbHLbdX79PoTbNRfTaHu7JeX9T7gshJo3j1NHFWRUt417KeWxAZk G2GfzsNaF2ro1/o4fyuCBEyUU3l2JEWfzL/3RsizjyTtSQeT5J3JX25cBoB4f6baJRVr uetA== 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 e96si19791544plb.123.2019.02.20.04.32.22; Wed, 20 Feb 2019 04:32:37 -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 S1727839AbfBTMbr (ORCPT + 99 others); Wed, 20 Feb 2019 07:31:47 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:17121 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727458AbfBTMbp (ORCPT ); Wed, 20 Feb 2019 07:31:45 -0500 X-UUID: 8790289c4bf243978e7eab75d6bfdaff-20190220 X-UUID: 8790289c4bf243978e7eab75d6bfdaff-20190220 Received: from mtkcas09.mediatek.inc [(172.21.101.178)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1082570834; Wed, 20 Feb 2019 20:31:37 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs01n2.mediatek.inc (172.21.101.79) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 20 Feb 2019 20:31:36 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 20 Feb 2019 20:31:36 +0800 From: To: Zhang Rui , Eduardo Valentin , Daniel Lezcano , Rob Herring , Mark Rutland , Matthias Brugger CC: , , , , , Michael Kao Subject: [PATCH v2,5/7] thermal: mediatek: add flag for bank selection Date: Wed, 20 Feb 2019 20:31:31 +0800 Message-ID: <1550665893-22561-6-git-send-email-michael.kao@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1550665893-22561-1-git-send-email-michael.kao@mediatek.com> References: <1550665893-22561-1-git-send-email-michael.kao@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: 9802375734CC28087793DB99608572D72B6D43699BA5EC9FD9353FE3F7AC2BF32000: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 For past ic designs, the thermal controller should select banks before reading the thermal sensor. And the new ic design architecture removes this mechanism. Signed-off-by: Michael Kao --- drivers/thermal/mtk_thermal.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c index c96a746..0a3944e 100644 --- a/drivers/thermal/mtk_thermal.c +++ b/drivers/thermal/mtk_thermal.c @@ -213,6 +213,7 @@ struct mtk_thermal_data { const int cali_val; const int num_controller; const int *controller_offset; + bool need_switch_bank; struct thermal_bank_cfg bank_data[]; }; @@ -327,6 +328,7 @@ struct mtk_thermal { .cali_val = MT8173_CALIBRATION, .num_controller = MT8173_NUM_CONTROLLER, .controller_offset = mt8173_tc_offset, + .need_switch_bank = true, .bank_data = { { .num_sensors = 2, @@ -365,6 +367,7 @@ struct mtk_thermal { .cali_val = MT2701_CALIBRATION, .num_controller = MT2701_NUM_CONTROLLER, .controller_offset = mt2701_tc_offset, + .need_switch_bank = true, .bank_data = { { .num_sensors = 3, @@ -394,6 +397,7 @@ struct mtk_thermal { .cali_val = MT2712_CALIBRATION, .num_controller = MT2712_NUM_CONTROLLER, .controller_offset = mt2712_tc_offset, + .need_switch_bank = true, .bank_data = { { .num_sensors = 4, @@ -417,6 +421,7 @@ struct mtk_thermal { .cali_val = MT7622_CALIBRATION, .num_controller = MT7622_NUM_CONTROLLER, .controller_offset = mt7622_tc_offset, + .need_switch_bank = true, .bank_data = { { .num_sensors = 1, @@ -463,12 +468,14 @@ static void mtk_thermal_get_bank(struct mtk_thermal_bank *bank) struct mtk_thermal *mt = bank->mt; u32 val; - mutex_lock(&mt->lock); + if (mt->conf->need_switch_bank) { + mutex_lock(&mt->lock); - val = readl(mt->thermal_base + PTPCORESEL); - val &= ~0xf; - val |= bank->id; - writel(val, mt->thermal_base + PTPCORESEL); + val = readl(mt->thermal_base + PTPCORESEL); + val &= ~0xf; + val |= bank->id; + writel(val, mt->thermal_base + PTPCORESEL); + } } /** @@ -481,7 +488,8 @@ static void mtk_thermal_put_bank(struct mtk_thermal_bank *bank) { struct mtk_thermal *mt = bank->mt; - mutex_unlock(&mt->lock); + if (mt->conf->need_switch_bank) + mutex_unlock(&mt->lock); } /** -- 1.9.1