From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: linux-sh@vger.kernel.org
Subject: Re: [PATCH v4 1/3] ARM: shmobile: wait for MSTP clock status to toggle, when enabling it
Date: Sat, 28 Dec 2013 01:08:49 +0000 [thread overview]
Message-ID: <2281459.Ikp2F3UJbi@avalon> (raw)
In-Reply-To: <1387034633-3798-2-git-send-email-laurent.pinchart+renesas@ideasonboard.com>
Hi Geert,
On Sunday 15 December 2013 14:06:31 Geert Uytterhoeven wrote:
> On Sat, Dec 14, 2013 at 4:23 PM, Laurent Pinchart wrote:
> > static int sh_clk_mstp_enable(struct clk *clk)
> > {
> > sh_clk_write(sh_clk_read(clk) & ~(1 << clk->enable_bit), clk);
> > + if (clk->status_reg) {
> > + unsigned int (*read)(const void __iomem *addr);
> > + int i;
> > + void __iomem *mapped_status = (phys_addr_t)clk->status_reg
> > - + (phys_addr_t)clk->enable_reg + clk->mapped_reg;
> > +
> > + if (clk->flags & CLK_ENABLE_REG_8BIT)
> > + read = r8;
> > + else if (clk->flags & CLK_ENABLE_REG_16BIT)
> > + read = r16;
> > + else
> > + read = r32;
> > +
> > + for (i = 1000;
> > + (read(mapped_status) & (1 << clk->enable_bit)) && i;
> > + i--)
> > + cpu_relax();
> > + if (!i) {
> > + pr_err("cpg: failed to enable %p[%d]\n",
> > + clk->enable_reg, clk->enable_bit);
> > + return -ETIMEDOUT;
> > + }
>
> Just wondering: what's a typical value of i when leaving the loop?
1000 :-)
I've tested the VSP1 on Lager (which sometimes crashed when opening the device
without this patch) and the loop counter is always 1000 so far. Reading the
status register once seems to be enough to ensure that the clock really
starts, although in practice it might take more time for some devices.
--
Regards,
Laurent Pinchart
prev parent reply other threads:[~2013-12-28 1:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-14 15:23 [PATCH v4 1/3] ARM: shmobile: wait for MSTP clock status to toggle, when enabling it Laurent Pinchart
2013-12-15 13:06 ` Geert Uytterhoeven
2013-12-28 1:08 ` Laurent Pinchart [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=2281459.Ikp2F3UJbi@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=linux-sh@vger.kernel.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).