linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Heiko Stuebner <heiko@sntech.de>
To: Elaine Zhang <zhangqing@rock-chips.com>
Cc: mturquette@baylibre.com, sboyd@codeaurora.org,
	linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-rockchip@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org, huangtao@rock-chips.com,
	cl@rock-chips.com, xxx@rock-chips.com, xf@rock-chips.com
Subject: Re: [PATCH v3] clk: fractional-divider: fix up the fractional clk's jitter
Date: Tue, 01 Aug 2017 18:19:46 +0200	[thread overview]
Message-ID: <5990882.df1suBpf8V@phil> (raw)
In-Reply-To: <1500624187-12165-1-git-send-email-zhangqing@rock-chips.com>

Hi Elaine,

sorry this took a bit longer, but I didn't manage to find the time to
respond properly until now.

Am Freitag, 21. Juli 2017, 16:03:07 CEST schrieb Elaine Zhang:
> Fractional dividers may have special requirements concerning numerator
> and denominator selection that differ from just getting the best
> approximation.
> 
> For example on Rockchip socs the denominator must be at least 20 times
> larger than the numerator to generate precise clock frequencies.
> 
> Therefore add the ability to provide custom approximation functions,
> approx = rockchip_fractional_special_approx;
> but approx = NULL in the default case.
> 
> RK document description:
> 3.1.9  Fractional divider usage
> To get specific frequency, clocks of I2S, SPDIF, UARTcan be generated by
> fractional divider. Generally you must set that denominator is 20 times
> larger than numerator to generate precise clock frequency. So the
> fractional divider applies only to generate low frequency clock like
> I2S, UART.
> 
> Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
> ---
>  drivers/clk/clk-fractional-divider.c |  4 ++++
>  drivers/clk/rockchip/clk.c           | 20 ++++++++++++++++++++
>  include/linux/clk-provider.h         |  3 +++
>  3 files changed, 27 insertions(+)

The code below does go into the right direction, but I'd really like to
have the full approximation  overrideable. The reason is that while on
Rockchip SoCs it's enough to increase the parent rate, other socs might
have completely different requirements when determining numerator
and denominator.

So I've taken the time and modified your patch into 2 that look like I
would envision it - compile-tested only, so please test :-)
But essentially it only moves some things around but should be
functionally equivalent to your patch.

I'll add the patches as replies to this mail.


Two more things to keep in mind for the future below:

> @@ -145,6 +148,7 @@ struct clk_hw *clk_hw_register_fractional_divider(struct device *dev,
>  	fd->nmask = GENMASK(nwidth - 1, 0) << nshift;
>  	fd->flags = clk_divider_flags;
>  	fd->lock = lock;
> +	fd->approx = NULL;

not needed, as fd is allocated via kzalloc, so this is already NULL.
Also it is nicer to spell approximation full (which I've done in my rework)

[...]

> diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
> index a428aec36ace..807262375292 100644
> --- a/include/linux/clk-provider.h
> +++ b/include/linux/clk-provider.h
> @@ -564,6 +564,9 @@ struct clk_fractional_divider {
>  	u8		nwidth;
>  	u32		nmask;
>  	u8		flags;
> +	void            (*approx)(struct clk_hw *hw,

Please keep the spacing in line with other elements. Somehow
here spaces instead of a tab slipped in between void and (*appro...


Heiko

  reply	other threads:[~2017-08-01 16:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-21  8:03 [PATCH v3] clk: fractional-divider: fix up the fractional clk's jitter Elaine Zhang
2017-08-01 16:19 ` Heiko Stuebner [this message]
2017-08-01 16:21   ` [PATCH 1/2] clk: fractional-divider: allow overriding of approximation Heiko Stuebner
2017-08-02  3:43     ` Elaine Zhang
2017-08-07 23:02     ` Stephen Boyd
2017-08-08 15:58     ` Heiko Stuebner
2017-08-01 16:22   ` [PATCH 2/2] clk: rockchip: add special approximation to fix up fractional clk's jitter Heiko Stuebner
2017-08-02  3:43     ` Elaine Zhang
2017-08-08 15:58     ` Heiko Stuebner

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=5990882.df1suBpf8V@phil \
    --to=heiko@sntech.de \
    --cc=cl@rock-chips.com \
    --cc=huangtao@rock-chips.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@codeaurora.org \
    --cc=xf@rock-chips.com \
    --cc=xxx@rock-chips.com \
    --cc=zhangqing@rock-chips.com \
    /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).