From: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
To: Jean-Francois Moine <moinejf-GANU6spQydw@public.gmane.org>
Cc: Emilio Lopez <emilio-0Z03zUJReD5OxF6Tv1QG9Q@public.gmane.org>,
Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>,
Stephen Boyd <sboyd-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
linux-clk-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 2/3] clk: sunxi: Add sun6i/8i PLL video support
Date: Sun, 10 Apr 2016 02:50:06 -0700 [thread overview]
Message-ID: <20160410095006.GY4227@lukather> (raw)
In-Reply-To: <e63499f789971b8c45a0ae5e90bd127371cbcf19.1459358017.git.moinejf-GANU6spQydw@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 3273 bytes --]
Hi,
On Wed, Mar 30, 2016 at 06:50:43PM +0200, Jean-Francois Moine wrote:
> Add the PLL type which is used by the sun6i/8i families for video display.
>
> Signed-off-by: Jean-Francois Moine <moinejf-GANU6spQydw@public.gmane.org>
> ---
> Documentation/devicetree/bindings/clock/sunxi.txt | 1 +
> drivers/clk/sunxi/clk-sunxi.c | 65 +++++++++++++++++++++++
> 2 files changed, 66 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt b/Documentation/devicetree/bindings/clock/sunxi.txt
> index 8c0fda8..ff93aee 100644
> --- a/Documentation/devicetree/bindings/clock/sunxi.txt
> +++ b/Documentation/devicetree/bindings/clock/sunxi.txt
> @@ -10,6 +10,7 @@ Required properties:
> "allwinner,sun4i-a10-pll1-clk" - for the main PLL clock and PLL4
> "allwinner,sun6i-a31-pll1-clk" - for the main PLL clock on A31
> "allwinner,sun8i-a23-pll1-clk" - for the main PLL clock on A23
> + "allwinner,sun6i-a31-pll3-clk" - for the video PLL clock
> "allwinner,sun9i-a80-pll4-clk" - for the peripheral PLLs on A80
> "allwinner,sun4i-a10-pll5-clk" - for the PLL5 clock
> "allwinner,sun4i-a10-pll6-clk" - for the PLL6 clock
> diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
> index 0581e1b..270f2a9 100644
> --- a/drivers/clk/sunxi/clk-sunxi.c
> +++ b/drivers/clk/sunxi/clk-sunxi.c
> @@ -23,6 +23,7 @@
> #include <linux/slab.h>
> #include <linux/spinlock.h>
> #include <linux/log2.h>
> +#include <linux/rational.h>
>
> #include "clk-factors.h"
>
> @@ -1129,6 +1130,70 @@ CLK_OF_DECLARE(sun6i_pll6, "allwinner,sun6i-a31-pll6-clk",
> sun6i_pll6_clk_setup);
>
> /*
> + * sun6i pll3
> + *
> + * if (p == 0) rate = k ? 270MHz : 297MHz
> + * else rate = parent_rate / (m + 1) * (n + 1);
> + */
> +static void sun6i_pll3_factors(struct factors_request *req)
> +{
> + unsigned long n, m;
> +
> + if (req->rate == 270000000) {
> + req->m = 0;
> + req->p = 0;
> + req->k = 0;
> + } else if (req->rate == 297000000) {
> + req->m = 0;
> + req->p = 0;
> + req->k = 1;
> + } else {
> + rational_best_approximation(req->rate,
> + req->parent_rate,
> + 1 << 7, 1 << 4, &n, &m);
> + req->rate = req->parent_rate / m * n;
> + req->p = 1;
> + req->m = m - 1;
> + req->n = n - 1;
> + }
> +}
> +
> +static void sun6i_pll3_recalc(struct factors_request *req)
> +{
> + if (req->p)
> + req->rate = req->parent_rate / (req->m + 1) * (req->n + 1);
> + else if (req->k)
> + req->rate = 270000000;
> + else
> + req->rate = 297000000;
> +}
> +
> +static const struct clk_factors_config sun6i_pll3_config = {
> + .mshift = 0,
> + .mwidth = 4,
> + .nshift = 8,
> + .nwidth = 7,
> + .pshift = 24, /* mode selection fractional / integer */
> + .pwidth = 1,
> + .kshift = 25, /* fraction 270 / 297 MHz */
> + .kwidth = 1,
> +};
That's not what p and k are.
Please add extra parameters to deal with fractional rates in the
clk_factors_config (like an extra bit + an array with the two rate
exposed.
That way, you can also deal with it in the core, instead of doing a
hack.
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2016-04-10 9:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-30 17:13 [PATCH 0/3] clk: sunxi: Add the clocks used for audio/video on sun8i Jean-Francois Moine
[not found] ` <cover.1459358017.git.moinejf-GANU6spQydw@public.gmane.org>
2016-03-30 16:43 ` [PATCH 1/3] clk: sunxi: Add sun6i/8i display support Jean-Francois Moine
[not found] ` <2b347763e38cfeeb7a2d6af6357eaea6c4ec07ac.1459358017.git.moinejf-GANU6spQydw@public.gmane.org>
2016-04-01 17:05 ` Rob Herring
2016-04-10 9:40 ` Maxime Ripard
2016-03-30 16:50 ` [PATCH 2/3] clk: sunxi: Add sun6i/8i PLL video support Jean-Francois Moine
2016-04-01 17:07 ` Rob Herring
[not found] ` <e63499f789971b8c45a0ae5e90bd127371cbcf19.1459358017.git.moinejf-GANU6spQydw@public.gmane.org>
2016-04-10 9:50 ` Maxime Ripard [this message]
2016-04-10 17:11 ` Jean-Francois Moine
2016-03-30 16:57 ` [PATCH 3/3] clk: sunxi: Add sun8i PLL audio support Jean-Francois Moine
2016-04-01 17:08 ` Rob Herring
2016-04-10 9:53 ` Maxime Ripard
2016-04-10 16:55 ` Jean-Francois Moine
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=20160410095006.GY4227@lukather \
--to=maxime.ripard-wi1+55scjutkeb57/3fjtnbpr1lh4cv8@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=emilio-0Z03zUJReD5OxF6Tv1QG9Q@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-clk-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=moinejf-GANU6spQydw@public.gmane.org \
--cc=sboyd-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=wens-jdAy2FN1RRM@public.gmane.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).