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: 626781 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6CFEBC43217 for ; Fri, 18 Nov 2022 11:05:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241563AbiKRLFC (ORCPT ); Fri, 18 Nov 2022 06:05:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241539AbiKRLFB (ORCPT ); Fri, 18 Nov 2022 06:05:01 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8150D970A4 for ; Fri, 18 Nov 2022 03:04:46 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id c65-20020a1c3544000000b003cfffd00fc0so3277791wma.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=ysq9AA65+8kWS/6OqGmIkWRfIXGdXcWRKPV3sUnamoIwFD9KXTKO9w5UMkctUUpCDl rbflsuShn+xU2qcIPFLEDfi3MT63VkQJi3RpWI+it/vPnnGQaSDxeNMVmdOXRfp6itL3 26JgpaLEXhRu3o6y9peygb0y9AOaEiCiFwqlg5cw9DV2q9TKe+1gO+DOm3oWpfhj+AFT Xq6OrjwL2dP0ai1Y5BodmAdnzIkSgPYSzrz8euLnBctHdDxRRYBsIgvVW4jsSSyCQEg3 KK7enWmslLibPLRZHbYsk3XudIniiiPd+GjMnLIVoghydZurxA8OfrNBTn9OHjjh2wfk zEAQ== X-Gm-Message-State: ANoB5pnW43YVn522s6uIcm0ey9MJLOumg8zIiwCiTVNXBVc65PNp81ak mJ9zUoO8D+pAJQJElFn592BL7Q== X-Google-Smtp-Source: AA0mqf5Z2s7uT/ojkbi4kQH8ZukBjcYstw7H33D/YaQ6a6I60O8J6S4JZCXIyK7cgUZqBWAF7EE9/w== 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= Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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); }