From mboxrd@z Thu Jan 1 00:00:00 1970 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 94D6BC54E58 for ; Mon, 11 Mar 2024 05:34:43 +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:In-Reply-To:From:References:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bjS0hEMcQincMY0YiNDElfXBdsi9my58+f4Qdn5DW3g=; b=lxh4T5KDedb1hB nIQ4g8mLU3djxiPa1JQdg8kauGuop1La6NdVPjDlHQthfphTvwxYr8ackWAI8inxfbX1OjoADy8v5 S3MqNu6H+bC82p4ACepFPcXEuXKPnr66g5yqJhCdCcKCsxOV4DNO0rujFCRxvk51DPllafWOizeYu xKPE4U7rNQw+kR+GVNuUyXY1BCnrR5aHhsxWQgGAKvJfDmGPMXy4ZwWQkgwUKnz3QfG2UfmiC+LKZ zPCEkOd20m8USnI6o/p14r1KqllAN5iXHzh1a5U8NYuiySDijatuENct2DDUWnYXu/28aJRcoSXWH t2IABP3wfuJQUqnxA7rg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjYIv-00000000GIb-3g66; Mon, 11 Mar 2024 05:34:29 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjYIs-00000000GHn-1wQ8 for linux-arm-kernel@lists.infradead.org; Mon, 11 Mar 2024 05:34:28 +0000 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-513173e8191so3709133e87.1 for ; Sun, 10 Mar 2024 22:34:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1710135264; x=1710740064; darn=lists.infradead.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=i4oFriuVpik3kxTE+F3ATr5sVhpxlaV2CyW7MSXr7XM=; b=e06W4ZvgQCLDiRZfqUA9UYxr9LiNJZoLkuezyYZXX43kaoX7+YahA/4DW5kwcq+c4p Xv4xXqEhS50lMOvkEfRBFkihsaPQWmlFcb6qiUIV27cnAmeUpqDBewt8eWiw/6gO/i8P +iNef3eLncR90zKI2PvZn0g1Sg5LD24aRtQK8HaL62aHGj+EuX0LXQrsyVKq2ME3BgX7 zq8iMXonAwM5q3HCbjYbT4gLmtDENBT3WaXqhIeYWcleRnBov6ffKjFWCxKtFljH/ECw W9g7J4CF6wPD95m8hupYY88ZYLiYj6e4ss6lUvUW52/vTayqNWG1s31dMab+W6WXgxII DjyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710135264; x=1710740064; h=content-transfer-encoding:in-reply-to:from:references: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=i4oFriuVpik3kxTE+F3ATr5sVhpxlaV2CyW7MSXr7XM=; b=CFD1IVIXLGrhvG8TpF/5DJDlKb3xZDBp1au+t69t/iZFHNr94OSWCKS+jaMyYL8jvj pIF+qZu+QaOXN4/ghW3h+Kk/xKtRz7sSdC9N2E7hWK5AwnVjQwhoXSqRzdroDDfeRdh0 c37yxUFz16yUvcati44GtaP6BNmEeS736kKE+1+BHgzwqBmuIXgHwzBzl9aw8S8Pvuxt kHGI8UxCNatIal74Y8GSCXkR07Yq7N0EM+ZTi36bpglH5St753nBy1lljz/NxWSG27Lo REmLzecVPWxKtdHLWp/OtKpxPzoYLGWQlheG6IhDADhiwd4NTVjpwrIHG4zoWlokVXrC myaw== X-Forwarded-Encrypted: i=1; AJvYcCXqmIOv9e+rbvXc252OcQaabAXdd00OHYO2fEq1Somsv06I5YKlUECZy2q2SsMXV8ULxXyLJWkRp1I1O7bJ/4Sn4KrCc1VGA+CpbmCbcWm52uaDO7E= X-Gm-Message-State: AOJu0YxfhZ8B8WA7drPQfVVEoSN7xlWxFYClLFvRmK4ibmpOG6032gpm NWivRvtF9xY3w+8SRU1qo7QuRpsOX9i+2h4p3GlYwKtrs+jd4XuxxWBrTVkPwVTzxgDoQY/K+bv X X-Google-Smtp-Source: AGHT+IHNRWI3XKfvnftfwOlSr4Ea/ajJim8mIIcLpfbErv0NVc6dNa6acmyhS9jZCbVdPf8ooIBdmg== X-Received: by 2002:a05:6512:2823:b0:513:42e:ddf0 with SMTP id cf35-20020a056512282300b00513042eddf0mr4948217lfb.36.1710135264238; Sun, 10 Mar 2024 22:34:24 -0700 (PDT) Received: from [192.168.50.4] ([82.78.167.38]) by smtp.gmail.com with ESMTPSA id je1-20020a05600c1f8100b00412c1d51a0dsm7705109wmb.45.2024.03.10.22.34.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 10 Mar 2024 22:34:23 -0700 (PDT) Message-ID: <8c53aff9-eddf-47e3-939f-a1e2abb8d824@tuxon.dev> Date: Mon, 11 Mar 2024 07:34:22 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 24/39] clk: at91: sam9x7: add support for HW PLL freq dividers Content-Language: en-US To: Varshini Rajendran , mturquette@baylibre.com, sboyd@kernel.org, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, mripard@kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20240223171342.669133-1-varshini.rajendran@microchip.com> <20240223172758.672796-1-varshini.rajendran@microchip.com> From: claudiu beznea In-Reply-To: <20240223172758.672796-1-varshini.rajendran@microchip.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240310_223426_689810_581E00D1 X-CRM114-Status: GOOD ( 25.80 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 23.02.2024 19:27, Varshini Rajendran wrote: > Add support for hardware dividers for PLL IDs in sam9x7 SoC. The system > PLL - PLLA and the system PLL divided by 2 - PLLADIV2 with PLL ID 0 and > 4 respectively, both have a hardware divider /2. This has to taken into to be taken > account in the software to obtain the right frequencies. Support for the > same is added in the PLL driver. > > fcorepllack -----> HW Div = 2 -+--> fpllack > | > +--> HW Div = 2 ---> fplladiv2ck > > In this case the corepll freq is 1600 MHz. So, the plla freq is 800 MHz > after the hardware divider and the plladiv2 freq is 400 MHz after the > hardware divider (Given that the DIVPMC is 0). s/Given/given > > Signed-off-by: Varshini Rajendran > --- > drivers/clk/at91/clk-sam9x60-pll.c | 38 ++++++++++++++++++++++++++---- > drivers/clk/at91/pmc.h | 1 + > 2 files changed, 34 insertions(+), 5 deletions(-) > > diff --git a/drivers/clk/at91/clk-sam9x60-pll.c b/drivers/clk/at91/clk-sam9x60-pll.c > index b0314dfd7393..1f80759309c0 100644 > --- a/drivers/clk/at91/clk-sam9x60-pll.c > +++ b/drivers/clk/at91/clk-sam9x60-pll.c > @@ -73,9 +73,15 @@ static unsigned long sam9x60_frac_pll_recalc_rate(struct clk_hw *hw, > { > struct sam9x60_pll_core *core = to_sam9x60_pll_core(hw); > struct sam9x60_frac *frac = to_sam9x60_frac(core); > + unsigned long freq; > > - return parent_rate * (frac->mul + 1) + > + freq = parent_rate * (frac->mul + 1) + > DIV_ROUND_CLOSEST_ULL((u64)parent_rate * frac->frac, (1 << 22)); > + > + if (core->layout->div2) > + freq >>= 1; > + > + return freq; > } > > static int sam9x60_frac_pll_set(struct sam9x60_pll_core *core) > @@ -432,6 +438,12 @@ static unsigned long sam9x60_div_pll_recalc_rate(struct clk_hw *hw, > return DIV_ROUND_CLOSEST_ULL(parent_rate, (div->div + 1)); > } > > +static unsigned long sam9x60_fixed_div_pll_recalc_rate(struct clk_hw *hw, > + unsigned long parent_rate) > +{ > + return parent_rate >> 1; > +} > + > static long sam9x60_div_pll_compute_div(struct sam9x60_pll_core *core, > unsigned long *parent_rate, > unsigned long rate) > @@ -606,6 +618,16 @@ static const struct clk_ops sam9x60_div_pll_ops_chg = { > .restore_context = sam9x60_div_pll_restore_context, > }; > > +static const struct clk_ops sam9x60_fixed_div_pll_ops = { > + .prepare = sam9x60_div_pll_prepare, > + .unprepare = sam9x60_div_pll_unprepare, > + .is_prepared = sam9x60_div_pll_is_prepared, > + .recalc_rate = sam9x60_fixed_div_pll_recalc_rate, > + .round_rate = sam9x60_div_pll_round_rate, > + .save_context = sam9x60_div_pll_save_context, > + .restore_context = sam9x60_div_pll_restore_context, > +}; > + > struct clk_hw * __init > sam9x60_clk_register_frac_pll(struct regmap *regmap, spinlock_t *lock, > const char *name, const char *parent_name, > @@ -725,10 +747,16 @@ sam9x60_clk_register_div_pll(struct regmap *regmap, spinlock_t *lock, > else > init.parent_names = &parent_name; > init.num_parents = 1; > - if (flags & CLK_SET_RATE_GATE) > - init.ops = &sam9x60_div_pll_ops; > - else > - init.ops = &sam9x60_div_pll_ops_chg; > + > + if (layout->div2) { > + init.ops = &sam9x60_fixed_div_pll_ops; > + } else { > + if (flags & CLK_SET_RATE_GATE) > + init.ops = &sam9x60_div_pll_ops; > + else > + init.ops = &sam9x60_div_pll_ops_chg; > + } > + can't it be something like: if (layout->div2) // ... else if (flags & CLK_SET_RATE_GATE) // ... else // ? > init.flags = flags; > > div->core.id = id; > diff --git a/drivers/clk/at91/pmc.h b/drivers/clk/at91/pmc.h > index bb9da35198d9..91d1c6305d95 100644 > --- a/drivers/clk/at91/pmc.h > +++ b/drivers/clk/at91/pmc.h > @@ -64,6 +64,7 @@ struct clk_pll_layout { > u8 frac_shift; > u8 div_shift; > u8 endiv_shift; > + u8 div2; > }; > > extern const struct clk_pll_layout at91rm9200_pll_layout; _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel