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 4B993C61DA4 for ; Fri, 27 Jan 2023 22:21:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232853AbjA0WVN (ORCPT ); Fri, 27 Jan 2023 17:21:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231163AbjA0WVL (ORCPT ); Fri, 27 Jan 2023 17:21:11 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB2FD875A5 for ; Fri, 27 Jan 2023 14:21:08 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id r2so6224841wrv.7 for ; Fri, 27 Jan 2023 14:21:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=u7mNH8UjS1eLeKEg29OSJTNzCrRV1GaewWlhXhn/Ass=; b=phX5a0bkyIOQHgeKrnGJ6rP2bFpUOK7+GfRnIGaTXbJHXepfIv3gEQw48mJPig+faD TnUHxa80I7+4/bpCYyiJbYnwnb9UzCcDTCfoxEsIaSlgLIsfyEkzyl66zWgmoEBk52gM 03EFgs6sTQAY3FtxiyKuCSZtpb9Qbrv3J0XBq/HnJAA6h5FWsWSa2JWiy+6dcErkMotM agNBfcUn7fOkpRaNVJ5X3xki4GHiX/hml0PzClY3zDeOAQnHhoZn6iiccU9g1e/FEPPW UL8kmJzSulZMmgIhybb4RkxJbY+h+YuYjCv0MX2lvOsOjemhoTogf2Omta/Pu05L+1L4 9NRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=u7mNH8UjS1eLeKEg29OSJTNzCrRV1GaewWlhXhn/Ass=; b=XaetXZRLsvqh9gDZp2x7WlG7NKV8GxasvA7TfXAH43oTLEGYgyI+g0oXwlOkhSfZS3 06GjO14yDQAEDX2xlvGESU5uuB2eUz6vXCMqUriCKX18bn8CrJWM4GeVaEu15kr01pib oj4KU+5HiKnCpnY04n1gQLTLaIK71HlWHqdjz3UGhRFRRNZHWaixD5C9z6lepwmdQy6t bZ+KtUwD53OEbrfMBNQNQxIBdjX0KQWWeHI9ZeYJu3p7gaN8Jb00TJ9HyaIoouAjt912 zgvMh0iPNGwVyg2L7mTnYn56bs3DdItZffYz4slr6pGdgZ8So4JiZ9kloXOs/6QkQNbH C7Gw== X-Gm-Message-State: AFqh2krqTrgBQC2VHV6cpaQDTlOjaTPlrwcjwpPnVs0vRi+IfBNi8Tm3 MX0+hzcEqnBCo6yAO85jR3WKGA== X-Google-Smtp-Source: AMrXdXvpTC0WEHjMIdqtZJgSJEbDnzIJWgxxB9utWCGhrm/ZU+Tpgj0xpGRTg69JQyKH6I1qyty5mQ== X-Received: by 2002:adf:8b45:0:b0:2bd:e8c9:bcd5 with SMTP id v5-20020adf8b45000000b002bde8c9bcd5mr34310410wra.61.1674858067148; Fri, 27 Jan 2023 14:21:07 -0800 (PST) Received: from [192.168.0.20] (62.213.132.195.rev.sfr.net. [195.132.213.62]) by smtp.gmail.com with ESMTPSA id e10-20020a5d500a000000b002be0b1e556esm4947431wrt.59.2023.01.27.14.21.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 27 Jan 2023 14:21:06 -0800 (PST) Message-ID: Date: Fri, 27 Jan 2023 23:21:05 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.0 Subject: Re: [PATCH v9 2/5] thermal: mediatek: control buffer enablement tweaks Content-Language: en-US To: Daniel Lezcano , "Rafael J. Wysocki" , 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 , Michael Kao References: <20221018-up-i350-thermal-bringup-v9-0-55a1ae14af74@baylibre.com> <20221018-up-i350-thermal-bringup-v9-2-55a1ae14af74@baylibre.com> From: Amjad Ouled-Ameur In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/27/23 22:48, Daniel Lezcano wrote: > On 27/01/2023 16:44, Amjad Ouled-Ameur wrote: >> 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); >>       } > > This change conflicts with commit 4f2ee0aa2e706 > > I fixed it with: > > -       if (mt->conf->version != MTK_THERMAL_V1) { > -               mtk_thermal_turn_on_buffer(apmixed_base); > +       mtk_thermal_turn_on_buffer(apmixed_base); > + > +       if (mt->conf->version != MTK_THERMAL_V1) >                 mtk_thermal_release_periodic_ts(mt, auxadc_base); > -       } > I think it's rather MTK_THERMAL_V2 and not MTK_THERMAL_V1. Other than that, it looks fine by me, thanks. Amjad > Let me know if there is something wrong. > >