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 B39C4C2BD09 for ; Mon, 15 Jul 2024 08:07:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type: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=0ZZF6SHcFUEyiyR+Vm+15zWotXyhNbxhylYVl4y9i0Q=; b=I/unczDNlh920Nm9oQKXWTW2MZ QinKnCDWIeFvf6IooSP4MX0mtE9pcT9w/wY95bCYVbJcp5q7gAuZgRGJTRIRhDy1CxKjdyoKCW3we Fkhn/3Q0PH+EZbsjIklBjr+y1KPi2iY9d3tGD/3RRbNzSbEGqeOZALyfvcvXYg4DToIKcKzYA4y9M QXGtHgaYovjVLxQZy2hwcg0WLYTjF3eGbwnjU5Cy6V9o86ECRUbM8S5GrvyJ9Gt3S+6JEV/aUmxlj eVZATk/wiIL9Zo0wN5XIspIoTC59klaXTYsLuUUB1KoFBp9MHfZc0HZzo8lmQyKs9VV8kKXxVuTss TGKONpfw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTGje-00000006GcA-461O; Mon, 15 Jul 2024 08:07:02 +0000 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTGjL-00000006GXy-2itk for linux-arm-kernel@lists.infradead.org; Mon, 15 Jul 2024 08:06:45 +0000 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4257d5fc9b7so30680545e9.2 for ; Mon, 15 Jul 2024 01:06:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1721030801; x=1721635601; 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=0ZZF6SHcFUEyiyR+Vm+15zWotXyhNbxhylYVl4y9i0Q=; b=TVDXIF2Lz3f1KwSpXMdMJhg4t2ZYu5UQLzprh/PpR8Gb/vnoORSgMFMP4zawWVJBSq /+xgbtyEbUiLHSDuPxkaWDKNmU0aXmx+ju6+E6Aku6e+RixO0rYjHQjfP+5M7b2rt6UK E6T+bQALA58Go47WVIvv7ipjkgzkX062GEp144D+f3qeWGa2y1Jiho5NXWBWLkG5TeJc e4h3oScr4yMKEbYoTowcS1cgLZDApCobIJz4SGpcf2xZL1Er3uBqeTxEEUhkyiA6blwd KFKg63q7Yc9anITKTUYzmfLOm7rgepwQq8+P9lZn6wglTCYwuc9xF6JNSSvRuW6t2Ap7 Kq3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721030801; x=1721635601; 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=0ZZF6SHcFUEyiyR+Vm+15zWotXyhNbxhylYVl4y9i0Q=; b=Xqd1ZxvOy+dcyzF/XitoTji8gdlDQYiZEwCJWx6SUit3UTU7WiNS7UDIoUwXhCbQFN O+ZipO6V/HA8iO+4RaOLFalix07B9lJReZd2Y87SixiFAorLGPSLyaiNImqej6wNM2N8 6QXii/TeUiGsnq2yDsXkDTKBm0WotCB2CbYOox/95RkujabS/YUtsI158fx5o4lY2hTc nXDTOP3v2FJwyKjaA7BCgG38Ee4dW9aJamEfHf5PvH2QJbA3rkkXGRw0e8IKMQQNlNip px2F7MetRR23OPRrbp/MORCrLYVLELuBB5SGiLSq05Il4zWzM/Lc8zsf4eYHb4m/9dEg +wKA== X-Forwarded-Encrypted: i=1; AJvYcCXNB+m78BTnKKMKQ8XKbiiMliDED5Oz7kW+sdl4Cp1IM3ZnAlD0poJGU6r2S1Lj1OooUkTsHFzlQ4Oj2dDaf/UgqfnesXIAhAg0FHXdA5DIfGx4p4I= X-Gm-Message-State: AOJu0YyFIWpFIfxzAa+UsNQ8RMiYzraM1c1LqSE+1NYhTq+0Iioc5v7s ZhPH9CSTJ5wUX0qxldm7ijg4GABcA7I3pSUPrG6uOj9vXEnX2AJDO9/GT5ji7oM= X-Google-Smtp-Source: AGHT+IGQxkCi+Sc9wBZNomHEVlA4JrxK+a6uMp912PveNzQBaXW9hcRRP6sKp7S+aVLFF5/drBpXyA== X-Received: by 2002:adf:e5c4:0:b0:366:ecc4:aa70 with SMTP id ffacd0b85a97d-367cea46912mr13511131f8f.5.1721030801484; Mon, 15 Jul 2024 01:06:41 -0700 (PDT) Received: from [192.168.50.4] ([82.78.167.171]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680db047c4sm5607243f8f.108.2024.07.15.01.06.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 15 Jul 2024 01:06:41 -0700 (PDT) Message-ID: Date: Mon, 15 Jul 2024 11:06:39 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 10/27] 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, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20240703102011.193343-1-varshini.rajendran@microchip.com> <20240703102736.195810-1-varshini.rajendran@microchip.com> From: claudiu beznea In-Reply-To: <20240703102736.195810-1-varshini.rajendran@microchip.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240715_010643_871894_E3019821 X-CRM114-Status: GOOD ( 24.93 ) 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 On 03.07.2024 13: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 be taken into > 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). > > Signed-off-by: Varshini Rajendran Reviewed-by: Claudiu Beznea > --- > Changes in v5: > - Corrected typos in commit message. > - Rewrote the conditional statement. > --- > drivers/clk/at91/clk-sam9x60-pll.c | 30 ++++++++++++++++++++++++++++-- > drivers/clk/at91/pmc.h | 1 + > 2 files changed, 29 insertions(+), 2 deletions(-) > > diff --git a/drivers/clk/at91/clk-sam9x60-pll.c b/drivers/clk/at91/clk-sam9x60-pll.c > index b0314dfd7393..fda041102224 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,14 @@ 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) > + > + 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; > + > 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;