From patchwork Wed Jul 20 18:18:53 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: 12924358 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 2E9C8C433EF for ; Wed, 20 Jul 2022 18:21:32 +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=aQNao3OVtWVWPnwPyZxNAJQOj0180i9vqO4bKbg5JG4=; b=DvLZtruheh1lQl M+H/jIRfmndilHat/goz4KxJ39dd73HR3h8PnmPQXNZCDMF/H4U8nYTb4pYwgrZ3HEgDQaYo7Y1Xo yn0Ddlt4oIYNyploKtHxVfpRUZ1JEhsRj+gN6iuB5pkzkiPejBnwg3dH+Vb3k9s0hpeJWjmE3RzUf Mw3FULyrHewiBUWMgDhGTyFvgB/AG2m1hbwBnkpKZ6lE0ECY48WsTdXccmdPMOTB8P/PTTcrk6dHy f/TS8doOe6AI6pa6wDaz3+9mDDgLiA0pChI9Sc4ghzQqieM0W6i2cIkdgWcgkLC29hvzApgr7NVCV PTdP9Q6Jg4xQmUaFvGpA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oEEJC-009ASM-AC; Wed, 20 Jul 2022 18:20:30 +0000 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oEEIN-009A02-W9 for linux-arm-kernel@lists.infradead.org; Wed, 20 Jul 2022 18:19:44 +0000 Received: by mail-wr1-x429.google.com with SMTP id h9so2209389wrm.0 for ; Wed, 20 Jul 2022 11:19:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u7ClOaY29q/UhKGleJgriKV9seCgrAHzD4o55sbVqbE=; b=U25zxMuTlfG9FKoGJ8D0VJx2M73CYydlvOMHsJis/rV0YVmrC6mR0xG6wVsf0jVtsh LGYhX+2OZHZGLcWAYcBwN/kxj5pEKVfWT5CI5VYGAljVYrY+Tc6MtBikiOmQJ2WG1ElO ORuSxTh7fBcVgNVov8LDetdZJ0eiSyVtZZy/l1UjoMgZsBV8SEaNK5YFxMt6TSF63ODI ZSH8Q+t/5HwvjV+sbwr7RV8a1wYelm/dKcbV6mwjwG45OHZsG1YqVIniZL7nYRd1elvv rEW6Wxoz3UwFc07F5QgYKPyJCr2UYU/mr7bNC/sdKOddwNjIN8nGLWnMAxzpqeAOqmvF 6cAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u7ClOaY29q/UhKGleJgriKV9seCgrAHzD4o55sbVqbE=; b=GgZRM0RcFdsRuWnenRfMcb3hd4RDEqcsDroL1LsE6fRGXj7bIE3esTxryiFoziddc3 CKwcahUuCtcNKtlf+9YubjfNLFtHh2DqjY+UD8WsP3UX09AXlvrhmJD8Cwj5lfiBESDw bVkQ7AIVJzWf1lrqIK0cBHtVEZOfjQipORfcJzq3v0Qzx31x4Ll8ANbw6D7eNsh01IQ4 SA2AOZKr/mxhtFfGL5DYocnGMsszVipHzzpOiCDUoejyBlKcAsxGXVRAalBjOOLaUbnP UsJhhTXzG6mNDbJAl0c7p8/2ya4O9XL2yqoDSXzkExT2SgC3rOUIqbhOgMFeIqIP6Dat YRTA== X-Gm-Message-State: AJIora/hb4OBYaQobnU7oOpzq57/W/1m/hmRxEfUkWOmv5tjc8L08AvD 6YkaWruIW2jEQXHuzM2aH1GfqA== X-Google-Smtp-Source: AGRyM1vfj2pobuNQH2wthtGApjgEuP8BunLn/EqZqFLAOjATur0M5PpTlWR4RkCynwXU5aGpbpkUkw== X-Received: by 2002:adf:ee4b:0:b0:21e:4ecf:b150 with SMTP id w11-20020adfee4b000000b0021e4ecfb150mr2128791wro.290.1658341177830; Wed, 20 Jul 2022 11:19:37 -0700 (PDT) Received: from amjad-ThinkPad-T490.home (2a01cb040613180084408ac44a1fa242.ipv6.abo.wanadoo.fr. [2a01:cb04:613:1800:8440:8ac4:4a1f:a242]) by smtp.googlemail.com with ESMTPSA id z17-20020a05600c0a1100b003a31d200a7dsm3400093wmp.9.2022.07.20.11.19.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 11:19:37 -0700 (PDT) From: Amjad Ouled-Ameur To: matthias.bgg@gmail.com Cc: rafael@kernel.org, fparent@baylibre.com, amitk@kernel.org, daniel.lezcano@linaro.org, devicetree@vger.kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-pm@vger.kernel.org, robh+dt@kernel.org, rui.zhang@intel.com, Markus Schneider-Pargmann , Amjad Ouled-Ameur Subject: [PATCH v2 3/4] thermal: mediatek: control buffer enablement tweaks Date: Wed, 20 Jul 2022 20:18:53 +0200 Message-Id: <20220720181854.547881-4-aouledameur@baylibre.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220720181854.547881-1-aouledameur@baylibre.com> References: <20220720181854.547881-1-aouledameur@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220720_111940_038159_75A90899 X-CRM114-Status: GOOD ( 16.00 ) 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: 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 Reviewed-by: Amjad Ouled-Ameur Tested-by: Amjad Ouled-Ameur --- drivers/thermal/mtk_thermal.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c index 216eb0d61c5b..1dc276f8c4f1 100644 --- a/drivers/thermal/mtk_thermal.c +++ b/drivers/thermal/mtk_thermal.c @@ -283,6 +283,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 { @@ -578,6 +581,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 = ~0x37, + .apmixed_buffer_ctl_set = 0x1, }; /* @@ -1031,14 +1037,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; - tmp = readl(apmixed_base + APMIXED_SYS_TS_CON1); - tmp &= ~(0x37); - tmp |= 0x1; - writel(tmp, apmixed_base + APMIXED_SYS_TS_CON1); + if (!mt->conf->apmixed_buffer_ctl_reg) + return; + + 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); } @@ -1138,8 +1148,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); }