All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@arm.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 1/9] sunxi: clk: enable clk and reset for CCU devices
Date: Wed, 30 Jan 2019 10:55:54 +0000	[thread overview]
Message-ID: <20190130105554.306f9a01@donnerap.cambridge.arm.com> (raw)
In-Reply-To: <CAMty3ZDfdxF+Vdu29nQfBENRV+BOgATZ4m9UtSpD75cTSPrOZA@mail.gmail.com>

On Wed, 30 Jan 2019 16:08:14 +0530
Jagan Teki <jagan@amarulasolutions.com> wrote:

> On Wed, Jan 30, 2019 at 4:04 PM Andre Przywara
> <andre.przywara@arm.com> wrote:
> >
> > On Tue, 29 Jan 2019 23:56:44 +0530
> > Jagan Teki <jagan@amarulasolutions.com> wrote:
> >
> > Hi,
> >  
> > > On Tue, Jan 29, 2019 at 11:47 PM Andre Przywara
> > > <andre.przywara@foss.arm.com> wrote:  
> > > >
> > > > On Tue, 29 Jan 2019 23:40:26 +0530
> > > > Jagan Teki <jagan@amarulasolutions.com> wrote:
> > > >  
> > > > > On Tue, Jan 29, 2019 at 9:25 PM Andre Przywara
> > > > > <andre.przywara@arm.com> wrote:  
> > > > > >
> > > > > > Some Allwinner clock devices have parent clocks and reset
> > > > > > gates itself, which need to be activated for them to work.
> > > > > >
> > > > > > Add some code to just assert all resets and enable all
> > > > > > clocks given. This should enable the A80 MMC config clock,
> > > > > > which requires both to be activated. The full CCU devices
> > > > > > typically don't require resets, and have just fixed clocks
> > > > > > as their parents. Since we treat both as optional and
> > > > > > enabling fixed clocks is a NOP, this works for all cases,
> > > > > > without the need to differentiate between those clock types.
> > > > > >
> > > > > > Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> > > > > > ---
> > > > > >  drivers/clk/sunxi/clk_sunxi.c | 12 ++++++++++++
> > > > > >  1 file changed, 12 insertions(+)
> > > > > >
> > > > > > diff --git a/drivers/clk/sunxi/clk_sunxi.c
> > > > > > b/drivers/clk/sunxi/clk_sunxi.c index 62ce2994e4..6d4aeb5315
> > > > > > 100644 --- a/drivers/clk/sunxi/clk_sunxi.c
> > > > > > +++ b/drivers/clk/sunxi/clk_sunxi.c
> > > > > > @@ -8,6 +8,7 @@
> > > > > >  #include <clk-uclass.h>
> > > > > >  #include <dm.h>
> > > > > >  #include <errno.h>
> > > > > > +#include <reset.h>
> > > > > >  #include <asm/io.h>
> > > > > >  #include <asm/arch/ccu.h>
> > > > > >  #include <linux/log2.h>
> > > > > > @@ -61,6 +62,9 @@ struct clk_ops sunxi_clk_ops = {
> > > > > >  int sunxi_clk_probe(struct udevice *dev)
> > > > > >  {
> > > > > >         struct ccu_priv *priv = dev_get_priv(dev);
> > > > > > +       struct clk_bulk clk_bulk;
> > > > > > +       struct reset_ctl_bulk rst_bulk;
> > > > > > +       int ret;
> > > > > >
> > > > > >         priv->base = dev_read_addr_ptr(dev);
> > > > > >         if (!priv->base)
> > > > > > @@ -70,5 +74,13 @@ int sunxi_clk_probe(struct udevice *dev)
> > > > > >         if (!priv->desc)
> > > > > >                 return -EINVAL;
> > > > > >
> > > > > > +       ret = clk_get_bulk(dev, &clk_bulk);
> > > > > > +       if (!ret)
> > > > > > +               clk_enable_bulk(&clk_bulk);
> > > > > > +
> > > > > > +       ret = reset_get_bulk(dev, &rst_bulk);
> > > > > > +       if (!ret)
> > > > > > +               reset_deassert_bulk(&rst_bulk);
> > > > > > +  
> > > > >
> > > > > Can't we do this locally to clk_a80 probe?  
> > > >
> > > > That's the point: there is no such thing. For all SoCs we use
> > > > the shared sunxi_clk_probe() function. Doing this only for the
> > > > A80 would mean to split this up, which is duplicating a lot of
> > > > code for very little effect. The code here just enables every
> > > > clock and reset given, which is generic and should always be
> > > > the right thing.  
> > >
> > > But enable and dessert of clock and reset is job respective IP
> > > driver isn't it?  
> >
> > Which IP driver are you thinking about? This is "the IP driver"
> > for those clock, isn't it?  
> 
> IP can be any peripheral like USB, MMC, UART and it those drivers job
> to get and enable the clock isn't it?

Yes, using the DM_CLK framework. This is what we do: the A80 MMC DT
node refers to the MMC config clock (instead of the generic CCU), and
the MMC driver doesn't care about any requirement this clock has
*itself*.
This is the responsibility of the *A80 MMC config clock driver*, which
we introduce in patch 3/9. So in *this* driver's probe function you
would need to enable the parent clocks, which is exactly what we do.
Just by re-using the existing sunxi_clk_probe() function.

> I assume this code would do the same thing what these peripheral
> driver do?

It does, it's just one layer in between.
-----------------------
A64 MMC driver   A64 CCU driver           fixed clock driver
                 sunxi_clk_probe()
                     clk_enable()    ->   (NULL)
clk_enable()  -> sunxi_clk_enable()
-----------------------
A80 MMC driver   A80 MMC cfg clk driver   A80 CCU driver     fixed clk
                                          sunxi_clk_probe()
                                             clk_enable() -> (NULL)
                 sunxi_clk_probe()
                     clk_enable()    ->   sunxi_clk_enable()
clk_enable()  -> sunxi_clk_enable()
-----------------------

Hope that makes it clearer.

Cheers,
Andre.

> 
> > > > > > +       ret = clk_get_bulk(dev, &clk_bulk);
> > > > > > +       if (!ret)
> > > > > > +               clk_enable_bulk(&clk_bulk);
> > > > > > +
> > > > > > +       ret = reset_get_bulk(dev, &rst_bulk);
> > > > > > +       if (!ret)
> > > > > > +               reset_deassert_bulk(&rst_bulk);  

  reply	other threads:[~2019-01-30 10:55 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-29 15:54 [U-Boot] [PATCH v4 0/9] mmc: sunxi: Enable DM_MMC Andre Przywara
2019-01-29 15:54 ` [U-Boot] [PATCH v4 1/9] sunxi: clk: enable clk and reset for CCU devices Andre Przywara
2019-01-29 18:10   ` Jagan Teki
2019-01-29 18:16     ` Andre Przywara
2019-01-29 18:26       ` Jagan Teki
2019-01-30 10:33         ` Andre Przywara
2019-01-30 10:38           ` Jagan Teki
2019-01-30 10:55             ` Andre Przywara [this message]
2019-01-30 12:46               ` Jagan Teki
2019-01-30 13:42                 ` Andre Przywara
2019-01-30 14:19                   ` Jagan Teki
2019-01-30 14:31                     ` Andre Przywara
2019-01-30 14:47                       ` Jagan Teki
2019-01-30 16:13                         ` Andre Przywara
2019-01-30 16:24                           ` Jagan Teki
2019-01-29 15:54 ` [U-Boot] [PATCH v4 2/9] sunxi: clk: add MMC gates/resets Andre Przywara
2019-01-29 18:02   ` Jagan Teki
2019-01-29 15:54 ` [U-Boot] [PATCH v4 3/9] sunxi: clk: A80: add MMC clock support Andre Przywara
2019-01-29 18:04   ` Jagan Teki
2019-01-29 18:13   ` Jagan Teki
2019-01-29 15:54 ` [U-Boot] [PATCH v4 4/9] mmc: sunxi: Add remaining compatible strings Andre Przywara
2019-01-29 18:08   ` Jagan Teki
2019-01-29 15:54 ` [U-Boot] [PATCH v4 5/9] mmc: sunxi: Add DM_MMC support for H6 Andre Przywara
2019-01-29 18:08   ` Jagan Teki
2019-01-29 15:54 ` [U-Boot] [PATCH v4 6/9] mmc: sunxi: Add DM clk and reset support Andre Przywara
2019-01-29 18:14   ` Jagan Teki
2019-01-29 15:54 ` [U-Boot] [PATCH v4 7/9] sunxi: board: do MMC pinmux setup for DM_MMC builds Andre Przywara
2019-01-29 18:17   ` Jagan Teki
2019-01-29 15:54 ` [U-Boot] [PATCH v4 8/9] arm: sunxi: Enable DM_MMC Andre Przywara
2019-01-29 15:54 ` [U-Boot] [PATCH v4 9/9] arm: dts: sunxi: Enumerate MMC2 as MMC1 Andre Przywara
2019-01-29 17:42 ` [U-Boot] [PATCH v4 0/9] mmc: sunxi: Enable DM_MMC Jagan Teki
2019-01-29 17:49   ` Andre Przywara
2019-01-29 17:53     ` Jagan Teki
2019-01-30 10:16 ` Tomas Novotny
2019-01-30 11:46   ` Andre Przywara
2019-01-30 12:50     ` Jagan Teki
2019-01-30 13:56       ` Andre Przywara
2019-01-30 13:35     ` Tomas Novotny

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=20190130105554.306f9a01@donnerap.cambridge.arm.com \
    --to=andre.przywara@arm.com \
    --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.