All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Chris Brandt <chris.brandt@renesas.com>
Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
	Simon Horman <horms+renesas@verge.net.au>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@codeaurora.org>,
	linux-clk <linux-clk@vger.kernel.org>,
	Linux-Renesas <linux-renesas-soc@vger.kernel.org>
Subject: Re: [PATCH v2] clk: renesas: rz: Select EXTAL vs USB clock
Date: Tue, 30 Aug 2016 09:23:06 +0200	[thread overview]
Message-ID: <CAMuHMdUEK47vKF2qO-_p4i0xEqnWG9Vu2AH_1f=eQ_mz4mwDjA@mail.gmail.com> (raw)
In-Reply-To: <20160830031358.19468-1-chris.brandt@renesas.com>

Hi Chris,

On Tue, Aug 30, 2016 at 5:13 AM, Chris Brandt <chris.brandt@renesas.com> wrote:
> Check the MD_CLK pin to determine the current clock mode in order to set
> the pll clock parent correctly.
>
> Signed-off-by: Chris Brandt <chris.brandt@renesas.com>

Thanks for your patch!

> ---
> v2:
> * Switched to reading MD_CLK pin to determine mode
> ---
>  drivers/clk/renesas/clk-rz.c | 21 +++++++++++++++++----
>  1 file changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/clk/renesas/clk-rz.c b/drivers/clk/renesas/clk-rz.c
> index f6312c6..2fc8aae 100644
> --- a/drivers/clk/renesas/clk-rz.c
> +++ b/drivers/clk/renesas/clk-rz.c
> @@ -25,6 +25,9 @@ struct rz_cpg {
>  #define CPG_FRQCR      0x10
>  #define CPG_FRQCR2     0x14
>
> +#define PPR0 0xFCFE3200
> +#define PIBC0 0xFCFE7000
> +
>  /* -----------------------------------------------------------------------------
>   * Initialization
>   */
> @@ -37,10 +40,20 @@ rz_cpg_register_clock(struct device_node *np, struct rz_cpg *cpg, const char *na
>         static const unsigned frqcr_tab[4] = { 3, 2, 0, 1 };
>
>         if (strcmp(name, "pll") == 0) {
> -               /* FIXME: cpg_mode should be read from GPIO. But no GPIO support yet */
> -               unsigned cpg_mode = 0; /* hardcoded to EXTAL for now */
> -               const char *parent_name = of_clk_get_parent_name(np, cpg_mode);
> -
> +               unsigned int cpg_mode;
> +               const char *parent_name;
> +               void __iomem *ppr0, *pibc0;
> +
> +               /* MD_CLK is on P0_2 */
> +               ppr0 = ioremap_nocache(PPR0, 2);
> +               pibc0 = ioremap_nocache(PIBC0, 2);
> +               BUG_ON(!ppr0 || !pibc0);
> +               iowrite16(4, pibc0);    /* Enable input buffer */
> +               cpg_mode = ioread16(ppr0) & 4;
> +               iounmap(ppr0);
> +               iounmap(pibc0);
> +
> +               parent_name = cpg_mode ? "usb_x1" : "extal";

If you would use "cpg_mode = (ioread16(ppr0) >> 2) & 1;", the value of
cpg_mode would be in sync with Table 6.2. Then you can avoid relying on actual
clock names in DT, and keep

    parent_name = of_clk_get_parent_name(np, cpg_mode);

The bindings already dictate the parent clocks must match clock modes in the
datasheet, i.e. Table 6.2.

For easier maintenance, I would factor out reading the mode pins in a separate
function. When a proper GPIO driver is added, the function can be removed,
and its callsite updated.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

  parent reply	other threads:[~2016-08-30  7:23 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-25 19:05 [PATCH] clk: renesas: rz: Select EXTAL vs USB clock Chris Brandt
2016-08-29 13:18 ` Geert Uytterhoeven
2016-08-29 14:53   ` Chris Brandt
2016-08-29 14:53     ` Chris Brandt
2016-08-29 15:13     ` Geert Uytterhoeven
2016-08-29 15:32       ` Chris Brandt
2016-08-29 15:32         ` Chris Brandt
2016-08-29 15:41         ` Geert Uytterhoeven
2016-08-29 16:04           ` Chris Brandt
2016-08-29 16:04             ` Chris Brandt
2016-08-29 18:39 ` Sergei Shtylyov
2016-08-29 18:41   ` Geert Uytterhoeven
2016-08-30  3:13 ` [PATCH v2] " Chris Brandt
2016-08-30  7:04   ` Simon Horman
2016-08-30  7:06     ` Simon Horman
2016-08-30  7:23   ` Geert Uytterhoeven [this message]
2016-08-30 13:31     ` Chris Brandt
2016-08-30 13:31       ` Chris Brandt
2016-09-01 13:10   ` [PATCH v3] " Chris Brandt
2016-09-01 19:21     ` Geert Uytterhoeven
2016-09-01 19:41       ` Chris Brandt
2016-09-01 19:41         ` Chris Brandt
2016-09-02  2:32     ` [PATCH v4] " Chris Brandt
2016-09-02  8:19       ` Geert Uytterhoeven

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='CAMuHMdUEK47vKF2qO-_p4i0xEqnWG9Vu2AH_1f=eQ_mz4mwDjA@mail.gmail.com' \
    --to=geert@linux-m68k.org \
    --cc=chris.brandt@renesas.com \
    --cc=horms+renesas@verge.net.au \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@codeaurora.org \
    --cc=sergei.shtylyov@cogentembedded.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.