devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maxime Ripard <maxime.ripard@bootlin.com>
To: Jernej Skrabec <jernej.skrabec@siol.net>
Cc: mark.rutland@arm.com, devicetree@vger.kernel.org,
	airlied@linux.ie, mturquette@baylibre.com,
	linux-sunxi@googlegroups.com, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org, sboyd@kernel.org, wens@csie.org,
	robh+dt@kernel.org, linux-clk@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 01/16] clk: sunxi-ng: Add check for minimal rate to NM PLLs
Date: Wed, 28 Feb 2018 08:34:40 +0100	[thread overview]
Message-ID: <20180228073440.6ejo3wjdqag6h4nl@flea> (raw)
In-Reply-To: <20180227222701.9716-2-jernej.skrabec@siol.net>


[-- Attachment #1.1: Type: text/plain, Size: 2344 bytes --]

Hi,

On Tue, Feb 27, 2018 at 11:26:46PM +0100, Jernej Skrabec wrote:
> Some NM PLLs doesn't work well when their output clock rate is set below
> certain rate.
> 
> Add support for that constrain.
> 
> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
> ---
>  drivers/clk/sunxi-ng/ccu_nm.c | 11 +++++++----
>  drivers/clk/sunxi-ng/ccu_nm.h | 27 +++++++++++++++++++++++++++
>  2 files changed, 34 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/clk/sunxi-ng/ccu_nm.c b/drivers/clk/sunxi-ng/ccu_nm.c
> index a16de092bf94..7fc743c78c1b 100644
> --- a/drivers/clk/sunxi-ng/ccu_nm.c
> +++ b/drivers/clk/sunxi-ng/ccu_nm.c
> @@ -20,7 +20,7 @@ struct _ccu_nm {
>  };
>  
>  static void ccu_nm_find_best(unsigned long parent, unsigned long rate,
> -			     struct _ccu_nm *nm)
> +			     unsigned long min_rate, struct _ccu_nm *nm)
>  {
>  	unsigned long best_rate = 0;
>  	unsigned long best_n = 0, best_m = 0;
> @@ -30,7 +30,7 @@ static void ccu_nm_find_best(unsigned long parent, unsigned long rate,
>  		for (_m = nm->min_m; _m <= nm->max_m; _m++) {
>  			unsigned long tmp_rate = parent * _n  / _m;
>  
> -			if (tmp_rate > rate)
> +			if (tmp_rate > rate || tmp_rate < min_rate)
>  				continue;
>  
>  			if ((rate - tmp_rate) < (rate - best_rate)) {
> @@ -117,6 +117,9 @@ static long ccu_nm_round_rate(struct clk_hw *hw, unsigned long rate,
>  	if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
>  		rate *= nm->fixed_post_div;
>  
> +	if (rate < nm->min_rate)
> +		rate = nm->min_rate;
> +

I guess you can just return there. There's no point in trying to find
the factors at this point, since the minimum should be a value that
can be reached.

>  	if (ccu_frac_helper_has_rate(&nm->common, &nm->frac, rate)) {
>  		if (nm->common.features & CCU_FEATURE_FIXED_POSTDIV)
>  			rate /= nm->fixed_post_div;
> @@ -134,7 +137,7 @@ static long ccu_nm_round_rate(struct clk_hw *hw, unsigned long rate,
>  	_nm.min_m = 1;
>  	_nm.max_m = nm->m.max ?: 1 << nm->m.width;
>  
> -	ccu_nm_find_best(*parent_rate, rate, &_nm);
> +	ccu_nm_find_best(*parent_rate, rate, nm->min_rate, &_nm);

Therefore, you don't need to change the prototype there either.

Maxime

-- 
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2018-02-28  7:34 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-27 22:26 [PATCH v2 00/16] Implement H3/H5 HDMI driver Jernej Skrabec
     [not found] ` <20180227222701.9716-1-jernej.skrabec-gGgVlfcn5nU@public.gmane.org>
2018-02-27 22:26   ` [PATCH v2 01/16] clk: sunxi-ng: Add check for minimal rate to NM PLLs Jernej Skrabec
2018-02-28  7:34     ` Maxime Ripard [this message]
2018-02-28 21:55       ` Jernej Škrabec
2018-02-27 22:26   ` [PATCH v2 02/16] clk: sunxi-ng: h3: h5: Add minimal rate for video PLL Jernej Skrabec
2018-02-27 22:26   ` [PATCH v2 03/16] clk: sunxi-ng: h3: h5: Allow some clocks to set parent rate Jernej Skrabec
2018-02-27 22:26   ` [PATCH v2 04/16] clk: sunxi-ng: h3: h5: export CLK_PLL_VIDEO Jernej Skrabec
2018-02-27 22:26   ` [PATCH v2 05/16] dt-bindings: display: sun4i-drm: Add compatibles for H3 HDMI pipeline Jernej Skrabec
2018-02-27 22:26   ` [PATCH v2 06/16] drm/sun4i: Don't process LVDS if TCON doesn't support it Jernej Skrabec
2018-02-28  7:36     ` Maxime Ripard
2018-02-28 21:43       ` Jernej Škrabec
2018-03-02  8:12         ` Maxime Ripard
2018-02-27 22:26   ` [PATCH v2 07/16] drm/sun4i: Add support for H3 display engine Jernej Skrabec
2018-02-27 22:26   ` [PATCH v2 08/16] drm/sun4i: Add support for H3 mixer 0 Jernej Skrabec
2018-02-27 22:26   ` [PATCH v2 09/16] drm/sun4i: Fix polarity configuration for DW HDMI PHY Jernej Skrabec
2018-02-27 22:26   ` [PATCH v2 10/16] drm/sun4i: Add support for variants to " Jernej Skrabec
2018-02-27 22:26   ` [PATCH v2 11/16] drm/sun4i: Move and expand DW HDMI PHY register macros Jernej Skrabec
2018-02-27 22:26   ` [PATCH v2 12/16] drm/sun4i: Add support for H3 HDMI PHY variant Jernej Skrabec
2018-02-27 22:26   ` [PATCH v2 13/16] drm/sun4i: Allow building on arm64 Jernej Skrabec
2018-02-27 22:26   ` [PATCH v2 14/16] ARM: dts: sunxi: h3/h5: Add HDMI pipeline Jernej Skrabec
2018-02-27 22:27   ` [PATCH v2 15/16] ARM: dts: sun8i: h3: Enable HDMI output on H3 boards Jernej Skrabec
2018-02-27 22:27   ` [PATCH v2 16/16] ARM64: dts: sun50i: h5: Enable HDMI output on H5 boards Jernej Skrabec
2018-02-28 21:23   ` [PATCH v2 00/16] Implement H3/H5 HDMI driver Jernej Škrabec
2018-03-01  8:23     ` Maxime Ripard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180228073440.6ejo3wjdqag6h4nl@flea \
    --to=maxime.ripard@bootlin.com \
    --cc=airlied@linux.ie \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jernej.skrabec@siol.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sunxi@googlegroups.com \
    --cc=mark.rutland@arm.com \
    --cc=mturquette@baylibre.com \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=wens@csie.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).