From patchwork Wed Jan 25 09:50:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amjad Ouled-Ameur X-Patchwork-Id: 48081 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp189569wrn; Wed, 25 Jan 2023 01:56:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXvLNqQKXaOBt6Uc7HhoQNx3YVYmSTi0vF+dYWEL74NVHlx5SMs20mdgTA+rkP6hTrfS+D90 X-Received: by 2002:a05:6a20:6702:b0:b8:c659:9d56 with SMTP id q2-20020a056a20670200b000b8c6599d56mr33890926pzh.46.1674640594907; Wed, 25 Jan 2023 01:56:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674640594; cv=none; d=google.com; s=arc-20160816; b=FR+3R1SEdO66Xvawsg3KyEEDqfHRyOrKwhQUPdHbGBuqYqR/SHAQc4ajpfdtFnu5Eg VFTbQFfLl2ciRCQ3fG3Mv1dyQc8q5CkZS4dscuRhsY293gLwLmZf/rzgW0Nvh8LQYX4n Bowm+IHFp1dzbH5bSddyimkJgkNj+74bchlMzE19F/ZbDuUSFafU+mabFl5Z0XX22gOL ttoDvPDjEMEhQQB5ygOEIHe25fBwOCSrGvv8GF9B0euNB3Ax7xRQ7k2uwwsKUWXzncJ0 6B+R94EhcyUH9PqEJy08JY4S/k4SVYh/7YL1ByVitKa5YOfjx0zJvoMXouyQrq5WUeGD ysJA== 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=a8rG7Mbgb1oWT4fX2vZyNeYThYNVXL6oBqBlNEJwaWo=; b=rV6cuyt+LJ7uqXqU+t+MwzV8qvJmNG4KRYGl7wExgRjTcpdZ25oPzJy87RmsNkcKN1 sCRclk+KrAP0CGyePN4G4eEapLJmIt3Szpcyo4kfS5q+GSE1KVaoT9ikqczw6HgOmyNc cctvXaNvxR8CDf5Q0C4ZtfmUBSTsNxNGdOUp/AE2i/FEQQ5VvyYIRxiw2pHZMVqA4Dtm CXUEqyztRyfZJgq8wb4ns4AjLKCEZfEa7APDP+24+pFrM4MM5mea5GSDH68kmvvJ9Fv3 pOshACq1df7DRAPHIMCT/0cqOkCOMPHtYxkCYgZTvPpxdsCJDvMO7abnjAFoWIvnyENs n2Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=xPWzL4S4; 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 i26-20020aa78d9a000000b0058e0bdc7032si4919488pfr.108.2023.01.25.01.56.22; Wed, 25 Jan 2023 01:56:34 -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=xPWzL4S4; 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 S235442AbjAYJvQ (ORCPT + 99 others); Wed, 25 Jan 2023 04:51:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235347AbjAYJvH (ORCPT ); Wed, 25 Jan 2023 04:51:07 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC1FE4C2A for ; Wed, 25 Jan 2023 01:51:04 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id q5so11778639wrv.0 for ; Wed, 25 Jan 2023 01:51:04 -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=a8rG7Mbgb1oWT4fX2vZyNeYThYNVXL6oBqBlNEJwaWo=; b=xPWzL4S43VKse9dWE8bt5cpWWfxCYYdjSEnvvA18Lvlhc/05RPdQbUtIXakb3vBwOr yvTO5WToHjWPcxv2LW1ueJxhU0PfaDPRmCtYjxQsZ3sU1yQmGMS3+a9TqsoIteKsbReD E6udwR9XHgscFD4p3EXKzHbpMD+F6R1VBsvHQ8tJoRRyV4M0XEzwFOp3eQVwWN5CF1gS /wszNzazSfHLc52rPtQ1ybUM/SwoxBBoW8g2fNCzZouSJ1SJ2BIglkEJXL7vmff1zvPJ PY4u69Zcwb/CGFAYHJ5szMqb1+PkSMyrvhSnRyjsC2FX/XUN4MtNGpJiZbfy3+9Oc7ch PTAQ== 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=a8rG7Mbgb1oWT4fX2vZyNeYThYNVXL6oBqBlNEJwaWo=; b=70KSABZ9JZaVS5FSy2vPh+VGvzZ96/smmV+QaW1Y930ryfM05+3aC2T+1oWg+ds/n+ 8xv0+JdjwBGuOys87rPL2QQifz3MkchHvgZoG9MNwG7l0/GXlw7E6Zsg0ZtUXR01MfYj 7j5O+31MMhOhP6reU2p4IE6MmiHoDD4QrcEHKwjLObK94tCzQAKoe6pJx33khjdU6dW1 z8mei5RmbkwgunqHXSEXMQevHXiSC7C8p6D2gECTI0eNNXnVt+oXO5S53gJV8wtNigWC 2MBXuCw+OgSo8KnZ+AIY0oMBWQNbhIj9yA4+MGdpoJc8bzLdOEpY7udARlYZPtIRh/fn KtIA== X-Gm-Message-State: AO0yUKUCwyBZwkcOw3TKbEhwV10I2KOgM/ZK4VMKimaYpesDczTntib9 OG1yIFlNAYQBcAZk8b6FHDDKTA== X-Received: by 2002:a5d:66ce:0:b0:2bf:b765:74cf with SMTP id k14-20020a5d66ce000000b002bfb76574cfmr2102506wrw.30.1674640263230; Wed, 25 Jan 2023 01:51:03 -0800 (PST) Received: from [127.0.1.1] (62.213.132.195.rev.sfr.net. [195.132.213.62]) by smtp.googlemail.com with ESMTPSA id j26-20020a5d453a000000b002bdf3809f59sm3955072wra.38.2023.01.25.01.51.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 01:51:02 -0800 (PST) From: Amjad Ouled-Ameur Date: Wed, 25 Jan 2023 10:50:30 +0100 Subject: [PATCH v8 2/5] thermal: mediatek: control buffer enablement tweaks MIME-Version: 1.0 Message-Id: <20221018-up-i350-thermal-bringup-v8-2-23e8fbb08837@baylibre.com> References: <20221018-up-i350-thermal-bringup-v8-0-23e8fbb08837@baylibre.com> In-Reply-To: <20221018-up-i350-thermal-bringup-v8-0-23e8fbb08837@baylibre.com> To: "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui , Rob Herring , Krzysztof Kozlowski Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Fabien Parent , Matthias Brugger , AngeloGioacchino Del Regno , Rob Herring , Markus Schneider-Pargmann , Hsin-Yi Wang , Amjad Ouled-Ameur , Michael Kao X-Mailer: b4 0.11.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1674640259; l=2546; i=aouledameur@baylibre.com; s=20220920; h=from:subject:message-id; bh=o4V8Nb038m3SOSHzM/Z25bSLgf/ue1pK+n3hiU0se4A=; b=z+eBUVG5tTpkdOflpaYTVv0RLdNKf8a4pIUewm6Ch4PuTfzhjtAJJ58QazUubZZjO6YaNfGgl8VM yS/u5hKRAwrw+zWBjbi6O4hrypwnQNNl63tdF+8pse8qmBDQEers 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=ham 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?1755987936036630671?= X-GMAIL-MSGID: =?utf-8?q?1755987936036630671?= 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); }