From patchwork Mon Sep 11 18:33:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wunderlich X-Patchwork-Id: 13379585 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 405E9EE57DF for ; Mon, 11 Sep 2023 18:34:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=W8bn/CiSUcXaJjz6EUhUR8UWdJubXvx987HCqZQGPwU=; b=t18wthamI3ChFX ImuLvJLUDd8W4aU3tIZidKo/tWU3+67VatRbwptZXBrSYo7b0424lsnIadgBO4rFG8FE7+m9NweCG YGFUBdXIa5Jzq+oYSAGHUWjbCHZvJN+pXL1NRiY4VxW26Ni6ZZFW2TaClDyZ5Qu/wraNakw1x0WZO VOquApbzGmOYBGvYuF0QIV+xzwJnPlZ3gTPQSpgCHm02Mcpwj7JfmckYa8nK+Z9uGUc6Zxo76dLHy G4Q8X/4zlB829wYYg1F/v+lm8iZ8yWcToy/Fm0j5F1usuSXQwFLIiEVvLPykKuzuLq06aV8y5afue QSni5u6d61RdzDxVylKw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qfljl-0018CT-23; Mon, 11 Sep 2023 18:34:17 +0000 Received: from mxout3.routing.net ([2a03:2900:1:a::8]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qfljd-00189W-33; Mon, 11 Sep 2023 18:34:12 +0000 Received: from mxbox3.masterlogin.de (unknown [192.168.10.78]) by mxout3.routing.net (Postfix) with ESMTP id 8F86460546; Mon, 11 Sep 2023 18:34:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailerdienst.de; s=20200217; t=1694457245; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E/Gp1HOJQpVt6kzdG1jbBjVVoqID2dO0BkBbfKI/SKo=; b=T3GbUsbwnNVvUGY8yPZLniV/AUr8EG6aIW6ALp3mgTsJWef6nYUREpaG8EOemJtykiHkQ5 eTAS+00g8kHtMzUm+FHLwKOp/uKUm3tO1MDyJEZoSTxBFuRlLubzs8VwykqborcfnTnBc1 iSDMWmVoR0c/Z+OrRYdz9sCwYAJkhYs= Received: from frank-G5.. (fttx-pool-217.61.151.158.bambit.de [217.61.151.158]) by mxbox3.masterlogin.de (Postfix) with ESMTPSA id A9F8636077E; Mon, 11 Sep 2023 18:34:04 +0000 (UTC) From: Frank Wunderlich To: linux-mediatek@lists.infradead.org Cc: Frank Wunderlich , "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Daniel Golle Subject: [RFC v1 3/3] thermal/drivers/mediatek/lvts_thermal: add mt7988 support Date: Mon, 11 Sep 2023 20:33:54 +0200 Message-Id: <20230911183354.11487-4-linux@fw-web.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230911183354.11487-1-linux@fw-web.de> References: <20230911183354.11487-1-linux@fw-web.de> MIME-Version: 1.0 X-Mail-ID: a4e93b6f-45bb-4e0f-b9a9-b41ceba0b075 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230911_113410_124061_343A95EF X-CRM114-Status: GOOD ( 13.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Frank Wunderlich Add Support for mediatek fologic 880/MT7988. Signed-off-by: Frank Wunderlich --- drivers/thermal/mediatek/lvts_thermal.c | 73 +++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c index c1004b4da3b6..48b257a3c80e 100644 --- a/drivers/thermal/mediatek/lvts_thermal.c +++ b/drivers/thermal/mediatek/lvts_thermal.c @@ -82,6 +82,8 @@ #define LVTS_GOLDEN_TEMP_DEFAULT 50 #define LVTS_COEFF_A_MT8195 -250460 #define LVTS_COEFF_B_MT8195 250460 +#define LVTS_COEFF_A_MT7988 -204650 +#define LVTS_COEFF_B_MT7988 204650 #define LVTS_MSR_IMMEDIATE_MODE 0 #define LVTS_MSR_FILTERED_MODE 1 @@ -1272,6 +1274,67 @@ static int lvts_remove(struct platform_device *pdev) return 0; } +/* + * LVTS MT7988 + */ +#define LVTS_HW_SHUTDOWN_MT7988 117000 +//enum mt7988_lvts_domain { MT7988_AP_DOMAIN, MT7988_NUM_DOMAIN }; + +enum mt7988_lvts_sensor_enum { + MT7988_TS3_0, + MT7988_TS3_1, + MT7988_TS3_2, + MT7988_TS3_3, + MT7988_TS4_0, + MT7988_TS4_1, + MT7988_TS4_2, + MT7988_TS4_3, + MT7988_NUM_TS +}; + +//Efuse base : 0x11f50000 +//lvts offset in efuse : 0x918 (set in efuse dts node as calibration data) +//offsets: +//918 = LVTS_3_0_COUNT_R +//91C = LVTS_3_1_COUNT_R +//920 = LVTS_3_2_COUNT_R +//924 = LVTS_3_3_COUNT_R +//928 = LVTS_3_COUNT_RC + +//92C = LVTS_4_0_COUNT_R +//930 = LVTS_4_1_COUNT_R +//934 = LVTS_4_2_COUNT_R +//938 = LVTS_4_3_COUNT_R +//93C = LVTS_4_COUNT_RC + +static const struct lvts_ctrl_data mt7988_lvts_data_ctrl[] = { + { + .cal_offset = { 0x00, 0x04, 0x08, 0x0c }, //918,91C,920,924 + .lvts_sensor = { + { .dt_id = MT7988_TS3_0 }, + { .dt_id = MT7988_TS3_1 }, + { .dt_id = MT7988_TS3_2 }, + { .dt_id = MT7988_TS3_3 } + }, + .num_lvts_sensor = 4, + .offset = 0x0, + .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT7988, + }, + { + .cal_offset = { 0x14, 0x18, 0x1c, 0x20 }, //92C,930,934,938 + .lvts_sensor = { + { .dt_id = MT7988_TS4_0}, + { .dt_id = MT7988_TS4_1}, + { .dt_id = MT7988_TS4_2}, + { .dt_id = MT7988_TS4_3} + }, + .num_lvts_sensor = 4, + .offset = 0x100, + .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT7988, + } +}; + +//MT8195 static const struct lvts_ctrl_data mt8195_lvts_mcu_data_ctrl[] = { { .cal_offset = { 0x04, 0x07 }, @@ -1351,6 +1414,15 @@ static const struct lvts_ctrl_data mt8195_lvts_ap_data_ctrl[] = { } }; +static const struct lvts_data mt7988_lvts_data = { + .lvts_ctrl = mt7988_lvts_data_ctrl, + .num_lvts_ctrl = ARRAY_SIZE(mt7988_lvts_data_ctrl), + .coeff = { + .a = LVTS_COEFF_A_MT7988, + .b = LVTS_COEFF_B_MT7988, + }, +}; + static const struct lvts_data mt8195_lvts_mcu_data = { .lvts_ctrl = mt8195_lvts_mcu_data_ctrl, .num_lvts_ctrl = ARRAY_SIZE(mt8195_lvts_mcu_data_ctrl), @@ -1372,6 +1444,7 @@ static const struct lvts_data mt8195_lvts_ap_data = { }; static const struct of_device_id lvts_of_match[] = { + { .compatible = "mediatek,mt7988-lvts", .data = &mt7988_lvts_data }, { .compatible = "mediatek,mt8195-lvts-mcu", .data = &mt8195_lvts_mcu_data }, { .compatible = "mediatek,mt8195-lvts-ap", .data = &mt8195_lvts_ap_data }, {},