* [Qemu-devel] [PATCH 1/6] i.MX: Allow GPT timer to rollover.
@ 2016-01-26 21:44 Jean-Christophe Dubois
2016-01-26 21:54 ` Eric Blake
0 siblings, 1 reply; 3+ messages in thread
From: Jean-Christophe Dubois @ 2016-01-26 21:44 UTC (permalink / raw)
To: qemu-devel, peter.maydell, rosthwaite.peter; +Cc: Jean-Christophe Dubois
GPT timer need to rolloever when it reaches 0xffffffff.
It also need to reset to 0 when in "retart mode" and crossing the
compare 1 register.
Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net>
---
hw/timer/imx_gpt.c | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/hw/timer/imx_gpt.c b/hw/timer/imx_gpt.c
index b1893b8..b227256 100644
--- a/hw/timer/imx_gpt.c
+++ b/hw/timer/imx_gpt.c
@@ -133,7 +133,7 @@ static inline uint32_t imx_gpt_find_limit(uint32_t count, uint32_t reg,
static void imx_gpt_compute_next_timeout(IMXGPTState *s, bool event)
{
uint32_t timeout = GPT_TIMER_MAX;
- uint32_t count = 0;
+ uint32_t count;
long long limit;
if (!(s->cr & GPT_CR_EN)) {
@@ -141,20 +141,23 @@ static void imx_gpt_compute_next_timeout(IMXGPTState *s, bool event)
return;
}
- if (event) {
- /* This is a timer event */
+ /* update the count */
+ count = imx_gpt_update_count(s);
- if ((s->cr & GPT_CR_FRR) && (s->next_timeout != GPT_TIMER_MAX)) {
- /*
- * if we are in free running mode and we have not reached
- * the GPT_TIMER_MAX limit, then update the count
+ if (event) {
+ /*
+ * This is an event (the ptimer reached 0 and stopped), and the
+ * timer counter is now equal to s->next_timeout.
+ */
+ if (!(s->cr & GPT_CR_FRR) && (count == s->ocr1)) {
+ /* We are in restart mode and we crossed the compare channel 1
+ * value. We need to reset the counter to 0.
*/
- count = imx_gpt_update_count(s);
+ count = s->cnt = s->next_timeout = 0;
+ } else if (count == GPT_TIMER_MAX) {
+ /* We reached GPT_TIMER_MAX so we need to rollover */
+ count = s->cnt = s->next_timeout = 0;
}
- } else {
- /* not a timer event, then just update the count */
-
- count = imx_gpt_update_count(s);
}
/* now, find the next timeout related to count */
--
2.5.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [Qemu-devel] [PATCH 1/6] i.MX: Allow GPT timer to rollover.
2016-01-26 21:44 [Qemu-devel] [PATCH 1/6] i.MX: Allow GPT timer to rollover Jean-Christophe Dubois
@ 2016-01-26 21:54 ` Eric Blake
2016-01-26 22:21 ` Jean-Christophe DUBOIS
0 siblings, 1 reply; 3+ messages in thread
From: Eric Blake @ 2016-01-26 21:54 UTC (permalink / raw)
To: Jean-Christophe Dubois, qemu-devel, peter.maydell,
rosthwaite.peter
[-- Attachment #1: Type: text/plain, Size: 582 bytes --]
On 01/26/2016 02:44 PM, Jean-Christophe Dubois wrote:
[meta-reply]
Make sure your git settings properly thread your messages. Your 1/6 came
through as a top-level thread, rather than in-reply-to the 0/6 cover
letter (likewise for the rest of the series).
> GPT timer need to rolloever when it reaches 0xffffffff.
s/rolloever/rollover/
>
> It also need to reset to 0 when in "retart mode" and crossing the
s/retart/restart/
> compare 1 register.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH 1/6] i.MX: Allow GPT timer to rollover.
2016-01-26 21:54 ` Eric Blake
@ 2016-01-26 22:21 ` Jean-Christophe DUBOIS
0 siblings, 0 replies; 3+ messages in thread
From: Jean-Christophe DUBOIS @ 2016-01-26 22:21 UTC (permalink / raw)
To: Eric Blake, qemu-devel, peter.maydell, crosthwaite.peter
Le 26/01/2016 22:54, Eric Blake a écrit :
> On 01/26/2016 02:44 PM, Jean-Christophe Dubois wrote:
>
> [meta-reply]
> Make sure your git settings properly thread your messages. Your 1/6 came
> through as a top-level thread, rather than in-reply-to the 0/6 cover
> letter (likewise for the rest of the series).
Yes, sorry about that, I forgot to set the "threaded" option.
>
>> GPT timer need to rolloever when it reaches 0xffffffff.
> s/rolloever/rollover/
>
>> It also need to reset to 0 when in "retart mode" and crossing the
> s/retart/restart/
>
>> compare 1 register.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-01-26 22:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-26 21:44 [Qemu-devel] [PATCH 1/6] i.MX: Allow GPT timer to rollover Jean-Christophe Dubois
2016-01-26 21:54 ` Eric Blake
2016-01-26 22:21 ` Jean-Christophe DUBOIS
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).