Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp881709rdb; Wed, 6 Dec 2023 02:39:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IFxrWC7swkoYqLrf5QQ3urLa9uHSyDAfZhsI0G+Nv33X1xEH14B6Ap7p115JKA0mmiL+aMC X-Received: by 2002:a05:6a00:14c9:b0:6ce:707e:ce with SMTP id w9-20020a056a0014c900b006ce707e00cemr2918059pfu.10.1701859156947; Wed, 06 Dec 2023 02:39:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701859156; cv=none; d=google.com; s=arc-20160816; b=zPhG1RzSqO833LSuumeXZxpKxUJ0QuEDrFjP0unkKtxoWexrsFhg5XGfz8Lg78hyOz ZULAbf5Mg194sIeiTDq48ub8Ghccog/1GY1ycPbfMdFfEiPfjow8SgYsf8PSB7x4OkuI 6iPAkrgrFtPlVXqCNcnf9g+CzYd8HuV3XNwkxiKyVZJhh5EfQitIwpukwgM6HcoADjxp SbwihuOgrgnZW1qxLGUhojOCREzmzzu3LHmS5iyR0IBs7bZr1DoI9lvX0w7TrJunP5ZF kPG+p9r/hYNXfWxCy3wTeMeYL0y15XHfFAif5OEK0SA4VrtyzbWN0d/hFEc3YTNQHJnG axjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=e1xXY/oktJYDScih4mF4ljjnwqUSEsE6Ib0gkc+Thb4=; fh=BScZ3A/A15YRtq/yCzX21TH7gFiGx9VyhAWiFW8OTD0=; b=RPV9Pcgl82g7DralRGtDdTgsXI4XhDUVcJsm6FppflSO5edl2p1mwAlaVUSJz1m96F BVkuICOKXMDChN/BbDMG1VWePce7Wmug54NueL40lf4nK7AyWQpPfF+m8ZArnJpCHTLd TEOx4qlZzRn+TXNt3xnhhSjfA651HoTlxeKgjH0VQ4RT4qIi2hA+5okr5ukRfLMhvOZO PcTS+JgTzFh5mlQGEJn4+YexsTv6I5oC2GpgNLf6B15d6HfAtuzdCrAhbAPiaVgpt0S+ WrDYMzuxP0adaefnu+sat+gamgBnwJHlSWxcLMnWVH45+f8G+6ogfGgvXHXucE+9s+d+ ZmUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="R/jsCb+c"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id g10-20020a656cca000000b005c1cd597808si12213193pgw.692.2023.12.06.02.39.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 02:39:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="R/jsCb+c"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 371B681A4FF1; Wed, 6 Dec 2023 02:39:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377508AbjLFKi4 (ORCPT + 99 others); Wed, 6 Dec 2023 05:38:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377494AbjLFKiv (ORCPT ); Wed, 6 Dec 2023 05:38:51 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C87E41730; Wed, 6 Dec 2023 02:38:42 -0800 (PST) Received: from [100.113.186.2] (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id CB93B660732A; Wed, 6 Dec 2023 10:38:39 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1701859121; bh=j6FSYq/wllVqa38fLBlpKeDl1PwQcbOvVLOoOX0UBbM=; h=Date:Subject:To:References:From:In-Reply-To:From; b=R/jsCb+crLicefguBjhSXx1mhP2GI7hlj0zO2u/FMxuvkISVnxmBdvV1vanKSwmhm 59aoYyl27HkFPeGTNKgXHf7LrPDGcLh6Y8KacgOAylkVSoqc2GqLGpeIQKl539mum2 GZZ1RxkZAiCZmKJne1SwuC26ccLZur4h1PkA+4uLCCaeq6TmfEj8bBD3ht77kvm/Px RlPKBrKQX0eQLbulorYkQXgRter30Y4vHZ7qVJzP9852TVcal0cIP2Q3kPsmoQ/J3I tizI9NHjpxn5J4TW3+4ccUfYPZBTMiCJYGAmh/Raj9bAqD071KohK8GHAh+wCNIlHY JxSbyd157tTyQ== Message-ID: <0ebce75d-0074-4128-b35e-e86ee3ee546b@collabora.com> Date: Wed, 6 Dec 2023 11:38:36 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 3/4] clk: mediatek: Add pcw_chg_shift control Content-Language: en-US To: Daniel Golle , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Turquette , Stephen Boyd , Matthias Brugger , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Sabrina Dubroca , Jianhui Zhao , Chen-Yu Tsai , "Garmin.Chang" , Sam Shih , Frank Wunderlich , Dan Carpenter , James Liao , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, netdev@vger.kernel.org References: <23bc89d407e7797e97b703fa939b43bfe79296ce.1701823757.git.daniel@makrotopia.org> <40981d0bb722eb509628bcf82c31f632e4cf747a.1701823757.git.daniel@makrotopia.org> From: AngeloGioacchino Del Regno In-Reply-To: <40981d0bb722eb509628bcf82c31f632e4cf747a.1701823757.git.daniel@makrotopia.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 06 Dec 2023 02:39:14 -0800 (PST) Il 06/12/23 01:57, Daniel Golle ha scritto: > From: Sam Shih > > Introduce pcw_chg_shfit control to optionally use that instead of the > hardcoded PCW_CHG_MASK macro. > This will needed for clocks on the MT7988 SoC. > > Signed-off-by: Sam Shih > Signed-off-by: Daniel Golle > --- > v3: use git --from ... > v2: no changes > > drivers/clk/mediatek/clk-pll.c | 5 ++++- > drivers/clk/mediatek/clk-pll.h | 1 + > 2 files changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/clk/mediatek/clk-pll.c b/drivers/clk/mediatek/clk-pll.c > index 513ab6b1b3229..9f08bc5d2a8a2 100644 > --- a/drivers/clk/mediatek/clk-pll.c > +++ b/drivers/clk/mediatek/clk-pll.c > @@ -114,7 +114,10 @@ static void mtk_pll_set_rate_regs(struct mtk_clk_pll *pll, u32 pcw, > pll->data->pcw_shift); > val |= pcw << pll->data->pcw_shift; > writel(val, pll->pcw_addr); > - chg = readl(pll->pcw_chg_addr) | PCW_CHG_MASK; > + if (pll->data->pcw_chg_shift) > + chg = readl(pll->pcw_chg_addr) | BIT(pll->data->pcw_chg_shift); > + else > + chg = readl(pll->pcw_chg_addr) | PCW_CHG_MASK; > writel(chg, pll->pcw_chg_addr); > if (pll->tuner_addr) > writel(val + 1, pll->tuner_addr); > diff --git a/drivers/clk/mediatek/clk-pll.h b/drivers/clk/mediatek/clk-pll.h > index f17278ff15d78..d28d317e84377 100644 > --- a/drivers/clk/mediatek/clk-pll.h > +++ b/drivers/clk/mediatek/clk-pll.h > @@ -44,6 +44,7 @@ struct mtk_pll_data { > u32 pcw_reg; > int pcw_shift; > u32 pcw_chg_reg; > + int pcw_chg_shift; > const struct mtk_pll_div_table *div_table; > const char *parent_name; > u32 en_reg; Hmm... no, this is not the best at all and can be improved. Okay, so, the situation here is that one or some PLL(s) on MT7988 have a different PCW_CHG_MASK as far as I understand. Situation here is: - Each PLL must be registered to clk-pll - Each driver declaring a PLL does exactly so - There's a function to register the PLL You definitely don't want to add a conditional in pll_set_rate(): even though this is technically not a performance path on the current SoCs (and will probably never be), it's simply useless to have this (very small) overhead there. The solution is to: - Change that pcw_chg_shift to an unsigned short int type (or u8, your call): you don't need 32 bits for this number, as the expected range of this member is [0-31], and this can be expressed in just 4 bits (u8 is the smallest though) - Add that to function mtk_clk_register_pll_ops() - Change mtk_pll_set_rate_regs() to always do chg = readl(pll->pcw_chg_addr) | BIT(pll->data->pcw_chg_shift); Cheers, Angelo