From: Peter Chubb <peter.chubb@nicta.com.au>
To: Jean-Christophe DUBOIS <jcd@tribudubois.net>
Cc: peter.maydell@linaro.org, peter.chubb@nicta.com.au,
qemu-devel@nongnu.org, philipo@ok-labs.com
Subject: Re: [Qemu-devel] [PATCH] i.MX: implement a more correct version of EPIT timer.
Date: Wed, 10 Apr 2013 09:27:20 +1000 [thread overview]
Message-ID: <84ehejl1yf.wl%peter@chubb.wattle.id.au> (raw)
In-Reply-To: <1365546746-7867-1-git-send-email-jcd@tribudubois.net>
> This patch is providing a complete version of the EPIT timer.
> Note, however that the GPT timer in the same file is still not
> complete.
Thanks!
Comments in=line below.
> @@ -411,7 +441,7 @@ static int imx_timerg_init(SysBusDevice *dev)
> #define CR_SWR (1 << 16)
> #define CR_IOVW (1 << 17)
> #define CR_DBGEN (1 << 18)
> -#define CR_EPIT (1 << 19)
> +#define CR_WAITEN (1 << 19)
>
In the docs this bit is called EPIT. Its function is to enable the
timer in wait-mode. So is conformance with the docs or the description
of the function more important? If you *do* rename it, there should
be a comment to say it's EPIT in the i.mx31 documentation.
>-static void set_timerp_freq(IMXTimerPState *s)
>+static void imx_reload_compare_timer(IMXTimerPState *s)
> {
>- int clksrc;
>- unsigned prescaler;
>- uint32_t freq;
>-
>- clksrc = (s->cr & CR_CLKSRC_MASK) >> CR_CLKSRC_SHIFT;
>- prescaler = 1 + ((s->cr >> CR_PRESCALE_SHIFT) & CR_PRESCALE_MASK);
>- freq = imx_clock_frequency(s->ccm, imx_timerp_clocks[clksrc]) / prescaler;
>-
>- s->freq = freq;
>- DPRINTF("Setting ptimer frequency to %u\n", freq);
>-
>- if (freq) {
>- ptimer_set_freq(s->timer, freq);
>+ if ((s->cr & CR_OCIEN) && s->cmp) {
>+ /* it the compare feature is on */]
s/it/if/
+ uint32_t tmp = imx_timerp_update_counts(s);
+ if (tmp > s->cmp) {
+ /* reinit the cmp timer if required */
+ ptimer_set_count(s->timer_cmp, tmp - s->cmp);
+ if ((s->cr & CR_EN)) {
+ /* Restart the cmp timer if required */
+ ptimer_run(s->timer_cmp, 0);
+ }
+ }
}
}
>@@ -526,40 +599,63 @@ static void imx_timerp_write(void *opaque, hwaddr offset,
>
> switch (offset >> 2) {
> case 0: /* CR */
>- if (value & CR_SWR) {
>+ s->cr = value & 0x03ffffff;
>+ if (s->cr & CR_SWR) {
>+ /* handle the reset */
> imx_timerp_reset(&s->busdev.qdev);
>- value &= ~CR_SWR;
>+ } else {
>+ set_timerp_freq(s);
> }
>- s->cr = value & 0x03ffffff;
>- set_timerp_freq(s);
>+ value &= s->cr;
You're letting the reset function clear the SWR. It's unclear to me
from the docs whether when the SWR bit is set, assignment to other
fields in the CR happens before or after the reset. I punted on
`after' (because it seemted to work), this changes to `before'.
The reset looks good --- you seem to understand the ptimer interface
better than I did when I updated this code.
Peter c
--
Dr Peter Chubb peter.chubb AT nicta.com.au
http://www.ssrg.nicta.com.au Software Systems Research Group/NICTA
next prev parent reply other threads:[~2013-04-09 23:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-09 22:32 [Qemu-devel] [PATCH] i.MX: implement a more correct version of EPIT timer Jean-Christophe DUBOIS
2013-04-09 23:27 ` Peter Chubb [this message]
2013-04-10 6:12 ` Jean-Christophe DUBOIS
2013-04-10 8:26 ` Peter Maydell
2013-04-10 19:55 ` Jean-Christophe DUBOIS
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=84ehejl1yf.wl%peter@chubb.wattle.id.au \
--to=peter.chubb@nicta.com.au \
--cc=jcd@tribudubois.net \
--cc=peter.maydell@linaro.org \
--cc=philipo@ok-labs.com \
--cc=qemu-devel@nongnu.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).