All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joel Stanley <joel@jms.id.au>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/3] aspeed: ast2500: Add AHB clock
Date: Wed, 12 Sep 2018 08:09:18 +0930	[thread overview]
Message-ID: <CACPK8XeiOF4HJkqPhDiyT3qg6g4c2V8WRetqep0PXKVYYo_xXg@mail.gmail.com> (raw)
In-Reply-To: <f13db87f-d13b-4ab3-1d82-10627879d159@kaod.org>

On Wed, 12 Sep 2018 at 03:13, Cédric Le Goater <clg@kaod.org> wrote:
>
> On 09/11/2018 06:42 PM, Maxim Sloyko wrote:
> >
> >
> > On Tue, Sep 11, 2018 at 12:35 AM, Joel Stanley <joel at jms.id.au <mailto:joel@jms.id.au>> wrote:
> >
> >     On Mon, 10 Sep 2018 at 23:48, Cédric Le Goater <clg at kaod.org <mailto:clg@kaod.org>> wrote:
> >     >
> >     > The AHB clock is used by the FMC/SPI controllers.
> >     >
> >     > Signed-off-by: Cédric Le Goater <clg at kaod.org <mailto:clg@kaod.org>>
> >     > ---
> >     >  arch/arm/include/asm/arch-aspeed/scu_ast2500.h |  2 ++
> >     >  include/dt-bindings/clock/ast2500-scu.h        |  1 +
> >     >  drivers/clk/aspeed/clk_ast2500.c               | 12 ++++++++++++
> >     >  3 files changed, 15 insertions(+)
> >     >
> >     > diff --git a/arch/arm/include/asm/arch-aspeed/scu_ast2500.h b/arch/arm/include/asm/arch-aspeed/scu_ast2500.h
> >     > index 4988ced7ddcc..6a90ded752ad 100644
> >     > --- a/arch/arm/include/asm/arch-aspeed/scu_ast2500.h
> >     > +++ b/arch/arm/include/asm/arch-aspeed/scu_ast2500.h
> >     > @@ -11,6 +11,8 @@
> >     >  #define SCU_HWSTRAP_VGAMEM_MASK                (3 << SCU_HWSTRAP_VGAMEM_SHIFT)
> >     >  #define SCU_HWSTRAP_MAC1_RGMII         (1 << 6)
> >     >  #define SCU_HWSTRAP_MAC2_RGMII         (1 << 7)
> >     > +#define SCU_HWSTRAP_AXIAHB_DIV_SHIFT   9
> >     > +#define SCU_HWSTRAP_AXIAHB_DIV_MASK    (0x7 << SCU_HWSTRAP_AXIAHB_DIV_SHIFT)
> >     >  #define SCU_HWSTRAP_DDR4               (1 << 24)
> >     >  #define SCU_HWSTRAP_CLKIN_25MHZ                (1 << 23)
> >     >
> >     > diff --git a/include/dt-bindings/clock/ast2500-scu.h b/include/dt-bindings/clock/ast2500-scu.h
> >     > index 4803abe9f628..03e6d16d3de0 100644
> >     > --- a/include/dt-bindings/clock/ast2500-scu.h
> >     > +++ b/include/dt-bindings/clock/ast2500-scu.h
> >     > @@ -17,6 +17,7 @@
> >     >  #define BCLK_MACCLK    103
> >     >  #define BCLK_SDCLK     104
> >     >  #define BCLK_ARMCLK    105
> >     > +#define BCLK_HCLK      106
> >
> >     I like how the clocks are grouped in this file. Are we confident that
> >     HCLK is going in the correct spot?
> >
> >     >  #define MCLK_DDR       201
> >     >
> >     > diff --git a/drivers/clk/aspeed/clk_ast2500.c b/drivers/clk/aspeed/clk_ast2500.c
> >     > index 526470051c5d..c55f8d5ae30d 100644
> >     > --- a/drivers/clk/aspeed/clk_ast2500.c
> >     > +++ b/drivers/clk/aspeed/clk_ast2500.c
> >     > @@ -143,6 +143,18 @@ static ulong ast2500_clk_get_rate(struct clk *clk)
> >     >                         rate = rate / apb_div;
> >     >                 }
> >     >                 break;
> >     > +       case BCLK_HCLK:
> >     > +               {
> >     > +                       ulong ahb_div = 1 + ((readl(&priv->scu->hwstrap)
> >     > +                                             & SCU_HWSTRAP_AXIAHB_DIV_MASK)
> >     > +                                            >> SCU_HWSTRAP_AXIAHB_DIV_SHIFT);
> >     > +                       ulong axi_div = 2;
> >     > +
> >     > +                       rate = ast2500_get_hpll_rate(
> >     > +                               clkin, readl(&priv->scu->h_pll_param));
> >     > +                       rate = rate / axi_div / ahb_div;
> >
> >     In the kernel driver I wrote it as:
> >
> >      rate / (axi_div + ahb_div)
> >
> >
> > These are two different formulae -- just want to make sure that the typo only made it into an email :)
> >
> > In any case, the exact right way to do this computation depends on how this is implemented in the hardware itself. Most likely it's to dividers in sequence, so dividing twice should be more accurate. Of course it would be nice if somebody with hw design experience could comment.
> >
> > If the datasheet has formula, I think the right way is to use it exactly as stated.
>
> it's two dividers in sequence in the datasheet. In the SDK also.
>
> >
> >
> >     I know that the maths works, but do the numbers come out as we expect
> >     when doing integer division?
>
> Yes. 192MHz.

Thanks for clarifying.

Reviewed-by: Joel Stanley <joel@jms.id.au>

  reply	other threads:[~2018-09-11 22:39 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-10 14:16 [U-Boot] [PATCH 0/3] Support for the Aspeed ast2500 FMC/SPI controllers Cédric Le Goater
2018-09-10 14:16 ` [U-Boot] [PATCH 1/3] aspeed: ast2500: Add AHB clock Cédric Le Goater
2018-09-11  7:35   ` Joel Stanley
2018-09-11 16:42     ` Maxim Sloyko
2018-09-11 17:43       ` Cédric Le Goater
2018-09-11 22:39         ` Joel Stanley [this message]
2018-09-27 13:41   ` Simon Glass
2018-09-10 14:16 ` [U-Boot] [PATCH 2/3] spi: Add support for the Aspeed ast2500 SPI controllers Cédric Le Goater
2018-09-11 22:38   ` Joel Stanley
2018-09-12  6:03     ` Cédric Le Goater
2018-09-27 13:41   ` Simon Glass
2018-09-28 11:42     ` Cédric Le Goater
2018-10-02 11:22       ` Simon Glass
2018-10-08  6:29         ` Cédric Le Goater
2018-10-04 15:57       ` Jagan Teki
2018-10-08  6:02         ` Cédric Le Goater
2018-10-10  6:16           ` Jagan Teki
2018-10-10  7:32             ` Boris Brezillon
2018-10-10 12:02               ` Cédric Le Goater
2019-01-25 17:28                 ` Cédric Le Goater
2019-01-25 18:00                   ` Boris Brezillon
2019-01-26 10:42                     ` Vignesh R
2018-09-10 14:16 ` [U-Boot] [PATCH 3/3] aspeed: Add SPI support to the ast2500 Eval Board Cédric Le Goater
2018-09-12  9:28   ` Joel Stanley
2018-09-20 14:53   ` Jagan Teki
2018-09-20 15:56     ` Cédric Le Goater

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=CACPK8XeiOF4HJkqPhDiyT3qg6g4c2V8WRetqep0PXKVYYo_xXg@mail.gmail.com \
    --to=joel@jms.id.au \
    --cc=u-boot@lists.denx.de \
    /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.