public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] usb: add clock support for generic EHCI
Date: Thu, 14 Jan 2016 00:58:36 +0100	[thread overview]
Message-ID: <201601140058.36922.marex@denx.de> (raw)
In-Reply-To: <CAK7LNARhZeuaKGTBb=nr0ot8TWAeBaRheEZGUSn4b-mB9WAB6g@mail.gmail.com>

On Wednesday, January 13, 2016 at 06:08:34 PM, Masahiro Yamada wrote:
> Hi Marek,

Hi!

> 2016-01-13 23:44 GMT+09:00 Marek Vasut <marex@denx.de>:
> >>  static int ehci_usb_probe(struct udevice *dev)
> >>  {
> >> 
> >> +     struct generic_ehci *priv = dev_get_priv(dev);
> >> 
> >>       struct ehci_hccr *hccr = (struct ehci_hccr *)dev_get_addr(dev);
> >>       struct ehci_hcor *hcor;
> >> 
> >> +     int i;
> >> +
> >> +     for (i = 0; i < EHCI_MAX_CLKS; i++) {
> > 
> > Hi!
> > 
> > Can't you dynamically figure out how many clock are in the clocks
> > property and allocate the clk_ids array based on that ? This would
> > remove the need for this EHCI_MAX_CLKS ad-hoc constant.
> 
> It is possible, but costly.
> 
> We have to know "#clock-cells" of each clock provider to do that.
> Effectively, we have to call fdt_clk_get() until it fails
> in order to get the number of the clocks.
> 
> Then, needed memory is allocated.
> 
> Again, we have to call fdt_clk_get(),
> this time, in order to really get and store the clocks.
> 
> I think this is why the Linux one also uses the fixed value for the array
> size.
> 
> See linux/drivers/usb/host/ehci-platform.c.

OK, let's go with this. Thanks for explaining.

> >> +             priv->clk_ids[i] = fdt_clk_get(dev, i,
> >> &priv->clk_devs[i]);
> > 
> > Do you need to stort clk_devs in the priv structure at all ?
> 
> Yes, if we call clock_disable() in the .remove callback.
> No, if we do not do that.

OK

> >> +             if (priv->clk_ids[i] < 0)
> >> +                     break;
> >> +             if (clk_enable(priv->clk_devs[i], priv->clk_ids[i]))
> > 
> > I think you should also disable the clock in ehci_usb_remove() {} .
> 
> Generally speaking, disabling clocks is more difficult than enabling them
> because we should have enable_count.
> (For example, assume two clock consumers share one clock gate)
> 
> Unlike Linux's clock framework, U-Boot's clock-uclass does not support
> the enable_count.
> 
> 
> Having said that, it makes sense to add clock_disable() in the .remove
> callback.

CCing Simon, let's see what he has to say.

Best regards,
Marek Vasut

      reply	other threads:[~2016-01-13 23:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-13  4:34 [U-Boot] [PATCH] usb: add clock support for generic EHCI Masahiro Yamada
2016-01-13 14:44 ` Marek Vasut
2016-01-13 17:08   ` Masahiro Yamada
2016-01-13 23:58     ` Marek Vasut [this message]

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=201601140058.36922.marex@denx.de \
    --to=marex@denx.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox