From patchwork Fri Nov 18 11:04:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amjad Ouled-Ameur X-Patchwork-Id: 22266 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp126896wrr; Fri, 18 Nov 2022 03:08:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf5N8YuGyz55RPcuHWSIw3j08Zx3O/dWymfnnxlJEJzmlGYdvS0mHlU53gL3QYMYN00b/YQ8 X-Received: by 2002:a17:90b:234d:b0:212:c06c:47ba with SMTP id ms13-20020a17090b234d00b00212c06c47bamr13519433pjb.131.1668769710943; Fri, 18 Nov 2022 03:08:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668769710; cv=none; d=google.com; s=arc-20160816; b=NagPI7Xz+CnQSLzFypWXOQz24ZbNrOxqhbpO1MKo8/zYxyxxZ8TC9oUnHoBiPS2gd+ dBPm9TL7OcT9If4OZgzHTmTYL3wwYkvoK8UAt+/o7W/SKKWSsUqrkGa68hnNksVshBam aDQzg2P8stymc6Fy3mkQy7a1qZ0MDBx+M3kkswzVd51K/WlD83TWEYqv9DKO1gWGR5MA fdcDRC+vrlcunXReapwMA0xAKGL9R/Gum5p9q7e2jAvPqCBoiC2hME9psnQRFKpU7+Xk IgKG07DmeHH64cl4SYbRhhmF8y6bfrl7pX7u0up/Mp+TryJDUnbs+U0zrz1tkAhFgNVc moFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=fyeoHLNYgE+7jRWrI7Gid0gjC7DyyjDTDuyVioxNv2s=; b=ENNVYSmCNryeUVBXjqe1OSKmSsVW/AdlxIGDe9u+FWAdXUs0BlJVh7sgGa1AkTR5Qg wTCP6l2rMTzyXujFkGXn/sKaaTssP2Oy+w9Wv15vaeHmXcJbhcO7rsgVFX+AxU4ibdXQ 5s0WEqYz5zichLBjX3ipPBi54oW43/9s830jXOrxxAKUQBqz8JFCysjhBjPgtrjIEDHZ hGKvkLPPPoJXfnTNDlObQ6Xcr3yDL98QdPnNFQIoCsf0scqyKHlNdeb/GbYgM5UHTfkD bbRiTkX9OGeYHXbfIGwwPQt0cRgLpMyVYekjyUlcK1zJt7w9+yjF+0i6M/DmgeA4brQW kumw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=lnmpQeD2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u9-20020a170903124900b00188c7b09446si4029580plh.44.2022.11.18.03.08.01; Fri, 18 Nov 2022 03:08:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=lnmpQeD2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234867AbiKRLFI (ORCPT + 99 others); Fri, 18 Nov 2022 06:05:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241547AbiKRLFB (ORCPT ); Fri, 18 Nov 2022 06:05:01 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C3B697A80 for ; Fri, 18 Nov 2022 03:04:46 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id 5so3395030wmo.1 for ; Fri, 18 Nov 2022 03:04:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=fyeoHLNYgE+7jRWrI7Gid0gjC7DyyjDTDuyVioxNv2s=; b=lnmpQeD29OtlmiLODfaUO4X03Cz3jnXA45M4S1331TbJxmDH6x8HQJ/zAySAh5xYdm a+4U2+ntc1abC9aVdCB4cRyd0Exx6+MHxKaWhH7l6YSRsX/hyJzaupSesQAwt69vVrA2 FlG+KFrvSWulI/s0kzqZwiurXraKgGbvgYsHK/8mf7Cu2PYSuzt2VJwaErMeIRuop2KE 6OnR3jy6i/ijsR+EGZlV7wjMfbrvic9WlCt3iPBtd8iGKEIQINaztz7QmYXydkRmxyVW rvbbLgJtz3FblUDr2iV0bjq31MEDLLUGzqW9f0iAtvhatcAjwPQpiYq6cq5Vm8chAlYx WxEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fyeoHLNYgE+7jRWrI7Gid0gjC7DyyjDTDuyVioxNv2s=; b=nRpwGkU/i1mabo2h0OkXsF3MgVVrudzlL7eme6NLa42vJuT016C8ZqfcnvBHL/tldW U9TpTxThlrOts77Ob4iKuSpMTDxphu1r2+3Z6dWDSOUcTGOlwfPDaU6SdEqYAuP6gG5U 758tuCjQfTnk0/c6vns0oTC/Ve1OXmiMVFF6+pFEtIZnJoMaXL/95IWIzLWm0Vr/aE8P OP5p2kUHtWdo0bt7QJXJRi1TJMWuPUG/jWGiSvZ8ODz2nljV4HLMjBdVvKdTpHZORQeU KzGjSiJhnkNCArXK3AUW4Gduljy5KkdTd5O4eHCVz0ucc2hMG9+P8vcmikC+LW8/P9G5 vLfg== X-Gm-Message-State: ANoB5pnA41KBqUSvzv8baovPelNaTkztmFVZ1CI7hKCg/euhDtv6n0eU UMiZzliPJzgsMrd50Y8xUs7Kew== X-Received: by 2002:a05:600c:3b84:b0:3cf:b73f:c062 with SMTP id n4-20020a05600c3b8400b003cfb73fc062mr8004968wms.204.1668769484910; Fri, 18 Nov 2022 03:04:44 -0800 (PST) Received: from [127.0.1.1] (210.145.15.109.rev.sfr.net. [109.15.145.210]) by smtp.googlemail.com with ESMTPSA id i14-20020adff30e000000b002368a6deaf8sm3316948wro.57.2022.11.18.03.04.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Nov 2022 03:04:44 -0800 (PST) From: Amjad Ouled-Ameur Date: Fri, 18 Nov 2022 12:04:28 +0100 Subject: [PATCH v7 2/4] thermal: mediatek: control buffer enablement tweaks MIME-Version: 1.0 Message-Id: <20221018-up-i350-thermal-bringup-v7-2-ebf08ff2eddb@baylibre.com> References: <20221018-up-i350-thermal-bringup-v7-0-ebf08ff2eddb@baylibre.com> In-Reply-To: <20221018-up-i350-thermal-bringup-v7-0-ebf08ff2eddb@baylibre.com> To: "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Rob Herring , Krzysztof Kozlowski , Zhang Rui Cc: AngeloGioacchino Del Regno , Fabien Parent , Matthias Brugger , Markus Schneider-Pargmann , linux-pm@vger.kernel.org, Rob Herring , Michael Kao , linux-kernel@vger.kernel.org, Hsin-Yi Wang , Amjad Ouled-Ameur , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org X-Mailer: b4 0.10.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1668769481; l=2549; i=aouledameur@baylibre.com; s=20220920; h=from:subject:message-id; bh=BUYgiWUyEmLmv5YqBlzSOjPnRULIXZAPNGFdkdhmkOQ=; b=Hv/1oPehOoXJm/XPVk7GdRrpDq0r896Pz2DLWRzc0Hg/KUFU6HAQy0YmZUyUyIRjhZhl4uRFoH0m e7doajURDSExpVZ7R7vTDgdxAvRfsQ+qgSKZRaBIbMZjJeA6LcBF X-Developer-Key: i=aouledameur@baylibre.com; a=ed25519; pk=HgYWawSL4qLGPx+RzJ+Cuu+V8Pi/KQnDDm1wjWPMOFE= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749831868424861786?= X-GMAIL-MSGID: =?utf-8?q?1749831868424861786?= From: Markus Schneider-Pargmann Add logic in order to be able to turn on the control buffer on MT8365. This change now allows to have control buffer support for MTK_THERMAL_V1, and it allows to define the register offset, and mask used to enable it. Signed-off-by: Markus Schneider-Pargmann Signed-off-by: Fabien Parent Signed-off-by: Amjad Ouled-Ameur Reviewed-by: AngeloGioacchino Del Regno --- drivers/thermal/mtk_thermal.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c index 8440692e3890..d8ddceb75372 100644 --- a/drivers/thermal/mtk_thermal.c +++ b/drivers/thermal/mtk_thermal.c @@ -271,6 +271,9 @@ struct mtk_thermal_data { bool need_switch_bank; struct thermal_bank_cfg bank_data[MAX_NUM_ZONES]; enum mtk_thermal_version version; + u32 apmixed_buffer_ctl_reg; + u32 apmixed_buffer_ctl_mask; + u32 apmixed_buffer_ctl_set; }; struct mtk_thermal { @@ -514,6 +517,9 @@ static const struct mtk_thermal_data mt7622_thermal_data = { .adcpnp = mt7622_adcpnp, .sensor_mux_values = mt7622_mux_values, .version = MTK_THERMAL_V2, + .apmixed_buffer_ctl_reg = APMIXED_SYS_TS_CON1, + .apmixed_buffer_ctl_mask = GENMASK(31, 6) | BIT(3), + .apmixed_buffer_ctl_set = BIT(0), }; /* @@ -963,14 +969,18 @@ static const struct of_device_id mtk_thermal_of_match[] = { }; MODULE_DEVICE_TABLE(of, mtk_thermal_of_match); -static void mtk_thermal_turn_on_buffer(void __iomem *apmixed_base) +static void mtk_thermal_turn_on_buffer(struct mtk_thermal *mt, + void __iomem *apmixed_base) { - int tmp; + u32 tmp; + + if (!mt->conf->apmixed_buffer_ctl_reg) + return; - tmp = readl(apmixed_base + APMIXED_SYS_TS_CON1); - tmp &= ~(0x37); - tmp |= 0x1; - writel(tmp, apmixed_base + APMIXED_SYS_TS_CON1); + tmp = readl(apmixed_base + mt->conf->apmixed_buffer_ctl_reg); + tmp &= mt->conf->apmixed_buffer_ctl_mask; + tmp |= mt->conf->apmixed_buffer_ctl_set; + writel(tmp, apmixed_base + mt->conf->apmixed_buffer_ctl_reg); udelay(200); } @@ -1070,8 +1080,9 @@ static int mtk_thermal_probe(struct platform_device *pdev) goto err_disable_clk_auxadc; } + mtk_thermal_turn_on_buffer(mt, apmixed_base); + if (mt->conf->version == MTK_THERMAL_V2) { - mtk_thermal_turn_on_buffer(apmixed_base); mtk_thermal_release_periodic_ts(mt, auxadc_base); }